src/share/vm/adlc/archDesc.cpp

Print this page
rev 2699 : 7090968: Allow adlc register class to depend on runtime conditions
Summary: allow reg_class definition as a function.
Reviewed-by:


 806     fprintf(errfile, "\n"); }
 807   return 1;
 808 }
 809 
 810 
 811 // ---------------------------------------------------------------------------
 812 //--------Utilities to build mappings for machine registers ------------------
 813 // ---------------------------------------------------------------------------
 814 
 815 // Construct the name of the register mask.
 816 static const char *getRegMask(const char *reg_class_name) {
 817   if( reg_class_name == NULL ) return "RegMask::Empty";
 818 
 819   if (strcmp(reg_class_name,"Universe")==0) {
 820     return "RegMask::Empty";
 821   } else if (strcmp(reg_class_name,"stack_slots")==0) {
 822     return "(Compile::current()->FIRST_STACK_mask())";
 823   } else {
 824     char       *rc_name = toUpper(reg_class_name);
 825     const char *mask    = "_mask";
 826     int         length  = (int)strlen(rc_name) + (int)strlen(mask) + 3;
 827     char       *regMask = new char[length];
 828     sprintf(regMask,"%s%s", rc_name, mask);
 829     return regMask;
 830   }
 831 }
 832 
 833 // Convert a register class name to its register mask.
 834 const char *ArchDesc::reg_class_to_reg_mask(const char *rc_name) {
 835   const char *reg_mask = "RegMask::Empty";
 836 
 837   if( _register ) {
 838     RegClass *reg_class  = _register->getRegClass(rc_name);
 839     if (reg_class == NULL) {
 840       syntax_err(0, "Use of an undefined register class %s", rc_name);
 841       return reg_mask;
 842     }
 843 
 844     // Construct the name of the register mask.
 845     reg_mask = getRegMask(rc_name);
 846   }
 847 
 848   return reg_mask;




 806     fprintf(errfile, "\n"); }
 807   return 1;
 808 }
 809 
 810 
 811 // ---------------------------------------------------------------------------
 812 //--------Utilities to build mappings for machine registers ------------------
 813 // ---------------------------------------------------------------------------
 814 
 815 // Construct the name of the register mask.
 816 static const char *getRegMask(const char *reg_class_name) {
 817   if( reg_class_name == NULL ) return "RegMask::Empty";
 818 
 819   if (strcmp(reg_class_name,"Universe")==0) {
 820     return "RegMask::Empty";
 821   } else if (strcmp(reg_class_name,"stack_slots")==0) {
 822     return "(Compile::current()->FIRST_STACK_mask())";
 823   } else {
 824     char       *rc_name = toUpper(reg_class_name);
 825     const char *mask    = "_mask";
 826     int         length  = (int)strlen(rc_name) + (int)strlen(mask) + 5;
 827     char       *regMask = new char[length];
 828     sprintf(regMask,"%s%s()", rc_name, mask);
 829     return regMask;
 830   }
 831 }
 832 
 833 // Convert a register class name to its register mask.
 834 const char *ArchDesc::reg_class_to_reg_mask(const char *rc_name) {
 835   const char *reg_mask = "RegMask::Empty";
 836 
 837   if( _register ) {
 838     RegClass *reg_class  = _register->getRegClass(rc_name);
 839     if (reg_class == NULL) {
 840       syntax_err(0, "Use of an undefined register class %s", rc_name);
 841       return reg_mask;
 842     }
 843 
 844     // Construct the name of the register mask.
 845     reg_mask = getRegMask(rc_name);
 846   }
 847 
 848   return reg_mask;