提交 9b6cb8d6 编写于 作者: R roland

7090968: Allow adlc register class to depend on runtime conditions

Summary: allow reg_class definition as a function.
Reviewed-by: kvn, never
上级 0574d537
...@@ -1019,7 +1019,7 @@ void emit_hi(CodeBuffer &cbuf, int val) { } ...@@ -1019,7 +1019,7 @@ void emit_hi(CodeBuffer &cbuf, int val) { }
//============================================================================= //=============================================================================
const RegMask& MachConstantBaseNode::_out_RegMask = PTR_REG_mask; const RegMask& MachConstantBaseNode::_out_RegMask = PTR_REG_mask();
int Compile::ConstantTable::calculate_table_base_offset() const { int Compile::ConstantTable::calculate_table_base_offset() const {
if (UseRDPCForConstantTableBase) { if (UseRDPCForConstantTableBase) {
...@@ -2024,7 +2024,7 @@ RegMask Matcher::modL_proj_mask() { ...@@ -2024,7 +2024,7 @@ RegMask Matcher::modL_proj_mask() {
} }
const RegMask Matcher::method_handle_invoke_SP_save_mask() { const RegMask Matcher::method_handle_invoke_SP_save_mask() {
return L7_REGP_mask; return L7_REGP_mask();
} }
%} %}
......
...@@ -1524,12 +1524,12 @@ bool Matcher::use_asm_for_ldiv_by_con( jlong divisor ) { ...@@ -1524,12 +1524,12 @@ bool Matcher::use_asm_for_ldiv_by_con( jlong divisor ) {
// Register for DIVI projection of divmodI // Register for DIVI projection of divmodI
RegMask Matcher::divI_proj_mask() { RegMask Matcher::divI_proj_mask() {
return EAX_REG_mask; return EAX_REG_mask();
} }
// Register for MODI projection of divmodI // Register for MODI projection of divmodI
RegMask Matcher::modI_proj_mask() { RegMask Matcher::modI_proj_mask() {
return EDX_REG_mask; return EDX_REG_mask();
} }
// Register for DIVL projection of divmodL // Register for DIVL projection of divmodL
...@@ -1545,7 +1545,7 @@ RegMask Matcher::modL_proj_mask() { ...@@ -1545,7 +1545,7 @@ RegMask Matcher::modL_proj_mask() {
} }
const RegMask Matcher::method_handle_invoke_SP_save_mask() { const RegMask Matcher::method_handle_invoke_SP_save_mask() {
return EBP_REG_mask; return EBP_REG_mask();
} }
// Returns true if the high 32 bits of the value is known to be zero. // Returns true if the high 32 bits of the value is known to be zero.
......
...@@ -2089,26 +2089,26 @@ bool Matcher::use_asm_for_ldiv_by_con( jlong divisor ) { ...@@ -2089,26 +2089,26 @@ bool Matcher::use_asm_for_ldiv_by_con( jlong divisor ) {
// Register for DIVI projection of divmodI // Register for DIVI projection of divmodI
RegMask Matcher::divI_proj_mask() { RegMask Matcher::divI_proj_mask() {
return INT_RAX_REG_mask; return INT_RAX_REG_mask();
} }
// Register for MODI projection of divmodI // Register for MODI projection of divmodI
RegMask Matcher::modI_proj_mask() { RegMask Matcher::modI_proj_mask() {
return INT_RDX_REG_mask; return INT_RDX_REG_mask();
} }
// Register for DIVL projection of divmodL // Register for DIVL projection of divmodL
RegMask Matcher::divL_proj_mask() { RegMask Matcher::divL_proj_mask() {
return LONG_RAX_REG_mask; return LONG_RAX_REG_mask();
} }
// Register for MODL projection of divmodL // Register for MODL projection of divmodL
RegMask Matcher::modL_proj_mask() { RegMask Matcher::modL_proj_mask() {
return LONG_RDX_REG_mask; return LONG_RDX_REG_mask();
} }
const RegMask Matcher::method_handle_invoke_SP_save_mask() { const RegMask Matcher::method_handle_invoke_SP_save_mask() {
return PTR_RBP_REG_mask; return PTR_RBP_REG_mask();
} }
static Address build_address(int b, int i, int s, int d) { static Address build_address(int b, int i, int s, int d) {
......
...@@ -982,27 +982,9 @@ void ADLParser::frame_parse(void) { ...@@ -982,27 +982,9 @@ void ADLParser::frame_parse(void) {
} }
if (strcmp(token,"interpreter_frame_pointer")==0) { if (strcmp(token,"interpreter_frame_pointer")==0) {
interpreter_frame_pointer_parse(frame, false); interpreter_frame_pointer_parse(frame, false);
// Add reg_class interpreter_frame_pointer_reg
if( _AD._register != NULL ) {
RegClass *reg_class = _AD._register->addRegClass("interpreter_frame_pointer_reg");
char *interpreter_frame_pointer_reg = frame->_interpreter_frame_pointer_reg;
if( interpreter_frame_pointer_reg != NULL ) {
RegDef *regDef = _AD._register->getRegDef(interpreter_frame_pointer_reg);
reg_class->addReg(regDef); // add regDef to regClass
}
}
} }
if (strcmp(token,"inline_cache_reg")==0) { if (strcmp(token,"inline_cache_reg")==0) {
inline_cache_parse(frame, false); inline_cache_parse(frame, false);
// Add reg_class inline_cache_reg
if( _AD._register != NULL ) {
RegClass *reg_class = _AD._register->addRegClass("inline_cache_reg");
char *inline_cache_reg = frame->_inline_cache_reg;
if( inline_cache_reg != NULL ) {
RegDef *regDef = _AD._register->getRegDef(inline_cache_reg);
reg_class->addReg(regDef); // add regDef to regClass
}
}
} }
if (strcmp(token,"compiler_method_oop_reg")==0) { if (strcmp(token,"compiler_method_oop_reg")==0) {
parse_err(WARN, "Using obsolete Token, compiler_method_oop_reg"); parse_err(WARN, "Using obsolete Token, compiler_method_oop_reg");
...@@ -1010,15 +992,6 @@ void ADLParser::frame_parse(void) { ...@@ -1010,15 +992,6 @@ void ADLParser::frame_parse(void) {
} }
if (strcmp(token,"interpreter_method_oop_reg")==0) { if (strcmp(token,"interpreter_method_oop_reg")==0) {
interpreter_method_oop_parse(frame, false); interpreter_method_oop_parse(frame, false);
// Add reg_class interpreter_method_oop_reg
if( _AD._register != NULL ) {
RegClass *reg_class = _AD._register->addRegClass("interpreter_method_oop_reg");
char *method_oop_reg = frame->_interpreter_method_oop_reg;
if( method_oop_reg != NULL ) {
RegDef *regDef = _AD._register->getRegDef(method_oop_reg);
reg_class->addReg(regDef); // add regDef to regClass
}
}
} }
if (strcmp(token,"cisc_spilling_operand_name")==0) { if (strcmp(token,"cisc_spilling_operand_name")==0) {
cisc_spilling_operand_name_parse(frame, false); cisc_spilling_operand_name_parse(frame, false);
...@@ -2363,6 +2336,14 @@ void ADLParser::reg_class_parse(void) { ...@@ -2363,6 +2336,14 @@ void ADLParser::reg_class_parse(void) {
} }
} }
next_char(); // Skip closing ')' next_char(); // Skip closing ')'
} else if (_curchar == '%') {
char *code = find_cpp_block("reg class");
if (code == NULL) {
parse_err(SYNERR, "missing code declaration for reg class.\n");
return;
}
reg_class->_user_defined = code;
return;
} }
// Check for terminating ';' // Check for terminating ';'
......
...@@ -823,9 +823,9 @@ static const char *getRegMask(const char *reg_class_name) { ...@@ -823,9 +823,9 @@ static const char *getRegMask(const char *reg_class_name) {
} else { } else {
char *rc_name = toUpper(reg_class_name); char *rc_name = toUpper(reg_class_name);
const char *mask = "_mask"; const char *mask = "_mask";
int length = (int)strlen(rc_name) + (int)strlen(mask) + 3; int length = (int)strlen(rc_name) + (int)strlen(mask) + 5;
char *regMask = new char[length]; char *regMask = new char[length];
sprintf(regMask,"%s%s", rc_name, mask); sprintf(regMask,"%s%s()", rc_name, mask);
return regMask; return regMask;
} }
} }
......
...@@ -219,7 +219,9 @@ void RegDef::output(FILE *fp) { // Write info to output files ...@@ -219,7 +219,9 @@ void RegDef::output(FILE *fp) { // Write info to output files
//------------------------------RegClass--------------------------------------- //------------------------------RegClass---------------------------------------
// Construct a register class into which registers will be inserted // Construct a register class into which registers will be inserted
RegClass::RegClass(const char *classid) : _stack_or_reg(false), _classid(classid), _regDef(cmpstr,hashstr, Form::arena) { RegClass::RegClass(const char *classid) : _stack_or_reg(false), _classid(classid), _regDef(cmpstr,hashstr, Form::arena),
_user_defined(NULL)
{
} }
// record a register in this class // record a register in this class
......
...@@ -161,6 +161,7 @@ public: ...@@ -161,6 +161,7 @@ public:
NameList _regDefs; // List of registers in class NameList _regDefs; // List of registers in class
Dict _regDef; // Dictionary of registers in class Dict _regDef; // Dictionary of registers in class
bool _stack_or_reg; // Allowed on any stack slot bool _stack_or_reg; // Allowed on any stack slot
char* _user_defined;
// Public Methods // Public Methods
RegClass(const char *classid);// Constructor RegClass(const char *classid);// Constructor
......
...@@ -162,11 +162,17 @@ void ArchDesc::declare_register_masks(FILE *fp_hpp) { ...@@ -162,11 +162,17 @@ void ArchDesc::declare_register_masks(FILE *fp_hpp) {
RegClass *reg_class = _register->getRegClass(rc_name); RegClass *reg_class = _register->getRegClass(rc_name);
assert( reg_class, "Using an undefined register class"); assert( reg_class, "Using an undefined register class");
int len = RegisterForm::RegMask_Size(); if (reg_class->_user_defined == NULL) {
fprintf(fp_hpp, "extern const RegMask %s%s_mask;\n", prefix, toUpper( rc_name ) ); fprintf(fp_hpp, "extern const RegMask _%s%s_mask;\n", prefix, toUpper( rc_name ) );
fprintf(fp_hpp, "inline const RegMask &%s%s_mask() { return _%s%s_mask; }\n", prefix, toUpper( rc_name ), prefix, toUpper( rc_name ));
} else {
fprintf(fp_hpp, "inline const RegMask &%s%s_mask() { %s }\n", prefix, toUpper( rc_name ), reg_class->_user_defined);
}
if( reg_class->_stack_or_reg ) { if( reg_class->_stack_or_reg ) {
fprintf(fp_hpp, "extern const RegMask %sSTACK_OR_%s_mask;\n", prefix, toUpper( rc_name ) ); assert(reg_class->_user_defined == NULL, "no user defined reg class here");
fprintf(fp_hpp, "extern const RegMask _%sSTACK_OR_%s_mask;\n", prefix, toUpper( rc_name ) );
fprintf(fp_hpp, "inline const RegMask &%sSTACK_OR_%s_mask() { return _%sSTACK_OR_%s_mask; }\n", prefix, toUpper( rc_name ), prefix, toUpper( rc_name ) );
} }
} }
} }
...@@ -188,8 +194,10 @@ void ArchDesc::build_register_masks(FILE *fp_cpp) { ...@@ -188,8 +194,10 @@ void ArchDesc::build_register_masks(FILE *fp_cpp) {
RegClass *reg_class = _register->getRegClass(rc_name); RegClass *reg_class = _register->getRegClass(rc_name);
assert( reg_class, "Using an undefined register class"); assert( reg_class, "Using an undefined register class");
if (reg_class->_user_defined != NULL) continue;
int len = RegisterForm::RegMask_Size(); int len = RegisterForm::RegMask_Size();
fprintf(fp_cpp, "const RegMask %s%s_mask(", prefix, toUpper( rc_name ) ); fprintf(fp_cpp, "const RegMask _%s%s_mask(", prefix, toUpper( rc_name ) );
{ int i; { int i;
for( i = 0; i < len-1; i++ ) for( i = 0; i < len-1; i++ )
fprintf(fp_cpp," 0x%x,",reg_class->regs_in_word(i,false)); fprintf(fp_cpp," 0x%x,",reg_class->regs_in_word(i,false));
...@@ -198,7 +206,7 @@ void ArchDesc::build_register_masks(FILE *fp_cpp) { ...@@ -198,7 +206,7 @@ void ArchDesc::build_register_masks(FILE *fp_cpp) {
if( reg_class->_stack_or_reg ) { if( reg_class->_stack_or_reg ) {
int i; int i;
fprintf(fp_cpp, "const RegMask %sSTACK_OR_%s_mask(", prefix, toUpper( rc_name ) ); fprintf(fp_cpp, "const RegMask _%sSTACK_OR_%s_mask(", prefix, toUpper( rc_name ) );
for( i = 0; i < len-1; i++ ) for( i = 0; i < len-1; i++ )
fprintf(fp_cpp," 0x%x,",reg_class->regs_in_word(i,true)); fprintf(fp_cpp," 0x%x,",reg_class->regs_in_word(i,true));
fprintf(fp_cpp," 0x%x );\n",reg_class->regs_in_word(i,true)); fprintf(fp_cpp," 0x%x );\n",reg_class->regs_in_word(i,true));
...@@ -2690,7 +2698,7 @@ static void defineIn_RegMask(FILE *fp, FormDict &globals, OperandForm &oper) { ...@@ -2690,7 +2698,7 @@ static void defineIn_RegMask(FILE *fp, FormDict &globals, OperandForm &oper) {
if (strcmp(first_reg_class, "stack_slots") == 0) { if (strcmp(first_reg_class, "stack_slots") == 0) {
fprintf(fp," return &(Compile::current()->FIRST_STACK_mask());\n"); fprintf(fp," return &(Compile::current()->FIRST_STACK_mask());\n");
} else { } else {
fprintf(fp," return &%s_mask;\n", toUpper(first_reg_class)); fprintf(fp," return &%s_mask();\n", toUpper(first_reg_class));
} }
} else { } else {
// Build a switch statement to return the desired mask. // Build a switch statement to return the desired mask.
...@@ -2702,7 +2710,7 @@ static void defineIn_RegMask(FILE *fp, FormDict &globals, OperandForm &oper) { ...@@ -2702,7 +2710,7 @@ static void defineIn_RegMask(FILE *fp, FormDict &globals, OperandForm &oper) {
if( !strcmp(reg_class, "stack_slots") ) { if( !strcmp(reg_class, "stack_slots") ) {
fprintf(fp, " case %d: return &(Compile::current()->FIRST_STACK_mask());\n", index); fprintf(fp, " case %d: return &(Compile::current()->FIRST_STACK_mask());\n", index);
} else { } else {
fprintf(fp, " case %d: return &%s_mask;\n", index, toUpper(reg_class)); fprintf(fp, " case %d: return &%s_mask();\n", index, toUpper(reg_class));
} }
} }
fprintf(fp," }\n"); fprintf(fp," }\n");
...@@ -4080,8 +4088,6 @@ void ArchDesc::buildFrameMethods(FILE *fp_cpp) { ...@@ -4080,8 +4088,6 @@ void ArchDesc::buildFrameMethods(FILE *fp_cpp) {
fprintf(fp_cpp,"OptoReg::Name Matcher::inline_cache_reg() {"); fprintf(fp_cpp,"OptoReg::Name Matcher::inline_cache_reg() {");
fprintf(fp_cpp," return OptoReg::Name(%s_num); }\n\n", fprintf(fp_cpp," return OptoReg::Name(%s_num); }\n\n",
_frame->_inline_cache_reg); _frame->_inline_cache_reg);
fprintf(fp_cpp,"const RegMask &Matcher::inline_cache_reg_mask() {");
fprintf(fp_cpp," return INLINE_CACHE_REG_mask; }\n\n");
fprintf(fp_cpp,"int Matcher::inline_cache_reg_encode() {"); fprintf(fp_cpp,"int Matcher::inline_cache_reg_encode() {");
fprintf(fp_cpp," return _regEncode[inline_cache_reg()]; }\n\n"); fprintf(fp_cpp," return _regEncode[inline_cache_reg()]; }\n\n");
...@@ -4089,8 +4095,6 @@ void ArchDesc::buildFrameMethods(FILE *fp_cpp) { ...@@ -4089,8 +4095,6 @@ void ArchDesc::buildFrameMethods(FILE *fp_cpp) {
fprintf(fp_cpp,"OptoReg::Name Matcher::interpreter_method_oop_reg() {"); fprintf(fp_cpp,"OptoReg::Name Matcher::interpreter_method_oop_reg() {");
fprintf(fp_cpp," return OptoReg::Name(%s_num); }\n\n", fprintf(fp_cpp," return OptoReg::Name(%s_num); }\n\n",
_frame->_interpreter_method_oop_reg); _frame->_interpreter_method_oop_reg);
fprintf(fp_cpp,"const RegMask &Matcher::interpreter_method_oop_reg_mask() {");
fprintf(fp_cpp," return INTERPRETER_METHOD_OOP_REG_mask; }\n\n");
fprintf(fp_cpp,"int Matcher::interpreter_method_oop_reg_encode() {"); fprintf(fp_cpp,"int Matcher::interpreter_method_oop_reg_encode() {");
fprintf(fp_cpp," return _regEncode[interpreter_method_oop_reg()]; }\n\n"); fprintf(fp_cpp," return _regEncode[interpreter_method_oop_reg()]; }\n\n");
...@@ -4101,11 +4105,6 @@ void ArchDesc::buildFrameMethods(FILE *fp_cpp) { ...@@ -4101,11 +4105,6 @@ void ArchDesc::buildFrameMethods(FILE *fp_cpp) {
else else
fprintf(fp_cpp," return OptoReg::Name(%s_num); }\n\n", fprintf(fp_cpp," return OptoReg::Name(%s_num); }\n\n",
_frame->_interpreter_frame_pointer_reg); _frame->_interpreter_frame_pointer_reg);
fprintf(fp_cpp,"const RegMask &Matcher::interpreter_frame_pointer_reg_mask() {");
if (_frame->_interpreter_frame_pointer_reg == NULL)
fprintf(fp_cpp," static RegMask dummy; return dummy; }\n\n");
else
fprintf(fp_cpp," return INTERPRETER_FRAME_POINTER_REG_mask; }\n\n");
// Frame Pointer definition // Frame Pointer definition
/* CNC - I can not contemplate having a different frame pointer between /* CNC - I can not contemplate having a different frame pointer between
......
...@@ -294,7 +294,6 @@ public: ...@@ -294,7 +294,6 @@ public:
RegMask _return_value_mask; RegMask _return_value_mask;
// Inline Cache Register // Inline Cache Register
static OptoReg::Name inline_cache_reg(); static OptoReg::Name inline_cache_reg();
static const RegMask &inline_cache_reg_mask();
static int inline_cache_reg_encode(); static int inline_cache_reg_encode();
// Register for DIVI projection of divmodI // Register for DIVI projection of divmodI
...@@ -324,7 +323,6 @@ public: ...@@ -324,7 +323,6 @@ public:
// and then expanded into the inline_cache_reg and a method_oop register // and then expanded into the inline_cache_reg and a method_oop register
static OptoReg::Name interpreter_method_oop_reg(); static OptoReg::Name interpreter_method_oop_reg();
static const RegMask &interpreter_method_oop_reg_mask();
static int interpreter_method_oop_reg_encode(); static int interpreter_method_oop_reg_encode();
static OptoReg::Name compiler_method_oop_reg(); static OptoReg::Name compiler_method_oop_reg();
...@@ -333,7 +331,6 @@ public: ...@@ -333,7 +331,6 @@ public:
// Interpreter's Frame Pointer Register // Interpreter's Frame Pointer Register
static OptoReg::Name interpreter_frame_pointer_reg(); static OptoReg::Name interpreter_frame_pointer_reg();
static const RegMask &interpreter_frame_pointer_reg_mask();
// Java-Native calling convention // Java-Native calling convention
// (what you use when intercalling between Java and C++ code) // (what you use when intercalling between Java and C++ code)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册