comparison src/share/vm/adlc/output_c.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 8e47bac5643a
children 705ef39fcaa9
comparison
equal deleted inserted replaced
6849:f6badecb7ea7 6850:d336b3173277
516 516
517 memset(res_mask, 0, cyclemasksize * sizeof(uint)); 517 memset(res_mask, 0, cyclemasksize * sizeof(uint));
518 518
519 int cycles = piperesource->_cycles; 519 int cycles = piperesource->_cycles;
520 uint stage = pipeline->_stages.index(piperesource->_stage); 520 uint stage = pipeline->_stages.index(piperesource->_stage);
521 if (NameList::Not_in_list == stage) {
522 fprintf(stderr,
523 "pipeline_res_mask_initializer: "
524 "semantic error: "
525 "pipeline stage undeclared: %s\n",
526 piperesource->_stage);
527 exit(1);
528 }
521 uint upper_limit = stage+cycles-1; 529 uint upper_limit = stage+cycles-1;
522 uint lower_limit = stage-1; 530 uint lower_limit = stage-1;
523 uint upper_idx = upper_limit >> 5; 531 uint upper_idx = upper_limit >> 5;
524 uint lower_idx = lower_limit >> 5; 532 uint lower_idx = lower_limit >> 5;
525 uint upper_position = upper_limit & 0x1f; 533 uint upper_position = upper_limit & 0x1f;
998 for ( _pipeline->_noplist.reset(); (nop = _pipeline->_noplist.iter()) != NULL; i++ ) { 1006 for ( _pipeline->_noplist.reset(); (nop = _pipeline->_noplist.iter()) != NULL; i++ ) {
999 fprintf(fp_cpp, " nop_list[%d] = (MachNode *) new (C) %sNode();\n", i, nop); 1007 fprintf(fp_cpp, " nop_list[%d] = (MachNode *) new (C) %sNode();\n", i, nop);
1000 } 1008 }
1001 fprintf(fp_cpp, "};\n\n"); 1009 fprintf(fp_cpp, "};\n\n");
1002 fprintf(fp_cpp, "#ifndef PRODUCT\n"); 1010 fprintf(fp_cpp, "#ifndef PRODUCT\n");
1003 fprintf(fp_cpp, "void Bundle::dump() const {\n"); 1011 fprintf(fp_cpp, "void Bundle::dump(outputStream *st) const {\n");
1004 fprintf(fp_cpp, " static const char * bundle_flags[] = {\n"); 1012 fprintf(fp_cpp, " static const char * bundle_flags[] = {\n");
1005 fprintf(fp_cpp, " \"\",\n"); 1013 fprintf(fp_cpp, " \"\",\n");
1006 fprintf(fp_cpp, " \"use nop delay\",\n"); 1014 fprintf(fp_cpp, " \"use nop delay\",\n");
1007 fprintf(fp_cpp, " \"use unconditional delay\",\n"); 1015 fprintf(fp_cpp, " \"use unconditional delay\",\n");
1008 fprintf(fp_cpp, " \"use conditional delay\",\n"); 1016 fprintf(fp_cpp, " \"use conditional delay\",\n");
1017 fprintf(fp_cpp, "};\n\n"); 1025 fprintf(fp_cpp, "};\n\n");
1018 1026
1019 // See if the same string is in the table 1027 // See if the same string is in the table
1020 fprintf(fp_cpp, " bool needs_comma = false;\n\n"); 1028 fprintf(fp_cpp, " bool needs_comma = false;\n\n");
1021 fprintf(fp_cpp, " if (_flags) {\n"); 1029 fprintf(fp_cpp, " if (_flags) {\n");
1022 fprintf(fp_cpp, " tty->print(\"%%s\", bundle_flags[_flags]);\n"); 1030 fprintf(fp_cpp, " st->print(\"%%s\", bundle_flags[_flags]);\n");
1023 fprintf(fp_cpp, " needs_comma = true;\n"); 1031 fprintf(fp_cpp, " needs_comma = true;\n");
1024 fprintf(fp_cpp, " };\n"); 1032 fprintf(fp_cpp, " };\n");
1025 fprintf(fp_cpp, " if (instr_count()) {\n"); 1033 fprintf(fp_cpp, " if (instr_count()) {\n");
1026 fprintf(fp_cpp, " tty->print(\"%%s%%d instr%%s\", needs_comma ? \", \" : \"\", instr_count(), instr_count() != 1 ? \"s\" : \"\");\n"); 1034 fprintf(fp_cpp, " st->print(\"%%s%%d instr%%s\", needs_comma ? \", \" : \"\", instr_count(), instr_count() != 1 ? \"s\" : \"\");\n");
1027 fprintf(fp_cpp, " needs_comma = true;\n"); 1035 fprintf(fp_cpp, " needs_comma = true;\n");
1028 fprintf(fp_cpp, " };\n"); 1036 fprintf(fp_cpp, " };\n");
1029 fprintf(fp_cpp, " uint r = resources_used();\n"); 1037 fprintf(fp_cpp, " uint r = resources_used();\n");
1030 fprintf(fp_cpp, " if (r) {\n"); 1038 fprintf(fp_cpp, " if (r) {\n");
1031 fprintf(fp_cpp, " tty->print(\"%%sresource%%s:\", needs_comma ? \", \" : \"\", (r & (r-1)) != 0 ? \"s\" : \"\");\n"); 1039 fprintf(fp_cpp, " st->print(\"%%sresource%%s:\", needs_comma ? \", \" : \"\", (r & (r-1)) != 0 ? \"s\" : \"\");\n");
1032 fprintf(fp_cpp, " for (uint i = 0; i < %d; i++)\n", _pipeline->_rescount); 1040 fprintf(fp_cpp, " for (uint i = 0; i < %d; i++)\n", _pipeline->_rescount);
1033 fprintf(fp_cpp, " if ((r & (1 << i)) != 0)\n"); 1041 fprintf(fp_cpp, " if ((r & (1 << i)) != 0)\n");
1034 fprintf(fp_cpp, " tty->print(\" %%s\", resource_names[i]);\n"); 1042 fprintf(fp_cpp, " st->print(\" %%s\", resource_names[i]);\n");
1035 fprintf(fp_cpp, " needs_comma = true;\n"); 1043 fprintf(fp_cpp, " needs_comma = true;\n");
1036 fprintf(fp_cpp, " };\n"); 1044 fprintf(fp_cpp, " };\n");
1037 fprintf(fp_cpp, " tty->print(\"\\n\");\n"); 1045 fprintf(fp_cpp, " st->print(\"\\n\");\n");
1038 fprintf(fp_cpp, "}\n"); 1046 fprintf(fp_cpp, "}\n");
1039 fprintf(fp_cpp, "#endif\n"); 1047 fprintf(fp_cpp, "#endif\n");
1040 } 1048 }
1041 1049
1042 // --------------------------------------------------------------------------- 1050 // ---------------------------------------------------------------------------
1044 // --------------------------------------------------------------------------- 1052 // ---------------------------------------------------------------------------
1045 1053
1046 static void defineOut_RegMask(FILE *fp, const char *node, const char *regMask) { 1054 static void defineOut_RegMask(FILE *fp, const char *node, const char *regMask) {
1047 fprintf(fp,"const RegMask &%sNode::out_RegMask() const { return (%s); }\n", 1055 fprintf(fp,"const RegMask &%sNode::out_RegMask() const { return (%s); }\n",
1048 node, regMask); 1056 node, regMask);
1049 }
1050
1051 // Scan the peepmatch and output a test for each instruction
1052 static void check_peepmatch_instruction_tree(FILE *fp, PeepMatch *pmatch, PeepConstraint *pconstraint) {
1053 int parent = -1;
1054 int inst_position = 0;
1055 const char* inst_name = NULL;
1056 int input = 0;
1057 fprintf(fp, " // Check instruction sub-tree\n");
1058 pmatch->reset();
1059 for( pmatch->next_instruction( parent, inst_position, inst_name, input );
1060 inst_name != NULL;
1061 pmatch->next_instruction( parent, inst_position, inst_name, input ) ) {
1062 // If this is not a placeholder
1063 if( ! pmatch->is_placeholder() ) {
1064 // Define temporaries 'inst#', based on parent and parent's input index
1065 if( parent != -1 ) { // root was initialized
1066 fprintf(fp, " inst%d = inst%d->in(%d);\n",
1067 inst_position, parent, input);
1068 }
1069
1070 // When not the root
1071 // Test we have the correct instruction by comparing the rule
1072 if( parent != -1 ) {
1073 fprintf(fp, " matches = matches && ( inst%d->rule() == %s_rule );",
1074 inst_position, inst_name);
1075 }
1076 } else {
1077 // Check that user did not try to constrain a placeholder
1078 assert( ! pconstraint->constrains_instruction(inst_position),
1079 "fatal(): Can not constrain a placeholder instruction");
1080 }
1081 }
1082 } 1057 }
1083 1058
1084 static void print_block_index(FILE *fp, int inst_position) { 1059 static void print_block_index(FILE *fp, int inst_position) {
1085 assert( inst_position >= 0, "Instruction number less than zero"); 1060 assert( inst_position >= 0, "Instruction number less than zero");
1086 fprintf(fp, "block_index"); 1061 fprintf(fp, "block_index");
1240 // Need parameter for index position if not result operand 1215 // Need parameter for index position if not result operand
1241 char left_reg_index[] = ",instXXXX_idxXXXX"; 1216 char left_reg_index[] = ",instXXXX_idxXXXX";
1242 if( left_op_index != 0 ) { 1217 if( left_op_index != 0 ) {
1243 assert( (left_index <= 9999) && (left_op_index <= 9999), "exceed string size"); 1218 assert( (left_index <= 9999) && (left_op_index <= 9999), "exceed string size");
1244 // Must have index into operands 1219 // Must have index into operands
1245 sprintf(left_reg_index,",inst%d_idx%d", left_index, left_op_index); 1220 sprintf(left_reg_index,",inst%d_idx%d", (int)left_index, left_op_index);
1246 } else { 1221 } else {
1247 strcpy(left_reg_index, ""); 1222 strcpy(left_reg_index, "");
1248 } 1223 }
1249 fprintf(fp, "(inst%d->_opnds[%d]->reg(ra_,inst%d%s) /* %d.%s */", 1224 fprintf(fp, "(inst%d->_opnds[%d]->reg(ra_,inst%d%s) /* %d.%s */",
1250 left_index, left_op_index, left_index, left_reg_index, left_index, left_op ); 1225 left_index, left_op_index, left_index, left_reg_index, left_index, left_op );
1253 if( right_index != -1 ) { 1228 if( right_index != -1 ) {
1254 char right_reg_index[18] = ",instXXXX_idxXXXX"; 1229 char right_reg_index[18] = ",instXXXX_idxXXXX";
1255 if( right_op_index != 0 ) { 1230 if( right_op_index != 0 ) {
1256 assert( (right_index <= 9999) && (right_op_index <= 9999), "exceed string size"); 1231 assert( (right_index <= 9999) && (right_op_index <= 9999), "exceed string size");
1257 // Must have index into operands 1232 // Must have index into operands
1258 sprintf(right_reg_index,",inst%d_idx%d", right_index, right_op_index); 1233 sprintf(right_reg_index,",inst%d_idx%d", (int)right_index, right_op_index);
1259 } else { 1234 } else {
1260 strcpy(right_reg_index, ""); 1235 strcpy(right_reg_index, "");
1261 } 1236 }
1262 fprintf(fp, "/* %d.%s */ inst%d->_opnds[%d]->reg(ra_,inst%d%s)", 1237 fprintf(fp, "/* %d.%s */ inst%d->_opnds[%d]->reg(ra_,inst%d%s)",
1263 right_index, right_op, right_index, right_op_index, right_index, right_reg_index ); 1238 right_index, right_op, right_index, right_op_index, right_index, right_reg_index );
1643 // Check for an operand which is created in the expand rule 1618 // Check for an operand which is created in the expand rule
1644 if ((exp_pos = node->_exprule->_newopers.index(opid)) != -1) { 1619 if ((exp_pos = node->_exprule->_newopers.index(opid)) != -1) {
1645 new_pos = new_inst->operand_position(parameter,Component::USE); 1620 new_pos = new_inst->operand_position(parameter,Component::USE);
1646 exp_pos += node->num_opnds(); 1621 exp_pos += node->num_opnds();
1647 // If there is no use of the created operand, just skip it 1622 // If there is no use of the created operand, just skip it
1648 if (new_pos != -1) { 1623 if (new_pos != NameList::Not_in_list) {
1649 //Copy the operand from the original made above 1624 //Copy the operand from the original made above
1650 fprintf(fp," n%d->set_opnd_array(%d, op%d->clone(C)); // %s\n", 1625 fprintf(fp," n%d->set_opnd_array(%d, op%d->clone(C)); // %s\n",
1651 cnt, new_pos, exp_pos-node->num_opnds(), opid); 1626 cnt, new_pos, exp_pos-node->num_opnds(), opid);
1652 // Check for who defines this operand & add edge if needed 1627 // Check for who defines this operand & add edge if needed
1653 fprintf(fp," if(tmp%d != NULL)\n", exp_pos); 1628 fprintf(fp," if(tmp%d != NULL)\n", exp_pos);
1787 if( cur_num_opnds > 1 && cur_num_opnds != node->num_unique_opnds() ) { 1762 if( cur_num_opnds > 1 && cur_num_opnds != node->num_unique_opnds() ) {
1788 Component *comp = NULL; 1763 Component *comp = NULL;
1789 // Build mapping from num_edges to local variables 1764 // Build mapping from num_edges to local variables
1790 fprintf(fp," unsigned num0 = 0;\n"); 1765 fprintf(fp," unsigned num0 = 0;\n");
1791 for( i = 1; i < cur_num_opnds; i++ ) { 1766 for( i = 1; i < cur_num_opnds; i++ ) {
1792 fprintf(fp," unsigned num%d = opnd_array(%d)->num_edges();\n",i,i); 1767 fprintf(fp," unsigned num%d = opnd_array(%d)->num_edges();",i,i);
1768 fprintf(fp, " \t// %s\n", node->opnd_ident(i));
1793 } 1769 }
1794 // Build a mapping from operand index to input edges 1770 // Build a mapping from operand index to input edges
1795 fprintf(fp," unsigned idx0 = oper_input_base();\n"); 1771 fprintf(fp," unsigned idx0 = oper_input_base();\n");
1796 for( i = 0; i < cur_num_opnds; i++ ) { 1772 for( i = 0; i < cur_num_opnds; i++ ) {
1797 fprintf(fp," unsigned idx%d = idx%d + num%d;\n", 1773 fprintf(fp," unsigned idx%d = idx%d + num%d;\n",
1932 _reloc_type = AdlcVMDeps::none_reloc_type(); 1908 _reloc_type = AdlcVMDeps::none_reloc_type();
1933 _strings_to_emit.clear(); 1909 _strings_to_emit.clear();
1934 } 1910 }
1935 1911
1936 // Track necessary state when identifying a replacement variable 1912 // Track necessary state when identifying a replacement variable
1913 // @arg rep_var: The formal parameter of the encoding.
1937 void update_state(const char *rep_var) { 1914 void update_state(const char *rep_var) {
1938 // A replacement variable or one of its subfields 1915 // A replacement variable or one of its subfields
1939 // Obtain replacement variable from list 1916 // Obtain replacement variable from list
1940 if ( (*rep_var) != '$' ) { 1917 if ( (*rep_var) != '$' ) {
1941 // A replacement variable, '$' prefix 1918 // A replacement variable, '$' prefix
1953 "Replacement variable %s not allowed in instruct %s (only in MachConstantNode).\n", 1930 "Replacement variable %s not allowed in instruct %s (only in MachConstantNode).\n",
1954 rep_var, _encoding._name); 1931 rep_var, _encoding._name);
1955 } 1932 }
1956 } 1933 }
1957 else { 1934 else {
1958 // Lookup its position in parameter list 1935 // Lookup its position in (formal) parameter list of encoding
1959 int param_no = _encoding.rep_var_index(rep_var); 1936 int param_no = _encoding.rep_var_index(rep_var);
1960 if ( param_no == -1 ) { 1937 if ( param_no == -1 ) {
1961 _AD.syntax_err( _encoding._linenum, 1938 _AD.syntax_err( _encoding._linenum,
1962 "Replacement variable %s not found in enc_class %s.\n", 1939 "Replacement variable %s not found in enc_class %s.\n",
1963 rep_var, _encoding._name); 1940 rep_var, _encoding._name);
1964 } 1941 }
1965 1942
1966 // Lookup the corresponding ins_encode parameter 1943 // Lookup the corresponding ins_encode parameter
1944 // This is the argument (actual parameter) to the encoding.
1967 const char *inst_rep_var = _ins_encode.rep_var_name(_inst, param_no); 1945 const char *inst_rep_var = _ins_encode.rep_var_name(_inst, param_no);
1968 if (inst_rep_var == NULL) { 1946 if (inst_rep_var == NULL) {
1969 _AD.syntax_err( _ins_encode._linenum, 1947 _AD.syntax_err( _ins_encode._linenum,
1970 "Parameter %s not passed to enc_class %s from instruct %s.\n", 1948 "Parameter %s not passed to enc_class %s from instruct %s.\n",
1971 rep_var, _encoding._name, _inst._ident); 1949 rep_var, _encoding._name, _inst._ident);
2327 } else { 2305 } else {
2328 fprintf(_fp,"->%s(ra_,this", reg_convert != NULL ? reg_convert : "reg"); 2306 fprintf(_fp,"->%s(ra_,this", reg_convert != NULL ? reg_convert : "reg");
2329 // Add parameter for index position, if not result operand 2307 // Add parameter for index position, if not result operand
2330 if( _operand_idx != 0 ) fprintf(_fp,",idx%d", _operand_idx); 2308 if( _operand_idx != 0 ) fprintf(_fp,",idx%d", _operand_idx);
2331 fprintf(_fp,")"); 2309 fprintf(_fp,")");
2310 fprintf(_fp, "/* %s */", _operand_name);
2332 } 2311 }
2333 } else { 2312 } else {
2334 assert( _reg_status == LITERAL_OUTPUT, "should have output register literal in emit_rep_var"); 2313 assert( _reg_status == LITERAL_OUTPUT, "should have output register literal in emit_rep_var");
2335 // Register literal has already been sent to output file, nothing more needed 2314 // Register literal has already been sent to output file, nothing more needed
2336 } 2315 }
2366 } else { 2345 } else {
2367 fprintf(_fp,"->constant()"); 2346 fprintf(_fp,"->constant()");
2368 } 2347 }
2369 } else { 2348 } else {
2370 assert( _constant_status == LITERAL_OUTPUT, "should have output constant literal in emit_rep_var"); 2349 assert( _constant_status == LITERAL_OUTPUT, "should have output constant literal in emit_rep_var");
2371 // Cosntant literal has already been sent to output file, nothing more needed 2350 // Constant literal has already been sent to output file, nothing more needed
2372 } 2351 }
2373 } 2352 }
2374 else if ( strcmp(rep_var,"$disp") == 0 ) { 2353 else if ( strcmp(rep_var,"$disp") == 0 ) {
2375 Form::DataType stack_type = _operand ? _operand->is_user_name_for_sReg() : Form::none; 2354 Form::DataType stack_type = _operand ? _operand->is_user_name_for_sReg() : Form::none;
2376 if( _operand && _operand_idx==0 && stack_type != Form::none ) { 2355 if( _operand && _operand_idx==0 && stack_type != Form::none ) {
2385 else if ( strcmp(rep_var,"$method") == 0 ) { 2364 else if ( strcmp(rep_var,"$method") == 0 ) {
2386 fprintf(_fp,"->method()"); 2365 fprintf(_fp,"->method()");
2387 } 2366 }
2388 else { 2367 else {
2389 printf("emit_field: %s\n",rep_var); 2368 printf("emit_field: %s\n",rep_var);
2369 globalAD->syntax_err(_inst._linenum, "Unknown replacement variable %s in format statement of %s.",
2370 rep_var, _inst._ident);
2390 assert( false, "UnImplemented()"); 2371 assert( false, "UnImplemented()");
2391 } 2372 }
2392 } 2373 }
2393 2374
2394 2375
2482 2463
2483 void ArchDesc::defineSize(FILE *fp, InstructForm &inst) { 2464 void ArchDesc::defineSize(FILE *fp, InstructForm &inst) {
2484 2465
2485 //(1) 2466 //(1)
2486 // Output instruction's emit prototype 2467 // Output instruction's emit prototype
2487 fprintf(fp,"uint %sNode::size(PhaseRegAlloc *ra_) const {\n", 2468 fprintf(fp,"uint %sNode::size(PhaseRegAlloc *ra_) const {\n",
2488 inst._ident); 2469 inst._ident);
2489 2470
2490 fprintf(fp, " assert(VerifyOops || MachNode::size(ra_) <= %s, \"bad fixed size\");\n", inst._size); 2471 fprintf(fp, " assert(VerifyOops || MachNode::size(ra_) <= %s, \"bad fixed size\");\n", inst._size);
2491 2472
2492 //(2) 2473 //(2)
2493 // Print the size 2474 // Print the size
2494 fprintf(fp, " return (VerifyOops ? MachNode::size(ra_) : %s);\n", inst._size); 2475 fprintf(fp, " return (VerifyOops ? MachNode::size(ra_) : %s);\n", inst._size);
2495 2476
2496 // (3) and (4) 2477 // (3) and (4)
2497 fprintf(fp,"}\n"); 2478 fprintf(fp,"}\n");
2498 } 2479 }
2499 2480
2577 if ( user_defined == false ) { 2558 if ( user_defined == false ) {
2578 fprintf(fp, " // User did not define which encode class to use.\n"); 2559 fprintf(fp, " // User did not define which encode class to use.\n");
2579 } 2560 }
2580 2561
2581 // (3) and (4) 2562 // (3) and (4)
2582 fprintf(fp, "}\n"); 2563 fprintf(fp, "}\n\n");
2583 } 2564 }
2584 2565
2585 // defineEvalConstant --------------------------------------------------------- 2566 // defineEvalConstant ---------------------------------------------------------
2586 void ArchDesc::defineEvalConstant(FILE* fp, InstructForm& inst) { 2567 void ArchDesc::defineEvalConstant(FILE* fp, InstructForm& inst) {
2587 InsEncode* encode = inst._constant; 2568 InsEncode* encode = inst._constant;
2725 // (0) MachOper *MachOperXOper::clone(Compile* C) const { 2706 // (0) MachOper *MachOperXOper::clone(Compile* C) const {
2726 // (1) return new (C) MachXOper( _ccode, _c0, _c1, ..., _cn); 2707 // (1) return new (C) MachXOper( _ccode, _c0, _c1, ..., _cn);
2727 // (2) } 2708 // (2) }
2728 // 2709 //
2729 static void defineClone(FILE *fp, FormDict &globalNames, OperandForm &oper) { 2710 static void defineClone(FILE *fp, FormDict &globalNames, OperandForm &oper) {
2730 fprintf(fp,"MachOper *%sOper::clone(Compile* C) const {\n", oper._ident); 2711 fprintf(fp,"MachOper *%sOper::clone(Compile* C) const {\n", oper._ident);
2731 // Check for constants that need to be copied over 2712 // Check for constants that need to be copied over
2732 const int num_consts = oper.num_consts(globalNames); 2713 const int num_consts = oper.num_consts(globalNames);
2733 const bool is_ideal_bool = oper.is_ideal_bool(); 2714 const bool is_ideal_bool = oper.is_ideal_bool();
2734 if( (num_consts > 0) ) { 2715 if( (num_consts > 0) ) {
2735 fprintf(fp," return new (C) %sOper(", oper._ident); 2716 fprintf(fp," return new (C) %sOper(", oper._ident);
2736 // generate parameters for constants 2717 // generate parameters for constants
2737 int i = 0; 2718 int i = 0;
2738 fprintf(fp,"_c%d", i); 2719 fprintf(fp,"_c%d", i);
2739 for( i = 1; i < num_consts; ++i) { 2720 for( i = 1; i < num_consts; ++i) {
2740 fprintf(fp,", _c%d", i); 2721 fprintf(fp,", _c%d", i);
2742 // finish line (1) 2723 // finish line (1)
2743 fprintf(fp,");\n"); 2724 fprintf(fp,");\n");
2744 } 2725 }
2745 else { 2726 else {
2746 assert( num_consts == 0, "Currently support zero or one constant per operand clone function"); 2727 assert( num_consts == 0, "Currently support zero or one constant per operand clone function");
2747 fprintf(fp," return new (C) %sOper();\n", oper._ident); 2728 fprintf(fp," return new (C) %sOper();\n", oper._ident);
2748 } 2729 }
2749 // finish method 2730 // finish method
2750 fprintf(fp,"}\n"); 2731 fprintf(fp,"}\n");
2751 } 2732 }
2752
2753 static void define_hash(FILE *fp, char *operand) {
2754 fprintf(fp,"uint %sOper::hash() const { return 5; }\n", operand);
2755 }
2756
2757 static void define_cmp(FILE *fp, char *operand) {
2758 fprintf(fp,"uint %sOper::cmp( const MachOper &oper ) const { return opcode() == oper.opcode(); }\n", operand);
2759 }
2760
2761 2733
2762 // Helper functions for bug 4796752, abstracted with minimal modification 2734 // Helper functions for bug 4796752, abstracted with minimal modification
2763 // from define_oper_interface() 2735 // from define_oper_interface()
2764 OperandForm *rep_var_to_operand(const char *encoding, OperandForm &oper, FormDict &globals) { 2736 OperandForm *rep_var_to_operand(const char *encoding, OperandForm &oper, FormDict &globals) {
2765 OperandForm *op = NULL; 2737 OperandForm *op = NULL;
2850 fprintf(fp,"(PhaseRegAlloc *ra_, const Node *node, int idx) const { \n"); 2822 fprintf(fp,"(PhaseRegAlloc *ra_, const Node *node, int idx) const { \n");
2851 emit_position = true; 2823 emit_position = true;
2852 } else if ( (strcmp(name,"disp") == 0) ) { 2824 } else if ( (strcmp(name,"disp") == 0) ) {
2853 fprintf(fp,"(PhaseRegAlloc *ra_, const Node *node, int idx) const { \n"); 2825 fprintf(fp,"(PhaseRegAlloc *ra_, const Node *node, int idx) const { \n");
2854 } else { 2826 } else {
2855 fprintf(fp,"() const { "); 2827 fprintf(fp,"() const { \n");
2856 } 2828 }
2857 2829
2858 // Check for hexadecimal value OR replacement variable 2830 // Check for hexadecimal value OR replacement variable
2859 if( *encoding == '$' ) { 2831 if( *encoding == '$' ) {
2860 // Replacement variable 2832 // Replacement variable
2861 const char *rep_var = encoding + 1; 2833 const char *rep_var = encoding + 1;
2862 fprintf(fp,"// Replacement variable: %s\n", encoding+1); 2834 fprintf(fp," // Replacement variable: %s\n", encoding+1);
2863 // Lookup replacement variable, rep_var, in operand's component list 2835 // Lookup replacement variable, rep_var, in operand's component list
2864 const Component *comp = oper._components.search(rep_var); 2836 const Component *comp = oper._components.search(rep_var);
2865 assert( comp != NULL, "Replacement variable not found in components"); 2837 assert( comp != NULL, "Replacement variable not found in components");
2866 // Lookup operand form for replacement variable's type 2838 // Lookup operand form for replacement variable's type
2867 const char *type = comp->_type; 2839 const char *type = comp->_type;
2878 if ( idx_offset > 0 ) fprintf(fp, "+%d",idx_offset); 2850 if ( idx_offset > 0 ) fprintf(fp, "+%d",idx_offset);
2879 fprintf(fp,"));\n"); 2851 fprintf(fp,"));\n");
2880 } else if ( op->ideal_to_sReg_type(op->_ident) != Form::none ) { 2852 } else if ( op->ideal_to_sReg_type(op->_ident) != Form::none ) {
2881 // StackSlot for an sReg comes either from input node or from self, when idx==0 2853 // StackSlot for an sReg comes either from input node or from self, when idx==0
2882 fprintf(fp," if( idx != 0 ) {\n"); 2854 fprintf(fp," if( idx != 0 ) {\n");
2883 fprintf(fp," // Access register number for input operand\n"); 2855 fprintf(fp," // Access stack offset (register number) for input operand\n");
2884 fprintf(fp," return ra_->reg2offset(ra_->get_reg_first(node->in(idx)));/* sReg */\n"); 2856 fprintf(fp," return ra_->reg2offset(ra_->get_reg_first(node->in(idx)));/* sReg */\n");
2885 fprintf(fp," }\n"); 2857 fprintf(fp," }\n");
2886 fprintf(fp," // Access register number from myself\n"); 2858 fprintf(fp," // Access stack offset (register number) from myself\n");
2887 fprintf(fp," return ra_->reg2offset(ra_->get_reg_first(node));/* sReg */\n"); 2859 fprintf(fp," return ra_->reg2offset(ra_->get_reg_first(node));/* sReg */\n");
2888 } else if (op->_matrule && op->_matrule->is_base_constant(globals)) { 2860 } else if (op->_matrule && op->_matrule->is_base_constant(globals)) {
2889 // Constant 2861 // Constant
2890 // Check which constant this name maps to: _c0, _c1, ..., _cn 2862 // Check which constant this name maps to: _c0, _c1, ..., _cn
2891 const int idx = oper.constant_position(globals, comp); 2863 const int idx = oper.constant_position(globals, comp);
2898 assert( false, "Attempting to emit a non-register or non-constant"); 2870 assert( false, "Attempting to emit a non-register or non-constant");
2899 } 2871 }
2900 } 2872 }
2901 else if( *encoding == '0' && *(encoding+1) == 'x' ) { 2873 else if( *encoding == '0' && *(encoding+1) == 'x' ) {
2902 // Hex value 2874 // Hex value
2903 fprintf(fp,"return %s;", encoding); 2875 fprintf(fp," return %s;\n", encoding);
2904 } else { 2876 } else {
2905 assert( false, "Do not support octal or decimal encode constants"); 2877 assert( false, "Do not support octal or decimal encode constants");
2906 } 2878 }
2907 fprintf(fp," }\n"); 2879 fprintf(fp," }\n");
2908 2880
3131 _instructions.reset(); 3103 _instructions.reset();
3132 while( (instr = (InstructForm*)_instructions.iter()) != NULL ) { 3104 while( (instr = (InstructForm*)_instructions.iter()) != NULL ) {
3133 // Output the definition for number of relocation entries 3105 // Output the definition for number of relocation entries
3134 uint reloc_size = instr->reloc(_globalNames); 3106 uint reloc_size = instr->reloc(_globalNames);
3135 if ( reloc_size != 0 ) { 3107 if ( reloc_size != 0 ) {
3136 fprintf(fp,"int %sNode::reloc() const {\n", instr->_ident); 3108 fprintf(fp,"int %sNode::reloc() const {\n", instr->_ident);
3137 fprintf(fp, " return %d;\n", reloc_size ); 3109 fprintf(fp," return %d;\n", reloc_size);
3138 fprintf(fp,"}\n"); 3110 fprintf(fp,"}\n");
3139 fprintf(fp,"\n"); 3111 fprintf(fp,"\n");
3140 } 3112 }
3141 } 3113 }
3142 fprintf(fp,"\n"); 3114 fprintf(fp,"\n");
3239 3211
3240 // Information needed to generate the ReduceOp mapping for the DFA 3212 // Information needed to generate the ReduceOp mapping for the DFA
3241 class OutputReduceOp : public OutputMap { 3213 class OutputReduceOp : public OutputMap {
3242 public: 3214 public:
3243 OutputReduceOp(FILE *hpp, FILE *cpp, FormDict &globals, ArchDesc &AD) 3215 OutputReduceOp(FILE *hpp, FILE *cpp, FormDict &globals, ArchDesc &AD)
3244 : OutputMap(hpp, cpp, globals, AD) {}; 3216 : OutputMap(hpp, cpp, globals, AD, "reduceOp") {};
3245 3217
3246 void declaration() { fprintf(_hpp, "extern const int reduceOp[];\n"); } 3218 void declaration() { fprintf(_hpp, "extern const int reduceOp[];\n"); }
3247 void definition() { fprintf(_cpp, "const int reduceOp[] = {\n"); } 3219 void definition() { fprintf(_cpp, "const int reduceOp[] = {\n"); }
3248 void closing() { fprintf(_cpp, " 0 // no trailing comma\n"); 3220 void closing() { fprintf(_cpp, " 0 // no trailing comma\n");
3249 OutputMap::closing(); 3221 OutputMap::closing();
3274 3246
3275 // Information needed to generate the LeftOp mapping for the DFA 3247 // Information needed to generate the LeftOp mapping for the DFA
3276 class OutputLeftOp : public OutputMap { 3248 class OutputLeftOp : public OutputMap {
3277 public: 3249 public:
3278 OutputLeftOp(FILE *hpp, FILE *cpp, FormDict &globals, ArchDesc &AD) 3250 OutputLeftOp(FILE *hpp, FILE *cpp, FormDict &globals, ArchDesc &AD)
3279 : OutputMap(hpp, cpp, globals, AD) {}; 3251 : OutputMap(hpp, cpp, globals, AD, "leftOp") {};
3280 3252
3281 void declaration() { fprintf(_hpp, "extern const int leftOp[];\n"); } 3253 void declaration() { fprintf(_hpp, "extern const int leftOp[];\n"); }
3282 void definition() { fprintf(_cpp, "const int leftOp[] = {\n"); } 3254 void definition() { fprintf(_cpp, "const int leftOp[] = {\n"); }
3283 void closing() { fprintf(_cpp, " 0 // no trailing comma\n"); 3255 void closing() { fprintf(_cpp, " 0 // no trailing comma\n");
3284 OutputMap::closing(); 3256 OutputMap::closing();
3304 3276
3305 // Information needed to generate the RightOp mapping for the DFA 3277 // Information needed to generate the RightOp mapping for the DFA
3306 class OutputRightOp : public OutputMap { 3278 class OutputRightOp : public OutputMap {
3307 public: 3279 public:
3308 OutputRightOp(FILE *hpp, FILE *cpp, FormDict &globals, ArchDesc &AD) 3280 OutputRightOp(FILE *hpp, FILE *cpp, FormDict &globals, ArchDesc &AD)
3309 : OutputMap(hpp, cpp, globals, AD) {}; 3281 : OutputMap(hpp, cpp, globals, AD, "rightOp") {};
3310 3282
3311 void declaration() { fprintf(_hpp, "extern const int rightOp[];\n"); } 3283 void declaration() { fprintf(_hpp, "extern const int rightOp[];\n"); }
3312 void definition() { fprintf(_cpp, "const int rightOp[] = {\n"); } 3284 void definition() { fprintf(_cpp, "const int rightOp[] = {\n"); }
3313 void closing() { fprintf(_cpp, " 0 // no trailing comma\n"); 3285 void closing() { fprintf(_cpp, " 0 // no trailing comma\n");
3314 OutputMap::closing(); 3286 OutputMap::closing();
3334 3306
3335 // Information needed to generate the Rule names for the DFA 3307 // Information needed to generate the Rule names for the DFA
3336 class OutputRuleName : public OutputMap { 3308 class OutputRuleName : public OutputMap {
3337 public: 3309 public:
3338 OutputRuleName(FILE *hpp, FILE *cpp, FormDict &globals, ArchDesc &AD) 3310 OutputRuleName(FILE *hpp, FILE *cpp, FormDict &globals, ArchDesc &AD)
3339 : OutputMap(hpp, cpp, globals, AD) {}; 3311 : OutputMap(hpp, cpp, globals, AD, "ruleName") {};
3340 3312
3341 void declaration() { fprintf(_hpp, "extern const char *ruleName[];\n"); } 3313 void declaration() { fprintf(_hpp, "extern const char *ruleName[];\n"); }
3342 void definition() { fprintf(_cpp, "const char *ruleName[] = {\n"); } 3314 void definition() { fprintf(_cpp, "const char *ruleName[] = {\n"); }
3343 void closing() { fprintf(_cpp, " \"no trailing comma\"\n"); 3315 void closing() { fprintf(_cpp, " \"invalid rule name\" // no trailing comma\n");
3344 OutputMap::closing(); 3316 OutputMap::closing();
3345 } 3317 }
3346 void map(OpClassForm &opc) { fprintf(_cpp, " \"%s\"", _AD.machOperEnum(opc._ident) ); } 3318 void map(OpClassForm &opc) { fprintf(_cpp, " \"%s\"", _AD.machOperEnum(opc._ident) ); }
3347 void map(OperandForm &oper) { fprintf(_cpp, " \"%s\"", _AD.machOperEnum(oper._ident) ); } 3319 void map(OperandForm &oper) { fprintf(_cpp, " \"%s\"", _AD.machOperEnum(oper._ident) ); }
3348 void map(char *name) { fprintf(_cpp, " \"%s\"", name ? name : "0"); } 3320 void map(char *name) { fprintf(_cpp, " \"%s\"", name ? name : "0"); }
3352 3324
3353 // Information needed to generate the swallowed mapping for the DFA 3325 // Information needed to generate the swallowed mapping for the DFA
3354 class OutputSwallowed : public OutputMap { 3326 class OutputSwallowed : public OutputMap {
3355 public: 3327 public:
3356 OutputSwallowed(FILE *hpp, FILE *cpp, FormDict &globals, ArchDesc &AD) 3328 OutputSwallowed(FILE *hpp, FILE *cpp, FormDict &globals, ArchDesc &AD)
3357 : OutputMap(hpp, cpp, globals, AD) {}; 3329 : OutputMap(hpp, cpp, globals, AD, "swallowed") {};
3358 3330
3359 void declaration() { fprintf(_hpp, "extern const bool swallowed[];\n"); } 3331 void declaration() { fprintf(_hpp, "extern const bool swallowed[];\n"); }
3360 void definition() { fprintf(_cpp, "const bool swallowed[] = {\n"); } 3332 void definition() { fprintf(_cpp, "const bool swallowed[] = {\n"); }
3361 void closing() { fprintf(_cpp, " false // no trailing comma\n"); 3333 void closing() { fprintf(_cpp, " false // no trailing comma\n");
3362 OutputMap::closing(); 3334 OutputMap::closing();
3373 3345
3374 // Information needed to generate the decision array for instruction chain rule 3346 // Information needed to generate the decision array for instruction chain rule
3375 class OutputInstChainRule : public OutputMap { 3347 class OutputInstChainRule : public OutputMap {
3376 public: 3348 public:
3377 OutputInstChainRule(FILE *hpp, FILE *cpp, FormDict &globals, ArchDesc &AD) 3349 OutputInstChainRule(FILE *hpp, FILE *cpp, FormDict &globals, ArchDesc &AD)
3378 : OutputMap(hpp, cpp, globals, AD) {}; 3350 : OutputMap(hpp, cpp, globals, AD, "instruction_chain_rule") {};
3379 3351
3380 void declaration() { fprintf(_hpp, "extern const bool instruction_chain_rule[];\n"); } 3352 void declaration() { fprintf(_hpp, "extern const bool instruction_chain_rule[];\n"); }
3381 void definition() { fprintf(_cpp, "const bool instruction_chain_rule[] = {\n"); } 3353 void definition() { fprintf(_cpp, "const bool instruction_chain_rule[] = {\n"); }
3382 void closing() { fprintf(_cpp, " false // no trailing comma\n"); 3354 void closing() { fprintf(_cpp, " false // no trailing comma\n");
3383 OutputMap::closing(); 3355 OutputMap::closing();
3414 for(; (op = (OperandForm*)_operands.iter()) != NULL; ) { 3386 for(; (op = (OperandForm*)_operands.iter()) != NULL; ) {
3415 // Ensure this is a machine-world instruction 3387 // Ensure this is a machine-world instruction
3416 if ( op->ideal_only() ) continue; 3388 if ( op->ideal_only() ) continue;
3417 3389
3418 // Generate the entry for this opcode 3390 // Generate the entry for this opcode
3419 map.map(*op); fprintf(fp_cpp, ", // %d\n", idx); 3391 fprintf(fp_cpp, " /* %4d */", idx); map.map(*op); fprintf(fp_cpp, ",\n");
3420 ++idx; 3392 ++idx;
3421 }; 3393 };
3422 fprintf(fp_cpp, " // last operand\n"); 3394 fprintf(fp_cpp, " // last operand\n");
3423 3395
3424 // Place all user-defined operand classes into the mapping 3396 // Place all user-defined operand classes into the mapping
3425 map.record_position(OutputMap::BEGIN_OPCLASSES, idx ); 3397 map.record_position(OutputMap::BEGIN_OPCLASSES, idx );
3426 _opclass.reset(); 3398 _opclass.reset();
3427 for(; (opc = (OpClassForm*)_opclass.iter()) != NULL; ) { 3399 for(; (opc = (OpClassForm*)_opclass.iter()) != NULL; ) {
3428 map.map(*opc); fprintf(fp_cpp, ", // %d\n", idx); 3400 fprintf(fp_cpp, " /* %4d */", idx); map.map(*opc); fprintf(fp_cpp, ",\n");
3429 ++idx; 3401 ++idx;
3430 }; 3402 };
3431 fprintf(fp_cpp, " // last operand class\n"); 3403 fprintf(fp_cpp, " // last operand class\n");
3432 3404
3433 // Place all internally defined operands into the mapping 3405 // Place all internally defined operands into the mapping
3434 map.record_position(OutputMap::BEGIN_INTERNALS, idx ); 3406 map.record_position(OutputMap::BEGIN_INTERNALS, idx );
3435 _internalOpNames.reset(); 3407 _internalOpNames.reset();
3436 char *name = NULL; 3408 char *name = NULL;
3437 for(; (name = (char *)_internalOpNames.iter()) != NULL; ) { 3409 for(; (name = (char *)_internalOpNames.iter()) != NULL; ) {
3438 map.map(name); fprintf(fp_cpp, ", // %d\n", idx); 3410 fprintf(fp_cpp, " /* %4d */", idx); map.map(name); fprintf(fp_cpp, ",\n");
3439 ++idx; 3411 ++idx;
3440 }; 3412 };
3441 fprintf(fp_cpp, " // last internally defined operand\n"); 3413 fprintf(fp_cpp, " // last internally defined operand\n");
3442 3414
3443 // Place all user-defined instructions into the mapping 3415 // Place all user-defined instructions into the mapping
3451 // Ensure this is a machine-world instruction 3423 // Ensure this is a machine-world instruction
3452 if ( inst->ideal_only() ) continue; 3424 if ( inst->ideal_only() ) continue;
3453 if ( ! inst->is_simple_chain_rule(_globalNames) ) continue; 3425 if ( ! inst->is_simple_chain_rule(_globalNames) ) continue;
3454 if ( inst->rematerialize(_globalNames, get_registers()) ) continue; 3426 if ( inst->rematerialize(_globalNames, get_registers()) ) continue;
3455 3427
3456 map.map(*inst); fprintf(fp_cpp, ", // %d\n", idx); 3428 fprintf(fp_cpp, " /* %4d */", idx); map.map(*inst); fprintf(fp_cpp, ",\n");
3457 ++idx; 3429 ++idx;
3458 }; 3430 };
3459 map.record_position(OutputMap::BEGIN_REMATERIALIZE, idx ); 3431 map.record_position(OutputMap::BEGIN_REMATERIALIZE, idx );
3460 _instructions.reset(); 3432 _instructions.reset();
3461 for(; (inst = (InstructForm*)_instructions.iter()) != NULL; ) { 3433 for(; (inst = (InstructForm*)_instructions.iter()) != NULL; ) {
3462 // Ensure this is a machine-world instruction 3434 // Ensure this is a machine-world instruction
3463 if ( inst->ideal_only() ) continue; 3435 if ( inst->ideal_only() ) continue;
3464 if ( ! inst->is_simple_chain_rule(_globalNames) ) continue; 3436 if ( ! inst->is_simple_chain_rule(_globalNames) ) continue;
3465 if ( ! inst->rematerialize(_globalNames, get_registers()) ) continue; 3437 if ( ! inst->rematerialize(_globalNames, get_registers()) ) continue;
3466 3438
3467 map.map(*inst); fprintf(fp_cpp, ", // %d\n", idx); 3439 fprintf(fp_cpp, " /* %4d */", idx); map.map(*inst); fprintf(fp_cpp, ",\n");
3468 ++idx; 3440 ++idx;
3469 }; 3441 };
3470 map.record_position(OutputMap::END_INST_CHAIN_RULES, idx ); 3442 map.record_position(OutputMap::END_INST_CHAIN_RULES, idx );
3471 } 3443 }
3472 // Output all instructions that are NOT simple chain rules 3444 // Output all instructions that are NOT simple chain rules
3476 // Ensure this is a machine-world instruction 3448 // Ensure this is a machine-world instruction
3477 if ( inst->ideal_only() ) continue; 3449 if ( inst->ideal_only() ) continue;
3478 if ( inst->is_simple_chain_rule(_globalNames) ) continue; 3450 if ( inst->is_simple_chain_rule(_globalNames) ) continue;
3479 if ( ! inst->rematerialize(_globalNames, get_registers()) ) continue; 3451 if ( ! inst->rematerialize(_globalNames, get_registers()) ) continue;
3480 3452
3481 map.map(*inst); fprintf(fp_cpp, ", // %d\n", idx); 3453 fprintf(fp_cpp, " /* %4d */", idx); map.map(*inst); fprintf(fp_cpp, ",\n");
3482 ++idx; 3454 ++idx;
3483 }; 3455 };
3484 map.record_position(OutputMap::END_REMATERIALIZE, idx ); 3456 map.record_position(OutputMap::END_REMATERIALIZE, idx );
3485 _instructions.reset(); 3457 _instructions.reset();
3486 for(; (inst = (InstructForm*)_instructions.iter()) != NULL; ) { 3458 for(; (inst = (InstructForm*)_instructions.iter()) != NULL; ) {
3487 // Ensure this is a machine-world instruction 3459 // Ensure this is a machine-world instruction
3488 if ( inst->ideal_only() ) continue; 3460 if ( inst->ideal_only() ) continue;
3489 if ( inst->is_simple_chain_rule(_globalNames) ) continue; 3461 if ( inst->is_simple_chain_rule(_globalNames) ) continue;
3490 if ( inst->rematerialize(_globalNames, get_registers()) ) continue; 3462 if ( inst->rematerialize(_globalNames, get_registers()) ) continue;
3491 3463
3492 map.map(*inst); fprintf(fp_cpp, ", // %d\n", idx); 3464 fprintf(fp_cpp, " /* %4d */", idx); map.map(*inst); fprintf(fp_cpp, ",\n");
3493 ++idx; 3465 ++idx;
3494 }; 3466 };
3495 } 3467 }
3496 fprintf(fp_cpp, " // last instruction\n"); 3468 fprintf(fp_cpp, " // last instruction\n");
3497 map.record_position(OutputMap::END_INSTRUCTIONS, idx ); 3469 map.record_position(OutputMap::END_INSTRUCTIONS, idx );
3569 _register->reset_RegDefs(); 3541 _register->reset_RegDefs();
3570 for( rdef = _register->iter_RegDefs(); rdef != NULL; rdef = next ) { 3542 for( rdef = _register->iter_RegDefs(); rdef != NULL; rdef = next ) {
3571 next = _register->iter_RegDefs(); 3543 next = _register->iter_RegDefs();
3572 char policy = reg_save_policy(rdef->_callconv); 3544 char policy = reg_save_policy(rdef->_callconv);
3573 const char *comma = (next != NULL) ? "," : " // no trailing comma"; 3545 const char *comma = (next != NULL) ? "," : " // no trailing comma";
3574 fprintf(fp_cpp, " '%c'%s\n", policy, comma); 3546 fprintf(fp_cpp, " '%c'%s // %s\n", policy, comma, rdef->_regname);
3575 } 3547 }
3576 fprintf(fp_cpp, "};\n\n"); 3548 fprintf(fp_cpp, "};\n\n");
3577 3549
3578 // Construct Native Save-Policy array 3550 // Construct Native Save-Policy array
3579 fprintf(fp_cpp, "// Map from machine-independent register number to c_reg_save_policy\n"); 3551 fprintf(fp_cpp, "// Map from machine-independent register number to c_reg_save_policy\n");
3581 _register->reset_RegDefs(); 3553 _register->reset_RegDefs();
3582 for( rdef = _register->iter_RegDefs(); rdef != NULL; rdef = next ) { 3554 for( rdef = _register->iter_RegDefs(); rdef != NULL; rdef = next ) {
3583 next = _register->iter_RegDefs(); 3555 next = _register->iter_RegDefs();
3584 char policy = reg_save_policy(rdef->_c_conv); 3556 char policy = reg_save_policy(rdef->_c_conv);
3585 const char *comma = (next != NULL) ? "," : " // no trailing comma"; 3557 const char *comma = (next != NULL) ? "," : " // no trailing comma";
3586 fprintf(fp_cpp, " '%c'%s\n", policy, comma); 3558 fprintf(fp_cpp, " '%c'%s // %s\n", policy, comma, rdef->_regname);
3587 } 3559 }
3588 fprintf(fp_cpp, "};\n\n"); 3560 fprintf(fp_cpp, "};\n\n");
3589 3561
3590 // Construct Register Save Type array 3562 // Construct Register Save Type array
3591 fprintf(fp_cpp, "// Map from machine-independent register number to register_save_type\n"); 3563 fprintf(fp_cpp, "// Map from machine-independent register number to register_save_type\n");
3792 } 3764 }
3793 dont_care = true; 3765 dont_care = true;
3794 // For each operand not in the match rule, call MachOperGenerator 3766 // For each operand not in the match rule, call MachOperGenerator
3795 // with the enum for the opcode that needs to be built. 3767 // with the enum for the opcode that needs to be built.
3796 ComponentList clist = inst->_components; 3768 ComponentList clist = inst->_components;
3797 int index = clist.operand_position(comp->_name, comp->_usedef); 3769 int index = clist.operand_position(comp->_name, comp->_usedef, inst);
3798 const char *opcode = machOperEnum(comp->_type); 3770 const char *opcode = machOperEnum(comp->_type);
3799 fprintf(fp_cpp, "%s node->set_opnd_array(%d, ", indent, index); 3771 fprintf(fp_cpp, "%s node->set_opnd_array(%d, ", indent, index);
3800 fprintf(fp_cpp, "MachOperGenerator(%s, C));\n", opcode); 3772 fprintf(fp_cpp, "MachOperGenerator(%s, C));\n", opcode);
3801 } 3773 }
3802 } 3774 }
3987 3959
3988 // Generate the case statement for this instruction 3960 // Generate the case statement for this instruction
3989 fprintf(fp_cpp, " case %s_rule:", opClass); 3961 fprintf(fp_cpp, " case %s_rule:", opClass);
3990 3962
3991 // Start local scope 3963 // Start local scope
3992 fprintf(fp_cpp, " {\n"); 3964 fprintf(fp_cpp, " {\n");
3993 // Generate code to construct the new MachNode 3965 // Generate code to construct the new MachNode
3994 buildMachNode(fp_cpp, inst, " "); 3966 buildMachNode(fp_cpp, inst, " ");
3995 // Return result and exit scope 3967 // Return result and exit scope
3996 fprintf(fp_cpp, " return node;\n"); 3968 fprintf(fp_cpp, " return node;\n");
3997 fprintf(fp_cpp, " }\n"); 3969 fprintf(fp_cpp, " }\n");
4136 4108
4137 static int PrintAdlcCisc = 0; 4109 static int PrintAdlcCisc = 0;
4138 //---------------------------identify_cisc_spilling---------------------------- 4110 //---------------------------identify_cisc_spilling----------------------------
4139 // Get info for the CISC_oracle and MachNode::cisc_version() 4111 // Get info for the CISC_oracle and MachNode::cisc_version()
4140 void ArchDesc::identify_cisc_spill_instructions() { 4112 void ArchDesc::identify_cisc_spill_instructions() {
4113
4114 if (_frame == NULL)
4115 return;
4141 4116
4142 // Find the user-defined operand for cisc-spilling 4117 // Find the user-defined operand for cisc-spilling
4143 if( _frame->_cisc_spilling_operand_name != NULL ) { 4118 if( _frame->_cisc_spilling_operand_name != NULL ) {
4144 const Form *form = _globalNames[_frame->_cisc_spilling_operand_name]; 4119 const Form *form = _globalNames[_frame->_cisc_spilling_operand_name];
4145 OperandForm *oper = form ? form->is_operand() : NULL; 4120 OperandForm *oper = form ? form->is_operand() : NULL;