src/share/vm/adlc/formssel.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File 6961690 Sdiff src/share/vm/adlc

src/share/vm/adlc/formssel.cpp

Print this page
rev 1838 : 6961690: load oops from constant table on SPARC
Summary: oops should be loaded from the constant table of an nmethod instead of materializing them with a long code sequence.
Reviewed-by:


  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 // FORMS.CPP - Definitions for ADL Parser Forms Classes
  26 #include "adlc.hpp"
  27 
  28 //==============================Instructions===================================
  29 //------------------------------InstructForm-----------------------------------
  30 InstructForm::InstructForm(const char *id, bool ideal_only)
  31   : _ident(id), _ideal_only(ideal_only),
  32     _localNames(cmpstr, hashstr, Form::arena),
  33     _effects(cmpstr, hashstr, Form::arena) {


  34       _ftype = Form::INS;
  35 
  36       _matrule   = NULL;
  37       _insencode = NULL;

  38       _opcode    = NULL;
  39       _size      = NULL;
  40       _attribs   = NULL;
  41       _predicate = NULL;
  42       _exprule   = NULL;
  43       _rewrule   = NULL;
  44       _format    = NULL;
  45       _peephole  = NULL;
  46       _ins_pipe  = NULL;
  47       _uniq_idx  = NULL;
  48       _num_uniq  = 0;
  49       _cisc_spill_operand = Not_cisc_spillable;// Which operand may cisc-spill
  50       _cisc_spill_alternate = NULL;            // possible cisc replacement
  51       _cisc_reg_mask_name = NULL;
  52       _is_cisc_alternate = false;
  53       _is_short_branch = false;
  54       _short_branch_form = NULL;
  55       _alignment = 1;
  56 }
  57 
  58 InstructForm::InstructForm(const char *id, InstructForm *instr, MatchRule *rule)
  59   : _ident(id), _ideal_only(false),
  60     _localNames(instr->_localNames),
  61     _effects(instr->_effects) {


  62       _ftype = Form::INS;
  63 
  64       _matrule   = rule;
  65       _insencode = instr->_insencode;

  66       _opcode    = instr->_opcode;
  67       _size      = instr->_size;
  68       _attribs   = instr->_attribs;
  69       _predicate = instr->_predicate;
  70       _exprule   = instr->_exprule;
  71       _rewrule   = instr->_rewrule;
  72       _format    = instr->_format;
  73       _peephole  = instr->_peephole;
  74       _ins_pipe  = instr->_ins_pipe;
  75       _uniq_idx  = instr->_uniq_idx;
  76       _num_uniq  = instr->_num_uniq;
  77       _cisc_spill_operand = Not_cisc_spillable;// Which operand may cisc-spill
  78       _cisc_spill_alternate = NULL;            // possible cisc replacement
  79       _cisc_reg_mask_name = NULL;
  80       _is_cisc_alternate = false;
  81       _is_short_branch = false;
  82       _short_branch_form = NULL;
  83       _alignment = 1;
  84      // Copy parameters
  85      const char *name;


1077     return "MachCallLeafNode";
1078   }
1079   else if (is_ideal_return()) {
1080     return "MachReturnNode";
1081   }
1082   else if (is_ideal_halt()) {
1083     return "MachHaltNode";
1084   }
1085   else if (is_ideal_safepoint()) {
1086     return "MachSafePointNode";
1087   }
1088   else if (is_ideal_if()) {
1089     return "MachIfNode";
1090   }
1091   else if (is_ideal_fastlock()) {
1092     return "MachFastLockNode";
1093   }
1094   else if (is_ideal_nop()) {
1095     return "MachNopNode";
1096   }



