comparison src/share/vm/adlc/output_c.cpp @ 628:7bb995fbd3c0

Merge
author trims
date Thu, 12 Mar 2009 18:16:36 -0700
parents 337400e7a5dd
children 2056494941db
comparison
equal deleted inserted replaced
580:ce2272390558 628:7bb995fbd3c0
1 /* 1 /*
2 * Copyright 1998-2008 Sun Microsystems, Inc. All Rights Reserved. 2 * Copyright 1998-2009 Sun Microsystems, Inc. All Rights Reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 * 4 *
5 * This code is free software; you can redistribute it and/or modify it 5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as 6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
223 (const PipeClassOperandForm *)pipeclass->_localUsage[paramname]; 223 (const PipeClassOperandForm *)pipeclass->_localUsage[paramname];
224 if (pipeopnd && !pipeopnd->isWrite() && strcmp(pipeopnd->_stage, "Universal")) 224 if (pipeopnd && !pipeopnd->isWrite() && strcmp(pipeopnd->_stage, "Universal"))
225 pipeclass->_parameters.reset(); 225 pipeclass->_parameters.reset();
226 226
227 while ( (paramname = pipeclass->_parameters.iter()) != NULL ) { 227 while ( (paramname = pipeclass->_parameters.iter()) != NULL ) {
228 const PipeClassOperandForm *pipeopnd = 228 const PipeClassOperandForm *tmppipeopnd =
229 (const PipeClassOperandForm *)pipeclass->_localUsage[paramname]; 229 (const PipeClassOperandForm *)pipeclass->_localUsage[paramname];
230 230
231 if (pipeopnd) 231 if (tmppipeopnd)
232 templen += 10 + (int)strlen(pipeopnd->_stage); 232 templen += 10 + (int)strlen(tmppipeopnd->_stage);
233 else 233 else
234 templen += 19; 234 templen += 19;
235 235
236 paramcount++; 236 paramcount++;
237 } 237 }
251 pipeopnd = (const PipeClassOperandForm *)pipeclass->_localUsage[paramname]; 251 pipeopnd = (const PipeClassOperandForm *)pipeclass->_localUsage[paramname];
252 if (pipeopnd && !pipeopnd->isWrite() && strcmp(pipeopnd->_stage, "Universal")) 252 if (pipeopnd && !pipeopnd->isWrite() && strcmp(pipeopnd->_stage, "Universal"))
253 pipeclass->_parameters.reset(); 253 pipeclass->_parameters.reset();
254 254
255 while ( (paramname = pipeclass->_parameters.iter()) != NULL ) { 255 while ( (paramname = pipeclass->_parameters.iter()) != NULL ) {
256 const PipeClassOperandForm *pipeopnd = 256 const PipeClassOperandForm *tmppipeopnd =
257 (const PipeClassOperandForm *)pipeclass->_localUsage[paramname]; 257 (const PipeClassOperandForm *)pipeclass->_localUsage[paramname];
258 templen += sprintf(&operand_stages[templen], " stage_%s%c\n", 258 templen += sprintf(&operand_stages[templen], " stage_%s%c\n",
259 pipeopnd ? pipeopnd->_stage : "undefined", 259 tmppipeopnd ? tmppipeopnd->_stage : "undefined",
260 (++i < paramcount ? ',' : ' ') ); 260 (++i < paramcount ? ',' : ' ') );
261 } 261 }
262 262
263 // See if the same string is in the table 263 // See if the same string is in the table
264 int ndx = pipeline_reads.index(operand_stages); 264 int ndx = pipeline_reads.index(operand_stages);
1040 node, regMask); 1040 node, regMask);
1041 } 1041 }
1042 1042
1043 // Scan the peepmatch and output a test for each instruction 1043 // Scan the peepmatch and output a test for each instruction
1044 static void check_peepmatch_instruction_tree(FILE *fp, PeepMatch *pmatch, PeepConstraint *pconstraint) { 1044 static void check_peepmatch_instruction_tree(FILE *fp, PeepMatch *pmatch, PeepConstraint *pconstraint) {
1045 intptr_t parent = -1; 1045 int parent = -1;
1046 intptr_t inst_position = 0; 1046 int inst_position = 0;
1047 const char *inst_name = NULL; 1047 const char* inst_name = NULL;
1048 intptr_t input = 0; 1048 int input = 0;
1049 fprintf(fp, " // Check instruction sub-tree\n"); 1049 fprintf(fp, " // Check instruction sub-tree\n");
1050 pmatch->reset(); 1050 pmatch->reset();
1051 for( pmatch->next_instruction( parent, inst_position, inst_name, input ); 1051 for( pmatch->next_instruction( parent, inst_position, inst_name, input );
1052 inst_name != NULL; 1052 inst_name != NULL;
1053 pmatch->next_instruction( parent, inst_position, inst_name, input ) ) { 1053 pmatch->next_instruction( parent, inst_position, inst_name, input ) ) {
1054 // If this is not a placeholder 1054 // If this is not a placeholder
1055 if( ! pmatch->is_placeholder() ) { 1055 if( ! pmatch->is_placeholder() ) {
1056 // Define temporaries 'inst#', based on parent and parent's input index 1056 // Define temporaries 'inst#', based on parent and parent's input index
1057 if( parent != -1 ) { // root was initialized 1057 if( parent != -1 ) { // root was initialized
1058 fprintf(fp, " inst%ld = inst%ld->in(%ld);\n", 1058 fprintf(fp, " inst%d = inst%d->in(%d);\n",
1059 inst_position, parent, input); 1059 inst_position, parent, input);
1060 } 1060 }
1061 1061
1062 // When not the root 1062 // When not the root
1063 // Test we have the correct instruction by comparing the rule 1063 // Test we have the correct instruction by comparing the rule
1064 if( parent != -1 ) { 1064 if( parent != -1 ) {
1065 fprintf(fp, " matches = matches && ( inst%ld->rule() == %s_rule );", 1065 fprintf(fp, " matches = matches && ( inst%d->rule() == %s_rule );",
1066 inst_position, inst_name); 1066 inst_position, inst_name);
1067 } 1067 }
1068 } else { 1068 } else {
1069 // Check that user did not try to constrain a placeholder 1069 // Check that user did not try to constrain a placeholder
1070 assert( ! pconstraint->constrains_instruction(inst_position), 1070 assert( ! pconstraint->constrains_instruction(inst_position),
1071 "fatal(): Can not constrain a placeholder instruction"); 1071 "fatal(): Can not constrain a placeholder instruction");
1072 } 1072 }
1073 } 1073 }
1074 } 1074 }
1075 1075
1076 static void print_block_index(FILE *fp, intptr_t inst_position) { 1076 static void print_block_index(FILE *fp, int inst_position) {
1077 assert( inst_position >= 0, "Instruction number less than zero"); 1077 assert( inst_position >= 0, "Instruction number less than zero");
1078 fprintf(fp, "block_index"); 1078 fprintf(fp, "block_index");
1079 if( inst_position != 0 ) { 1079 if( inst_position != 0 ) {
1080 fprintf(fp, " - %ld", inst_position); 1080 fprintf(fp, " - %d", inst_position);
1081 } 1081 }
1082 } 1082 }
1083 1083
1084 // Scan the peepmatch and output a test for each instruction 1084 // Scan the peepmatch and output a test for each instruction
1085 static void check_peepmatch_instruction_sequence(FILE *fp, PeepMatch *pmatch, PeepConstraint *pconstraint) { 1085 static void check_peepmatch_instruction_sequence(FILE *fp, PeepMatch *pmatch, PeepConstraint *pconstraint) {
1086 intptr_t parent = -1; 1086 int parent = -1;
1087 intptr_t inst_position = 0; 1087 int inst_position = 0;
1088 const char *inst_name = NULL; 1088 const char* inst_name = NULL;
1089 intptr_t input = 0; 1089 int input = 0;
1090 fprintf(fp, " // Check instruction sub-tree\n"); 1090 fprintf(fp, " // Check instruction sub-tree\n");
1091 pmatch->reset(); 1091 pmatch->reset();
1092 for( pmatch->next_instruction( parent, inst_position, inst_name, input ); 1092 for( pmatch->next_instruction( parent, inst_position, inst_name, input );
1093 inst_name != NULL; 1093 inst_name != NULL;
1094 pmatch->next_instruction( parent, inst_position, inst_name, input ) ) { 1094 pmatch->next_instruction( parent, inst_position, inst_name, input ) ) {
1099 fprintf(fp, " // Identify previous instruction if inside this block\n"); 1099 fprintf(fp, " // Identify previous instruction if inside this block\n");
1100 fprintf(fp, " if( "); 1100 fprintf(fp, " if( ");
1101 print_block_index(fp, inst_position); 1101 print_block_index(fp, inst_position);
1102 fprintf(fp, " > 0 ) {\n Node *n = block->_nodes.at("); 1102 fprintf(fp, " > 0 ) {\n Node *n = block->_nodes.at(");
1103 print_block_index(fp, inst_position); 1103 print_block_index(fp, inst_position);
1104 fprintf(fp, ");\n inst%ld = (n->is_Mach()) ? ", inst_position); 1104 fprintf(fp, ");\n inst%d = (n->is_Mach()) ? ", inst_position);
1105 fprintf(fp, "n->as_Mach() : NULL;\n }\n"); 1105 fprintf(fp, "n->as_Mach() : NULL;\n }\n");
1106 } 1106 }
1107 1107
1108 // When not the root 1108 // When not the root
1109 // Test we have the correct instruction by comparing the rule. 1109 // Test we have the correct instruction by comparing the rule.
1110 if( parent != -1 ) { 1110 if( parent != -1 ) {
1111 fprintf(fp, " matches = matches && (inst%ld != NULL) && (inst%ld->rule() == %s_rule);\n", 1111 fprintf(fp, " matches = matches && (inst%d != NULL) && (inst%d->rule() == %s_rule);\n",
1112 inst_position, inst_position, inst_name); 1112 inst_position, inst_position, inst_name);
1113 } 1113 }
1114 } else { 1114 } else {
1115 // Check that user did not try to constrain a placeholder 1115 // Check that user did not try to constrain a placeholder
1116 assert( ! pconstraint->constrains_instruction(inst_position), 1116 assert( ! pconstraint->constrains_instruction(inst_position),
1119 } 1119 }
1120 } 1120 }
1121 1121
1122 // Build mapping for register indices, num_edges to input 1122 // Build mapping for register indices, num_edges to input
1123 static void build_instruction_index_mapping( FILE *fp, FormDict &globals, PeepMatch *pmatch ) { 1123 static void build_instruction_index_mapping( FILE *fp, FormDict &globals, PeepMatch *pmatch ) {
1124 intptr_t parent = -1; 1124 int parent = -1;
1125 intptr_t inst_position = 0; 1125 int inst_position = 0;
1126 const char *inst_name = NULL; 1126 const char* inst_name = NULL;
1127 intptr_t input = 0; 1127 int input = 0;
1128 fprintf(fp, " // Build map to register info\n"); 1128 fprintf(fp, " // Build map to register info\n");
1129 pmatch->reset(); 1129 pmatch->reset();
1130 for( pmatch->next_instruction( parent, inst_position, inst_name, input ); 1130 for( pmatch->next_instruction( parent, inst_position, inst_name, input );
1131 inst_name != NULL; 1131 inst_name != NULL;
1132 pmatch->next_instruction( parent, inst_position, inst_name, input ) ) { 1132 pmatch->next_instruction( parent, inst_position, inst_name, input ) ) {
1134 if( ! pmatch->is_placeholder() ) { 1134 if( ! pmatch->is_placeholder() ) {
1135 // Define temporaries 'inst#', based on self's inst_position 1135 // Define temporaries 'inst#', based on self's inst_position
1136 InstructForm *inst = globals[inst_name]->is_instruction(); 1136 InstructForm *inst = globals[inst_name]->is_instruction();
1137 if( inst != NULL ) { 1137 if( inst != NULL ) {
1138 char inst_prefix[] = "instXXXX_"; 1138 char inst_prefix[] = "instXXXX_";
1139 sprintf(inst_prefix, "inst%ld_", inst_position); 1139 sprintf(inst_prefix, "inst%d_", inst_position);
1140 char receiver[] = "instXXXX->"; 1140 char receiver[] = "instXXXX->";
1141 sprintf(receiver, "inst%ld->", inst_position); 1141 sprintf(receiver, "inst%d->", inst_position);
1142 inst->index_temps( fp, globals, inst_prefix, receiver ); 1142 inst->index_temps( fp, globals, inst_prefix, receiver );
1143 } 1143 }
1144 } 1144 }
1145 } 1145 }
1146 } 1146 }
1166 if( strcmp(pconstraint->_relation,"==") != 0 ) { 1166 if( strcmp(pconstraint->_relation,"==") != 0 ) {
1167 assert( false, "Unimplemented()" ); 1167 assert( false, "Unimplemented()" );
1168 } 1168 }
1169 1169
1170 // LEFT 1170 // LEFT
1171 intptr_t left_index = pconstraint->_left_inst; 1171 int left_index = pconstraint->_left_inst;
1172 const char *left_op = pconstraint->_left_op; 1172 const char *left_op = pconstraint->_left_op;
1173 // Access info on the instructions whose operands are compared 1173 // Access info on the instructions whose operands are compared
1174 InstructForm *inst_left = globals[pmatch->instruction_name(left_index)]->is_instruction(); 1174 InstructForm *inst_left = globals[pmatch->instruction_name(left_index)]->is_instruction();
1175 assert( inst_left, "Parser should guaranty this is an instruction"); 1175 assert( inst_left, "Parser should guaranty this is an instruction");
1176 int left_op_base = inst_left->oper_input_base(globals); 1176 int left_op_base = inst_left->oper_input_base(globals);
1189 Form::InterfaceType left_interface_type = left_opclass->interface_type(globals); 1189 Form::InterfaceType left_interface_type = left_opclass->interface_type(globals);
1190 1190
1191 1191
1192 // RIGHT 1192 // RIGHT
1193 int right_op_index = -1; 1193 int right_op_index = -1;
1194 intptr_t right_index = pconstraint->_right_inst; 1194 int right_index = pconstraint->_right_inst;
1195 const char *right_op = pconstraint->_right_op; 1195 const char *right_op = pconstraint->_right_op;
1196 if( right_index != -1 ) { // Match operand 1196 if( right_index != -1 ) { // Match operand
1197 // Access info on the instructions whose operands are compared 1197 // Access info on the instructions whose operands are compared
1198 InstructForm *inst_right = globals[pmatch->instruction_name(right_index)]->is_instruction(); 1198 InstructForm *inst_right = globals[pmatch->instruction_name(right_index)]->is_instruction();
1199 assert( inst_right, "Parser should guaranty this is an instruction"); 1199 assert( inst_right, "Parser should guaranty this is an instruction");
1349 preplace->next_instruction(root_inst); 1349 preplace->next_instruction(root_inst);
1350 InstructForm *root_form = globals[root_inst]->is_instruction(); 1350 InstructForm *root_form = globals[root_inst]->is_instruction();
1351 assert( root_form != NULL, "Replacement instruction was not previously defined"); 1351 assert( root_form != NULL, "Replacement instruction was not previously defined");
1352 fprintf(fp, " %sNode *root = new (C) %sNode();\n", root_inst, root_inst); 1352 fprintf(fp, " %sNode *root = new (C) %sNode();\n", root_inst, root_inst);
1353 1353
1354 intptr_t inst_num; 1354 int inst_num;
1355 const char *op_name; 1355 const char *op_name;
1356 int opnds_index = 0; // define result operand 1356 int opnds_index = 0; // define result operand
1357 // Then install the use-operands for the new sub-tree 1357 // Then install the use-operands for the new sub-tree
1358 // preplace->reset(); // reset breaks iteration 1358 // preplace->reset(); // reset breaks iteration
1359 for( preplace->next_operand( inst_num, op_name ); 1359 for( preplace->next_operand( inst_num, op_name );
1360 op_name != NULL; 1360 op_name != NULL;
1361 preplace->next_operand( inst_num, op_name ) ) { 1361 preplace->next_operand( inst_num, op_name ) ) {
1362 InstructForm *inst_form; 1362 InstructForm *inst_form;
1363 inst_form = globals[pmatch->instruction_name(inst_num)]->is_instruction(); 1363 inst_form = globals[pmatch->instruction_name(inst_num)]->is_instruction();
1364 assert( inst_form, "Parser should guaranty this is an instruction"); 1364 assert( inst_form, "Parser should guaranty this is an instruction");
1365 int op_base = inst_form->oper_input_base(globals);
1366 int inst_op_num = inst_form->operand_position(op_name, Component::USE); 1365 int inst_op_num = inst_form->operand_position(op_name, Component::USE);
1367 if( inst_op_num == NameList::Not_in_list ) 1366 if( inst_op_num == NameList::Not_in_list )
1368 inst_op_num = inst_form->operand_position(op_name, Component::USE_DEF); 1367 inst_op_num = inst_form->operand_position(op_name, Component::USE_DEF);
1369 assert( inst_op_num != NameList::Not_in_list, "Did not find operand as USE"); 1368 assert( inst_op_num != NameList::Not_in_list, "Did not find operand as USE");
1370 // find the name of the OperandForm from the local name 1369 // find the name of the OperandForm from the local name
1377 // Add control edge for this node 1376 // Add control edge for this node
1378 fprintf(fp, " root->add_req(_in[0]); // control edge\n"); 1377 fprintf(fp, " root->add_req(_in[0]); // control edge\n");
1379 // Add unmatched edges from root of match tree 1378 // Add unmatched edges from root of match tree
1380 int op_base = root_form->oper_input_base(globals); 1379 int op_base = root_form->oper_input_base(globals);
1381 for( int unmatched_edge = 1; unmatched_edge < op_base; ++unmatched_edge ) { 1380 for( int unmatched_edge = 1; unmatched_edge < op_base; ++unmatched_edge ) {
1382 fprintf(fp, " root->add_req(inst%ld->in(%d)); // unmatched ideal edge\n", 1381 fprintf(fp, " root->add_req(inst%d->in(%d)); // unmatched ideal edge\n",
1383 inst_num, unmatched_edge); 1382 inst_num, unmatched_edge);
1384 } 1383 }
1385 // If new instruction captures bottom type 1384 // If new instruction captures bottom type
1386 if( root_form->captures_bottom_type() ) { 1385 if( root_form->captures_bottom_type() ) {
1387 // Get bottom type from instruction whose result we are replacing 1386 // Get bottom type from instruction whose result we are replacing
1388 fprintf(fp, " root->_bottom_type = inst%ld->bottom_type();\n", inst_num); 1387 fprintf(fp, " root->_bottom_type = inst%d->bottom_type();\n", inst_num);
1389 } 1388 }
1390 // Define result register and result operand 1389 // Define result register and result operand
1391 fprintf(fp, " ra_->add_reference(root, inst%ld);\n", inst_num); 1390 fprintf(fp, " ra_->add_reference(root, inst%d);\n", inst_num);
1392 fprintf(fp, " ra_->set_oop (root, ra_->is_oop(inst%ld));\n", inst_num); 1391 fprintf(fp, " ra_->set_oop (root, ra_->is_oop(inst%d));\n", inst_num);
1393 fprintf(fp, " ra_->set_pair(root->_idx, ra_->get_reg_second(inst%ld), ra_->get_reg_first(inst%ld));\n", inst_num, inst_num); 1392 fprintf(fp, " ra_->set_pair(root->_idx, ra_->get_reg_second(inst%d), ra_->get_reg_first(inst%d));\n", inst_num, inst_num);
1394 fprintf(fp, " root->_opnds[0] = inst%ld->_opnds[0]->clone(C); // result\n", inst_num); 1393 fprintf(fp, " root->_opnds[0] = inst%d->_opnds[0]->clone(C); // result\n", inst_num);
1395 fprintf(fp, " // ----- Done with initial setup -----\n"); 1394 fprintf(fp, " // ----- Done with initial setup -----\n");
1396 } else { 1395 } else {
1397 if( (op_form == NULL) || (op_form->is_base_constant(globals) == Form::none) ) { 1396 if( (op_form == NULL) || (op_form->is_base_constant(globals) == Form::none) ) {
1398 // Do not have ideal edges for constants after matching 1397 // Do not have ideal edges for constants after matching
1399 fprintf(fp, " for( unsigned x%d = inst%ld_idx%d; x%d < inst%ld_idx%d; x%d++ )\n", 1398 fprintf(fp, " for( unsigned x%d = inst%d_idx%d; x%d < inst%d_idx%d; x%d++ )\n",
1400 inst_op_num, inst_num, inst_op_num, 1399 inst_op_num, inst_num, inst_op_num,
1401 inst_op_num, inst_num, inst_op_num+1, inst_op_num ); 1400 inst_op_num, inst_num, inst_op_num+1, inst_op_num );
1402 fprintf(fp, " root->add_req( inst%ld->in(x%d) );\n", 1401 fprintf(fp, " root->add_req( inst%d->in(x%d) );\n",
1403 inst_num, inst_op_num ); 1402 inst_num, inst_op_num );
1404 } else { 1403 } else {
1405 fprintf(fp, " // no ideal edge for constants after matching\n"); 1404 fprintf(fp, " // no ideal edge for constants after matching\n");
1406 } 1405 }
1407 fprintf(fp, " root->_opnds[%d] = inst%ld->_opnds[%d]->clone(C);\n", 1406 fprintf(fp, " root->_opnds[%d] = inst%d->_opnds[%d]->clone(C);\n",
1408 opnds_index, inst_num, inst_op_num ); 1407 opnds_index, inst_num, inst_op_num );
1409 } 1408 }
1410 ++opnds_index; 1409 ++opnds_index;
1411 } 1410 }
1412 }else { 1411 }else {
1441 assert( pmatch != NULL, "fatal(), missing peepmatch rule"); 1440 assert( pmatch != NULL, "fatal(), missing peepmatch rule");
1442 if( max_position < pmatch->max_position() ) max_position = pmatch->max_position(); 1441 if( max_position < pmatch->max_position() ) max_position = pmatch->max_position();
1443 } 1442 }
1444 for( int i = 0; i <= max_position; ++i ) { 1443 for( int i = 0; i <= max_position; ++i ) {
1445 if( i == 0 ) { 1444 if( i == 0 ) {
1446 fprintf(fp, " MachNode *inst0 = this;\n", i); 1445 fprintf(fp, " MachNode *inst0 = this;\n");
1447 } else { 1446 } else {
1448 fprintf(fp, " MachNode *inst%d = NULL;\n", i); 1447 fprintf(fp, " MachNode *inst%d = NULL;\n", i);
1449 } 1448 }
1450 } 1449 }
1451 1450
1741 new_num_opnds++; 1740 new_num_opnds++;
1742 } 1741 }
1743 } 1742 }
1744 // delete the rest of edges 1743 // delete the rest of edges
1745 fprintf(fp," for(int i = idx%d - 1; i >= (int)idx%d; i--) {\n", cur_num_opnds, new_num_opnds); 1744 fprintf(fp," for(int i = idx%d - 1; i >= (int)idx%d; i--) {\n", cur_num_opnds, new_num_opnds);
1746 fprintf(fp," del_req(i);\n", i); 1745 fprintf(fp," del_req(i);\n");
1747 fprintf(fp," }\n"); 1746 fprintf(fp," }\n");
1748 fprintf(fp," _num_opnds = %d;\n", new_num_opnds); 1747 fprintf(fp," _num_opnds = %d;\n", new_num_opnds);
1749 } 1748 }
1750 } 1749 }
1751 1750
1815 } 1814 }
1816 } 1815 }
1817 1816
1818 fprintf(fp,"\n"); 1817 fprintf(fp,"\n");
1819 if( node->expands() ) { 1818 if( node->expands() ) {
1820 fprintf(fp," return result;\n",cnt-1); 1819 fprintf(fp," return result;\n");
1821 } else { 1820 } else {
1822 fprintf(fp," return this;\n"); 1821 fprintf(fp," return this;\n");
1823 } 1822 }
1824 fprintf(fp,"}\n"); 1823 fprintf(fp,"}\n");
1825 fprintf(fp,"\n"); 1824 fprintf(fp,"\n");
2138 2137
2139 if ( (*rep_var) == '$' ) { 2138 if ( (*rep_var) == '$' ) {
2140 // A subfield variable, '$$' prefix 2139 // A subfield variable, '$$' prefix
2141 emit_field( rep_var ); 2140 emit_field( rep_var );
2142 } else { 2141 } else {
2143 // A replacement variable, '$' prefix 2142 if (_strings_to_emit.peek() != NULL &&
2144 emit_rep_var( rep_var ); 2143 strcmp(_strings_to_emit.peek(), "$Address") == 0) {
2144 fprintf(_fp, "Address::make_raw(");
2145
2146 emit_rep_var( rep_var );
2147 fprintf(_fp,"->base(ra_,this,idx%d), ", _operand_idx);
2148
2149 _reg_status = LITERAL_ACCESSED;
2150 emit_rep_var( rep_var );
2151 fprintf(_fp,"->index(ra_,this,idx%d), ", _operand_idx);
2152
2153 _reg_status = LITERAL_ACCESSED;
2154 emit_rep_var( rep_var );
2155 fprintf(_fp,"->scale(), ");
2156
2157 _reg_status = LITERAL_ACCESSED;
2158 emit_rep_var( rep_var );
2159 Form::DataType stack_type = _operand ? _operand->is_user_name_for_sReg() : Form::none;
2160 if( _operand && _operand_idx==0 && stack_type != Form::none ) {
2161 fprintf(_fp,"->disp(ra_,this,0), ");
2162 } else {
2163 fprintf(_fp,"->disp(ra_,this,idx%d), ", _operand_idx);
2164 }
2165
2166 _reg_status = LITERAL_ACCESSED;
2167 emit_rep_var( rep_var );
2168 fprintf(_fp,"->disp_is_oop())");
2169
2170 // skip trailing $Address
2171 _strings_to_emit.iter();
2172 } else {
2173 // A replacement variable, '$' prefix
2174 const char* next = _strings_to_emit.peek();
2175 const char* next2 = _strings_to_emit.peek(2);
2176 if (next != NULL && next2 != NULL && strcmp(next2, "$Register") == 0 &&
2177 (strcmp(next, "$base") == 0 || strcmp(next, "$index") == 0)) {
2178 // handle $rev_var$$base$$Register and $rev_var$$index$$Register by
2179 // producing as_Register(opnd_array(#)->base(ra_,this,idx1)).
2180 fprintf(_fp, "as_Register(");
2181 // emit the operand reference
2182 emit_rep_var( rep_var );
2183 rep_var = _strings_to_emit.iter();
2184 assert(strcmp(rep_var, "$base") == 0 || strcmp(rep_var, "$index") == 0, "bad pattern");
2185 // handle base or index
2186 emit_field(rep_var);
2187 rep_var = _strings_to_emit.iter();
2188 assert(strcmp(rep_var, "$Register") == 0, "bad pattern");
2189 // close up the parens
2190 fprintf(_fp, ")");
2191 } else {
2192 emit_rep_var( rep_var );
2193 }
2194 }
2145 } // end replacement and/or subfield 2195 } // end replacement and/or subfield
2146 } 2196 }
2147 } 2197 }
2148 2198
2149 void emit_reloc_type(const char* type) { 2199 void emit_reloc_type(const char* type) {