109 else if (!strcmp(ident, "definitions")) definitions_parse(); 110 else if (!strcmp(ident, "peephole")) peep_parse(); 111 else if (!strcmp(ident, "#line")) preproc_line(); 112 else if (!strcmp(ident, "#define")) preproc_define(); 113 else if (!strcmp(ident, "#undef")) preproc_undef(); 114 else { 115 parse_err(SYNERR, "expected one of - instruct, operand, ins_attrib, op_attrib, source, register, pipeline, encode\n Found %s",ident); 116 } 117 } 118 119 // Done with parsing, check consistency. 120 121 if (_preproc_depth != 0) { 122 parse_err(SYNERR, "End of file inside #ifdef"); 123 } 124 125 // AttributeForms ins_cost and op_cost must be defined for default behaviour 126 if (_globalNames[AttributeForm::_ins_cost] == NULL) { 127 parse_err(SEMERR, "Did not declare 'ins_cost' attribute"); 128 } 129 if (_globalNames[AttributeForm::_ins_pc_relative] == NULL) { 130 parse_err(SEMERR, "Did not declare 'ins_pc_relative' attribute"); 131 } 132 if (_globalNames[AttributeForm::_op_cost] == NULL) { 133 parse_err(SEMERR, "Did not declare 'op_cost' attribute"); 134 } 135 } 136 137 // ******************** Private Level 1 Parse Functions ******************** 138 //------------------------------instr_parse------------------------------------ 139 // Parse the contents of an instruction definition, build the InstructForm to 140 // represent that instruction, and add it to the InstructForm list. 141 void ADLParser::instr_parse(void) { 142 char *ident; 143 InstructForm *instr; 144 MatchRule *rule; 145 int match_rules_cnt = 0; 146 147 // First get the name of the instruction 148 if( (ident = get_unique_ident(_globalNames,"instruction")) == NULL ) 149 return; 150 instr = new InstructForm(ident); // Create new instruction form 151 instr->_linenum = linenum(); | 109 else if (!strcmp(ident, "definitions")) definitions_parse(); 110 else if (!strcmp(ident, "peephole")) peep_parse(); 111 else if (!strcmp(ident, "#line")) preproc_line(); 112 else if (!strcmp(ident, "#define")) preproc_define(); 113 else if (!strcmp(ident, "#undef")) preproc_undef(); 114 else { 115 parse_err(SYNERR, "expected one of - instruct, operand, ins_attrib, op_attrib, source, register, pipeline, encode\n Found %s",ident); 116 } 117 } 118 119 // Done with parsing, check consistency. 120 121 if (_preproc_depth != 0) { 122 parse_err(SYNERR, "End of file inside #ifdef"); 123 } 124 125 // AttributeForms ins_cost and op_cost must be defined for default behaviour 126 if (_globalNames[AttributeForm::_ins_cost] == NULL) { 127 parse_err(SEMERR, "Did not declare 'ins_cost' attribute"); 128 } 129 if (_globalNames[AttributeForm::_op_cost] == NULL) { 130 parse_err(SEMERR, "Did not declare 'op_cost' attribute"); 131 } 132 } 133 134 // ******************** Private Level 1 Parse Functions ******************** 135 //------------------------------instr_parse------------------------------------ 136 // Parse the contents of an instruction definition, build the InstructForm to 137 // represent that instruction, and add it to the InstructForm list. 138 void ADLParser::instr_parse(void) { 139 char *ident; 140 InstructForm *instr; 141 MatchRule *rule; 142 int match_rules_cnt = 0; 143 144 // First get the name of the instruction 145 if( (ident = get_unique_ident(_globalNames,"instruction")) == NULL ) 146 return; 147 instr = new InstructForm(ident); // Create new instruction form 148 instr->_linenum = linenum(); |