Mercurial > hg > truffle
comparison src/share/vm/adlc/formssel.cpp @ 6850:d336b3173277
8000592: Improve adlc usability
Summary: several changes to adlc to improve its usability
Reviewed-by: kvn
Contributed-by: goetz.lindenmaier@sap.com
author | kvn |
---|---|
date | Tue, 09 Oct 2012 16:09:31 -0700 |
parents | f6badecb7ea7 |
children | b30b3c2a0cf2 |
comparison
equal
deleted
inserted
replaced
6849:f6badecb7ea7 | 6850:d336b3173277 |
---|---|
565 const char *rc_name = opform->constrained_reg_class(); | 565 const char *rc_name = opform->constrained_reg_class(); |
566 if( rc_name ) { | 566 if( rc_name ) { |
567 if( strcmp(rc_name,"stack_slots") ) { | 567 if( strcmp(rc_name,"stack_slots") ) { |
568 // Check for ideal_type of RegFlags | 568 // Check for ideal_type of RegFlags |
569 const char *type = opform->ideal_type( globals, registers ); | 569 const char *type = opform->ideal_type( globals, registers ); |
570 if( !strcmp(type,"RegFlags") ) | 570 if( (type != NULL) && !strcmp(type, "RegFlags") ) |
571 rematerialize = true; | 571 rematerialize = true; |
572 } else | 572 } else |
573 rematerialize = false; // Do not rematerialize things target stk | 573 rematerialize = false; // Do not rematerialize things target stk |
574 } | 574 } |
575 } | 575 } |
793 } | 793 } |
794 */ | 794 */ |
795 return num_opnds; | 795 return num_opnds; |
796 } | 796 } |
797 | 797 |
798 const char *InstructForm::opnd_ident(int idx) { | |
799 return _components.at(idx)->_name; | |
800 } | |
801 | |
802 const char *InstructForm::unique_opnd_ident(int idx) { | |
803 uint i; | |
804 for (i = 1; i < num_opnds(); ++i) { | |
805 if (unique_opnds_idx(i) == idx) { | |
806 break; | |
807 } | |
808 } | |
809 return (_components.at(i) != NULL) ? _components.at(i)->_name : ""; | |
810 } | |
811 | |
798 // Return count of unmatched operands. | 812 // Return count of unmatched operands. |
799 uint InstructForm::num_post_match_opnds() { | 813 uint InstructForm::num_post_match_opnds() { |
800 uint num_post_match_opnds = _components.count(); | 814 uint num_post_match_opnds = _components.count(); |
801 uint num_match_opnds = _components.match_count(); | 815 uint num_match_opnds = _components.match_count(); |
802 num_post_match_opnds = num_post_match_opnds - num_match_opnds; | 816 num_post_match_opnds = num_post_match_opnds - num_match_opnds; |
864 base += needs_base_oop_edge(globals); | 878 base += needs_base_oop_edge(globals); |
865 | 879 |
866 return base; | 880 return base; |
867 } | 881 } |
868 | 882 |
883 // This function determines the order of the MachOper in _opnds[] | |
884 // by writing the operand names into the _components list. | |
885 // | |
869 // Implementation does not modify state of internal structures | 886 // Implementation does not modify state of internal structures |
870 void InstructForm::build_components() { | 887 void InstructForm::build_components() { |
871 // Add top-level operands to the components | 888 // Add top-level operands to the components |
872 if (_matrule) _matrule->append_components(_localNames, _components); | 889 if (_matrule) _matrule->append_components(_localNames, _components); |
873 | 890 |
959 return; | 976 return; |
960 } | 977 } |
961 | 978 |
962 // Return zero-based position in component list; -1 if not in list. | 979 // Return zero-based position in component list; -1 if not in list. |
963 int InstructForm::operand_position(const char *name, int usedef) { | 980 int InstructForm::operand_position(const char *name, int usedef) { |
964 return unique_opnds_idx(_components.operand_position(name, usedef)); | 981 return unique_opnds_idx(_components.operand_position(name, usedef, this)); |
965 } | 982 } |
966 | 983 |
967 int InstructForm::operand_position_format(const char *name) { | 984 int InstructForm::operand_position_format(const char *name) { |
968 return unique_opnds_idx(_components.operand_position_format(name)); | 985 return unique_opnds_idx(_components.operand_position_format(name, this)); |
969 } | 986 } |
970 | 987 |
971 // Return zero-based position in component list; -1 if not in list. | 988 // Return zero-based position in component list; -1 if not in list. |
972 int InstructForm::label_position() { | 989 int InstructForm::label_position() { |
973 return unique_opnds_idx(_components.label_position()); | 990 return unique_opnds_idx(_components.label_position()); |
1223 different = true; | 1240 different = true; |
1224 } | 1241 } |
1225 if (different) { | 1242 if (different) { |
1226 globalAD->syntax_err(short_branch->_linenum, "Instruction %s and its short form %s have different parameters\n", _ident, short_branch->_ident); | 1243 globalAD->syntax_err(short_branch->_linenum, "Instruction %s and its short form %s have different parameters\n", _ident, short_branch->_ident); |
1227 } | 1244 } |
1228 if (AD._short_branch_debug) { | 1245 if (AD._adl_debug > 1 || AD._short_branch_debug) { |
1229 fprintf(stderr, "Instruction %s has short form %s\n", _ident, short_branch->_ident); | 1246 fprintf(stderr, "Instruction %s has short form %s\n", _ident, short_branch->_ident); |
1230 } | 1247 } |
1231 _short_branch_form = short_branch; | 1248 _short_branch_form = short_branch; |
1232 return true; | 1249 return true; |
1233 } | 1250 } |
1255 } | 1272 } |
1256 | 1273 |
1257 // Find replacement variable's type | 1274 // Find replacement variable's type |
1258 const Form *form = _localNames[rep_var]; | 1275 const Form *form = _localNames[rep_var]; |
1259 if (form == NULL) { | 1276 if (form == NULL) { |
1260 fprintf(stderr, "unknown replacement variable in format statement: '%s'\n", rep_var); | 1277 globalAD->syntax_err(_linenum, "Unknown replacement variable %s in format statement of %s.", |
1261 assert(false, "ShouldNotReachHere()"); | 1278 rep_var, _ident); |
1279 return; | |
1262 } | 1280 } |
1263 OpClassForm *opc = form->is_opclass(); | 1281 OpClassForm *opc = form->is_opclass(); |
1264 assert( opc, "replacement variable was not found in local names"); | 1282 assert( opc, "replacement variable was not found in local names"); |
1265 // Lookup the index position of the replacement variable | 1283 // Lookup the index position of the replacement variable |
1266 int idx = operand_position_format(rep_var); | 1284 int idx = operand_position_format(rep_var); |
1267 if ( idx == -1 ) { | 1285 if ( idx == -1 ) { |
1268 assert( strcmp(opc->_ident,"label")==0, "Unimplemented"); | 1286 globalAD->syntax_err(_linenum, "Could not find replacement variable %s in format statement of %s.\n", |
1269 assert( false, "ShouldNotReachHere()"); | 1287 rep_var, _ident); |
1288 assert(strcmp(opc->_ident, "label") == 0, "Unimplemented"); | |
1289 return; | |
1270 } | 1290 } |
1271 | 1291 |
1272 if (is_noninput_operand(idx)) { | 1292 if (is_noninput_operand(idx)) { |
1273 // This component isn't in the input array. Print out the static | 1293 // This component isn't in the input array. Print out the static |
1274 // name of the register. | 1294 // name of the register. |
1275 OperandForm* oper = form->is_operand(); | 1295 OperandForm* oper = form->is_operand(); |
1276 if (oper != NULL && oper->is_bound_register()) { | 1296 if (oper != NULL && oper->is_bound_register()) { |
1277 const RegDef* first = oper->get_RegClass()->find_first_elem(); | 1297 const RegDef* first = oper->get_RegClass()->find_first_elem(); |
1278 fprintf(fp, " tty->print(\"%s\");\n", first->_regname); | 1298 fprintf(fp, " st->print(\"%s\");\n", first->_regname); |
1279 } else { | 1299 } else { |
1280 globalAD->syntax_err(_linenum, "In %s can't find format for %s %s", _ident, opc->_ident, rep_var); | 1300 globalAD->syntax_err(_linenum, "In %s can't find format for %s %s", _ident, opc->_ident, rep_var); |
1281 } | 1301 } |
1282 } else { | 1302 } else { |
1283 // Output the format call for this operand | 1303 // Output the format call for this operand |
1371 | 1391 |
1372 // Compute the index into vector of operand pointers: | 1392 // Compute the index into vector of operand pointers: |
1373 // idx0=0 is used to indicate that info comes from this same node, not from input edge. | 1393 // idx0=0 is used to indicate that info comes from this same node, not from input edge. |
1374 // idx1 starts at oper_input_base() | 1394 // idx1 starts at oper_input_base() |
1375 if ( cur_num_opnds >= 1 ) { | 1395 if ( cur_num_opnds >= 1 ) { |
1376 fprintf(fp," // Start at oper_input_base() and count operands\n"); | 1396 fprintf(fp," // Start at oper_input_base() and count operands\n"); |
1377 fprintf(fp," unsigned %sidx0 = %d;\n", prefix, oper_input_base(globals)); | 1397 fprintf(fp," unsigned %sidx0 = %d;\n", prefix, oper_input_base(globals)); |
1378 fprintf(fp," unsigned %sidx1 = %d;\n", prefix, oper_input_base(globals)); | 1398 fprintf(fp," unsigned %sidx1 = %d;", prefix, oper_input_base(globals)); |
1399 fprintf(fp," \t// %s\n", unique_opnd_ident(1)); | |
1379 | 1400 |
1380 // Generate starting points for other unique operands if they exist | 1401 // Generate starting points for other unique operands if they exist |
1381 for ( idx = 2; idx < num_unique_opnds(); ++idx ) { | 1402 for ( idx = 2; idx < num_unique_opnds(); ++idx ) { |
1382 if( *receiver == 0 ) { | 1403 if( *receiver == 0 ) { |
1383 fprintf(fp," unsigned %sidx%d = %sidx%d + opnd_array(%d)->num_edges();\n", | 1404 fprintf(fp," unsigned %sidx%d = %sidx%d + opnd_array(%d)->num_edges();", |
1384 prefix, idx, prefix, idx-1, idx-1 ); | 1405 prefix, idx, prefix, idx-1, idx-1 ); |
1385 } else { | 1406 } else { |
1386 fprintf(fp," unsigned %sidx%d = %sidx%d + %s_opnds[%d]->num_edges();\n", | 1407 fprintf(fp," unsigned %sidx%d = %sidx%d + %s_opnds[%d]->num_edges();", |
1387 prefix, idx, prefix, idx-1, receiver, idx-1 ); | 1408 prefix, idx, prefix, idx-1, receiver, idx-1 ); |
1388 } | 1409 } |
1410 fprintf(fp," \t// %s\n", unique_opnd_ident(idx)); | |
1389 } | 1411 } |
1390 } | 1412 } |
1391 if( *receiver != 0 ) { | 1413 if( *receiver != 0 ) { |
1392 // This value is used by generate_peepreplace when copying a node. | 1414 // This value is used by generate_peepreplace when copying a node. |
1393 // Don't emit it in other cases since it can hide bugs with the | 1415 // Don't emit it in other cases since it can hide bugs with the |
1394 // use invalid idx's. | 1416 // use invalid idx's. |
1395 fprintf(fp," unsigned %sidx%d = %sreq(); \n", prefix, idx, receiver); | 1417 fprintf(fp," unsigned %sidx%d = %sreq(); \n", prefix, idx, receiver); |
1396 } | 1418 } |
1397 | 1419 |
1398 } | 1420 } |
1399 | 1421 |
1400 // --------------------------- | 1422 // --------------------------- |
1774 if(!strcmp(name, "CALL")) return Component::CALL; | 1796 if(!strcmp(name, "CALL")) return Component::CALL; |
1775 assert( false,"Invalid effect name specified\n"); | 1797 assert( false,"Invalid effect name specified\n"); |
1776 return Component::INVALID; | 1798 return Component::INVALID; |
1777 } | 1799 } |
1778 | 1800 |
1801 const char *Component::getUsedefName() { | |
1802 switch (_usedef) { | |
1803 case Component::INVALID: return "INVALID"; break; | |
1804 case Component::USE: return "USE"; break; | |
1805 case Component::USE_DEF: return "USE_DEF"; break; | |
1806 case Component::USE_KILL: return "USE_KILL"; break; | |
1807 case Component::KILL: return "KILL"; break; | |
1808 case Component::TEMP: return "TEMP"; break; | |
1809 case Component::DEF: return "DEF"; break; | |
1810 case Component::CALL: return "CALL"; break; | |
1811 default: assert(false, "unknown effect"); | |
1812 } | |
1813 return "Undefined Use/Def info"; | |
1814 } | |
1815 | |
1779 Effect::Effect(const char *name) : _name(name), _use_def(effect_lookup(name)) { | 1816 Effect::Effect(const char *name) : _name(name), _use_def(effect_lookup(name)) { |
1780 _ftype = Form::EFF; | 1817 _ftype = Form::EFF; |
1781 } | 1818 } |
1819 | |
1782 Effect::~Effect() { | 1820 Effect::~Effect() { |
1783 } | 1821 } |
1784 | 1822 |
1785 // Dynamic type check | 1823 // Dynamic type check |
1786 Effect *Effect::is_effect() const { | 1824 Effect *Effect::is_effect() const { |
2273 | 2311 |
2274 return; | 2312 return; |
2275 } | 2313 } |
2276 | 2314 |
2277 int OperandForm::operand_position(const char *name, int usedef) { | 2315 int OperandForm::operand_position(const char *name, int usedef) { |
2278 return _components.operand_position(name, usedef); | 2316 return _components.operand_position(name, usedef, this); |
2279 } | 2317 } |
2280 | 2318 |
2281 | 2319 |
2282 // Return zero-based position in component list, only counting constants; | 2320 // Return zero-based position in component list, only counting constants; |
2283 // Return -1 if not in list. | 2321 // Return -1 if not in list. |
2399 void OperandForm::int_format(FILE *fp, FormDict &globals, uint index) { | 2437 void OperandForm::int_format(FILE *fp, FormDict &globals, uint index) { |
2400 Form::DataType dtype; | 2438 Form::DataType dtype; |
2401 if (_matrule && (_matrule->is_base_register(globals) || | 2439 if (_matrule && (_matrule->is_base_register(globals) || |
2402 strcmp(ideal_type(globalAD->globalNames()), "RegFlags") == 0)) { | 2440 strcmp(ideal_type(globalAD->globalNames()), "RegFlags") == 0)) { |
2403 // !!!!! !!!!! | 2441 // !!!!! !!!!! |
2404 fprintf(fp, "{ char reg_str[128];\n"); | 2442 fprintf(fp," { char reg_str[128];\n"); |
2405 fprintf(fp," ra->dump_register(node,reg_str);\n"); | 2443 fprintf(fp," ra->dump_register(node,reg_str);\n"); |
2406 fprintf(fp," tty->print(\"%cs\",reg_str);\n",'%'); | 2444 fprintf(fp," st->print(\"%cs\",reg_str);\n",'%'); |
2407 fprintf(fp," }\n"); | 2445 fprintf(fp," }\n"); |
2408 } else if (_matrule && (dtype = _matrule->is_base_constant(globals)) != Form::none) { | 2446 } else if (_matrule && (dtype = _matrule->is_base_constant(globals)) != Form::none) { |
2409 format_constant( fp, index, dtype ); | 2447 format_constant( fp, index, dtype ); |
2410 } else if (ideal_to_sReg_type(_ident) != Form::none) { | 2448 } else if (ideal_to_sReg_type(_ident) != Form::none) { |
2411 // Special format for Stack Slot Register | 2449 // Special format for Stack Slot Register |
2412 fprintf(fp, "{ char reg_str[128];\n"); | 2450 fprintf(fp," { char reg_str[128];\n"); |
2413 fprintf(fp," ra->dump_register(node,reg_str);\n"); | 2451 fprintf(fp," ra->dump_register(node,reg_str);\n"); |
2414 fprintf(fp," tty->print(\"%cs\",reg_str);\n",'%'); | 2452 fprintf(fp," st->print(\"%cs\",reg_str);\n",'%'); |
2415 fprintf(fp," }\n"); | 2453 fprintf(fp," }\n"); |
2416 } else { | 2454 } else { |
2417 fprintf(fp,"tty->print(\"No format defined for %s\n\");\n", _ident); | 2455 fprintf(fp," st->print(\"No format defined for %s\n\");\n", _ident); |
2418 fflush(fp); | 2456 fflush(fp); |
2419 fprintf(stderr,"No format defined for %s\n", _ident); | 2457 fprintf(stderr,"No format defined for %s\n", _ident); |
2420 dump(); | 2458 dump(); |
2421 assert( false,"Internal error:\n output_internal_operand() attempting to output other than a Register or Constant"); | 2459 assert( false,"Internal error:\n output_internal_operand() attempting to output other than a Register or Constant"); |
2422 } | 2460 } |
2426 // external access to reg# node->in(idx)->_idx, | 2464 // external access to reg# node->in(idx)->_idx, |
2427 void OperandForm::ext_format(FILE *fp, FormDict &globals, uint index) { | 2465 void OperandForm::ext_format(FILE *fp, FormDict &globals, uint index) { |
2428 Form::DataType dtype; | 2466 Form::DataType dtype; |
2429 if (_matrule && (_matrule->is_base_register(globals) || | 2467 if (_matrule && (_matrule->is_base_register(globals) || |
2430 strcmp(ideal_type(globalAD->globalNames()), "RegFlags") == 0)) { | 2468 strcmp(ideal_type(globalAD->globalNames()), "RegFlags") == 0)) { |
2431 fprintf(fp, "{ char reg_str[128];\n"); | 2469 fprintf(fp," { char reg_str[128];\n"); |
2432 fprintf(fp," ra->dump_register(node->in(idx"); | 2470 fprintf(fp," ra->dump_register(node->in(idx"); |
2433 if ( index != 0 ) fprintf(fp, "+%d",index); | 2471 if ( index != 0 ) fprintf(fp, "+%d",index); |
2434 fprintf(fp, "),reg_str);\n"); | 2472 fprintf(fp, "),reg_str);\n"); |
2435 fprintf(fp," tty->print(\"%cs\",reg_str);\n",'%'); | 2473 fprintf(fp," st->print(\"%cs\",reg_str);\n",'%'); |
2436 fprintf(fp," }\n"); | 2474 fprintf(fp," }\n"); |
2437 } else if (_matrule && (dtype = _matrule->is_base_constant(globals)) != Form::none) { | 2475 } else if (_matrule && (dtype = _matrule->is_base_constant(globals)) != Form::none) { |
2438 format_constant( fp, index, dtype ); | 2476 format_constant( fp, index, dtype ); |
2439 } else if (ideal_to_sReg_type(_ident) != Form::none) { | 2477 } else if (ideal_to_sReg_type(_ident) != Form::none) { |
2440 // Special format for Stack Slot Register | 2478 // Special format for Stack Slot Register |
2441 fprintf(fp, "{ char reg_str[128];\n"); | 2479 fprintf(fp," { char reg_str[128];\n"); |
2442 fprintf(fp," ra->dump_register(node->in(idx"); | 2480 fprintf(fp," ra->dump_register(node->in(idx"); |
2443 if ( index != 0 ) fprintf(fp, "+%d",index); | 2481 if ( index != 0 ) fprintf(fp, "+%d",index); |
2444 fprintf(fp, "),reg_str);\n"); | 2482 fprintf(fp, "),reg_str);\n"); |
2445 fprintf(fp," tty->print(\"%cs\",reg_str);\n",'%'); | 2483 fprintf(fp," st->print(\"%cs\",reg_str);\n",'%'); |
2446 fprintf(fp," }\n"); | 2484 fprintf(fp," }\n"); |
2447 } else { | 2485 } else { |
2448 fprintf(fp,"tty->print(\"No format defined for %s\n\");\n", _ident); | 2486 fprintf(fp," st->print(\"No format defined for %s\n\");\n", _ident); |
2449 assert( false,"Internal error:\n output_external_operand() attempting to output other than a Register or Constant"); | 2487 assert( false,"Internal error:\n output_external_operand() attempting to output other than a Register or Constant"); |
2450 } | 2488 } |
2451 } | 2489 } |
2452 | 2490 |
2453 void OperandForm::format_constant(FILE *fp, uint const_index, uint const_type) { | 2491 void OperandForm::format_constant(FILE *fp, uint const_index, uint const_type) { |
2454 switch(const_type) { | 2492 switch(const_type) { |
2455 case Form::idealI: fprintf(fp,"st->print(\"#%%d\", _c%d);\n", const_index); break; | 2493 case Form::idealI: fprintf(fp," st->print(\"#%%d\", _c%d);\n", const_index); break; |
2456 case Form::idealP: fprintf(fp,"_c%d->dump_on(st);\n", const_index); break; | 2494 case Form::idealP: fprintf(fp," if (_c%d) _c%d->dump_on(st);\n", const_index, const_index); break; |
2457 case Form::idealNKlass: | 2495 case Form::idealNKlass: |
2458 case Form::idealN: fprintf(fp,"_c%d->dump_on(st);\n", const_index); break; | 2496 case Form::idealN: fprintf(fp," if (_c%d) _c%d->dump_on(st);\n", const_index, const_index); break; |
2459 case Form::idealL: fprintf(fp,"st->print(\"#%%lld\", _c%d);\n", const_index); break; | 2497 case Form::idealL: fprintf(fp," st->print(\"#%%lld\", _c%d);\n", const_index); break; |
2460 case Form::idealF: fprintf(fp,"st->print(\"#%%f\", _c%d);\n", const_index); break; | 2498 case Form::idealF: fprintf(fp," st->print(\"#%%f\", _c%d);\n", const_index); break; |
2461 case Form::idealD: fprintf(fp,"st->print(\"#%%f\", _c%d);\n", const_index); break; | 2499 case Form::idealD: fprintf(fp," st->print(\"#%%f\", _c%d);\n", const_index); break; |
2462 default: | 2500 default: |
2463 assert( false, "ShouldNotReachHere()"); | 2501 assert( false, "ShouldNotReachHere()"); |
2464 } | 2502 } |
2465 } | 2503 } |
2466 | 2504 |
2826 | 2864 |
2827 void Component::output(FILE *fp) { | 2865 void Component::output(FILE *fp) { |
2828 fprintf(fp,"Component:"); // Write to output files | 2866 fprintf(fp,"Component:"); // Write to output files |
2829 fprintf(fp, " name = %s", _name); | 2867 fprintf(fp, " name = %s", _name); |
2830 fprintf(fp, ", type = %s", _type); | 2868 fprintf(fp, ", type = %s", _type); |
2831 const char * usedef = "Undefined Use/Def info"; | 2869 assert(_usedef != 0, "unknown effect"); |
2832 switch (_usedef) { | 2870 fprintf(fp, ", use/def = %s\n", getUsedefName()); |
2833 case USE: usedef = "USE"; break; | |
2834 case USE_DEF: usedef = "USE_DEF"; break; | |
2835 case USE_KILL: usedef = "USE_KILL"; break; | |
2836 case KILL: usedef = "KILL"; break; | |
2837 case TEMP: usedef = "TEMP"; break; | |
2838 case DEF: usedef = "DEF"; break; | |
2839 default: assert(false, "unknown effect"); | |
2840 } | |
2841 fprintf(fp, ", use/def = %s\n", usedef); | |
2842 } | 2871 } |
2843 | 2872 |
2844 | 2873 |
2845 //------------------------------ComponentList--------------------------------- | 2874 //------------------------------ComponentList--------------------------------- |
2846 ComponentList::ComponentList() : NameList(), _matchcnt(0) { | 2875 ComponentList::ComponentList() : NameList(), _matchcnt(0) { |
2928 } | 2957 } |
2929 | 2958 |
2930 return count; | 2959 return count; |
2931 } | 2960 } |
2932 | 2961 |
2933 // Return zero-based position in list; -1 if not in list. | 2962 // Return zero-based position of operand 'name' in list; -1 if not in list. |
2934 // if parameter 'usedef' is ::USE, it will match USE, USE_DEF, ... | 2963 // if parameter 'usedef' is ::USE, it will match USE, USE_DEF, ... |
2935 int ComponentList::operand_position(const char *name, int usedef) { | 2964 int ComponentList::operand_position(const char *name, int usedef, Form *fm) { |
2936 PreserveIter pi(this); | 2965 PreserveIter pi(this); |
2937 int position = 0; | 2966 int position = 0; |
2938 int num_opnds = num_operands(); | 2967 int num_opnds = num_operands(); |
2939 Component *component; | 2968 Component *component; |
2940 Component* preceding_non_use = NULL; | 2969 Component* preceding_non_use = NULL; |
2953 && usedef==Component::USE && component->isa(Component::DEF) ) { | 2982 && usedef==Component::USE && component->isa(Component::DEF) ) { |
2954 assert(position+1 < num_opnds, "advertised index in bounds"); | 2983 assert(position+1 < num_opnds, "advertised index in bounds"); |
2955 return position+1; | 2984 return position+1; |
2956 } else { | 2985 } else { |
2957 if( preceding_non_use && strcmp(component->_name, preceding_non_use->_name) ) { | 2986 if( preceding_non_use && strcmp(component->_name, preceding_non_use->_name) ) { |
2958 fprintf(stderr, "the name '%s' should not precede the name '%s'\n", preceding_non_use->_name, name); | 2987 fprintf(stderr, "the name '%s(%s)' should not precede the name '%s(%s)'", |
2988 preceding_non_use->_name, preceding_non_use->getUsedefName(), | |
2989 name, component->getUsedefName()); | |
2990 if (fm && fm->is_instruction()) fprintf(stderr, "in form '%s'", fm->is_instruction()->_ident); | |
2991 if (fm && fm->is_operand()) fprintf(stderr, "in form '%s'", fm->is_operand()->_ident); | |
2992 fprintf(stderr, "\n"); | |
2959 } | 2993 } |
2960 if( position >= num_opnds ) { | 2994 if( position >= num_opnds ) { |
2961 fprintf(stderr, "the name '%s' is too late in its name list\n", name); | 2995 fprintf(stderr, "the name '%s' is too late in its name list", name); |
2996 if (fm && fm->is_instruction()) fprintf(stderr, "in form '%s'", fm->is_instruction()->_ident); | |
2997 if (fm && fm->is_operand()) fprintf(stderr, "in form '%s'", fm->is_operand()->_ident); | |
2998 fprintf(stderr, "\n"); | |
2962 } | 2999 } |
2963 assert(position < num_opnds, "advertised index in bounds"); | 3000 assert(position < num_opnds, "advertised index in bounds"); |
2964 return position; | 3001 return position; |
2965 } | 3002 } |
2966 } | 3003 } |
3002 } | 3039 } |
3003 } | 3040 } |
3004 return Not_in_list; | 3041 return Not_in_list; |
3005 } | 3042 } |
3006 | 3043 |
3007 int ComponentList::operand_position_format(const char *name) { | 3044 int ComponentList::operand_position_format(const char *name, Form *fm) { |
3008 PreserveIter pi(this); | 3045 PreserveIter pi(this); |
3009 int first_position = operand_position(name); | 3046 int first_position = operand_position(name); |
3010 int use_position = operand_position(name, Component::USE); | 3047 int use_position = operand_position(name, Component::USE, fm); |
3011 | 3048 |
3012 return ((first_position < use_position) ? use_position : first_position); | 3049 return ((first_position < use_position) ? use_position : first_position); |
3013 } | 3050 } |
3014 | 3051 |
3015 int ComponentList::label_position() { | 3052 int ComponentList::label_position() { |
3268 // If there is no right reduction, return NULL. | 3305 // If there is no right reduction, return NULL. |
3269 const char *rightStr = NULL; | 3306 const char *rightStr = NULL; |
3270 | 3307 |
3271 // If we are a "Set", start from the right child. | 3308 // If we are a "Set", start from the right child. |
3272 const MatchNode *const mnode = sets_result() ? | 3309 const MatchNode *const mnode = sets_result() ? |
3273 (const MatchNode *const)this->_rChild : | 3310 (const MatchNode *)this->_rChild : |
3274 (const MatchNode *const)this; | 3311 (const MatchNode *)this; |
3275 | 3312 |
3276 // If our right child exists, it is the right reduction | 3313 // If our right child exists, it is the right reduction |
3277 if ( mnode->_rChild ) { | 3314 if ( mnode->_rChild ) { |
3278 rightStr = mnode->_rChild->_internalop ? mnode->_rChild->_internalop | 3315 rightStr = mnode->_rChild->_internalop ? mnode->_rChild->_internalop |
3279 : mnode->_rChild->_opType; | 3316 : mnode->_rChild->_opType; |
3286 // If there is no left reduction, return NULL. | 3323 // If there is no left reduction, return NULL. |
3287 const char *leftStr = NULL; | 3324 const char *leftStr = NULL; |
3288 | 3325 |
3289 // If we are a "Set", start from the right child. | 3326 // If we are a "Set", start from the right child. |
3290 const MatchNode *const mnode = sets_result() ? | 3327 const MatchNode *const mnode = sets_result() ? |
3291 (const MatchNode *const)this->_rChild : | 3328 (const MatchNode *)this->_rChild : |
3292 (const MatchNode *const)this; | 3329 (const MatchNode *)this; |
3293 | 3330 |
3294 // If our left child exists, it is the left reduction | 3331 // If our left child exists, it is the left reduction |
3295 if ( mnode->_lChild ) { | 3332 if ( mnode->_lChild ) { |
3296 leftStr = mnode->_lChild->_internalop ? mnode->_lChild->_internalop | 3333 leftStr = mnode->_lChild->_internalop ? mnode->_lChild->_internalop |
3297 : mnode->_lChild->_opType; | 3334 : mnode->_lChild->_opType; |
4111 | 4148 |
4112 void MatchRule::dump() { | 4149 void MatchRule::dump() { |
4113 output(stderr); | 4150 output(stderr); |
4114 } | 4151 } |
4115 | 4152 |
4116 void MatchRule::output(FILE *fp) { | 4153 // Write just one line. |
4154 void MatchRule::output_short(FILE *fp) { | |
4117 fprintf(fp,"MatchRule: ( %s",_name); | 4155 fprintf(fp,"MatchRule: ( %s",_name); |
4118 if (_lChild) _lChild->output(fp); | 4156 if (_lChild) _lChild->output(fp); |
4119 if (_rChild) _rChild->output(fp); | 4157 if (_rChild) _rChild->output(fp); |
4120 fprintf(fp," )\n"); | 4158 fprintf(fp," )"); |
4121 fprintf(fp," nesting depth = %d\n", _depth); | 4159 } |
4160 | |
4161 void MatchRule::output(FILE *fp) { | |
4162 output_short(fp); | |
4163 fprintf(fp,"\n nesting depth = %d\n", _depth); | |
4122 if (_result) fprintf(fp," Result Type = %s", _result); | 4164 if (_result) fprintf(fp," Result Type = %s", _result); |
4123 fprintf(fp,"\n"); | 4165 fprintf(fp,"\n"); |
4124 } | 4166 } |
4125 | 4167 |
4126 //------------------------------Attribute-------------------------------------- | 4168 //------------------------------Attribute-------------------------------------- |