src/share/vm/adlc/formsopt.hpp

Tue, 23 Nov 2010 13:22:55 -0800

author
stefank
date
Tue, 23 Nov 2010 13:22:55 -0800
changeset 2314
f95d63e2154a
parent 1907
c18cbe5936b8
child 3317
db2e64ca2d5a
permissions
-rw-r--r--

6989984: Use standard include model for Hospot
Summary: Replaced MakeDeps and the includeDB files with more standardized solutions.
Reviewed-by: coleenp, kvn, kamg

     1 /*
     2  * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     8  *
     9  * This code is distributed in the hope that it will be useful, but WITHOUT
    10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    12  * version 2 for more details (a copy is included in the LICENSE file that
    13  * accompanied this code).
    14  *
    15  * You should have received a copy of the GNU General Public License version
    16  * 2 along with this work; if not, write to the Free Software Foundation,
    17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    18  *
    19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    20  * or visit www.oracle.com if you need additional information or have any
    21  * questions.
    22  *
    23  */
    25 #ifndef SHARE_VM_ADLC_FORMSOPT_HPP
    26 #define SHARE_VM_ADLC_FORMSOPT_HPP
    28 // FORMSOPT.HPP - ADL Parser Target Specific Optimization Forms Classes
    30 // Class List
    31 class Form;
    32 class InstructForm;
    33 class OperandForm;
    34 class OpClassForm;
    35 class AttributeForm;
    36 class RegisterForm;
    37 class PipelineForm;
    38 class SourceForm;
    39 class EncodeForm;
    40 class Component;
    41 class Constraint;
    42 class Predicate;
    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;
    73 class ArchDesc;
    75 //==============================Register Allocation============================
    76 //------------------------------RegisterForm-----------------------------------
    77 class RegisterForm : public Form {
    78 private:
    79   AllocClass *_current_ac;         // State used by iter_RegDefs()
    81 public:
    82   // Public Data
    83   NameList    _rdefs;              // List of register definition names
    84   Dict        _regDef;             // map register name to RegDef*
    86   NameList    _rclasses;           // List of register class names
    87   Dict        _regClass;           // map register class name to RegClass*
    89   NameList    _aclasses;           // List of allocation class names
    90   Dict        _allocClass;         // Dictionary of allocation classes
    92   static int  _reg_ctr;         // Register counter
    93   static int  RegMask_Size();   // Compute RegMask size
    95   // Public Methods
    96   RegisterForm();
    97   ~RegisterForm();
    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();
   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);
   111   RegClass   *getRegClass(const char *className);
   113   // Return register mask, compressed chunk and register #
   114   uint       reg_mask(char *register_class);
   116   // Check that register classes are compatible with chunks
   117   bool       verify();
   119   void dump();                     // Debug printer
   120   void output(FILE *fp);           // Write info to output files
   121 };
   123 //------------------------------RegDef-----------------------------------------
   124 class RegDef : public Form {
   125 public:
   126   // Public Data
   127   const char *_regname;            // ADLC (Opto) Register name
   128   const char *_callconv;           // Calling convention
   129   const char *_c_conv;             // Native calling convention, 'C'
   130   const char *_idealtype;          // Ideal Type for register save/restore
   131   const char *_concrete;           // concrete register name
   133 private:
   134   const char *_register_encode;   // The register encoding
   135   // The chunk and register mask bits define info for register allocation
   136   uint32      _register_num;      // Which register am I
   138 public:
   139   // Public Methods
   140   RegDef(char  *regname, char *callconv, char *c_conv,
   141          char *idealtype, char *encoding, char *concrete);
   142   ~RegDef();                       // Destructor
   144   // Interface to define/redefine the register number
   145   void     set_register_num(uint32 new_register_num);
   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;
   152   void dump();                     // Debug printer
   153   void output(FILE *fp);           // Write info to output files
   154 };
   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
   165   // Public Methods
   166   RegClass(const char *classid);// Constructor
   168   void addReg(RegDef *regDef);  // Add a register to this class
   170   uint size() const;            // Number of registers in class
   171   int regs_in_word( int wordnum, bool stack_also );
   173   const RegDef *get_RegDef(const char *regDef_name) const;
   175   // Returns the lowest numbered register in the mask.
   176   const RegDef* find_first_elem();
   178   // Iteration support
   179   void          reset();        // Reset the following two iterators
   180   RegDef       *RegDef_iter();  // which move jointly,
   181   const char   *rd_name_iter(); // invoking either advances both.
   183   void dump();                  // Debug printer
   184   void output(FILE *fp);        // Write info to output files
   185 };
   187 //------------------------------AllocClass-------------------------------------
   188 class AllocClass : public Form {
   189 private:
   191 public:
   192   // Public Data
   193   char    *_classid;            // Name of class
   194   NameList _regDefs;            // List of registers in class
   195   Dict     _regDef;             // Dictionary of registers in class
   197   // Public Methods
   198   AllocClass(char *classid);    // Constructor
   200   void addReg(RegDef *regDef);  // Add a register to this class
   201   uint size() {return _regDef.Size();} // Number of registers in class
   203   void dump();                  // Debug printer
   204   void output(FILE *fp);        // Write info to output files
   205 };
   208 //==============================Frame Handling================================
   209 //------------------------------FrameForm-------------------------------------
   210 class FrameForm : public Form {
   211 private:
   213 public:
   214   // Public Data
   215   bool  _direction;                // Direction of stack growth
   216   char *_sync_stack_slots;
   217   char *_inline_cache_reg;
   218   char *_interpreter_method_oop_reg;
   219   char *_interpreter_frame_pointer_reg;
   220   char *_cisc_spilling_operand_name;
   221   char *_frame_pointer;
   222   char *_c_frame_pointer;
   223   char *_alignment;
   224   bool  _return_addr_loc;
   225   bool  _c_return_addr_loc;
   226   char *_return_addr;
   227   char *_c_return_addr;
   228   char *_in_preserve_slots;
   229   char *_varargs_C_out_slots_killed;
   230   char *_calling_convention;
   231   char *_c_calling_convention;
   232   char *_return_value;
   233   char *_c_return_value;
   235   // Public Methods
   236   FrameForm();
   237   ~FrameForm();
   239   void dump();                     // Debug printer
   240   void output(FILE *fp);           // Write info to output files
   241 };
   244 //==============================Scheduling=====================================
   245 //------------------------------PipelineForm-----------------------------------
   246 class PipelineForm : public Form {
   247 private:
   249 public:
   250   // Public Data
   251   NameList   _reslist;            // List of pipeline resources
   252   FormDict   _resdict;            // Resource Name -> ResourceForm mapping
   253   int        _rescount;           // Number of resources (ignores OR cases)
   254   int        _maxcycleused;       // Largest cycle used relative to beginning of instruction
   256   NameList   _stages;             // List of pipeline stages on architecture
   257   int        _stagecnt;           // Number of stages listed
   259   NameList   _classlist;          // List of pipeline classes
   260   FormDict   _classdict;          // Class Name -> PipeClassForm mapping
   261   int        _classcnt;           // Number of classes
   263   NameList   _noplist;            // List of NOP instructions
   264   int        _nopcnt;             // Number of nop instructions
   266   bool       _variableSizeInstrs; // Indicates if this architecture has variable sized instructions
   267   bool       _branchHasDelaySlot; // Indicates that branches have delay slot instructions
   268   int        _maxInstrsPerBundle; // Indicates the maximum number of instructions for ILP
   269   int        _maxBundlesPerCycle; // Indicates the maximum number of bundles for ILP
   270   int        _instrUnitSize;      // The minimum instruction unit size, in bytes
   271   int        _bundleUnitSize;     // The bundle unit size, in bytes
   272   int        _instrFetchUnitSize; // The size of the I-fetch unit, in bytes [must be power of 2]
   273   int        _instrFetchUnits;    // The number of I-fetch units processed per cycle
   275   // Public Methods
   276   PipelineForm();
   277   ~PipelineForm();
   279   void dump();                    // Debug printer
   280   void output(FILE *fp);          // Write info to output files
   281 };
   283 //------------------------------ResourceForm-----------------------------------
   284 class ResourceForm : public Form {
   285 public:
   286   unsigned mask() const { return _resmask; };
   288 private:
   289   // Public Data
   290   unsigned _resmask;         // Resource Mask (OR of resource specifier bits)
   292 public:
   294   // Virtual Methods
   295   virtual ResourceForm  *is_resource()    const;
   297   // Public Methods
   298   ResourceForm(unsigned resmask); // Constructor
   299   ~ResourceForm();                // Destructor
   301   void dump();                    // Debug printer
   302   void output(FILE *fp);          // Write info to output files
   303 };
   305 //------------------------------PipeClassOperandForm-----------------------------
   306 class PipeClassOperandForm : public Form {
   307 private:
   309 public:
   310   // Public Data
   311   const char *_stage;             // Name of Stage
   312   unsigned _iswrite;              // Read or Write
   313   unsigned _more_instrs;          // Additional Instructions
   315   // Public Methods
   316   PipeClassOperandForm(const char *stage, unsigned iswrite, unsigned more_instrs)
   317   : _stage(stage)
   318   , _iswrite(iswrite)
   319   , _more_instrs(more_instrs)
   320  {};
   322   ~PipeClassOperandForm() {};     // Destructor
   324   bool isWrite() const { return _iswrite != 0; }
   326   void dump();                    // Debug printer
   327   void output(FILE *fp);          // Write info to output files
   328 };
   330 //------------------------------PipeClassResourceForm--------------------------
   331 class PipeClassResourceForm : public Form {
   332 private:
   334 public:
   335   // Public Data
   336   const char *_resource;          // Resource
   337   const char *_stage;             // Stage the resource is used in
   338   int         _cycles;            // Number of cycles the resource is used
   340   // Public Methods
   341   PipeClassResourceForm(const char *resource, const char *stage, int cycles)
   342                                   // Constructor
   343     : _resource(resource)
   344     , _stage(stage)
   345     , _cycles(cycles)
   346     {};
   348   ~PipeClassResourceForm() {};    // Destructor
   350   void dump();                    // Debug printer
   351   void output(FILE *fp);          // Write info to output files
   352 };
   354 //------------------------------PipeClassForm----------------------------------
   355 class PipeClassForm : public Form {
   356 private:
   358 public:
   360   // Public Data
   361   const char       *_ident;             // Name of class
   362   int               _num;               // Used in name of MachNode subclass
   363   NameList          _parameters;        // Locally defined names
   364   FormDict          _localNames;        // Table of operands & their types
   365   FormDict          _localUsage;        // Table of operand usage
   366   FormList          _resUsage;          // List of resource usage
   367   NameList          _instructs;         // List of instructions and machine nodes that use this pipeline class
   368   bool              _has_fixed_latency; // Always takes this number of cycles
   369   int               _fixed_latency;     // Always takes this number of cycles
   370   int               _instruction_count; // Number of instructions in first bundle
   371   bool              _has_multiple_bundles;  // Indicates if 1 or multiple bundles
   372   bool              _has_branch_delay_slot; // Has branch delay slot as last instruction
   373   bool              _force_serialization;   // This node serializes relative to surrounding nodes
   374   bool              _may_have_no_code;      // This node may generate no code based on register allocation
   376   // Virtual Methods
   377   virtual PipeClassForm  *is_pipeclass()    const;
   379   // Public Methods
   380   PipeClassForm(const char *id, int num);
   381                                   // Constructor
   382   ~PipeClassForm();               // Destructor
   384   bool hasFixedLatency() { return _has_fixed_latency; }
   385   int fixedLatency() { return _fixed_latency; }
   387   void setFixedLatency(int fixed_latency) { _has_fixed_latency = 1; _fixed_latency = fixed_latency; }
   389   void setInstructionCount(int i)    { _instruction_count = i; }
   390   void setMultipleBundles(bool b)    { _has_multiple_bundles = b; }
   391   void setBranchDelay(bool s)        { _has_branch_delay_slot = s; }
   392   void setForceSerialization(bool s) { _force_serialization = s; }
   393   void setMayHaveNoCode(bool s)      { _may_have_no_code = s; }
   395   int  InstructionCount()   const { return _instruction_count; }
   396   bool hasMultipleBundles() const { return _has_multiple_bundles; }
   397   bool hasBranchDelay()     const { return _has_branch_delay_slot; }
   398   bool forceSerialization() const { return _force_serialization; }
   399   bool mayHaveNoCode()      const { return _may_have_no_code; }
   401   void dump();                    // Debug printer
   402   void output(FILE *fp);          // Write info to output files
   403 };
   406 //==============================Peephole Optimization==========================
   407 //------------------------------Peephole---------------------------------------
   408 class Peephole : public Form {
   409 private:
   410   static int      _peephole_counter;// Incremented by each peephole rule parsed
   411   int             _peephole_number;// Remember my order in architecture description
   412   PeepMatch      *_match;          // Instruction pattern to match
   413   PeepConstraint *_constraint;     // List of additional constraints
   414   PeepReplace    *_replace;        // Instruction pattern to substitute in
   416   Peephole *_next;
   418 public:
   419   // Public Methods
   420   Peephole();
   421   ~Peephole();
   423   // Append a peephole rule with the same root instruction
   424   void append_peephole(Peephole *next_peephole);
   426   // Store the components of this peephole rule
   427   void add_match(PeepMatch *only_one_match);
   428   void append_constraint(PeepConstraint *next_constraint);
   429   void add_replace(PeepReplace *only_one_replacement);
   431   // Access the components of this peephole rule
   432   int             peephole_number() { return _peephole_number; }
   433   PeepMatch      *match()       { return _match; }
   434   PeepConstraint *constraints() { return _constraint; }
   435   PeepReplace    *replacement() { return _replace; }
   436   Peephole       *next()        { return _next; }
   438   void dump();                     // Debug printer
   439   void output(FILE *fp);           // Write info to output files
   440 };
   443 class PeepMatch : public Form {
   444 private:
   445   char *_rule;
   446   // NameList  _depth;                // Depth of this instruction
   447   NameList  _parent;
   448   NameList  _position;
   449   NameList  _instrs;               // List of instructions in match rule
   450   NameList  _input;                // input position in parent's instruction
   451   int       _max_position;
   453 public:
   454   // Public Methods
   455   PeepMatch(char *rule);
   456   ~PeepMatch();
   458   // Insert info into the match-rule
   459   void  add_instruction(int parent, int position, const char *name, int input);
   461   // Access info about instructions in the peep-match rule
   462   int   max_position();
   463   const char *instruction_name(int position);
   464   // Iterate through all info on matched instructions
   465   void  reset();
   466   void  next_instruction(int &parent, int &position, const char* &name, int &input);
   467   // 'true' if current position in iteration is a placeholder, not matched.
   468   bool  is_placeholder();
   470   void dump();
   471   void output(FILE *fp);
   472 };
   475 class PeepConstraint : public Form {
   476 private:
   477   PeepConstraint *_next;           // Additional constraints ANDed together
   479 public:
   480   const int   _left_inst;
   481   const char* _left_op;
   482   const char* _relation;
   483   const int   _right_inst;
   484   const char* _right_op;
   486 public:
   487   // Public Methods
   488   PeepConstraint(int left_inst,  char* left_op, char* relation,
   489                  int right_inst, char* right_op);
   490   ~PeepConstraint();
   492   // Check if constraints use instruction at position
   493   bool constrains_instruction(int position);
   495   // Add another constraint
   496   void append(PeepConstraint *next_peep_constraint);
   497   // Access the next constraint in the list
   498   PeepConstraint *next();
   500   void dump();
   501   void output(FILE *fp);
   502 };
   505 class PeepReplace : public Form {
   506 private:
   507   char *_rule;
   508   NameList _instruction;
   509   NameList _operand_inst_num;
   510   NameList _operand_op_name;
   512 public:
   514   // Public Methods
   515   PeepReplace(char *rule);
   516   ~PeepReplace();
   518   // Add contents of peepreplace
   519   void  add_instruction(char *root);
   520   void  add_operand( int inst_num, char *inst_operand );
   522   // Access contents of peepreplace
   523   void  reset();
   524   void  next_instruction(const char * &root);
   525   void  next_operand(int &inst_num, const char * &inst_operand );
   527   // Utilities
   528   void dump();
   529   void output(FILE *fp);
   530 };
   533 class PeepChild : public Form {
   534 public:
   535   const int   _inst_num;         // Number of instruction (-1 if only named)
   536   const char *_inst_op;          // Instruction's operand, NULL if number == -1
   537   const char *_inst_name;        // Name of the instruction
   539 public:
   540   PeepChild(char *inst_name)
   541     : _inst_num(-1), _inst_op(NULL), _inst_name(inst_name) {};
   542   PeepChild(int inst_num, char *inst_op, char *inst_name)
   543     : _inst_num(inst_num), _inst_op(inst_op), _inst_name(inst_name) {};
   544   ~PeepChild();
   546   bool  use_leaf_operand()        { return _inst_num != -1; };
   547   bool  generate_an_instruction() { return _inst_num == -1; }
   549   void dump();
   550   void output(FILE *fp);
   551 };
   553 #endif // SHARE_VM_ADLC_FORMSOPT_HPP

mercurial