comparison src/share/vm/adlc/adlparse.cpp @ 14431:1410ad6b05f1

8028401: PPC (part 117): Improve usability of adlc and format() functionality. Summary: Add additional, more verbose syntax checks in adlc. Fix printing constant's problem in format(). Reviewed-by: kvn
author goetz
date Fri, 15 Nov 2013 12:01:00 -0800
parents 044b28168e20
children 318d0622a6d7
comparison
equal deleted inserted replaced
14430:ea78de16a4a4 14431:1410ad6b05f1
3994 } 3994 }
3995 3995
3996 //------------------------------expand_parse----------------------------------- 3996 //------------------------------expand_parse-----------------------------------
3997 ExpandRule* ADLParser::expand_parse(InstructForm *instr) { 3997 ExpandRule* ADLParser::expand_parse(InstructForm *instr) {
3998 char *ident, *ident2; 3998 char *ident, *ident2;
3999 OperandForm *oper;
4000 InstructForm *ins;
4001 NameAndList *instr_and_operands = NULL; 3999 NameAndList *instr_and_operands = NULL;
4002 ExpandRule *exp = new ExpandRule(); 4000 ExpandRule *exp = new ExpandRule();
4003 4001
4004 // Expand is a block containing an ordered list of instructions, each of 4002 // Expand is a block containing an ordered list of operands with initializers,
4005 // which has an ordered list of operands. 4003 // or instructions, each of which has an ordered list of operands.
4006 // Check for block delimiter 4004 // Check for block delimiter
4007 skipws(); // Skip leading whitespace 4005 skipws(); // Skip leading whitespace
4008 if ((_curchar != '%') 4006 if ((_curchar != '%')
4009 || (next_char(), (_curchar != '{')) ) { // If not open block 4007 || (next_char(), (_curchar != '{')) ) { // If not open block
4010 parse_err(SYNERR, "missing '%%{' in expand definition\n"); 4008 parse_err(SYNERR, "missing '%%{' in expand definition\n");
4014 do { 4012 do {
4015 ident = get_ident(); // Grab next identifier 4013 ident = get_ident(); // Grab next identifier
4016 if (ident == NULL) { 4014 if (ident == NULL) {
4017 parse_err(SYNERR, "identifier expected at %c\n", _curchar); 4015 parse_err(SYNERR, "identifier expected at %c\n", _curchar);
4018 continue; 4016 continue;
4019 } // Check that you have a valid instruction 4017 }
4018
4019 // Check whether we should parse an instruction or operand.
4020 const Form *form = _globalNames[ident]; 4020 const Form *form = _globalNames[ident];
4021 ins = form ? form->is_instruction() : NULL; 4021 bool parse_oper = false;
4022 if (ins == NULL) { 4022 bool parse_ins = false;
4023 if (form == NULL) {
4024 skipws();
4025 // Check whether this looks like an instruction specification. If so,
4026 // just parse the instruction. The declaration of the instruction is
4027 // not needed here.
4028 if (_curchar == '(') parse_ins = true;
4029 } else if (form->is_instruction()) {
4030 parse_ins = true;
4031 } else if (form->is_operand()) {
4032 parse_oper = true;
4033 } else {
4034 parse_err(SYNERR, "instruction/operand name expected at %s\n", ident);
4035 continue;
4036 }
4037
4038 if (parse_oper) {
4023 // This is a new operand 4039 // This is a new operand
4024 oper = form ? form->is_operand() : NULL; 4040 OperandForm *oper = form->is_operand();
4025 if (oper == NULL) { 4041 if (oper == NULL) {
4026 parse_err(SYNERR, "instruction/operand name expected at %s\n", ident); 4042 parse_err(SYNERR, "instruction/operand name expected at %s\n", ident);
4027 continue; 4043 continue;
4028 } 4044 }
4029 // Throw the operand on the _newopers list 4045 // Throw the operand on the _newopers list
4054 } 4070 }
4055 else next_char(); // Skip the ; 4071 else next_char(); // Skip the ;
4056 skipws(); 4072 skipws();
4057 } 4073 }
4058 else { 4074 else {
4075 assert(parse_ins, "sanity");
4059 // Add instruction to list 4076 // Add instruction to list
4060 instr_and_operands = new NameAndList(ident); 4077 instr_and_operands = new NameAndList(ident);
4061 // Grab operands, build nameList of them, and then put into dictionary 4078 // Grab operands, build nameList of them, and then put into dictionary
4062 skipws(); 4079 skipws();
4063 if (_curchar != '(') { // Check for parenthesized operand list 4080 if (_curchar != '(') { // Check for parenthesized operand list
4077 const Form *form2 = instr->_localNames[ident2]; 4094 const Form *form2 = instr->_localNames[ident2];
4078 if (!form2) { 4095 if (!form2) {
4079 parse_err(SYNERR, "operand name expected at %s\n", ident2); 4096 parse_err(SYNERR, "operand name expected at %s\n", ident2);
4080 continue; 4097 continue;
4081 } 4098 }
4082 oper = form2->is_operand(); 4099 OperandForm *oper = form2->is_operand();
4083 if (oper == NULL && !form2->is_opclass()) { 4100 if (oper == NULL && !form2->is_opclass()) {
4084 parse_err(SYNERR, "operand name expected at %s\n", ident2); 4101 parse_err(SYNERR, "operand name expected at %s\n", ident2);
4085 continue; 4102 continue;
4086 } // Add operand to list 4103 } // Add operand to list
4087 instr_and_operands->add_entry(ident2); 4104 instr_and_operands->add_entry(ident2);