src/share/vm/adlc/formssel.hpp

Mon, 07 Jul 2014 10:12:40 +0200

author
stefank
date
Mon, 07 Jul 2014 10:12:40 +0200
changeset 6992
2c6ef90f030a
parent 6503
a9becfeecd1b
child 6876
710a3c8b516e
child 7853
a1642365d69f
permissions
-rw-r--r--

8049421: G1 Class Unloading after completing a concurrent mark cycle
Reviewed-by: tschatzl, ehelin, brutisso, coleenp, roland, iveresov
Contributed-by: stefan.karlsson@oracle.com, mikael.gerdin@oracle.com

     1 /*
     2  * Copyright (c) 1998, 2013, 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_FORMSSEL_HPP
    26 #define SHARE_VM_ADLC_FORMSSEL_HPP
    28 // FORMSSEL.HPP - ADL Parser Instruction Selection Forms Classes
    30 // Class List
    31 class Form;
    32 class InstructForm;
    33 class MachNodeForm;
    34 class OperandForm;
    35 class OpClassForm;
    36 class AttributeForm;
    37 class RegisterForm;
    38 class PipelineForm;
    39 class SourceForm;
    40 class EncodeForm;
    41 class Component;
    42 class Constraint;
    43 class Predicate;
    44 class MatchRule;
    45 class Attribute;
    46 class Effect;
    47 class ExpandRule;
    48 class RewriteRule;
    49 class ConstructRule;
    50 class FormatRule;
    51 class Peephole;
    52 class EncClass;
    53 class Interface;
    54 class RegInterface;
    55 class ConstInterface;
    56 class MemInterface;
    57 class CondInterface;
    58 class Opcode;
    59 class InsEncode;
    60 class RegDef;
    61 class RegClass;
    62 class AllocClass;
    63 class ResourceForm;
    64 class PipeDesc;
    65 class PipeClass;
    66 class PeepMatch;
    67 class PeepConstraint;
    68 class PeepReplace;
    69 class MatchList;
    71 class ArchDesc;
    73 //==============================Instructions===================================
    74 //------------------------------InstructForm-----------------------------------
    75 class InstructForm : public Form {
    76 private:
    77   bool           _ideal_only;       // Not a user-defined instruction
    78   // Members used for tracking CISC-spilling
    79   int            _cisc_spill_operand;// Which operand may cisc-spill
    80   void           set_cisc_spill_operand(uint op_index) { _cisc_spill_operand = op_index; }
    81   bool           _is_cisc_alternate;
    82   InstructForm  *_cisc_spill_alternate;// cisc possible replacement
    83   const char    *_cisc_reg_mask_name;
    84   InstructForm  *_short_branch_form;
    85   bool           _is_short_branch;
    86   bool           _is_mach_constant;    // True if Node is a MachConstantNode.
    87   bool           _needs_constant_base; // True if Node needs the mach_constant_base input.
    88   uint           _alignment;
    90 public:
    91   // Public Data
    92   const char    *_ident;               // Name of this instruction
    93   NameList       _parameters;          // Locally defined names
    94   FormDict       _localNames;          // Table of operands & their types
    95   MatchRule     *_matrule;             // Matching rule for this instruction
    96   Opcode        *_opcode;              // Encoding of the opcode for instruction
    97   char          *_size;                // Size of instruction
    98   InsEncode     *_insencode;           // Encoding class instruction belongs to
    99   InsEncode     *_constant;            // Encoding class constant value belongs to
   100   bool           _is_postalloc_expand; // Indicates that encoding just does a lateExpand.
   101   Attribute     *_attribs;             // List of Attribute rules
   102   Predicate     *_predicate;           // Predicate test for this instruction
   103   FormDict       _effects;             // Dictionary of effect rules
   104   ExpandRule    *_exprule;             // Expand rule for this instruction
   105   RewriteRule   *_rewrule;             // Rewrite rule for this instruction
   106   FormatRule    *_format;              // Format for assembly generation
   107   Peephole      *_peephole;            // List of peephole rules for instruction
   108   const char    *_ins_pipe;            // Instruction Scheduling description class
   110   uint          *_uniq_idx;            // Indexes of unique operands
   111   uint           _uniq_idx_length;     // Length of _uniq_idx array
   112   uint           _num_uniq;            // Number  of unique operands
   113   ComponentList  _components;          // List of Components matches MachNode's
   114                                        // operand structure
   116   bool           _has_call;            // contain a call and caller save registers should be saved?
   118   // Public Methods
   119   InstructForm(const char *id, bool ideal_only = false);
   120   InstructForm(const char *id, InstructForm *instr, MatchRule *rule);
   121   ~InstructForm();
   123   // Dynamic type check
   124   virtual InstructForm *is_instruction() const;
   126   virtual bool        ideal_only() const;
   128   // This instruction sets a result
   129   virtual bool        sets_result() const;
   130   // This instruction needs projections for additional DEFs or KILLs
   131   virtual bool        needs_projections();
   132   // This instruction needs extra nodes for temporary inputs
   133   virtual bool        has_temps();
   134   // This instruction defines or kills more than one object
   135   virtual uint        num_defs_or_kills();
   136   // This instruction has an expand rule?
   137   virtual bool        expands() const ;
   138   // This instruction has a late expand rule?
   139   virtual bool        postalloc_expands() const;
   140   // Return this instruction's first peephole rule, or NULL
   141   virtual Peephole   *peepholes() const;
   142   // Add a peephole rule to this instruction
   143   virtual void        append_peephole(Peephole *peep);
   145   virtual bool        is_pinned(FormDict &globals); // should be pinned inside block
   146   virtual bool        is_projection(FormDict &globals); // node requires projection
   147   virtual bool        is_parm(FormDict &globals); // node matches ideal 'Parm'
   148   // ideal opcode enumeration
   149   virtual const char *ideal_Opcode(FormDict &globals)  const;
   150   virtual int         is_expensive() const;     // node matches ideal 'CosD'
   151   virtual int         is_empty_encoding() const; // _size=0 and/or _insencode empty
   152   virtual int         is_tls_instruction() const; // tlsLoadP rule or ideal ThreadLocal
   153   virtual int         is_ideal_copy() const;    // node matches ideal 'Copy*'
   154   virtual bool        is_ideal_negD() const;    // node matches ideal 'NegD'
   155   virtual bool        is_ideal_if()   const;    // node matches ideal 'If'
   156   virtual bool        is_ideal_fastlock() const; // node matches 'FastLock'
   157   virtual bool        is_ideal_membar() const;  // node matches ideal 'MemBarXXX'
   158   virtual bool        is_ideal_loadPC() const;  // node matches ideal 'LoadPC'
   159   virtual bool        is_ideal_box() const;     // node matches ideal 'Box'
   160   virtual bool        is_ideal_goto() const;    // node matches ideal 'Goto'
   161   virtual bool        is_ideal_branch() const;  // "" 'If' | 'Goto' | 'LoopEnd' | 'Jump'
   162   virtual bool        is_ideal_jump() const;    // node matches ideal 'Jump'
   163   virtual bool        is_ideal_return() const;  // node matches ideal 'Return'
   164   virtual bool        is_ideal_halt() const;    // node matches ideal 'Halt'
   165   virtual bool        is_ideal_safepoint() const; // node matches 'SafePoint'
   166   virtual bool        is_ideal_nop() const;     // node matches 'Nop'
   167   virtual bool        is_ideal_control() const; // control node
   168   virtual bool        is_vector() const;        // vector instruction
   170   virtual Form::CallType is_ideal_call() const; // matches ideal 'Call'
   171   virtual Form::DataType is_ideal_load() const; // node matches ideal 'LoadXNode'
   172   // Should antidep checks be disabled for this Instruct
   173   // See definition of MatchRule::skip_antidep_check
   174   bool skip_antidep_check() const;
   175   virtual Form::DataType is_ideal_store() const;// node matches ideal 'StoreXNode'
   176           bool        is_ideal_mem() const { return is_ideal_load() != Form::none || is_ideal_store() != Form::none; }
   177   virtual uint        two_address(FormDict &globals); // output reg must match input reg
   178   // when chaining a constant to an instruction, return 'true' and set opType
   179   virtual Form::DataType is_chain_of_constant(FormDict &globals);
   180   virtual Form::DataType is_chain_of_constant(FormDict &globals, const char * &opType);
   181   virtual Form::DataType is_chain_of_constant(FormDict &globals, const char * &opType, const char * &result_type);
   183   // Check if a simple chain rule
   184   virtual bool        is_simple_chain_rule(FormDict &globals) const;
   186   // check for structural rematerialization
   187   virtual bool        rematerialize(FormDict &globals, RegisterForm *registers);
   189   // loads from memory, so must check for anti-dependence
   190   virtual bool        needs_anti_dependence_check(FormDict &globals) const;
   191   virtual int         memory_operand(FormDict &globals) const;
   192           bool        is_wide_memory_kill(FormDict &globals) const;
   194   enum memory_operand_type {
   195     NO_MEMORY_OPERAND = -1,
   196     MANY_MEMORY_OPERANDS = 999999
   197   };
   200   // This instruction captures the machine-independent bottom_type
   201   // Expected use is for pointer vs oop determination for LoadP
   202   virtual bool        captures_bottom_type(FormDict& globals) const;
   204   virtual const char *cost();      // Access ins_cost attribute
   205   virtual uint        num_opnds(); // Count of num_opnds for MachNode class
   206                                    // Counts USE_DEF opnds twice.  See also num_unique_opnds().
   207   virtual uint        num_post_match_opnds();
   208   virtual uint        num_consts(FormDict &globals) const;// Constants in match rule
   209   // Constants in match rule with specified type
   210   virtual uint        num_consts(FormDict &globals, Form::DataType type) const;
   212   // Return the register class associated with 'leaf'.
   213   virtual const char *out_reg_class(FormDict &globals);
   215   // number of ideal node inputs to skip
   216   virtual uint        oper_input_base(FormDict &globals);
   218   // Does this instruction need a base-oop edge?
   219   int needs_base_oop_edge(FormDict &globals) const;
   221   // Build instruction predicates.  If the user uses the same operand name
   222   // twice, we need to check that the operands are pointer-eequivalent in
   223   // the DFA during the labeling process.
   224   Predicate *build_predicate();
   226   virtual void        build_components(); // top-level operands
   227   // Return zero-based position in component list; -1 if not in list.
   228   virtual int         operand_position(const char *name, int usedef);
   229   virtual int         operand_position_format(const char *name);
   231   // Return zero-based position in component list; -1 if not in list.
   232   virtual int         label_position();
   233   virtual int         method_position();
   234   // Return number of relocation entries needed for this instruction.
   235   virtual uint        reloc(FormDict &globals);
   237   const char         *opnd_ident(int idx);  // Name of operand #idx.
   238   const char         *reduce_result();
   239   // Return the name of the operand on the right hand side of the binary match
   240   // Return NULL if there is no right hand side
   241   const char         *reduce_right(FormDict &globals)  const;
   242   const char         *reduce_left(FormDict &globals)   const;
   244   // Base class for this instruction, MachNode except for calls
   245   virtual const char *mach_base_class(FormDict &globals)  const;
   247   // Check if this instruction can cisc-spill to 'alternate'
   248   bool                cisc_spills_to(ArchDesc &AD, InstructForm *alternate);
   249   InstructForm       *cisc_spill_alternate() { return _cisc_spill_alternate; }
   250   int                 cisc_spill_operand() const { return _cisc_spill_operand; }
   251   bool                is_cisc_alternate() const { return _is_cisc_alternate; }
   252   void                set_cisc_alternate(bool val) { _is_cisc_alternate = val; }
   253   const char         *cisc_reg_mask_name() const { return _cisc_reg_mask_name; }
   254   void                set_cisc_reg_mask_name(const char *rm_name) { _cisc_reg_mask_name = rm_name; }
   255   // Output cisc-method prototypes and method bodies
   256   void                declare_cisc_version(ArchDesc &AD, FILE *fp_cpp);
   257   bool                define_cisc_version (ArchDesc &AD, FILE *fp_cpp);
   259   bool                check_branch_variant(ArchDesc &AD, InstructForm *short_branch);
   261   bool                is_short_branch() { return _is_short_branch; }
   262   void                set_short_branch(bool val) { _is_short_branch = val; }
   264   bool                    is_mach_constant() const { return _is_mach_constant;     }
   265   void                set_is_mach_constant(bool x) {        _is_mach_constant = x; }
   266   bool                    needs_constant_base() const { return _needs_constant_base;     }
   267   void                set_needs_constant_base(bool x) {        _needs_constant_base = x; }
   269   InstructForm       *short_branch_form() { return _short_branch_form; }
   270   bool                has_short_branch_form() { return _short_branch_form != NULL; }
   271   // Output short branch prototypes and method bodies
   272   void                declare_short_branch_methods(FILE *fp_cpp);
   273   bool                define_short_branch_methods(ArchDesc &AD, FILE *fp_cpp);
   275   uint                alignment() { return _alignment; }
   276   void                set_alignment(uint val) { _alignment = val; }
   278   // Seach through operands to determine operands unique positions.
   279   void                set_unique_opnds();
   280   uint                num_unique_opnds() { return _num_uniq; }
   281   uint                unique_opnds_idx(int idx) {
   282     if (_uniq_idx != NULL && idx > 0) {
   283       assert((uint)idx < _uniq_idx_length, "out of bounds");
   284       return _uniq_idx[idx];
   285     } else {
   286       return idx;
   287     }
   288   }
   289   const char         *unique_opnd_ident(uint idx);  // Name of operand at unique idx.
   291   // Operands which are only KILLs aren't part of the input array and
   292   // require special handling in some cases.  Their position in this
   293   // operand list is higher than the number of unique operands.
   294   bool is_noninput_operand(uint idx) {
   295     return (idx >= num_unique_opnds());
   296   }
   298   // --------------------------- FILE *output_routines
   299   //
   300   // Generate the format call for the replacement variable
   301   void                rep_var_format(FILE *fp, const char *rep_var);
   302   // Generate index values needed for determining the operand position
   303   void                index_temps   (FILE *fp, FormDict &globals, const char *prefix = "", const char *receiver = "");
   304   // ---------------------------
   306   virtual bool verify();           // Check consistency after parsing
   308   virtual void dump();             // Debug printer
   309   virtual void output(FILE *fp);   // Write to output files
   310 };
   312 //------------------------------EncodeForm-------------------------------------
   313 class EncodeForm : public Form {
   314 private:
   316 public:
   317   // Public Data
   318   NameList  _eclasses;            // List of encode class names
   319   Dict      _encClass;            // Map encode class names to EncClass objects
   321   // Public Methods
   322   EncodeForm();
   323   ~EncodeForm();
   325   EncClass   *add_EncClass(const char *className);
   326   EncClass   *encClass(const char *className);
   328   const char *encClassPrototype(const char *className);
   329   const char *encClassBody(const char *className);
   331   void dump();                     // Debug printer
   332   void output(FILE *fp);           // Write info to output files
   333 };
   335 //------------------------------EncClass---------------------------------------
   336 class EncClass : public Form {
   337 public:
   338   // NameList for parameter type and name
   339   NameList       _parameter_type;
   340   NameList       _parameter_name;
   342   // Breakdown the encoding into strings separated by $replacement_variables
   343   // There is an entry in _strings, perhaps NULL, that precedes each _rep_vars
   344   NameList       _code;            // Strings passed through to tty->print
   345   NameList       _rep_vars;        // replacement variables
   347   NameList       _parameters;      // Locally defined names
   348   FormDict       _localNames;      // Table of components & their types
   350 public:
   351   // Public Data
   352   const char    *_name;            // encoding class name
   354   // Public Methods
   355   EncClass(const char *name);
   356   ~EncClass();
   358   // --------------------------- Parameters
   359   // Add a parameter <type,name> pair
   360   void add_parameter(const char *parameter_type, const char *parameter_name);
   361   // Verify operand types in parameter list
   362   bool check_parameter_types(FormDict &globals);
   363   // Obtain the zero-based index corresponding to a replacement variable
   364   int         rep_var_index(const char *rep_var);
   365   int         num_args() { return _parameter_name.count(); }
   367   // --------------------------- Code Block
   368   // Add code
   369   void add_code(const char *string_preceding_replacement_var);
   370   // Add a replacement variable or one of its subfields
   371   // Subfields are stored with a leading '$'
   372   void add_rep_var(char *replacement_var);
   374   bool verify();
   375   void dump();
   376   void output(FILE *fp);
   377 };
   379 //------------------------------MachNode---------------------------------------
   380 class MachNodeForm: public Form {
   381 private:
   383 public:
   384   char          *_ident;           // Name of this instruction
   385   const char    *_machnode_pipe;   // Instruction Scheduline description class
   387   // Public Methods
   388   MachNodeForm(char *id);
   389   ~MachNodeForm();
   391   virtual MachNodeForm *is_machnode() const;
   393   void dump();                     // Debug printer
   394   void output(FILE *fp);           // Write info to output files
   395 };
   397 //------------------------------Opcode-----------------------------------------
   398 class Opcode : public Form {
   399 private:
   401 public:
   402   // Public Data
   403   // Strings representing instruction opcodes, user defines placement in emit
   404   char *_primary;
   405   char *_secondary;
   406   char *_tertiary;
   408   enum opcode_type {
   409     NOT_AN_OPCODE = -1,
   410     PRIMARY   = 1,
   411     SECONDARY = 2,
   412     TERTIARY  = 3
   413   };
   415   // Public Methods
   416   Opcode(char *primary, char *secondary, char *tertiary);
   417   ~Opcode();
   419   static Opcode::opcode_type as_opcode_type(const char *designator);
   421   void dump();
   422   void output(FILE *fp);
   424   // --------------------------- FILE *output_routines
   425   bool print_opcode(FILE *fp, Opcode::opcode_type desired_opcode);
   426 };
   428 //------------------------------InsEncode--------------------------------------
   429 class InsEncode : public Form {
   430 private:
   431   // Public Data (access directly only for reads)
   432   // The encodings can only have the values predefined by the ADLC:
   433   // blank, RegReg, RegMem, MemReg, ...
   434   NameList    _encoding;
   435   // NameList    _parameter;
   436   // The parameters for each encoding are preceeded by a NameList::_signal
   437   // and follow the parameters for the previous encoding.
   439   // char *_encode;                  // Type of instruction encoding
   441 public:
   442   // Public Methods
   443   InsEncode();
   444   ~InsEncode();
   446   // Add "encode class name" and its parameters
   447   NameAndList  *add_encode(char *encode_method_name);
   448   // Parameters are added to the returned "NameAndList" by the parser
   450   // Access the list of encodings
   451   void          reset();
   452   const char   *encode_class_iter();
   454   // Returns the number of arguments to the current encoding in the iteration
   455   int current_encoding_num_args() {
   456     return ((NameAndList*)_encoding.current())->count();
   457   }
   459   // --------------------------- Parameters
   460   // The following call depends upon position within encode_class_iteration
   461   //
   462   // Obtain parameter name from zero based index
   463   const char   *rep_var_name(InstructForm &inst, uint param_no);
   464   // ---------------------------
   466   void dump();
   467   void output(FILE *fp);
   468 };
   470 //------------------------------Effect-----------------------------------------
   471 class Effect : public Form {
   472 private:
   474 public:
   475   // Public Data
   476   const char  *_name;            // Pre-defined name for effect
   477   int         _use_def;          // Enumeration value of effect
   479   // Public Methods
   480   Effect(const char *name);      // Constructor
   481   ~Effect();                     // Destructor
   483   // Dynamic type check
   484   virtual Effect *is_effect() const;
   486   // Return 'true' if this use def info equals the parameter
   487   bool  is(int use_def_kill_enum) const;
   488   // Return 'true' if this use def info is a superset of parameter
   489   bool  isa(int use_def_kill_enum) const;
   491   void dump();                   // Debug printer
   492   void output(FILE *fp);         // Write info to output files
   493 };
   495 //------------------------------ExpandRule-------------------------------------
   496 class ExpandRule : public Form {
   497 private:
   498   NameList _expand_instrs;        // ordered list of instructions and operands
   500 public:
   501   // Public Data
   502   NameList _newopers;             // List of newly created operands
   503   Dict     _newopconst;           // Map new operands to their constructors
   505   void     add_instruction(NameAndList *instruction_name_and_operand_list);
   506   void     reset_instructions();
   507   NameAndList *iter_instructions();
   509   // Public Methods
   510   ExpandRule();                   // Constructor
   511   ~ExpandRule();                  // Destructor
   513   void dump();                    // Debug printer
   514   void output(FILE *fp);          // Write info to output files
   515 };
   517 //------------------------------RewriteRule------------------------------------
   518 class RewriteRule : public Form {
   519 private:
   521 public:
   522   // Public Data
   523   SourceForm     *_condition;      // Rewrite condition code
   524   InstructForm   *_instrs;         // List of instructions to expand to
   525   OperandForm    *_opers;          // List of operands generated by expand
   526   char           *_tempParams;     // Hold string until parser is finished.
   527   char           *_tempBlock;      // Hold string until parser is finished.
   529   // Public Methods
   530   RewriteRule(char* params, char* block) ;
   531   ~RewriteRule();                  // Destructor
   532   void dump();                     // Debug printer
   533   void output(FILE *fp);           // Write info to output files
   534 };
   537 //==============================Operands=======================================
   538 //------------------------------OpClassForm------------------------------------
   539 class OpClassForm : public Form {
   540 public:
   541   // Public Data
   542   const char    *_ident;           // Name of this operand
   543   NameList       _oplst;           // List of operand forms included in class
   545   // Public Methods
   546   OpClassForm(const char *id);
   547   ~OpClassForm();
   549   // dynamic type check
   550   virtual OpClassForm         *is_opclass() const;
   551   virtual Form::InterfaceType  interface_type(FormDict &globals) const;
   552   virtual bool                 stack_slots_only(FormDict &globals) const;
   554   virtual bool                 is_cisc_mem(FormDict &globals) const;
   557   // Min and Max opcodes of operands in this operand class
   558   int _minCode;
   559   int _maxCode;
   561   virtual bool ideal_only() const;
   562   virtual void dump();             // Debug printer
   563   virtual void output(FILE *fp);   // Write to output files
   564 };
   566 //------------------------------OperandForm------------------------------------
   567 class OperandForm : public OpClassForm {
   568 private:
   569   bool         _ideal_only; // Not a user-defined instruction
   571 public:
   572   // Public Data
   573   NameList       _parameters; // Locally defined names
   574   FormDict       _localNames; // Table of components & their types
   575   MatchRule     *_matrule;    // Matching rule for this operand
   576   Interface     *_interface;  // Encoding interface for this operand
   577   Attribute     *_attribs;    // List of Attribute rules
   578   Predicate     *_predicate;  // Predicate test for this operand
   579   Constraint    *_constraint; // Constraint Rule for this operand
   580   ConstructRule *_construct;  // Construction of operand data after matching
   581   FormatRule    *_format;     // Format for assembly generation
   582   NameList       _classes;    // List of opclasses which contain this oper
   584   ComponentList _components;  //
   586   // Public Methods
   587   OperandForm(const char *id);
   588   OperandForm(const char *id, bool ideal_only);
   589   ~OperandForm();
   591   // Dynamic type check
   592   virtual OperandForm *is_operand() const;
   594   virtual bool        ideal_only() const;
   595   virtual Form::InterfaceType interface_type(FormDict &globals) const;
   596   virtual bool                 stack_slots_only(FormDict &globals) const;
   598   virtual const char *cost();  // Access ins_cost attribute
   599   virtual uint        num_leaves() const;// Leaves in complex operand
   600   // Constants in operands' match rules
   601   virtual uint        num_consts(FormDict &globals) const;
   602   // Constants in operand's match rule with specified type
   603   virtual uint        num_consts(FormDict &globals, Form::DataType type) const;
   604   // Pointer Constants in operands' match rules
   605   virtual uint        num_const_ptrs(FormDict &globals) const;
   606   // The number of input edges in the machine world == num_leaves - num_consts
   607   virtual uint        num_edges(FormDict &globals) const;
   609   // Check if this operand is usable for cisc-spilling
   610   virtual bool        is_cisc_reg(FormDict &globals) const;
   612   // node matches ideal 'Bool', grab condition codes from the ideal world
   613   virtual bool        is_ideal_bool()  const;
   615   // Has an integer constant suitable for spill offsets
   616   bool has_conI(FormDict &globals) const {
   617     return (num_consts(globals,idealI) == 1) && !is_ideal_bool(); }
   618   bool has_conL(FormDict &globals) const {
   619     return (num_consts(globals,idealL) == 1) && !is_ideal_bool(); }
   621   // Node is user-defined operand for an sRegX
   622   virtual Form::DataType is_user_name_for_sReg() const;
   624   // Return ideal type, if there is a single ideal type for this operand
   625   virtual const char *ideal_type(FormDict &globals, RegisterForm *registers = NULL) const;
   626   // If there is a single ideal type for this interface field, return it.
   627   virtual const char *interface_ideal_type(FormDict   &globals,
   628                                            const char *field_name) const;
   630   // Return true if this operand represents a bound register class
   631   bool is_bound_register() const;
   633   // Return the Register class for this operand.  Returns NULL if
   634   // operand isn't a register form.
   635   RegClass* get_RegClass() const;
   637   virtual       bool  is_interface_field(const char   *field_name,
   638                                          const char   * &value) const;
   640   // If this operand has a single ideal type, return its type
   641   virtual Form::DataType simple_type(FormDict &globals) const;
   642   // If this operand is an ideal constant, return its type
   643   virtual Form::DataType is_base_constant(FormDict &globals) const;
   645   // "true" if this operand is a simple type that is swallowed
   646   virtual bool        swallowed(FormDict &globals) const;
   648   // Return register class name if a constraint specifies the register class.
   649   virtual const char *constrained_reg_class() const;
   650   // Return the register class associated with 'leaf'.
   651   virtual const char *in_reg_class(uint leaf, FormDict &globals);
   653   // Build component list from MatchRule and operand's parameter list
   654   virtual void        build_components(); // top-level operands
   656   // Return zero-based position in component list; -1 if not in list.
   657   virtual int         operand_position(const char *name, int usedef);
   659   // Return zero-based position in component list; -1 if not in list.
   660   virtual int         constant_position(FormDict &globals, const Component *comp);
   661   virtual int         constant_position(FormDict &globals, const char *local_name);
   662   // Return the operand form corresponding to the given index, else NULL.
   663   virtual OperandForm *constant_operand(FormDict &globals, uint const_index);
   665   // Return zero-based position in component list; -1 if not in list.
   666   virtual int         register_position(FormDict &globals, const char *regname);
   668   const char         *reduce_result() const;
   669   // Return the name of the operand on the right hand side of the binary match
   670   // Return NULL if there is no right hand side
   671   const char         *reduce_right(FormDict &globals)  const;
   672   const char         *reduce_left(FormDict &globals)   const;
   675   // --------------------------- FILE *output_routines
   676   //
   677   // Output code for disp_is_oop, if true.
   678   void                disp_is_oop(FILE *fp, FormDict &globals);
   679   // Generate code for internal and external format methods
   680   void                int_format(FILE *fp, FormDict &globals, uint index);
   681   void                ext_format(FILE *fp, FormDict &globals, uint index);
   682   void                format_constant(FILE *fp, uint con_index, uint con_type);
   683   // Output code to access the value of the index'th constant
   684   void                access_constant(FILE *fp, FormDict &globals,
   685                                       uint con_index);
   686   // ---------------------------
   689   virtual void dump();             // Debug printer
   690   virtual void output(FILE *fp);   // Write to output files
   691 };
   693 //------------------------------Constraint-------------------------------------
   694 class Constraint : public Form {
   695 private:
   697 public:
   698   const char      *_func;          // Constraint function
   699   const char      *_arg;           // function's argument
   701   // Public Methods
   702   Constraint(const char *func, const char *arg); // Constructor
   703   ~Constraint();
   705   bool stack_slots_only() const;
   707   void dump();                     // Debug printer
   708   void output(FILE *fp);           // Write info to output files
   709 };
   711 //------------------------------Predicate--------------------------------------
   712 class Predicate : public Form {
   713 private:
   715 public:
   716   // Public Data
   717   char *_pred;                     // C++ source string for predicate
   719   // Public Methods
   720   Predicate(char *pr);
   721   ~Predicate();
   723   void dump();
   724   void output(FILE *fp);
   725 };
   727 //------------------------------Interface--------------------------------------
   728 class Interface : public Form {
   729 private:
   731 public:
   732   // Public Data
   733   const char *_name;               // String representing the interface name
   735   // Public Methods
   736   Interface(const char *name);
   737   ~Interface();
   739   virtual Form::InterfaceType interface_type(FormDict &globals) const;
   741   RegInterface   *is_RegInterface();
   742   MemInterface   *is_MemInterface();
   743   ConstInterface *is_ConstInterface();
   744   CondInterface  *is_CondInterface();
   747   void dump();
   748   void output(FILE *fp);
   749 };
   751 //------------------------------RegInterface-----------------------------------
   752 class RegInterface : public Interface {
   753 private:
   755 public:
   756   // Public Methods
   757   RegInterface();
   758   ~RegInterface();
   760   void dump();
   761   void output(FILE *fp);
   762 };
   764 //------------------------------ConstInterface---------------------------------
   765 class ConstInterface : public Interface {
   766 private:
   768 public:
   769   // Public Methods
   770   ConstInterface();
   771   ~ConstInterface();
   773   void dump();
   774   void output(FILE *fp);
   775 };
   777 //------------------------------MemInterface-----------------------------------
   778 class MemInterface : public Interface {
   779 private:
   781 public:
   782   // Public Data
   783   char *_base;                     // Base address
   784   char *_index;                    // index
   785   char *_scale;                    // scaling factor
   786   char *_disp;                     // displacement
   788   // Public Methods
   789   MemInterface(char *base, char *index, char *scale, char *disp);
   790   ~MemInterface();
   792   void dump();
   793   void output(FILE *fp);
   794 };
   796 //------------------------------CondInterface----------------------------------
   797 class CondInterface : public Interface {
   798 private:
   800 public:
   801   const char *_equal;
   802   const char *_not_equal;
   803   const char *_less;
   804   const char *_greater_equal;
   805   const char *_less_equal;
   806   const char *_greater;
   807   const char *_overflow;
   808   const char *_no_overflow;
   809   const char *_equal_format;
   810   const char *_not_equal_format;
   811   const char *_less_format;
   812   const char *_greater_equal_format;
   813   const char *_less_equal_format;
   814   const char *_greater_format;
   815   const char *_overflow_format;
   816   const char *_no_overflow_format;
   818   // Public Methods
   819   CondInterface(const char* equal,         const char* equal_format,
   820                 const char* not_equal,     const char* not_equal_format,
   821                 const char* less,          const char* less_format,
   822                 const char* greater_equal, const char* greater_equal_format,
   823                 const char* less_equal,    const char* less_equal_format,
   824                 const char* greater,       const char* greater_format,
   825                 const char* overflow,      const char* overflow_format,
   826                 const char* no_overflow,   const char* no_overflow_format);
   827   ~CondInterface();
   829   void dump();
   830   void output(FILE *fp);
   831 };
   833 //------------------------------ConstructRule----------------------------------
   834 class ConstructRule : public Form {
   835 private:
   837 public:
   838   // Public Data
   839   char *_expr;                     // String representing the match expression
   840   char *_construct;                // String representing C++ constructor code
   842   // Public Methods
   843   ConstructRule(char *cnstr);
   844   ~ConstructRule();
   846   void dump();
   847   void output(FILE *fp);
   848 };
   851 //==============================Shared=========================================
   852 //------------------------------AttributeForm----------------------------------
   853 class AttributeForm : public Form {
   854 private:
   855   // counters for unique instruction or operand ID
   856   static int   _insId;             // user-defined machine instruction types
   857   static int   _opId;              // user-defined operand types
   859   int  id;                         // hold type for this object
   861 public:
   862   // Public Data
   863   char *_attrname;                 // Name of attribute
   864   int   _atype;                    // Either INS_ATTR or OP_ATTR
   865   char *_attrdef;                  // C++ source which evaluates to constant
   867   // Public Methods
   868   AttributeForm(char *attr, int type, char *attrdef);
   869   ~AttributeForm();
   871   // Dynamic type check
   872   virtual AttributeForm *is_attribute() const;
   874   int  type() { return id;}        // return this object's "id"
   876   static const char* _ins_cost;        // "ins_cost"
   877   static const char* _op_cost;         // "op_cost"
   879   void dump();                     // Debug printer
   880   void output(FILE *fp);           // Write output files
   881 };
   883 //------------------------------Component--------------------------------------
   884 class Component : public Form {
   885 private:
   887 public:
   888   // Public Data
   889   const char *_name;              // Name of this component
   890   const char *_type;              // Type of this component
   891   int         _usedef;            // Value of component
   893   // Public Methods
   894   Component(const char *name, const char *type, int usedef);
   895   ~Component();
   898   // Return 'true' if this use def info equals the parameter
   899   bool  is(int use_def_kill_enum) const;
   900   // Return 'true' if this use def info is a superset of parameter
   901   bool  isa(int use_def_kill_enum) const;
   902   int   promote_use_def_info(int new_use_def);
   903   const char *base_type(FormDict &globals);
   904   // Form::DataType is_base_constant(FormDict &globals);
   906   void dump();                     // Debug printer
   907   void output(FILE *fp);           // Write to output files
   908   const char* getUsedefName();
   910 public:
   911   // Implementation depends upon working bit intersection and union.
   912   enum use_def_enum {
   913     INVALID = 0x0,
   914     USE     = 0x1,
   915     DEF     = 0x2, USE_DEF   = 0x3,
   916     KILL    = 0x4, USE_KILL  = 0x5,
   917     SYNTHETIC = 0x8,
   918     TEMP = USE | SYNTHETIC,
   919     CALL = 0x10
   920   };
   921 };
   924 //------------------------------MatchNode--------------------------------------
   925 class MatchNode : public Form {
   926 private:
   928 public:
   929   // Public Data
   930   const char  *_result;            // The name of the output of this node
   931   const char  *_name;              // The name that appeared in the match rule
   932   const char  *_opType;            // The Operation/Type matched
   933   MatchNode   *_lChild;            // Left child in expression tree
   934   MatchNode   *_rChild;            // Right child in expression tree
   935   int         _numleaves;          // Sum of numleaves for all direct children
   936   ArchDesc    &_AD;                // Reference to ArchDesc object
   937   char        *_internalop;        // String representing internal operand
   938   int         _commutative_id;     // id of commutative operation
   940   // Public Methods
   941   MatchNode(ArchDesc &ad, const char *result = 0, const char *expr = 0,
   942             const char *opType=0, MatchNode *lChild=NULL,
   943             MatchNode *rChild=NULL);
   944   MatchNode(ArchDesc &ad, MatchNode& mNode); // Shallow copy constructor;
   945   MatchNode(ArchDesc &ad, MatchNode& mNode, int clone); // Construct clone
   946   ~MatchNode();
   948   // return 0 if not found:
   949   // return 1 if found and position is incremented by operand offset in rule
   950   bool       find_name(const char *str, int &position) const;
   951   bool       find_type(const char *str, int &position) const;
   952   virtual void append_components(FormDict& locals, ComponentList& components,
   953                                  bool def_flag = false) const;
   954   bool       base_operand(uint &position, FormDict &globals,
   955                          const char * &result, const char * &name,
   956                          const char * &opType) const;
   957   // recursive count on operands
   958   uint       num_consts(FormDict &globals) const;
   959   uint       num_const_ptrs(FormDict &globals) const;
   960   // recursive count of constants with specified type
   961   uint       num_consts(FormDict &globals, Form::DataType type) const;
   962   // uint       num_consts() const;   // Local inspection only
   963   int        needs_ideal_memory_edge(FormDict &globals) const;
   964   int        needs_base_oop_edge() const;
   966   // Help build instruction predicates.  Search for operand names.
   967   void count_instr_names( Dict &names );
   968   int build_instr_pred( char *buf, const char *name, int cnt );
   969   void build_internalop( );
   971   // Return the name of the operands associated with reducing to this operand:
   972   // The result type, plus the left and right sides of the binary match
   973   // Return NULL if there is no left or right hand side
   974   bool       sets_result()   const;    // rule "Set"s result of match
   975   const char *reduce_right(FormDict &globals)  const;
   976   const char *reduce_left (FormDict &globals)  const;
   978   // Recursive version of check in MatchRule
   979   int        cisc_spill_match(FormDict& globals, RegisterForm* registers,
   980                               MatchNode* mRule2, const char* &operand,
   981                               const char* &reg_type);
   982   int        cisc_spill_merge(int left_result, int right_result);
   984   virtual bool equivalent(FormDict& globals, MatchNode* mNode2);
   986   void       count_commutative_op(int& count);
   987   void       swap_commutative_op(bool atroot, int count);
   989   void dump();
   990   void output(FILE *fp);
   991 };
   993 //------------------------------MatchRule--------------------------------------
   994 class MatchRule : public MatchNode {
   995 private:
   997 public:
   998   // Public Data
   999   const char *_machType;            // Machine type index
  1000   int         _depth;               // Expression tree depth
  1001   char       *_construct;           // String representing C++ constructor code
  1002   int         _numchilds;           // Number of direct children
  1003   MatchRule  *_next;                // Pointer to next match rule
  1005   // Public Methods
  1006   MatchRule(ArchDesc &ad);
  1007   MatchRule(ArchDesc &ad, MatchRule* mRule); // Shallow copy constructor;
  1008   MatchRule(ArchDesc &ad, MatchNode* mroot, int depth, char* construct, int numleaves);
  1009   ~MatchRule();
  1011   virtual void append_components(FormDict& locals, ComponentList& components, bool def_flag = false) const;
  1012   // Recursive call on all operands' match rules in my match rule.
  1013   bool       base_operand(uint &position, FormDict &globals,
  1014                          const char * &result, const char * &name,
  1015                          const char * &opType) const;
  1018   bool       is_base_register(FormDict &globals) const;
  1019   Form::DataType is_base_constant(FormDict &globals) const;
  1020   bool       is_chain_rule(FormDict &globals) const;
  1021   int        is_ideal_copy() const;
  1022   int        is_expensive() const;     // node matches ideal 'CosD'
  1023   bool       is_ideal_if()   const;    // node matches ideal 'If'
  1024   bool       is_ideal_fastlock() const; // node matches ideal 'FastLock'
  1025   bool       is_ideal_jump()   const;  // node matches ideal 'Jump'
  1026   bool       is_ideal_membar() const;  // node matches ideal 'MemBarXXX'
  1027   bool       is_ideal_loadPC() const;  // node matches ideal 'LoadPC'
  1028   bool       is_ideal_box() const;     // node matches ideal 'Box'
  1029   bool       is_ideal_goto() const;    // node matches ideal 'Goto'
  1030   bool       is_ideal_loopEnd() const; // node matches ideal 'LoopEnd'
  1031   bool       is_ideal_bool() const;    // node matches ideal 'Bool'
  1032   bool       is_vector() const;        // vector instruction
  1033   Form::DataType is_ideal_load() const;// node matches ideal 'LoadXNode'
  1034   // Should antidep checks be disabled for this rule
  1035   // See definition of MatchRule::skip_antidep_check
  1036   bool skip_antidep_check() const;
  1037   Form::DataType is_ideal_store() const;// node matches ideal 'StoreXNode'
  1039   // Check if 'mRule2' is a cisc-spill variant of this MatchRule
  1040   int        matchrule_cisc_spill_match(FormDict &globals, RegisterForm* registers,
  1041                                         MatchRule* mRule2, const char* &operand,
  1042                                         const char* &reg_type);
  1044   // Check if 'mRule2' is equivalent to this MatchRule
  1045   virtual bool equivalent(FormDict& globals, MatchNode* mRule2);
  1047   void       matchrule_swap_commutative_op(const char* instr_ident, int count, int& match_rules_cnt);
  1049   void dump();
  1050   void output_short(FILE *fp);
  1051   void output(FILE *fp);
  1052 };
  1054 //------------------------------Attribute--------------------------------------
  1055 class Attribute : public Form {
  1056 private:
  1058 public:
  1059   // Public Data
  1060   char *_ident;                    // Name of predefined attribute
  1061   char *_val;                      // C++ source which evaluates to constant
  1062   int   _atype;                    // Either INS_ATTR or OP_ATTR
  1063   int   int_val(ArchDesc &ad);     // Return atoi(_val), ensuring syntax.
  1065   // Public Methods
  1066   Attribute(char *id, char* val, int type);
  1067   ~Attribute();
  1069   void dump();
  1070   void output(FILE *fp);
  1071 };
  1073 //------------------------------FormatRule-------------------------------------
  1074 class FormatRule : public Form {
  1075 private:
  1077 public:
  1078   // Public Data
  1079   // There is an entry in _strings, perhaps NULL, that precedes each _rep_vars
  1080   NameList  _strings;              // Strings passed through to tty->print
  1081   NameList  _rep_vars;             // replacement variables
  1082   char     *_temp;                 // String representing the assembly code
  1084   // Public Methods
  1085   FormatRule(char *temp);
  1086   ~FormatRule();
  1088   void dump();
  1089   void output(FILE *fp);
  1090 };
  1092 #endif // SHARE_VM_ADLC_FORMSSEL_HPP

mercurial