src/share/vm/opto/machnode.hpp

Thu, 21 Nov 2013 19:00:57 -0800

author
goetz
date
Thu, 21 Nov 2013 19:00:57 -0800
changeset 6487
15120a36272d
parent 6484
318d0622a6d7
child 6490
41b780b43b74
permissions
-rw-r--r--

8028767: PPC64: (part 121): smaller shared changes needed to build C2
Summary: smaller shared changes required to build the C2 compiler on PPC64.
Reviewed-by: kvn

     1 /*
     2  * Copyright (c) 1997, 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_OPTO_MACHNODE_HPP
    26 #define SHARE_VM_OPTO_MACHNODE_HPP
    28 #include "opto/callnode.hpp"
    29 #include "opto/matcher.hpp"
    30 #include "opto/multnode.hpp"
    31 #include "opto/node.hpp"
    32 #include "opto/regmask.hpp"
    34 class BiasedLockingCounters;
    35 class BufferBlob;
    36 class CodeBuffer;
    37 class JVMState;
    38 class MachCallDynamicJavaNode;
    39 class MachCallJavaNode;
    40 class MachCallLeafNode;
    41 class MachCallNode;
    42 class MachCallRuntimeNode;
    43 class MachCallStaticJavaNode;
    44 class MachEpilogNode;
    45 class MachIfNode;
    46 class MachNullCheckNode;
    47 class MachOper;
    48 class MachProjNode;
    49 class MachPrologNode;
    50 class MachReturnNode;
    51 class MachSafePointNode;
    52 class MachSpillCopyNode;
    53 class Matcher;
    54 class PhaseRegAlloc;
    55 class RegMask;
    56 class State;
    58 //---------------------------MachOper------------------------------------------
    59 class MachOper : public ResourceObj {
    60 public:
    61   // Allocate right next to the MachNodes in the same arena
    62   void *operator new( size_t x, Compile* C ) throw() { return C->node_arena()->Amalloc_D(x); }
    64   // Opcode
    65   virtual uint opcode() const = 0;
    67   // Number of input edges.
    68   // Generally at least 1
    69   virtual uint num_edges() const { return 1; }
    70   // Array of Register masks
    71   virtual const RegMask *in_RegMask(int index) const;
    73   // Methods to output the encoding of the operand
    75   // Negate conditional branches.  Error for non-branch Nodes
    76   virtual void negate();
    78   // Return the value requested
    79   // result register lookup, corresponding to int_format
    80   virtual int  reg(PhaseRegAlloc *ra_, const Node *node)   const;
    81   // input register lookup, corresponding to ext_format
    82   virtual int  reg(PhaseRegAlloc *ra_, const Node *node, int idx)   const;
    84   // helpers for MacroAssembler generation from ADLC
    85   Register  as_Register(PhaseRegAlloc *ra_, const Node *node)   const {
    86     return ::as_Register(reg(ra_, node));
    87   }
    88   Register  as_Register(PhaseRegAlloc *ra_, const Node *node, int idx)   const {
    89     return ::as_Register(reg(ra_, node, idx));
    90   }
    91   FloatRegister  as_FloatRegister(PhaseRegAlloc *ra_, const Node *node)   const {
    92     return ::as_FloatRegister(reg(ra_, node));
    93   }
    94   FloatRegister  as_FloatRegister(PhaseRegAlloc *ra_, const Node *node, int idx)   const {
    95     return ::as_FloatRegister(reg(ra_, node, idx));
    96   }
    98 #if defined(IA32) || defined(AMD64)
    99   XMMRegister  as_XMMRegister(PhaseRegAlloc *ra_, const Node *node)   const {
   100     return ::as_XMMRegister(reg(ra_, node));
   101   }
   102   XMMRegister  as_XMMRegister(PhaseRegAlloc *ra_, const Node *node, int idx)   const {
   103     return ::as_XMMRegister(reg(ra_, node, idx));
   104   }
   105 #endif
   107   virtual intptr_t  constant() const;
   108   virtual relocInfo::relocType constant_reloc() const;
   109   virtual jdouble constantD() const;
   110   virtual jfloat  constantF() const;
   111   virtual jlong   constantL() const;
   112   virtual TypeOopPtr *oop() const;
   113   virtual int  ccode() const;
   114   // A zero, default, indicates this value is not needed.
   115   // May need to lookup the base register, as done in int_ and ext_format
   116   virtual int  base (PhaseRegAlloc *ra_, const Node *node, int idx) const;
   117   virtual int  index(PhaseRegAlloc *ra_, const Node *node, int idx) const;
   118   virtual int  scale() const;
   119   // Parameters needed to support MEMORY_INTERFACE access to stackSlot
   120   virtual int  disp (PhaseRegAlloc *ra_, const Node *node, int idx) const;
   121   // Check for PC-Relative displacement
   122   virtual relocInfo::relocType disp_reloc() const;
   123   virtual int  constant_disp() const;   // usu. 0, may return Type::OffsetBot
   124   virtual int  base_position()  const;  // base edge position, or -1
   125   virtual int  index_position() const;  // index edge position, or -1
   127   // Access the TypeKlassPtr of operands with a base==RegI and disp==RegP
   128   // Only returns non-null value for i486.ad's indOffset32X
   129   virtual const TypePtr *disp_as_type() const { return NULL; }
   131   // Return the label
   132   virtual Label *label() const;
   134   // Return the method's address
   135   virtual intptr_t  method() const;
   137   // Hash and compare over operands are currently identical
   138   virtual uint  hash() const;
   139   virtual uint  cmp( const MachOper &oper ) const;
   141   // Virtual clone, since I do not know how big the MachOper is.
   142   virtual MachOper *clone(Compile* C) const = 0;
   144   // Return ideal Type from simple operands.  Fail for complex operands.
   145   virtual const Type *type() const;
   147   // Set an integer offset if we have one, or error otherwise
   148   virtual void set_con( jint c0 ) { ShouldNotReachHere();  }
   150 #ifndef PRODUCT
   151   // Return name of operand
   152   virtual const char    *Name() const { return "???";}
   154   // Methods to output the text version of the operand
   155   virtual void int_format(PhaseRegAlloc *,const MachNode *node, outputStream *st) const = 0;
   156   virtual void ext_format(PhaseRegAlloc *,const MachNode *node,int idx, outputStream *st) const=0;
   158   virtual void dump_spec(outputStream *st) const; // Print per-operand info
   160   // Check whether o is a valid oper.
   161   static bool notAnOper(const MachOper *o) {
   162     if (o == NULL)                   return true;
   163     if (((intptr_t)o & 1) != 0)      return true;
   164     if (*(address*)o == badAddress)  return true;  // kill by Node::destruct
   165     return false;
   166   }
   167 #endif // !PRODUCT
   168 };
   170 //------------------------------MachNode---------------------------------------
   171 // Base type for all machine specific nodes.  All node classes generated by the
   172 // ADLC inherit from this class.
   173 class MachNode : public Node {
   174 public:
   175   MachNode() : Node((uint)0), _num_opnds(0), _opnds(NULL) {
   176     init_class_id(Class_Mach);
   177   }
   178   // Required boilerplate
   179   virtual uint size_of() const { return sizeof(MachNode); }
   180   virtual int  Opcode() const;          // Always equal to MachNode
   181   virtual uint rule() const = 0;        // Machine-specific opcode
   182   // Number of inputs which come before the first operand.
   183   // Generally at least 1, to skip the Control input
   184   virtual uint oper_input_base() const { return 1; }
   185   // Position of constant base node in node's inputs. -1 if
   186   // no constant base node input.
   187   virtual uint mach_constant_base_node_input() const { return (uint)-1; }
   189   // Copy inputs and operands to new node of instruction.
   190   // Called from cisc_version() and short_branch_version().
   191   // !!!! The method's body is defined in ad_<arch>.cpp file.
   192   void fill_new_machnode(MachNode *n, Compile* C) const;
   194   // Return an equivalent instruction using memory for cisc_operand position
   195   virtual MachNode *cisc_version(int offset, Compile* C);
   196   // Modify this instruction's register mask to use stack version for cisc_operand
   197   virtual void use_cisc_RegMask();
   199   // Support for short branches
   200   bool may_be_short_branch() const { return (flags() & Flag_may_be_short_branch) != 0; }
   202   // Avoid back to back some instructions on some CPUs.
   203   bool avoid_back_to_back() const { return (flags() & Flag_avoid_back_to_back) != 0; }
   205   // instruction implemented with a call
   206   bool has_call() const { return (flags() & Flag_has_call) != 0; }
   208   // First index in _in[] corresponding to operand, or -1 if there is none
   209   int  operand_index(uint operand) const;
   210   int  operand_index(const MachOper *oper) const;
   212   // Register class input is expected in
   213   virtual const RegMask &in_RegMask(uint) const;
   215   // cisc-spillable instructions redefine for use by in_RegMask
   216   virtual const RegMask *cisc_RegMask() const { return NULL; }
   218   // If this instruction is a 2-address instruction, then return the
   219   // index of the input which must match the output.  Not nessecary
   220   // for instructions which bind the input and output register to the
   221   // same singleton regiser (e.g., Intel IDIV which binds AX to be
   222   // both an input and an output).  It is nessecary when the input and
   223   // output have choices - but they must use the same choice.
   224   virtual uint two_adr( ) const { return 0; }
   226   // Array of complex operand pointers.  Each corresponds to zero or
   227   // more leafs.  Must be set by MachNode constructor to point to an
   228   // internal array of MachOpers.  The MachOper array is sized by
   229   // specific MachNodes described in the ADL.
   230   uint _num_opnds;
   231   MachOper **_opnds;
   232   uint  num_opnds() const { return _num_opnds; }
   234   // Emit bytes into cbuf
   235   virtual void  emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const;
   236   // Expand node after register allocation.
   237   // Node is replaced by several nodes in the postalloc expand phase.
   238   // Corresponding methods are generated for nodes if they specify
   239   // postalloc_expand. See block.cpp for more documentation.
   240   virtual bool requires_postalloc_expand() const { return false; }
   241   virtual void postalloc_expand(GrowableArray <Node *> *nodes, PhaseRegAlloc *ra_);
   242   // Size of instruction in bytes
   243   virtual uint  size(PhaseRegAlloc *ra_) const;
   244   // Helper function that computes size by emitting code
   245   virtual uint  emit_size(PhaseRegAlloc *ra_) const;
   247   // Return the alignment required (in units of relocInfo::addr_unit())
   248   // for this instruction (must be a power of 2)
   249   virtual int   alignment_required() const { return 1; }
   251   // Return the padding (in bytes) to be emitted before this
   252   // instruction to properly align it.
   253   virtual int   compute_padding(int current_offset) const { return 0; }
   255   // Return number of relocatable values contained in this instruction
   256   virtual int   reloc() const { return 0; }
   258   // Return number of words used for double constants in this instruction
   259   virtual int   ins_num_consts() const { return 0; }
   261   // Hash and compare over operands.  Used to do GVN on machine Nodes.
   262   virtual uint  hash() const;
   263   virtual uint  cmp( const Node &n ) const;
   265   // Expand method for MachNode, replaces nodes representing pseudo
   266   // instructions with a set of nodes which represent real machine
   267   // instructions and compute the same value.
   268   virtual MachNode *Expand( State *, Node_List &proj_list, Node* mem ) { return this; }
   270   // Bottom_type call; value comes from operand0
   271   virtual const class Type *bottom_type() const { return _opnds[0]->type(); }
   272   virtual uint ideal_reg() const { const Type *t = _opnds[0]->type(); return t == TypeInt::CC ? Op_RegFlags : t->ideal_reg(); }
   274   // If this is a memory op, return the base pointer and fixed offset.
   275   // If there are no such, return NULL.  If there are multiple addresses
   276   // or the address is indeterminate (rare cases) then return (Node*)-1,
   277   // which serves as node bottom.
   278   // If the offset is not statically determined, set it to Type::OffsetBot.
   279   // This method is free to ignore stack slots if that helps.
   280   #define TYPE_PTR_SENTINAL  ((const TypePtr*)-1)
   281   // Passing TYPE_PTR_SENTINAL as adr_type asks for computation of the adr_type if possible
   282   const Node* get_base_and_disp(intptr_t &offset, const TypePtr* &adr_type) const;
   284   // Helper for get_base_and_disp: find the base and index input nodes.
   285   // Returns the MachOper as determined by memory_operand(), for use, if
   286   // needed by the caller. If (MachOper *)-1 is returned, base and index
   287   // are set to NodeSentinel. If (MachOper *) NULL is returned, base and
   288   // index are set to NULL.
   289   const MachOper* memory_inputs(Node* &base, Node* &index) const;
   291   // Helper for memory_inputs:  Which operand carries the necessary info?
   292   // By default, returns NULL, which means there is no such operand.
   293   // If it returns (MachOper*)-1, this means there are multiple memories.
   294   virtual const MachOper* memory_operand() const { return NULL; }
   296   // Call "get_base_and_disp" to decide which category of memory is used here.
   297   virtual const class TypePtr *adr_type() const;
   299   // Apply peephole rule(s) to this instruction
   300   virtual MachNode *peephole( Block *block, int block_index, PhaseRegAlloc *ra_, int &deleted, Compile* C );
   302   // Top-level ideal Opcode matched
   303   virtual int ideal_Opcode()     const { return Op_Node; }
   305   // Adds the label for the case
   306   virtual void add_case_label( int switch_val, Label* blockLabel);
   308   // Set the absolute address for methods
   309   virtual void method_set( intptr_t addr );
   311   // Should we clone rather than spill this instruction?
   312   bool rematerialize() const;
   314   // Get the pipeline info
   315   static const Pipeline *pipeline_class();
   316   virtual const Pipeline *pipeline() const;
   318 #ifndef PRODUCT
   319   virtual const char *Name() const = 0; // Machine-specific name
   320   virtual void dump_spec(outputStream *st) const; // Print per-node info
   321   void         dump_format(PhaseRegAlloc *ra, outputStream *st) const; // access to virtual
   322 #endif
   323 };
   325 //------------------------------MachIdealNode----------------------------
   326 // Machine specific versions of nodes that must be defined by user.
   327 // These are not converted by matcher from ideal nodes to machine nodes
   328 // but are inserted into the code by the compiler.
   329 class MachIdealNode : public MachNode {
   330 public:
   331   MachIdealNode( ) {}
   333   // Define the following defaults for non-matched machine nodes
   334   virtual uint oper_input_base() const { return 0; }
   335   virtual uint rule()            const { return 9999999; }
   336   virtual const class Type *bottom_type() const { return _opnds == NULL ? Type::CONTROL : MachNode::bottom_type(); }
   337 };
   339 //------------------------------MachTypeNode----------------------------
   340 // Machine Nodes that need to retain a known Type.
   341 class MachTypeNode : public MachNode {
   342   virtual uint size_of() const { return sizeof(*this); } // Size is bigger
   343 public:
   344   MachTypeNode( ) {}
   345   const Type *_bottom_type;
   347   virtual const class Type *bottom_type() const { return _bottom_type; }
   348 #ifndef PRODUCT
   349   virtual void dump_spec(outputStream *st) const;
   350 #endif
   351 };
   353 //------------------------------MachBreakpointNode----------------------------
   354 // Machine breakpoint or interrupt Node
   355 class MachBreakpointNode : public MachIdealNode {
   356 public:
   357   MachBreakpointNode( ) {}
   358   virtual void emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const;
   359   virtual uint size(PhaseRegAlloc *ra_) const;
   361 #ifndef PRODUCT
   362   virtual const char *Name() const { return "Breakpoint"; }
   363   virtual void format( PhaseRegAlloc *, outputStream *st ) const;
   364 #endif
   365 };
   367 //------------------------------MachConstantBaseNode--------------------------
   368 // Machine node that represents the base address of the constant table.
   369 class MachConstantBaseNode : public MachIdealNode {
   370 public:
   371   static const RegMask& _out_RegMask;  // We need the out_RegMask statically in MachConstantNode::in_RegMask().
   373 public:
   374   MachConstantBaseNode() : MachIdealNode() {
   375     init_class_id(Class_MachConstantBase);
   376   }
   377   virtual const class Type* bottom_type() const { return TypeRawPtr::NOTNULL; }
   378   virtual uint ideal_reg() const { return Op_RegP; }
   379   virtual uint oper_input_base() const { return 1; }
   381   virtual bool requires_postalloc_expand() const;
   382   virtual void postalloc_expand(GrowableArray <Node *> *nodes, PhaseRegAlloc *ra_);
   384   virtual void emit(CodeBuffer& cbuf, PhaseRegAlloc* ra_) const;
   385   virtual uint size(PhaseRegAlloc* ra_) const;
   386   virtual bool pinned() const { return UseRDPCForConstantTableBase; }
   388   static const RegMask& static_out_RegMask() { return _out_RegMask; }
   389   virtual const RegMask& out_RegMask() const { return static_out_RegMask(); }
   391 #ifndef PRODUCT
   392   virtual const char* Name() const { return "MachConstantBaseNode"; }
   393   virtual void format(PhaseRegAlloc*, outputStream* st) const;
   394 #endif
   395 };
   397 //------------------------------MachConstantNode-------------------------------
   398 // Machine node that holds a constant which is stored in the constant table.
   399 class MachConstantNode : public MachTypeNode {
   400 protected:
   401   Compile::Constant _constant;  // This node's constant.
   403 public:
   404   MachConstantNode() : MachTypeNode() {
   405     init_class_id(Class_MachConstant);
   406   }
   408   virtual void eval_constant(Compile* C) {
   409 #ifdef ASSERT
   410     tty->print("missing MachConstantNode eval_constant function: ");
   411     dump();
   412 #endif
   413     ShouldNotCallThis();
   414   }
   416   virtual const RegMask &in_RegMask(uint idx) const {
   417     if (idx == mach_constant_base_node_input())
   418       return MachConstantBaseNode::static_out_RegMask();
   419     return MachNode::in_RegMask(idx);
   420   }
   422   // Input edge of MachConstantBaseNode.
   423   virtual uint mach_constant_base_node_input() const { return req() - 1; }
   425   int  constant_offset();
   426   int  constant_offset() const { return ((MachConstantNode*) this)->constant_offset(); }
   427   // Unchecked version to avoid assertions in debug output.
   428   int  constant_offset_unchecked() const;
   429 };
   431 //------------------------------MachUEPNode-----------------------------------
   432 // Machine Unvalidated Entry Point Node
   433 class MachUEPNode : public MachIdealNode {
   434 public:
   435   MachUEPNode( ) {}
   436   virtual void emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const;
   437   virtual uint size(PhaseRegAlloc *ra_) const;
   439 #ifndef PRODUCT
   440   virtual const char *Name() const { return "Unvalidated-Entry-Point"; }
   441   virtual void format( PhaseRegAlloc *, outputStream *st ) const;
   442 #endif
   443 };
   445 //------------------------------MachPrologNode--------------------------------
   446 // Machine function Prolog Node
   447 class MachPrologNode : public MachIdealNode {
   448 public:
   449   MachPrologNode( ) {}
   450   virtual void emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const;
   451   virtual uint size(PhaseRegAlloc *ra_) const;
   452   virtual int reloc() const;
   454 #ifndef PRODUCT
   455   virtual const char *Name() const { return "Prolog"; }
   456   virtual void format( PhaseRegAlloc *, outputStream *st ) const;
   457 #endif
   458 };
   460 //------------------------------MachEpilogNode--------------------------------
   461 // Machine function Epilog Node
   462 class MachEpilogNode : public MachIdealNode {
   463 public:
   464   MachEpilogNode(bool do_poll = false) : _do_polling(do_poll) {}
   465   virtual void emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const;
   466   virtual uint size(PhaseRegAlloc *ra_) const;
   467   virtual int reloc() const;
   468   virtual const Pipeline *pipeline() const;
   470 private:
   471   bool _do_polling;
   473 public:
   474   bool do_polling() const { return _do_polling; }
   476   // Offset of safepoint from the beginning of the node
   477   int safepoint_offset() const;
   479 #ifndef PRODUCT
   480   virtual const char *Name() const { return "Epilog"; }
   481   virtual void format( PhaseRegAlloc *, outputStream *st ) const;
   482 #endif
   483 };
   485 //------------------------------MachNopNode-----------------------------------
   486 // Machine function Nop Node
   487 class MachNopNode : public MachIdealNode {
   488 private:
   489   int _count;
   490 public:
   491   MachNopNode( ) : _count(1) {}
   492   MachNopNode( int count ) : _count(count) {}
   493   virtual void emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const;
   494   virtual uint size(PhaseRegAlloc *ra_) const;
   496   virtual const class Type *bottom_type() const { return Type::CONTROL; }
   498   virtual int ideal_Opcode() const { return Op_Con; } // bogus; see output.cpp
   499   virtual const Pipeline *pipeline() const;
   500 #ifndef PRODUCT
   501   virtual const char *Name() const { return "Nop"; }
   502   virtual void format( PhaseRegAlloc *, outputStream *st ) const;
   503   virtual void dump_spec(outputStream *st) const { } // No per-operand info
   504 #endif
   505 };
   507 //------------------------------MachSpillCopyNode------------------------------
   508 // Machine SpillCopy Node.  Copies 1 or 2 words from any location to any
   509 // location (stack or register).
   510 class MachSpillCopyNode : public MachIdealNode {
   511   const RegMask *_in;           // RegMask for input
   512   const RegMask *_out;          // RegMask for output
   513   const Type *_type;
   514 public:
   515   MachSpillCopyNode( Node *n, const RegMask &in, const RegMask &out ) :
   516     MachIdealNode(), _in(&in), _out(&out), _type(n->bottom_type()) {
   517     init_class_id(Class_MachSpillCopy);
   518     init_flags(Flag_is_Copy);
   519     add_req(NULL);
   520     add_req(n);
   521   }
   522   virtual uint size_of() const { return sizeof(*this); }
   523   void set_out_RegMask(const RegMask &out) { _out = &out; }
   524   void set_in_RegMask(const RegMask &in) { _in = &in; }
   525   virtual const RegMask &out_RegMask() const { return *_out; }
   526   virtual const RegMask &in_RegMask(uint) const { return *_in; }
   527   virtual const class Type *bottom_type() const { return _type; }
   528   virtual uint ideal_reg() const { return _type->ideal_reg(); }
   529   virtual uint oper_input_base() const { return 1; }
   530   uint implementation( CodeBuffer *cbuf, PhaseRegAlloc *ra_, bool do_size, outputStream* st ) const;
   532   virtual void emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const;
   533   virtual uint size(PhaseRegAlloc *ra_) const;
   535 #ifndef PRODUCT
   536   virtual const char *Name() const { return "MachSpillCopy"; }
   537   virtual void format( PhaseRegAlloc *, outputStream *st ) const;
   538 #endif
   539 };
   541 //------------------------------MachBranchNode--------------------------------
   542 // Abstract machine branch Node
   543 class MachBranchNode : public MachIdealNode {
   544 public:
   545   MachBranchNode() : MachIdealNode() {
   546     init_class_id(Class_MachBranch);
   547   }
   548   virtual void label_set(Label* label, uint block_num) = 0;
   549   virtual void save_label(Label** label, uint* block_num) = 0;
   551   // Support for short branches
   552   virtual MachNode *short_branch_version(Compile* C) { return NULL; }
   554   virtual bool pinned() const { return true; };
   555 };
   557 //------------------------------MachNullChkNode--------------------------------
   558 // Machine-dependent null-pointer-check Node.  Points a real MachNode that is
   559 // also some kind of memory op.  Turns the indicated MachNode into a
   560 // conditional branch with good latency on the ptr-not-null path and awful
   561 // latency on the pointer-is-null path.
   563 class MachNullCheckNode : public MachBranchNode {
   564 public:
   565   const uint _vidx;             // Index of memop being tested
   566   MachNullCheckNode( Node *ctrl, Node *memop, uint vidx ) : MachBranchNode(), _vidx(vidx) {
   567     init_class_id(Class_MachNullCheck);
   568     add_req(ctrl);
   569     add_req(memop);
   570   }
   571   virtual uint size_of() const { return sizeof(*this); }
   573   virtual void emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const;
   574   virtual void label_set(Label* label, uint block_num);
   575   virtual void save_label(Label** label, uint* block_num);
   576   virtual void negate() { }
   577   virtual const class Type *bottom_type() const { return TypeTuple::IFBOTH; }
   578   virtual uint ideal_reg() const { return NotAMachineReg; }
   579   virtual const RegMask &in_RegMask(uint) const;
   580   virtual const RegMask &out_RegMask() const { return RegMask::Empty; }
   581 #ifndef PRODUCT
   582   virtual const char *Name() const { return "NullCheck"; }
   583   virtual void format( PhaseRegAlloc *, outputStream *st ) const;
   584 #endif
   585 };
   587 //------------------------------MachProjNode----------------------------------
   588 // Machine-dependent Ideal projections (how is that for an oxymoron).  Really
   589 // just MachNodes made by the Ideal world that replicate simple projections
   590 // but with machine-dependent input & output register masks.  Generally
   591 // produced as part of calling conventions.  Normally I make MachNodes as part
   592 // of the Matcher process, but the Matcher is ill suited to issues involving
   593 // frame handling, so frame handling is all done in the Ideal world with
   594 // occasional callbacks to the machine model for important info.
   595 class MachProjNode : public ProjNode {
   596 public:
   597   MachProjNode( Node *multi, uint con, const RegMask &out, uint ideal_reg ) : ProjNode(multi,con), _rout(out), _ideal_reg(ideal_reg) {
   598     init_class_id(Class_MachProj);
   599   }
   600   RegMask _rout;
   601   const uint  _ideal_reg;
   602   enum projType {
   603     unmatched_proj = 0,         // Projs for Control, I/O, memory not matched
   604     fat_proj       = 999        // Projs killing many regs, defined by _rout
   605   };
   606   virtual int   Opcode() const;
   607   virtual const Type *bottom_type() const;
   608   virtual const TypePtr *adr_type() const;
   609   virtual const RegMask &in_RegMask(uint) const { return RegMask::Empty; }
   610   virtual const RegMask &out_RegMask() const { return _rout; }
   611   virtual uint  ideal_reg() const { return _ideal_reg; }
   612   // Need size_of() for virtual ProjNode::clone()
   613   virtual uint  size_of() const { return sizeof(MachProjNode); }
   614 #ifndef PRODUCT
   615   virtual void dump_spec(outputStream *st) const;
   616 #endif
   617 };
   619 //------------------------------MachIfNode-------------------------------------
   620 // Machine-specific versions of IfNodes
   621 class MachIfNode : public MachBranchNode {
   622   virtual uint size_of() const { return sizeof(*this); } // Size is bigger
   623 public:
   624   float _prob;                  // Probability branch goes either way
   625   float _fcnt;                  // Frequency counter
   626   MachIfNode() : MachBranchNode() {
   627     init_class_id(Class_MachIf);
   628   }
   629   // Negate conditional branches.
   630   virtual void negate() = 0;
   631 #ifndef PRODUCT
   632   virtual void dump_spec(outputStream *st) const;
   633 #endif
   634 };
   636 //------------------------------MachGotoNode-----------------------------------
   637 // Machine-specific versions of GotoNodes
   638 class MachGotoNode : public MachBranchNode {
   639 public:
   640   MachGotoNode() : MachBranchNode() {
   641     init_class_id(Class_MachGoto);
   642   }
   643 };
   645 //------------------------------MachFastLockNode-------------------------------------
   646 // Machine-specific versions of FastLockNodes
   647 class MachFastLockNode : public MachNode {
   648   virtual uint size_of() const { return sizeof(*this); } // Size is bigger
   649 public:
   650   BiasedLockingCounters* _counters;
   652   MachFastLockNode() : MachNode() {}
   653 };
   655 //------------------------------MachReturnNode--------------------------------
   656 // Machine-specific versions of subroutine returns
   657 class MachReturnNode : public MachNode {
   658   virtual uint size_of() const; // Size is bigger
   659 public:
   660   RegMask *_in_rms;             // Input register masks, set during allocation
   661   ReallocMark _nesting;         // assertion check for reallocations
   662   const TypePtr* _adr_type;     // memory effects of call or return
   663   MachReturnNode() : MachNode() {
   664     init_class_id(Class_MachReturn);
   665     _adr_type = TypePtr::BOTTOM; // the default: all of memory
   666   }
   668   void set_adr_type(const TypePtr* atp) { _adr_type = atp; }
   670   virtual const RegMask &in_RegMask(uint) const;
   671   virtual bool pinned() const { return true; };
   672   virtual const TypePtr *adr_type() const;
   673 };
   675 //------------------------------MachSafePointNode-----------------------------
   676 // Machine-specific versions of safepoints
   677 class MachSafePointNode : public MachReturnNode {
   678 public:
   679   OopMap*         _oop_map;     // Array of OopMap info (8-bit char) for GC
   680   JVMState*       _jvms;        // Pointer to list of JVM State Objects
   681   uint            _jvmadj;      // Extra delta to jvms indexes (mach. args)
   682   OopMap*         oop_map() const { return _oop_map; }
   683   void            set_oop_map(OopMap* om) { _oop_map = om; }
   685   MachSafePointNode() : MachReturnNode(), _oop_map(NULL), _jvms(NULL), _jvmadj(0) {
   686     init_class_id(Class_MachSafePoint);
   687   }
   689   virtual JVMState* jvms() const { return _jvms; }
   690   void set_jvms(JVMState* s) {
   691     _jvms = s;
   692   }
   693   virtual const Type    *bottom_type() const;
   695   virtual const RegMask &in_RegMask(uint) const;
   697   // Functionality from old debug nodes
   698   Node *returnadr() const { return in(TypeFunc::ReturnAdr); }
   699   Node *frameptr () const { return in(TypeFunc::FramePtr); }
   701   Node *local(const JVMState* jvms, uint idx) const {
   702     assert(verify_jvms(jvms), "jvms must match");
   703     return in(_jvmadj + jvms->locoff() + idx);
   704   }
   705   Node *stack(const JVMState* jvms, uint idx) const {
   706     assert(verify_jvms(jvms), "jvms must match");
   707     return in(_jvmadj + jvms->stkoff() + idx);
   708  }
   709   Node *monitor_obj(const JVMState* jvms, uint idx) const {
   710     assert(verify_jvms(jvms), "jvms must match");
   711     return in(_jvmadj + jvms->monitor_obj_offset(idx));
   712   }
   713   Node *monitor_box(const JVMState* jvms, uint idx) const {
   714     assert(verify_jvms(jvms), "jvms must match");
   715     return in(_jvmadj + jvms->monitor_box_offset(idx));
   716   }
   717   void  set_local(const JVMState* jvms, uint idx, Node *c) {
   718     assert(verify_jvms(jvms), "jvms must match");
   719     set_req(_jvmadj + jvms->locoff() + idx, c);
   720   }
   721   void  set_stack(const JVMState* jvms, uint idx, Node *c) {
   722     assert(verify_jvms(jvms), "jvms must match");
   723     set_req(_jvmadj + jvms->stkoff() + idx, c);
   724   }
   725   void  set_monitor(const JVMState* jvms, uint idx, Node *c) {
   726     assert(verify_jvms(jvms), "jvms must match");
   727     set_req(_jvmadj + jvms->monoff() + idx, c);
   728   }
   729 };
   731 //------------------------------MachCallNode----------------------------------
   732 // Machine-specific versions of subroutine calls
   733 class MachCallNode : public MachSafePointNode {
   734 protected:
   735   virtual uint hash() const { return NO_HASH; }  // CFG nodes do not hash
   736   virtual uint cmp( const Node &n ) const;
   737   virtual uint size_of() const = 0; // Size is bigger
   738 public:
   739   const TypeFunc *_tf;        // Function type
   740   address      _entry_point;  // Address of the method being called
   741   float        _cnt;          // Estimate of number of times called
   742   uint         _argsize;      // Size of argument block on stack
   744   const TypeFunc* tf()        const { return _tf; }
   745   const address entry_point() const { return _entry_point; }
   746   const float   cnt()         const { return _cnt; }
   747   uint argsize()              const { return _argsize; }
   749   void set_tf(const TypeFunc* tf) { _tf = tf; }
   750   void set_entry_point(address p) { _entry_point = p; }
   751   void set_cnt(float c)           { _cnt = c; }
   752   void set_argsize(int s)         { _argsize = s; }
   754   MachCallNode() : MachSafePointNode() {
   755     init_class_id(Class_MachCall);
   756   }
   758   virtual const Type *bottom_type() const;
   759   virtual bool  pinned() const { return false; }
   760   virtual const Type *Value( PhaseTransform *phase ) const;
   761   virtual const RegMask &in_RegMask(uint) const;
   762   virtual int ret_addr_offset() { return 0; }
   764   bool returns_long() const { return tf()->return_type() == T_LONG; }
   765   bool return_value_is_used() const;
   766 #ifndef PRODUCT
   767   virtual void dump_spec(outputStream *st) const;
   768 #endif
   769 };
   771 //------------------------------MachCallJavaNode------------------------------
   772 // "Base" class for machine-specific versions of subroutine calls
   773 class MachCallJavaNode : public MachCallNode {
   774 protected:
   775   virtual uint cmp( const Node &n ) const;
   776   virtual uint size_of() const; // Size is bigger
   777 public:
   778   ciMethod* _method;             // Method being direct called
   779   int        _bci;               // Byte Code index of call byte code
   780   bool       _optimized_virtual; // Tells if node is a static call or an optimized virtual
   781   bool       _method_handle_invoke;   // Tells if the call has to preserve SP
   782   MachCallJavaNode() : MachCallNode() {
   783     init_class_id(Class_MachCallJava);
   784   }
   786   virtual const RegMask &in_RegMask(uint) const;
   788 #ifndef PRODUCT
   789   virtual void dump_spec(outputStream *st) const;
   790 #endif
   791 };
   793 //------------------------------MachCallStaticJavaNode------------------------
   794 // Machine-specific versions of monomorphic subroutine calls
   795 class MachCallStaticJavaNode : public MachCallJavaNode {
   796   virtual uint cmp( const Node &n ) const;
   797   virtual uint size_of() const; // Size is bigger
   798 public:
   799   const char *_name;            // Runtime wrapper name
   800   MachCallStaticJavaNode() : MachCallJavaNode() {
   801     init_class_id(Class_MachCallStaticJava);
   802   }
   804   // If this is an uncommon trap, return the request code, else zero.
   805   int uncommon_trap_request() const;
   807   virtual int ret_addr_offset();
   808 #ifndef PRODUCT
   809   virtual void dump_spec(outputStream *st) const;
   810   void dump_trap_args(outputStream *st) const;
   811 #endif
   812 };
   814 //------------------------------MachCallDynamicJavaNode------------------------
   815 // Machine-specific versions of possibly megamorphic subroutine calls
   816 class MachCallDynamicJavaNode : public MachCallJavaNode {
   817 public:
   818   int _vtable_index;
   819   MachCallDynamicJavaNode() : MachCallJavaNode() {
   820     init_class_id(Class_MachCallDynamicJava);
   821     DEBUG_ONLY(_vtable_index = -99);  // throw an assert if uninitialized
   822   }
   823   virtual int ret_addr_offset();
   824 #ifndef PRODUCT
   825   virtual void dump_spec(outputStream *st) const;
   826 #endif
   827 };
   829 //------------------------------MachCallRuntimeNode----------------------------
   830 // Machine-specific versions of subroutine calls
   831 class MachCallRuntimeNode : public MachCallNode {
   832   virtual uint cmp( const Node &n ) const;
   833   virtual uint size_of() const; // Size is bigger
   834 public:
   835   const char *_name;            // Printable name, if _method is NULL
   836   MachCallRuntimeNode() : MachCallNode() {
   837     init_class_id(Class_MachCallRuntime);
   838   }
   839   virtual int ret_addr_offset();
   840 #ifndef PRODUCT
   841   virtual void dump_spec(outputStream *st) const;
   842 #endif
   843 };
   845 class MachCallLeafNode: public MachCallRuntimeNode {
   846 public:
   847   MachCallLeafNode() : MachCallRuntimeNode() {
   848     init_class_id(Class_MachCallLeaf);
   849   }
   850 };
   852 //------------------------------MachHaltNode-----------------------------------
   853 // Machine-specific versions of halt nodes
   854 class MachHaltNode : public MachReturnNode {
   855 public:
   856   virtual JVMState* jvms() const;
   857 };
   860 //------------------------------MachTempNode-----------------------------------
   861 // Node used by the adlc to construct inputs to represent temporary registers
   862 class MachTempNode : public MachNode {
   863 private:
   864   MachOper *_opnd_array[1];
   866 public:
   867   virtual const RegMask &out_RegMask() const { return *_opnds[0]->in_RegMask(0); }
   868   virtual uint rule() const { return 9999999; }
   869   virtual void emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const {}
   871   MachTempNode(MachOper* oper) {
   872     init_class_id(Class_MachTemp);
   873     _num_opnds = 1;
   874     _opnds = _opnd_array;
   875     add_req(NULL);
   876     _opnds[0] = oper;
   877   }
   878   virtual uint size_of() const { return sizeof(MachTempNode); }
   880 #ifndef PRODUCT
   881   virtual void format(PhaseRegAlloc *, outputStream *st ) const {}
   882   virtual const char *Name() const { return "MachTemp";}
   883 #endif
   884 };
   888 //------------------------------labelOper--------------------------------------
   889 // Machine-independent version of label operand
   890 class labelOper : public MachOper {
   891 private:
   892   virtual uint           num_edges() const { return 0; }
   893 public:
   894   // Supported for fixed size branches
   895   Label* _label;                // Label for branch(es)
   897   uint _block_num;
   899   labelOper() : _block_num(0), _label(0) {}
   901   labelOper(Label* label, uint block_num) : _label(label), _block_num(block_num) {}
   903   labelOper(labelOper* l) : _label(l->_label) , _block_num(l->_block_num) {}
   905   virtual MachOper *clone(Compile* C) const;
   907   virtual Label *label() const { assert(_label != NULL, "need Label"); return _label; }
   909   virtual uint           opcode() const;
   911   virtual uint           hash()   const;
   912   virtual uint           cmp( const MachOper &oper ) const;
   913 #ifndef PRODUCT
   914   virtual const char    *Name()   const { return "Label";}
   916   virtual void int_format(PhaseRegAlloc *ra, const MachNode *node, outputStream *st) const;
   917   virtual void ext_format(PhaseRegAlloc *ra, const MachNode *node, int idx, outputStream *st) const { int_format( ra, node, st ); }
   918 #endif
   919 };
   922 //------------------------------methodOper--------------------------------------
   923 // Machine-independent version of method operand
   924 class methodOper : public MachOper {
   925 private:
   926   virtual uint           num_edges() const { return 0; }
   927 public:
   928   intptr_t _method;             // Address of method
   929   methodOper() :   _method(0) {}
   930   methodOper(intptr_t method) : _method(method)  {}
   932   virtual MachOper *clone(Compile* C) const;
   934   virtual intptr_t method() const { return _method; }
   936   virtual uint           opcode() const;
   938   virtual uint           hash()   const;
   939   virtual uint           cmp( const MachOper &oper ) const;
   940 #ifndef PRODUCT
   941   virtual const char    *Name()   const { return "Method";}
   943   virtual void int_format(PhaseRegAlloc *ra, const MachNode *node, outputStream *st) const;
   944   virtual void ext_format(PhaseRegAlloc *ra, const MachNode *node, int idx, outputStream *st) const { int_format( ra, node, st ); }
   945 #endif
   946 };
   948 #endif // SHARE_VM_OPTO_MACHNODE_HPP

mercurial