src/share/vm/adlc/formsopt.hpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File 8068945-8u-patched Sdiff src/share/vm/adlc

src/share/vm/adlc/formsopt.hpp

Print this page
rev 7385 : 8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
Summary: Introduce a new register class, reg_class_dynamic, that supports also cist-spillable masks.
Reviewed-by: kvn, dlong, roland


  43 class MatchRule;
  44 class Attribute;
  45 class Effect;
  46 class ExpandRule;
  47 class RewriteRule;
  48 class ConstructRule;
  49 class FormatRule;
  50 class Peephole;
  51 class PeepMatch;
  52 class PeepConstraint;
  53 class EncClass;
  54 class Interface;
  55 class RegInterface;
  56 class ConstInterface;
  57 class MemInterface;
  58 class CondInterface;
  59 class Opcode;
  60 class InsEncode;
  61 class RegDef;
  62 class RegClass;


  63 class AllocClass;
  64 class ResourceForm;
  65 class PipeClassForm;
  66 class PipeClassOperandForm;
  67 class PipeClassResourceForm;
  68 class PeepMatch;
  69 class PeepConstraint;
  70 class PeepReplace;
  71 class MatchList;
  72 
  73 class ArchDesc;
  74 
  75 //==============================Register Allocation============================
  76 //------------------------------RegisterForm-----------------------------------
  77 class RegisterForm : public Form {
  78 private:
  79   AllocClass *_current_ac;         // State used by iter_RegDefs()
  80 
  81 public:
  82   // Public Data
  83   NameList    _rdefs;              // List of register definition names
  84   Dict        _regDef;             // map register name to RegDef*
  85 
  86   NameList    _rclasses;           // List of register class names
  87   Dict        _regClass;           // map register class name to RegClass*
  88 
  89   NameList    _aclasses;           // List of allocation class names
  90   Dict        _allocClass;         // Dictionary of allocation classes
  91 
  92   static int  _reg_ctr;         // Register counter
  93   static int  RegMask_Size();   // Compute RegMask size
  94 
  95   // Public Methods
  96   RegisterForm();
  97   ~RegisterForm();
  98 
  99   void        addRegDef(char *regName, char *callingConv, char *c_conv,
 100                         char * idealtype, char *encoding, char* concreteName);
 101   RegClass   *addRegClass(const char *className);

 102   AllocClass *addAllocClass(char *allocName);
 103   void        addSpillRegClass();
 104 
 105   // Provide iteration over all register definitions
 106   // in the order used by the register allocator
 107   void        reset_RegDefs();
 108   RegDef     *iter_RegDefs();
 109   RegDef     *getRegDef  (const char *regName);
 110 
 111   RegClass   *getRegClass(const char *className);
 112 
 113   // Return register mask, compressed chunk and register #
 114   uint       reg_mask(char *register_class);
 115 
 116   // Check that register classes are compatible with chunks
 117   bool       verify();
 118 
 119   void dump();                     // Debug printer
 120   void output(FILE *fp);           // Write info to output files
 121 };


 137 
 138 public:
 139   // Public Methods
 140   RegDef(char  *regname, char *callconv, char *c_conv,
 141          char *idealtype, char *encoding, char *concrete);
 142   ~RegDef();                       // Destructor
 143 
 144   // Interface to define/redefine the register number
 145   void     set_register_num(uint32 new_register_num);
 146 
 147   // Bit pattern used for generating machine code
 148   const char *register_encode()   const;
 149   // Register number used in machine-independent code
 150   uint32   register_num()      const;
 151 
 152   void dump();                     // Debug printer
 153   void output(FILE *fp);           // Write info to output files
 154 };
 155 
 156 //------------------------------RegClass---------------------------------------









 157 class RegClass : public Form {
 158 public:
 159   // Public Data
 160   const char *_classid;         // Name of class
 161   NameList    _regDefs;         // List of registers in class
 162   Dict        _regDef;          // Dictionary of registers in class

 163   bool        _stack_or_reg;    // Allowed on any stack slot
 164   char*       _user_defined;
 165 

 166   // Public Methods
 167   RegClass(const char *classid);// Constructor

 168 
 169   void addReg(RegDef *regDef);  // Add a register to this class
 170 
 171   uint size() const;            // Number of registers in class
 172   int regs_in_word( int wordnum, bool stack_also );
 173 
 174   const RegDef *get_RegDef(const char *regDef_name) const;
 175 
 176   // Returns the lowest numbered register in the mask.
 177   const RegDef* find_first_elem();
 178 
 179   // Iteration support
 180   void          reset();        // Reset the following two iterators
 181   RegDef       *RegDef_iter();  // which move jointly,
 182   const char   *rd_name_iter(); // invoking either advances both.
 183 
 184   void dump();                  // Debug printer
 185   void output(FILE *fp);        // Write info to output files













































































































 186 };
 187 
 188 //------------------------------AllocClass-------------------------------------
 189 class AllocClass : public Form {
 190 private:
 191 
 192 public:
 193   // Public Data
 194   char    *_classid;            // Name of class
 195   NameList _regDefs;            // List of registers in class
 196   Dict     _regDef;             // Dictionary of registers in class
 197 
 198   // Public Methods
 199   AllocClass(char *classid);    // Constructor
 200 
 201   void addReg(RegDef *regDef);  // Add a register to this class
 202   uint size() {return _regDef.Size();} // Number of registers in class
 203 
 204   void dump();                  // Debug printer
 205   void output(FILE *fp);        // Write info to output files




  43 class MatchRule;
  44 class Attribute;
  45 class Effect;
  46 class ExpandRule;
  47 class RewriteRule;
  48 class ConstructRule;
  49 class FormatRule;
  50 class Peephole;
  51 class PeepMatch;
  52 class PeepConstraint;
  53 class EncClass;
  54 class Interface;
  55 class RegInterface;
  56 class ConstInterface;
  57 class MemInterface;
  58 class CondInterface;
  59 class Opcode;
  60 class InsEncode;
  61 class RegDef;
  62 class RegClass;
  63 class CodeSnippetRegClass;
  64 class ConditionalRegClass;
  65 class AllocClass;
  66 class ResourceForm;
  67 class PipeClassForm;
  68 class PipeClassOperandForm;
  69 class PipeClassResourceForm;
  70 class PeepMatch;
  71 class PeepConstraint;
  72 class PeepReplace;
  73 class MatchList;
  74 
  75 class ArchDesc;
  76 
  77 //==============================Register Allocation============================
  78 //------------------------------RegisterForm-----------------------------------
  79 class RegisterForm : public Form {
  80 private:
  81   AllocClass *_current_ac;         // State used by iter_RegDefs()
  82 
  83 public:
  84   // Public Data
  85   NameList    _rdefs;              // List of register definition names
  86   Dict        _regDef;             // map register name to RegDef*
  87 
  88   NameList    _rclasses;           // List of register class names
  89   Dict        _regClass;           // map register class name to RegClass*
  90 
  91   NameList    _aclasses;           // List of allocation class names
  92   Dict        _allocClass;         // Dictionary of allocation classes
  93 
  94   static int  _reg_ctr;         // Register counter
  95   static int  RegMask_Size();   // Compute RegMask size
  96 
  97   // Public Methods
  98   RegisterForm();
  99   ~RegisterForm();
 100 
 101   void        addRegDef(char *regName, char *callingConv, char *c_conv,
 102                         char * idealtype, char *encoding, char* concreteName);
 103   template<typename T> T* addRegClass(const char* className);
 104 
 105   AllocClass *addAllocClass(char *allocName);
 106   void        addSpillRegClass();
 107 
 108   // Provide iteration over all register definitions
 109   // in the order used by the register allocator
 110   void        reset_RegDefs();
 111   RegDef     *iter_RegDefs();
 112   RegDef     *getRegDef  (const char *regName);
 113 
 114   RegClass   *getRegClass(const char *className);
 115 
 116   // Return register mask, compressed chunk and register #
 117   uint       reg_mask(char *register_class);
 118 
 119   // Check that register classes are compatible with chunks
 120   bool       verify();
 121 
 122   void dump();                     // Debug printer
 123   void output(FILE *fp);           // Write info to output files
 124 };


 140 
 141 public:
 142   // Public Methods
 143   RegDef(char  *regname, char *callconv, char *c_conv,
 144          char *idealtype, char *encoding, char *concrete);
 145   ~RegDef();                       // Destructor
 146 
 147   // Interface to define/redefine the register number
 148   void     set_register_num(uint32 new_register_num);
 149 
 150   // Bit pattern used for generating machine code
 151   const char *register_encode()   const;
 152   // Register number used in machine-independent code
 153   uint32   register_num()      const;
 154 
 155   void dump();                     // Debug printer
 156   void output(FILE *fp);           // Write info to output files
 157 };
 158 
 159 //------------------------------RegClass---------------------------------------
 160 // Generic register class. This register class is the internal representation
 161 // for the following .ad file format:
 162 //
 163 //  reg_class ptr(RAX, RBX, ...);
 164 //
 165 // where ptr is the name of the register class, RAX and RBX are registers.
 166 //
 167 // This register class allows registers to be spilled onto the stack. Spilling
 168 // is allowed is field _stack_or_reg is true.
 169 class RegClass : public Form {
 170 public:
 171   // Public Data
 172   const char *_classid;         // Name of class
 173   NameList    _regDefs;         // List of registers in class
 174   Dict        _regDef;          // Dictionary of registers in class
 175 protected:
 176   bool        _stack_or_reg;    // Allowed on any stack slot

 177 
 178 public:
 179   // Public Methods
 180   RegClass(const char *classid);// Constructor
 181   virtual ~RegClass();
 182 
 183   void addReg(RegDef *regDef);  // Add a register to this class
 184 
 185   uint size() const;            // Number of registers in class
 186   int regs_in_word( int wordnum, bool stack_also );
 187 
 188   const RegDef *get_RegDef(const char *regDef_name) const;
 189 
 190   // Returns the lowest numbered register in the mask.
 191   const RegDef* find_first_elem();
 192 
 193   // Iteration support
 194   void          reset();        // Reset the following two iterators
 195   RegDef       *RegDef_iter();  // which move jointly,
 196   const char   *rd_name_iter(); // invoking either advances both.
 197 
 198   void dump();                  // Debug printer
 199   void output(FILE *fp);        // Write info to output files
 200 
 201   virtual bool has_stack_version() {
 202     return _stack_or_reg;
 203   }
 204   virtual void set_stack_version(bool flag) {
 205     _stack_or_reg = flag;
 206   }
 207 
 208   virtual void declare_register_masks(FILE* fp);
 209   virtual void build_register_masks(FILE* fp);
 210 };
 211 
 212 //------------------------------CodeSnippetRegClass----------------------------
 213 // Register class that has an user-defined C++ code snippet attached to it
 214 // to determine at runtime which register class to use. This register class is
 215 // the internal representation for the following .ad file format:
 216 //
 217 //  reg_class actual_dflt_reg %{
 218 //      if (VM_Version::has_vfp3_32()) {
 219 //          return DFLT_REG_mask();
 220 //      } else {
 221 //          return DFLT_LOW_REG_mask();
 222 //      }
 223 //  %}
 224 //
 225 // where DFLT_REG_mask() and DFLT_LOW_REG_mask() are the internal names of the
 226 // masks of register classes dflt_reg and dflt_low_reg.
 227 //
 228 // The attached code snippet can select also between more than two register classes.
 229 // This register class can be, however, used only if the register class is not
 230 // cisc-spillable (i.e., the registers of this class are not allowed on the stack,
 231 // which is equivalent with _stack_or_reg being false).
 232 class CodeSnippetRegClass : public RegClass {
 233 protected:
 234   char* _code_snippet;
 235 public:
 236   CodeSnippetRegClass(const char* classid);// Constructor
 237   ~CodeSnippetRegClass();
 238 
 239   void set_code_snippet(char* code) {
 240     _code_snippet = code;
 241   }
 242   char* code_snippet() {
 243     return _code_snippet;
 244   }
 245   void set_stack_version(bool flag) {
 246     assert(false, "User defined register classes are not allowed to spill to the stack.");
 247   }
 248   void declare_register_masks(FILE* fp);
 249   void build_register_masks(FILE* fp) {
 250     // We do not need to generate register masks because we select at runtime
 251     // between register masks generated for other register classes.
 252     return;
 253   }
 254 };
 255 
 256 //------------------------------ConditionalRegClass----------------------------
 257 // Register class that has two register classes and a runtime condition attached
 258 // to it. The condition is evaluated at runtime and either one of the register
 259 // attached register classes is selected. This register class is the internal
 260 // representation for the following .ad format:
 261 //
 262 //  reg_class_dynamic actual_dflt_reg(dflt_reg, low_reg,
 263 //                                    %{ VM_Version::has_vfp3_32() }%
 264 //                                    );
 265 //
 266 // This example is equivalent to the example used with the CodeSnippetRegClass
 267 // register class. A ConditionalRegClass works also if a register class is cisc-spillable
 268 // (i.e., _stack_or_reg is true), but if can select only between two register classes.
 269 class ConditionalRegClass : public RegClass {
 270 protected:
 271   // reference to condition code
 272   char* _condition_code;  // C++ condition code to dynamically determine which register class to use.
 273 
 274                           // Example syntax (equivalent to previous example):
 275                           //
 276                           //  reg_class actual_dflt_reg(dflt_reg, low_reg,
 277                           //                            %{ VM_Version::has_vfp3_32() }%
 278                           //                            );
 279   // reference to conditional register classes
 280   RegClass* _rclasses[2]; // 0 is the register class selected if the condition code returns true
 281                           // 1 is the register class selected if the condition code returns false
 282 public:
 283   ConditionalRegClass(const char* classid);// Constructor
 284   ~ConditionalRegClass();
 285 
 286   virtual void set_stack_version(bool flag) {
 287     RegClass::set_stack_version(flag);
 288     assert((_rclasses[0] != NULL), "Register class NULL for condition code == true");
 289     assert((_rclasses[1] != NULL), "Register class NULL for condition code == false");
 290     _rclasses[0]->set_stack_version(flag);
 291     _rclasses[1]->set_stack_version(flag);
 292   }
 293   void declare_register_masks(FILE* fp);
 294   void build_register_masks(FILE* fp) {
 295     // We do not need to generate register masks because we select at runtime
 296     // between register masks generated for other register classes.
 297     return;
 298   }
 299   void set_rclass_at_index(int index, RegClass* rclass) {
 300     assert((0 <= index && index < 2), "Condition code can select only between two register classes");
 301     _rclasses[index] = rclass;
 302   }
 303   void set_condition_code(char* code) {
 304     _condition_code = code;
 305   }
 306   char* condition_code() {
 307     return _condition_code;
 308   }
 309 };
 310 
 311 //------------------------------AllocClass-------------------------------------
 312 class AllocClass : public Form {
 313 private:
 314 
 315 public:
 316   // Public Data
 317   char    *_classid;            // Name of class
 318   NameList _regDefs;            // List of registers in class
 319   Dict     _regDef;             // Dictionary of registers in class
 320 
 321   // Public Methods
 322   AllocClass(char *classid);    // Constructor
 323 
 324   void addReg(RegDef *regDef);  // Add a register to this class
 325   uint size() {return _regDef.Size();} // Number of registers in class
 326 
 327   void dump();                  // Debug printer
 328   void output(FILE *fp);        // Write info to output files


src/share/vm/adlc/formsopt.hpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File