Mercurial > hg > graal-jvmci-8
comparison src/share/vm/adlc/output_c.cpp @ 4121:db2e64ca2d5a
7090968: Allow adlc register class to depend on runtime conditions
Summary: allow reg_class definition as a function.
Reviewed-by: kvn, never
author | roland |
---|---|
date | Tue, 22 Nov 2011 09:45:57 +0100 |
parents | 6729bbc1fcd6 |
children | da91efe96a93 |
comparison
equal
deleted
inserted
replaced
4120:f03a3c8bd5e5 | 4121:db2e64ca2d5a |
---|---|
160 (rc_name = _register->_rclasses.iter()) != NULL; ) { | 160 (rc_name = _register->_rclasses.iter()) != NULL; ) { |
161 const char *prefix = ""; | 161 const char *prefix = ""; |
162 RegClass *reg_class = _register->getRegClass(rc_name); | 162 RegClass *reg_class = _register->getRegClass(rc_name); |
163 assert( reg_class, "Using an undefined register class"); | 163 assert( reg_class, "Using an undefined register class"); |
164 | 164 |
165 int len = RegisterForm::RegMask_Size(); | 165 if (reg_class->_user_defined == NULL) { |
166 fprintf(fp_hpp, "extern const RegMask %s%s_mask;\n", prefix, toUpper( rc_name ) ); | 166 fprintf(fp_hpp, "extern const RegMask _%s%s_mask;\n", prefix, toUpper( rc_name ) ); |
167 fprintf(fp_hpp, "inline const RegMask &%s%s_mask() { return _%s%s_mask; }\n", prefix, toUpper( rc_name ), prefix, toUpper( rc_name )); | |
168 } else { | |
169 fprintf(fp_hpp, "inline const RegMask &%s%s_mask() { %s }\n", prefix, toUpper( rc_name ), reg_class->_user_defined); | |
170 } | |
167 | 171 |
168 if( reg_class->_stack_or_reg ) { | 172 if( reg_class->_stack_or_reg ) { |
169 fprintf(fp_hpp, "extern const RegMask %sSTACK_OR_%s_mask;\n", prefix, toUpper( rc_name ) ); | 173 assert(reg_class->_user_defined == NULL, "no user defined reg class here"); |
174 fprintf(fp_hpp, "extern const RegMask _%sSTACK_OR_%s_mask;\n", prefix, toUpper( rc_name ) ); | |
175 fprintf(fp_hpp, "inline const RegMask &%sSTACK_OR_%s_mask() { return _%sSTACK_OR_%s_mask; }\n", prefix, toUpper( rc_name ), prefix, toUpper( rc_name ) ); | |
170 } | 176 } |
171 } | 177 } |
172 } | 178 } |
173 } | 179 } |
174 | 180 |
186 (rc_name = _register->_rclasses.iter()) != NULL; ) { | 192 (rc_name = _register->_rclasses.iter()) != NULL; ) { |
187 const char *prefix = ""; | 193 const char *prefix = ""; |
188 RegClass *reg_class = _register->getRegClass(rc_name); | 194 RegClass *reg_class = _register->getRegClass(rc_name); |
189 assert( reg_class, "Using an undefined register class"); | 195 assert( reg_class, "Using an undefined register class"); |
190 | 196 |
197 if (reg_class->_user_defined != NULL) continue; | |
198 | |
191 int len = RegisterForm::RegMask_Size(); | 199 int len = RegisterForm::RegMask_Size(); |
192 fprintf(fp_cpp, "const RegMask %s%s_mask(", prefix, toUpper( rc_name ) ); | 200 fprintf(fp_cpp, "const RegMask _%s%s_mask(", prefix, toUpper( rc_name ) ); |
193 { int i; | 201 { int i; |
194 for( i = 0; i < len-1; i++ ) | 202 for( i = 0; i < len-1; i++ ) |
195 fprintf(fp_cpp," 0x%x,",reg_class->regs_in_word(i,false)); | 203 fprintf(fp_cpp," 0x%x,",reg_class->regs_in_word(i,false)); |
196 fprintf(fp_cpp," 0x%x );\n",reg_class->regs_in_word(i,false)); | 204 fprintf(fp_cpp," 0x%x );\n",reg_class->regs_in_word(i,false)); |
197 } | 205 } |
198 | 206 |
199 if( reg_class->_stack_or_reg ) { | 207 if( reg_class->_stack_or_reg ) { |
200 int i; | 208 int i; |
201 fprintf(fp_cpp, "const RegMask %sSTACK_OR_%s_mask(", prefix, toUpper( rc_name ) ); | 209 fprintf(fp_cpp, "const RegMask _%sSTACK_OR_%s_mask(", prefix, toUpper( rc_name ) ); |
202 for( i = 0; i < len-1; i++ ) | 210 for( i = 0; i < len-1; i++ ) |
203 fprintf(fp_cpp," 0x%x,",reg_class->regs_in_word(i,true)); | 211 fprintf(fp_cpp," 0x%x,",reg_class->regs_in_word(i,true)); |
204 fprintf(fp_cpp," 0x%x );\n",reg_class->regs_in_word(i,true)); | 212 fprintf(fp_cpp," 0x%x );\n",reg_class->regs_in_word(i,true)); |
205 } | 213 } |
206 } | 214 } |
2688 if (all_same) { | 2696 if (all_same) { |
2689 // Return the sole RegMask. | 2697 // Return the sole RegMask. |
2690 if (strcmp(first_reg_class, "stack_slots") == 0) { | 2698 if (strcmp(first_reg_class, "stack_slots") == 0) { |
2691 fprintf(fp," return &(Compile::current()->FIRST_STACK_mask());\n"); | 2699 fprintf(fp," return &(Compile::current()->FIRST_STACK_mask());\n"); |
2692 } else { | 2700 } else { |
2693 fprintf(fp," return &%s_mask;\n", toUpper(first_reg_class)); | 2701 fprintf(fp," return &%s_mask();\n", toUpper(first_reg_class)); |
2694 } | 2702 } |
2695 } else { | 2703 } else { |
2696 // Build a switch statement to return the desired mask. | 2704 // Build a switch statement to return the desired mask. |
2697 fprintf(fp," switch (index) {\n"); | 2705 fprintf(fp," switch (index) {\n"); |
2698 | 2706 |
2700 const char *reg_class = oper.in_reg_class(index, globals); | 2708 const char *reg_class = oper.in_reg_class(index, globals); |
2701 assert(reg_class != NULL, "did not find register mask"); | 2709 assert(reg_class != NULL, "did not find register mask"); |
2702 if( !strcmp(reg_class, "stack_slots") ) { | 2710 if( !strcmp(reg_class, "stack_slots") ) { |
2703 fprintf(fp, " case %d: return &(Compile::current()->FIRST_STACK_mask());\n", index); | 2711 fprintf(fp, " case %d: return &(Compile::current()->FIRST_STACK_mask());\n", index); |
2704 } else { | 2712 } else { |
2705 fprintf(fp, " case %d: return &%s_mask;\n", index, toUpper(reg_class)); | 2713 fprintf(fp, " case %d: return &%s_mask();\n", index, toUpper(reg_class)); |
2706 } | 2714 } |
2707 } | 2715 } |
2708 fprintf(fp," }\n"); | 2716 fprintf(fp," }\n"); |
2709 fprintf(fp," ShouldNotReachHere();\n"); | 2717 fprintf(fp," ShouldNotReachHere();\n"); |
2710 fprintf(fp," return NULL;\n"); | 2718 fprintf(fp," return NULL;\n"); |
4078 | 4086 |
4079 // Inline Cache Register, mask definition, and encoding | 4087 // Inline Cache Register, mask definition, and encoding |
4080 fprintf(fp_cpp,"OptoReg::Name Matcher::inline_cache_reg() {"); | 4088 fprintf(fp_cpp,"OptoReg::Name Matcher::inline_cache_reg() {"); |
4081 fprintf(fp_cpp," return OptoReg::Name(%s_num); }\n\n", | 4089 fprintf(fp_cpp," return OptoReg::Name(%s_num); }\n\n", |
4082 _frame->_inline_cache_reg); | 4090 _frame->_inline_cache_reg); |
4083 fprintf(fp_cpp,"const RegMask &Matcher::inline_cache_reg_mask() {"); | |
4084 fprintf(fp_cpp," return INLINE_CACHE_REG_mask; }\n\n"); | |
4085 fprintf(fp_cpp,"int Matcher::inline_cache_reg_encode() {"); | 4091 fprintf(fp_cpp,"int Matcher::inline_cache_reg_encode() {"); |
4086 fprintf(fp_cpp," return _regEncode[inline_cache_reg()]; }\n\n"); | 4092 fprintf(fp_cpp," return _regEncode[inline_cache_reg()]; }\n\n"); |
4087 | 4093 |
4088 // Interpreter's Method Oop Register, mask definition, and encoding | 4094 // Interpreter's Method Oop Register, mask definition, and encoding |
4089 fprintf(fp_cpp,"OptoReg::Name Matcher::interpreter_method_oop_reg() {"); | 4095 fprintf(fp_cpp,"OptoReg::Name Matcher::interpreter_method_oop_reg() {"); |
4090 fprintf(fp_cpp," return OptoReg::Name(%s_num); }\n\n", | 4096 fprintf(fp_cpp," return OptoReg::Name(%s_num); }\n\n", |
4091 _frame->_interpreter_method_oop_reg); | 4097 _frame->_interpreter_method_oop_reg); |
4092 fprintf(fp_cpp,"const RegMask &Matcher::interpreter_method_oop_reg_mask() {"); | |
4093 fprintf(fp_cpp," return INTERPRETER_METHOD_OOP_REG_mask; }\n\n"); | |
4094 fprintf(fp_cpp,"int Matcher::interpreter_method_oop_reg_encode() {"); | 4098 fprintf(fp_cpp,"int Matcher::interpreter_method_oop_reg_encode() {"); |
4095 fprintf(fp_cpp," return _regEncode[interpreter_method_oop_reg()]; }\n\n"); | 4099 fprintf(fp_cpp," return _regEncode[interpreter_method_oop_reg()]; }\n\n"); |
4096 | 4100 |
4097 // Interpreter's Frame Pointer Register, mask definition, and encoding | 4101 // Interpreter's Frame Pointer Register, mask definition, and encoding |
4098 fprintf(fp_cpp,"OptoReg::Name Matcher::interpreter_frame_pointer_reg() {"); | 4102 fprintf(fp_cpp,"OptoReg::Name Matcher::interpreter_frame_pointer_reg() {"); |
4099 if (_frame->_interpreter_frame_pointer_reg == NULL) | 4103 if (_frame->_interpreter_frame_pointer_reg == NULL) |
4100 fprintf(fp_cpp," return OptoReg::Bad; }\n\n"); | 4104 fprintf(fp_cpp," return OptoReg::Bad; }\n\n"); |
4101 else | 4105 else |
4102 fprintf(fp_cpp," return OptoReg::Name(%s_num); }\n\n", | 4106 fprintf(fp_cpp," return OptoReg::Name(%s_num); }\n\n", |
4103 _frame->_interpreter_frame_pointer_reg); | 4107 _frame->_interpreter_frame_pointer_reg); |
4104 fprintf(fp_cpp,"const RegMask &Matcher::interpreter_frame_pointer_reg_mask() {"); | |
4105 if (_frame->_interpreter_frame_pointer_reg == NULL) | |
4106 fprintf(fp_cpp," static RegMask dummy; return dummy; }\n\n"); | |
4107 else | |
4108 fprintf(fp_cpp," return INTERPRETER_FRAME_POINTER_REG_mask; }\n\n"); | |
4109 | 4108 |
4110 // Frame Pointer definition | 4109 // Frame Pointer definition |
4111 /* CNC - I can not contemplate having a different frame pointer between | 4110 /* CNC - I can not contemplate having a different frame pointer between |
4112 Java and native code; makes my head hurt to think about it. | 4111 Java and native code; makes my head hurt to think about it. |
4113 fprintf(fp_cpp,"OptoReg::Name Matcher::frame_pointer() const {"); | 4112 fprintf(fp_cpp,"OptoReg::Name Matcher::frame_pointer() const {"); |