1097   else if (captures_bottom_type(globals)) {
1098     return "MachTypeNode";
1099   } else {
1100     return "MachNode";
1101   }
1102   assert( false, "ShouldNotReachHere()");
1103   return NULL;
1104 }
1105 
1106 // Compare the instruction predicates for textual equality
1107 bool equivalent_predicates( const InstructForm *instr1, const InstructForm *instr2 ) {
1108   const Predicate *pred1  = instr1->_predicate;
1109   const Predicate *pred2  = instr2->_predicate;
1110   if( pred1 == NULL && pred2 == NULL ) {
1111     // no predicates means they are identical
1112     return true;
1113   }
1114   if( pred1 != NULL && pred2 != NULL ) {
1115     // compare the predicates
1116     if (ADLParser::equivalent_expressions(pred1->_pred, pred2->_pred)) {


1173       this != short_branch &&   // Don't match myself
1174       !is_short_branch() &&     // Don't match another short branch variant
1175       reduce_result() != NULL &&
1176       strcmp(reduce_result(), short_branch->reduce_result()) == 0 &&
1177       _matrule->equivalent(AD.globalNames(), short_branch->_matrule)) {
1178     // The instructions are equivalent.
1179     if (AD._short_branch_debug) {
1180       fprintf(stderr, "Instruction %s has short form %s\n", _ident, short_branch->_ident);
1181     }
1182     _short_branch_form = short_branch;
1183     return true;
1184   }
1185   return false;
1186 }
1187 
1188 
1189 // --------------------------- FILE *output_routines
1190 //
1191 // Generate the format call for the replacement variable
1192 void InstructForm::rep_var_format(FILE *fp, const char *rep_var) {















1193   // Find replacement variable's type
1194   const Form *form   = _localNames[rep_var];
1195   if (form == NULL) {
1196     fprintf(stderr, "unknown replacement variable in format statement: '%s'\n", rep_var);
1197     assert(false, "ShouldNotReachHere()");
1198   }
1199   OpClassForm *opc   = form->is_opclass();
1200   assert( opc, "replacement variable was not found in local names");
1201   // Lookup the index position of the replacement variable
1202   int idx  = operand_position_format(rep_var);
1203   if ( idx == -1 ) {
1204     assert( strcmp(opc->_ident,"label")==0, "Unimplemented");
1205     assert( false, "ShouldNotReachHere()");
1206   }
1207 
1208   if (is_noninput_operand(idx)) {
1209     // This component isn't in the input array.  Print out the static
1210     // name of the register.
1211     OperandForm* oper = form->is_operand();
1212     if (oper != NULL && oper->is_bound_register()) {


1331     fprintf(fp,"    unsigned %sidx%d = %sreq(); \n", prefix, idx, receiver);
1332   }
1333 
1334 }
1335 
1336 // ---------------------------
1337 bool InstructForm::verify() {
1338   // !!!!! !!!!!
1339   // Check that a "label" operand occurs last in the operand list, if present
1340   return true;
1341 }
1342 
1343 void InstructForm::dump() {
1344   output(stderr);
1345 }
1346 
1347 void InstructForm::output(FILE *fp) {
1348   fprintf(fp,"\nInstruction: %s\n", (_ident?_ident:""));
1349   if (_matrule)   _matrule->output(fp);
1350   if (_insencode) _insencode->output(fp);

1351   if (_opcode)    _opcode->output(fp);
1352   if (_attribs)   _attribs->output(fp);
1353   if (_predicate) _predicate->output(fp);
1354   if (_effects.Size()) {
1355     fprintf(fp,"Effects\n");
1356     _effects.dump();
1357   }
1358   if (_exprule)   _exprule->output(fp);
1359   if (_rewrule)   _rewrule->output(fp);
1360   if (_format)    _format->output(fp);
1361   if (_peephole)  _peephole->output(fp);
1362 }
1363 
1364 void MachNodeForm::dump() {
1365   output(stderr);
1366 }
1367 
1368 void MachNodeForm::output(FILE *fp) {
1369   fprintf(fp,"\nMachNode: %s\n", (_ident?_ident:""));
1370 }




  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 // FORMS.CPP - Definitions for ADL Parser Forms Classes
  26 #include "adlc.hpp"
  27 
  28 //==============================Instructions===================================
  29 //------------------------------InstructForm-----------------------------------
  30 InstructForm::InstructForm(const char *id, bool ideal_only)
  31   : _ident(id), _ideal_only(ideal_only),
  32     _localNames(cmpstr, hashstr, Form::arena),
  33     _effects(cmpstr, hashstr, Form::arena),
  34     _is_mach_constant(false)
  35 {
  36       _ftype = Form::INS;
  37 
  38       _matrule   = NULL;
  39       _insencode = NULL;
  40       _constant  = NULL;
  41       _opcode    = NULL;
  42       _size      = NULL;
  43       _attribs   = NULL;
  44       _predicate = NULL;
  45       _exprule   = NULL;
  46       _rewrule   = NULL;
  47       _format    = NULL;
  48       _peephole  = NULL;
  49       _ins_pipe  = NULL;
  50       _uniq_idx  = NULL;
  51       _num_uniq  = 0;
  52       _cisc_spill_operand = Not_cisc_spillable;// Which operand may cisc-spill
  53       _cisc_spill_alternate = NULL;            // possible cisc replacement
  54       _cisc_reg_mask_name = NULL;
  55       _is_cisc_alternate = false;
  56       _is_short_branch = false;
  57       _short_branch_form = NULL;
  58       _alignment = 1;
  59 }
  60 
  61 InstructForm::InstructForm(const char *id, InstructForm *instr, MatchRule *rule)
  62   : _ident(id), _ideal_only(false),
  63     _localNames(instr->_localNames),
  64     _effects(instr->_effects),
  65     _is_mach_constant(false)
  66 {
  67       _ftype = Form::INS;
  68 
  69       _matrule   = rule;
  70       _insencode = instr->_insencode;
  71       _constant  = instr->_constant;
  72       _opcode    = instr->_opcode;
  73       _size      = instr->_size;
  74       _attribs   = instr->_attribs;
  75       _predicate = instr->_predicate;
  76       _exprule   = instr->_exprule;
  77       _rewrule   = instr->_rewrule;
  78       _format    = instr->_format;
  79       _peephole  = instr->_peephole;
  80       _ins_pipe  = instr->_ins_pipe;
  81       _uniq_idx  = instr->_uniq_idx;
  82       _num_uniq  = instr->_num_uniq;
  83       _cisc_spill_operand = Not_cisc_spillable;// Which operand may cisc-spill
  84       _cisc_spill_alternate = NULL;            // possible cisc replacement
  85       _cisc_reg_mask_name = NULL;
  86       _is_cisc_alternate = false;
  87       _is_short_branch = false;
  88       _short_branch_form = NULL;
  89       _alignment = 1;
  90      // Copy parameters
  91      const char *name;


1083     return "MachCallLeafNode";
1084   }
1085   else if (is_ideal_return()) {
1086     return "MachReturnNode";
1087   }
1088   else if (is_ideal_halt()) {
1089     return "MachHaltNode";
1090   }
1091   else if (is_ideal_safepoint()) {
1092     return "MachSafePointNode";
1093   }
1094   else if (is_ideal_if()) {
1095     return "MachIfNode";
1096   }
1097   else if (is_ideal_fastlock()) {
1098     return "MachFastLockNode";
1099   }
1100   else if (is_ideal_nop()) {
1101     return "MachNopNode";
1102   }
1103   else if (is_mach_constant()) {
1104     return "MachConstantNode";
1105   }
1106   else if (captures_bottom_type(globals)) {
1107     return "MachTypeNode";
1108   } else {
1109     return "MachNode";
1110   }
1111   assert( false, "ShouldNotReachHere()");
1112   return NULL;
1113 }
1114 
1115 // Compare the instruction predicates for textual equality
1116 bool equivalent_predicates( const InstructForm *instr1, const InstructForm *instr2 ) {
1117   const Predicate *pred1  = instr1->_predicate;
1118   const Predicate *pred2  = instr2->_predicate;
1119   if( pred1 == NULL && pred2 == NULL ) {
1120     // no predicates means they are identical
1121     return true;
1122   }
1123   if( pred1 != NULL && pred2 != NULL ) {
1124     // compare the predicates
1125     if (ADLParser::equivalent_expressions(pred1->_pred, pred2->_pred)) {


1182       this != short_branch &&   // Don't match myself
1183       !is_short_branch() &&     // Don't match another short branch variant
1184       reduce_result() != NULL &&
1185       strcmp(reduce_result(), short_branch->reduce_result()) == 0 &&
1186       _matrule->equivalent(AD.globalNames(), short_branch->_matrule)) {
1187     // The instructions are equivalent.
1188     if (AD._short_branch_debug) {
1189       fprintf(stderr, "Instruction %s has short form %s\n", _ident, short_branch->_ident);
1190     }
1191     _short_branch_form = short_branch;
1192     return true;
1193   }
1194   return false;
1195 }
1196 
1197 
1198 // --------------------------- FILE *output_routines
1199 //
1200 // Generate the format call for the replacement variable
1201 void InstructForm::rep_var_format(FILE *fp, const char *rep_var) {
1202   // Handle special constant table variables.
1203   if (strcmp(rep_var, "constanttablebase") == 0) {
1204     fprintf(fp, "char reg[128];  ra->dump_register(in(mach_constant_base_node_input()), reg);\n");
1205     fprintf(fp, "st->print(\"%%s\");\n");
1206     return;
1207   }
1208   if (strcmp(rep_var, "constantoffset") == 0) {
1209     fprintf(fp, "st->print(\"#%%d\", constant_offset());\n");
1210     return;
1211   }
1212   if (strcmp(rep_var, "constantaddress") == 0) {
1213     fprintf(fp, "st->print(\"constant table base + #%%d\", constant_offset());\n");
1214     return;
1215   }
1216 
1217   // Find replacement variable's type
1218   const Form *form   = _localNames[rep_var];
1219   if (form == NULL) {
1220     fprintf(stderr, "unknown replacement variable in format statement: '%s'\n", rep_var);
1221     assert(false, "ShouldNotReachHere()");
1222   }
1223   OpClassForm *opc   = form->is_opclass();
1224   assert( opc, "replacement variable was not found in local names");
1225   // Lookup the index position of the replacement variable
1226   int idx  = operand_position_format(rep_var);
1227   if ( idx == -1 ) {
1228     assert( strcmp(opc->_ident,"label")==0, "Unimplemented");
1229     assert( false, "ShouldNotReachHere()");
1230   }
1231 
1232   if (is_noninput_operand(idx)) {
1233     // This component isn't in the input array.  Print out the static
1234     // name of the register.
1235     OperandForm* oper = form->is_operand();
1236     if (oper != NULL && oper->is_bound_register()) {


1355     fprintf(fp,"    unsigned %sidx%d = %sreq(); \n", prefix, idx, receiver);
1356   }
1357 
1358 }
1359 
1360 // ---------------------------
1361 bool InstructForm::verify() {
1362   // !!!!! !!!!!
1363   // Check that a "label" operand occurs last in the operand list, if present
1364   return true;
1365 }
1366 
1367 void InstructForm::dump() {
1368   output(stderr);
1369 }
1370 
1371 void InstructForm::output(FILE *fp) {
1372   fprintf(fp,"\nInstruction: %s\n", (_ident?_ident:""));
1373   if (_matrule)   _matrule->output(fp);
1374   if (_insencode) _insencode->output(fp);
1375   if (_constant)  _constant->output(fp);
1376   if (_opcode)    _opcode->output(fp);
1377   if (_attribs)   _attribs->output(fp);
1378   if (_predicate) _predicate->output(fp);
1379   if (_effects.Size()) {
1380     fprintf(fp,"Effects\n");
1381     _effects.dump();
1382   }
1383   if (_exprule)   _exprule->output(fp);
1384   if (_rewrule)   _rewrule->output(fp);
1385   if (_format)    _format->output(fp);
1386   if (_peephole)  _peephole->output(fp);
1387 }
1388 
1389 void MachNodeForm::dump() {
1390   output(stderr);
1391 }
1392 
1393 void MachNodeForm::output(FILE *fp) {
1394   fprintf(fp,"\nMachNode: %s\n", (_ident?_ident:""));
1395 }


src/share/vm/adlc/formssel.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File