src/share/vm/opto/regalloc.hpp

Thu, 21 Jul 2011 11:25:07 -0700

author
kvn
date
Thu, 21 Jul 2011 11:25:07 -0700
changeset 3037
3d42f82cd811
parent 2314
f95d63e2154a
child 3138
f6f3bb0ee072
permissions
-rw-r--r--

7063628: Use cbcond on T4
Summary: Add new short branch instruction to Hotspot sparc assembler.
Reviewed-by: never, twisti, jrose

     1 /*
     2  * Copyright (c) 2000, 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_OPTO_REGALLOC_HPP
    26 #define SHARE_VM_OPTO_REGALLOC_HPP
    28 #include "code/vmreg.hpp"
    29 #include "opto/block.hpp"
    30 #include "opto/matcher.hpp"
    31 #include "opto/phase.hpp"
    33 class Node;
    34 class Matcher;
    35 class PhaseCFG;
    37 #define  MAX_REG_ALLOCATORS   10
    39 //------------------------------PhaseRegAlloc------------------------------------
    40 // Abstract register allocator
    41 class PhaseRegAlloc : public Phase {
    42   static void (*_alloc_statistics[MAX_REG_ALLOCATORS])();
    43   static int _num_allocators;
    45 protected:
    46   OptoRegPair  *_node_regs;
    47   uint         _node_regs_max_index;
    48   VectorSet    _node_oops;         // Mapping from node indices to oopiness
    50   void alloc_node_regs(int size);  // allocate _node_regs table with at least "size" elements
    52   PhaseRegAlloc( uint unique, PhaseCFG &cfg, Matcher &matcher,
    53                  void (*pr_stats)());
    54 public:
    55   PhaseCFG &_cfg;               // Control flow graph
    56   uint _framesize;              // Size of frame in stack-slots. not counting preserve area
    57   OptoReg::Name _max_reg;       // Past largest register seen
    58   Matcher &_matcher;            // Convert Ideal to MachNodes
    59   uint node_regs_max_index() const { return _node_regs_max_index; }
    61   // Get the register associated with the Node
    62   OptoReg::Name get_reg_first( const Node *n ) const {
    63     debug_only( if( n->_idx >= _node_regs_max_index ) n->dump(); );
    64     assert( n->_idx < _node_regs_max_index, "Exceeded _node_regs array");
    65     return _node_regs[n->_idx].first();
    66   }
    67   OptoReg::Name get_reg_second( const Node *n ) const {
    68     debug_only( if( n->_idx >= _node_regs_max_index ) n->dump(); );
    69     assert( n->_idx < _node_regs_max_index, "Exceeded _node_regs array");
    70     return _node_regs[n->_idx].second();
    71   }
    73   // Do all the real work of allocate
    74   virtual void Register_Allocate() = 0;
    77   // notify the register allocator that "node" is a new reference
    78   // to the value produced by "old_node"
    79   virtual void add_reference( const Node *node, const Node *old_node) = 0;
    82   // Set the register associated with a new Node
    83   void set_bad( uint idx ) {
    84     assert( idx < _node_regs_max_index, "Exceeded _node_regs array");
    85     _node_regs[idx].set_bad();
    86   }
    87   void set1( uint idx, OptoReg::Name reg ) {
    88     assert( idx < _node_regs_max_index, "Exceeded _node_regs array");
    89     _node_regs[idx].set1(reg);
    90   }
    91   void set2( uint idx, OptoReg::Name reg ) {
    92     assert( idx < _node_regs_max_index, "Exceeded _node_regs array");
    93     _node_regs[idx].set2(reg);
    94   }
    95   void set_pair( uint idx, OptoReg::Name hi, OptoReg::Name lo ) {
    96     assert( idx < _node_regs_max_index, "Exceeded _node_regs array");
    97     _node_regs[idx].set_pair(hi, lo);
    98   }
    99   void set_ptr( uint idx, OptoReg::Name reg ) {
   100     assert( idx < _node_regs_max_index, "Exceeded _node_regs array");
   101     _node_regs[idx].set_ptr(reg);
   102   }
   103   // Set and query if a node produces an oop
   104   void set_oop( const Node *n, bool );
   105   bool is_oop( const Node *n ) const;
   107   // Convert a register number to a stack offset
   108   int reg2offset          ( OptoReg::Name reg ) const;
   109   int reg2offset_unchecked( OptoReg::Name reg ) const;
   111   // Convert a stack offset to a register number
   112   OptoReg::Name offset2reg( int stk_offset ) const;
   114   // Get the register encoding associated with the Node
   115   int get_encode( const Node *n ) const {
   116     assert( n->_idx < _node_regs_max_index, "Exceeded _node_regs array");
   117     OptoReg::Name first = _node_regs[n->_idx].first();
   118     OptoReg::Name second = _node_regs[n->_idx].second();
   119     assert( !OptoReg::is_valid(second) || second == first+1, "" );
   120     assert(OptoReg::is_reg(first), "out of range");
   121     return Matcher::_regEncode[first];
   122   }
   124   // Platform dependent hook for actions prior to allocation
   125   void  pd_preallocate_hook();
   127 #ifdef ASSERT
   128   // Platform dependent hook for verification after allocation.  Will
   129   // only get called when compiling with asserts.
   130   void  pd_postallocate_verify_hook();
   131 #endif
   133 #ifndef PRODUCT
   134   static int _total_framesize;
   135   static int _max_framesize;
   137   virtual void dump_frame() const = 0;
   138   virtual char *dump_register( const Node *n, char *buf  ) const = 0;
   139   static void print_statistics();
   140 #endif
   141 };
   143 #endif // SHARE_VM_OPTO_REGALLOC_HPP

mercurial