4080
4081 // Generate the default case for switch(opcode)
4082 fprintf(fp_cpp, " \n");
4083 fprintf(fp_cpp, " default:\n");
4084 fprintf(fp_cpp, " fprintf(stderr, \"Default MachNode Generator invoked for: \\n\");\n");
4085 fprintf(fp_cpp, " fprintf(stderr, \" opcode = %cd\\n\", opcode);\n", '%');
4086 fprintf(fp_cpp, " break;\n");
4087 fprintf(fp_cpp, " };\n");
4088
4089 // Generate the closing for method Matcher::MachNodeGenerator
4090 fprintf(fp_cpp, " return NULL;\n");
4091 fprintf(fp_cpp, "}\n");
4092 }
4093
4094
4095 //---------------------------buildInstructMatchCheck--------------------------
4096 // Output the method to Matcher which checks whether or not a specific
4097 // instruction has a matching rule for the host architecture.
4098 void ArchDesc::buildInstructMatchCheck(FILE *fp_cpp) const {
4099 fprintf(fp_cpp, "\n\n");
4100 fprintf(fp_cpp, "const bool Matcher::has_match_rule(int opcode) {\n");
4101 fprintf(fp_cpp, " assert(_last_machine_leaf < opcode && opcode < _last_opcode, \"opcode in range\");\n");
4102 fprintf(fp_cpp, " return _hasMatchRule[opcode];\n");
4103 fprintf(fp_cpp, "}\n\n");
4104
4105 fprintf(fp_cpp, "const bool Matcher::_hasMatchRule[_last_opcode] = {\n");
4106 int i;
4107 for (i = 0; i < _last_opcode - 1; i++) {
4108 fprintf(fp_cpp, " %-5s, // %s\n",
4109 _has_match_rule[i] ? "true" : "false",
4110 NodeClassNames[i]);
4111 }
4112 fprintf(fp_cpp, " %-5s // %s\n",
4113 _has_match_rule[i] ? "true" : "false",
4114 NodeClassNames[i]);
4115 fprintf(fp_cpp, "};\n");
4116 }
4117
4118 //---------------------------buildFrameMethods---------------------------------
4119 // Output the methods to Matcher which specify frame behavior
4120 void ArchDesc::buildFrameMethods(FILE *fp_cpp) {
4139 _frame->_return_addr);
4140 }
4141 // Java Stack Slot Preservation
4142 fprintf(fp_cpp,"uint Compile::in_preserve_stack_slots() ");
4143 fprintf(fp_cpp,"{ return %s; }\n\n", _frame->_in_preserve_slots);
4144 // Top Of Stack Slot Preservation, for both Java and C
4145 fprintf(fp_cpp,"uint Compile::out_preserve_stack_slots() ");
4146 fprintf(fp_cpp,"{ return SharedRuntime::out_preserve_stack_slots(); }\n\n");
4147 // varargs C out slots killed
4148 fprintf(fp_cpp,"uint Compile::varargs_C_out_slots_killed() const ");
4149 fprintf(fp_cpp,"{ return %s; }\n\n", _frame->_varargs_C_out_slots_killed);
4150 // Java Argument Position
4151 fprintf(fp_cpp,"void Matcher::calling_convention(BasicType *sig_bt, VMRegPair *regs, uint length, bool is_outgoing) {\n");
4152 fprintf(fp_cpp,"%s\n", _frame->_calling_convention);
4153 fprintf(fp_cpp,"}\n\n");
4154 // Native Argument Position
4155 fprintf(fp_cpp,"void Matcher::c_calling_convention(BasicType *sig_bt, VMRegPair *regs, uint length) {\n");
4156 fprintf(fp_cpp,"%s\n", _frame->_c_calling_convention);
4157 fprintf(fp_cpp,"}\n\n");
4158 // Java Return Value Location
4159 fprintf(fp_cpp,"OptoRegPair Matcher::return_value(int ideal_reg, bool is_outgoing) {\n");
4160 fprintf(fp_cpp,"%s\n", _frame->_return_value);
4161 fprintf(fp_cpp,"}\n\n");
4162 // Native Return Value Location
4163 fprintf(fp_cpp,"OptoRegPair Matcher::c_return_value(int ideal_reg, bool is_outgoing) {\n");
4164 fprintf(fp_cpp,"%s\n", _frame->_c_return_value);
4165 fprintf(fp_cpp,"}\n\n");
4166
4167 // Inline Cache Register, mask definition, and encoding
4168 fprintf(fp_cpp,"OptoReg::Name Matcher::inline_cache_reg() {");
4169 fprintf(fp_cpp," return OptoReg::Name(%s_num); }\n\n",
4170 _frame->_inline_cache_reg);
4171 fprintf(fp_cpp,"int Matcher::inline_cache_reg_encode() {");
4172 fprintf(fp_cpp," return _regEncode[inline_cache_reg()]; }\n\n");
4173
4174 // Interpreter's Method Oop Register, mask definition, and encoding
4175 fprintf(fp_cpp,"OptoReg::Name Matcher::interpreter_method_oop_reg() {");
4176 fprintf(fp_cpp," return OptoReg::Name(%s_num); }\n\n",
4177 _frame->_interpreter_method_oop_reg);
4178 fprintf(fp_cpp,"int Matcher::interpreter_method_oop_reg_encode() {");
4179 fprintf(fp_cpp," return _regEncode[interpreter_method_oop_reg()]; }\n\n");
4180
4181 // Interpreter's Frame Pointer Register, mask definition, and encoding
4182 fprintf(fp_cpp,"OptoReg::Name Matcher::interpreter_frame_pointer_reg() {");
4183 if (_frame->_interpreter_frame_pointer_reg == NULL)
|
4080
4081 // Generate the default case for switch(opcode)
4082 fprintf(fp_cpp, " \n");
4083 fprintf(fp_cpp, " default:\n");
4084 fprintf(fp_cpp, " fprintf(stderr, \"Default MachNode Generator invoked for: \\n\");\n");
4085 fprintf(fp_cpp, " fprintf(stderr, \" opcode = %cd\\n\", opcode);\n", '%');
4086 fprintf(fp_cpp, " break;\n");
4087 fprintf(fp_cpp, " };\n");
4088
4089 // Generate the closing for method Matcher::MachNodeGenerator
4090 fprintf(fp_cpp, " return NULL;\n");
4091 fprintf(fp_cpp, "}\n");
4092 }
4093
4094
4095 //---------------------------buildInstructMatchCheck--------------------------
4096 // Output the method to Matcher which checks whether or not a specific
4097 // instruction has a matching rule for the host architecture.
4098 void ArchDesc::buildInstructMatchCheck(FILE *fp_cpp) const {
4099 fprintf(fp_cpp, "\n\n");
4100 fprintf(fp_cpp, "const bool Matcher::has_match_rule(uint opcode) {\n");
4101 fprintf(fp_cpp, " assert(_last_machine_leaf < opcode && opcode < _last_opcode, \"opcode in range\");\n");
4102 fprintf(fp_cpp, " return _hasMatchRule[opcode];\n");
4103 fprintf(fp_cpp, "}\n\n");
4104
4105 fprintf(fp_cpp, "const bool Matcher::_hasMatchRule[_last_opcode] = {\n");
4106 int i;
4107 for (i = 0; i < _last_opcode - 1; i++) {
4108 fprintf(fp_cpp, " %-5s, // %s\n",
4109 _has_match_rule[i] ? "true" : "false",
4110 NodeClassNames[i]);
4111 }
4112 fprintf(fp_cpp, " %-5s // %s\n",
4113 _has_match_rule[i] ? "true" : "false",
4114 NodeClassNames[i]);
4115 fprintf(fp_cpp, "};\n");
4116 }
4117
4118 //---------------------------buildFrameMethods---------------------------------
4119 // Output the methods to Matcher which specify frame behavior
4120 void ArchDesc::buildFrameMethods(FILE *fp_cpp) {
4139 _frame->_return_addr);
4140 }
4141 // Java Stack Slot Preservation
4142 fprintf(fp_cpp,"uint Compile::in_preserve_stack_slots() ");
4143 fprintf(fp_cpp,"{ return %s; }\n\n", _frame->_in_preserve_slots);
4144 // Top Of Stack Slot Preservation, for both Java and C
4145 fprintf(fp_cpp,"uint Compile::out_preserve_stack_slots() ");
4146 fprintf(fp_cpp,"{ return SharedRuntime::out_preserve_stack_slots(); }\n\n");
4147 // varargs C out slots killed
4148 fprintf(fp_cpp,"uint Compile::varargs_C_out_slots_killed() const ");
4149 fprintf(fp_cpp,"{ return %s; }\n\n", _frame->_varargs_C_out_slots_killed);
4150 // Java Argument Position
4151 fprintf(fp_cpp,"void Matcher::calling_convention(BasicType *sig_bt, VMRegPair *regs, uint length, bool is_outgoing) {\n");
4152 fprintf(fp_cpp,"%s\n", _frame->_calling_convention);
4153 fprintf(fp_cpp,"}\n\n");
4154 // Native Argument Position
4155 fprintf(fp_cpp,"void Matcher::c_calling_convention(BasicType *sig_bt, VMRegPair *regs, uint length) {\n");
4156 fprintf(fp_cpp,"%s\n", _frame->_c_calling_convention);
4157 fprintf(fp_cpp,"}\n\n");
4158 // Java Return Value Location
4159 fprintf(fp_cpp,"OptoRegPair Matcher::return_value(uint ideal_reg, bool is_outgoing) {\n");
4160 fprintf(fp_cpp,"%s\n", _frame->_return_value);
4161 fprintf(fp_cpp,"}\n\n");
4162 // Native Return Value Location
4163 fprintf(fp_cpp,"OptoRegPair Matcher::c_return_value(uint ideal_reg, bool is_outgoing) {\n");
4164 fprintf(fp_cpp,"%s\n", _frame->_c_return_value);
4165 fprintf(fp_cpp,"}\n\n");
4166
4167 // Inline Cache Register, mask definition, and encoding
4168 fprintf(fp_cpp,"OptoReg::Name Matcher::inline_cache_reg() {");
4169 fprintf(fp_cpp," return OptoReg::Name(%s_num); }\n\n",
4170 _frame->_inline_cache_reg);
4171 fprintf(fp_cpp,"int Matcher::inline_cache_reg_encode() {");
4172 fprintf(fp_cpp," return _regEncode[inline_cache_reg()]; }\n\n");
4173
4174 // Interpreter's Method Oop Register, mask definition, and encoding
4175 fprintf(fp_cpp,"OptoReg::Name Matcher::interpreter_method_oop_reg() {");
4176 fprintf(fp_cpp," return OptoReg::Name(%s_num); }\n\n",
4177 _frame->_interpreter_method_oop_reg);
4178 fprintf(fp_cpp,"int Matcher::interpreter_method_oop_reg_encode() {");
4179 fprintf(fp_cpp," return _regEncode[interpreter_method_oop_reg()]; }\n\n");
4180
4181 // Interpreter's Frame Pointer Register, mask definition, and encoding
4182 fprintf(fp_cpp,"OptoReg::Name Matcher::interpreter_frame_pointer_reg() {");
4183 if (_frame->_interpreter_frame_pointer_reg == NULL)
|