src/share/vm/opto/regalloc.hpp

changeset 0
f90c822e73f8
child 6876
710a3c8b516e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/share/vm/opto/regalloc.hpp	Wed Apr 27 01:25:04 2016 +0800
     1.3 @@ -0,0 +1,135 @@
     1.4 +/*
     1.5 + * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
     1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.7 + *
     1.8 + * This code is free software; you can redistribute it and/or modify it
     1.9 + * under the terms of the GNU General Public License version 2 only, as
    1.10 + * published by the Free Software Foundation.
    1.11 + *
    1.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
    1.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1.14 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    1.15 + * version 2 for more details (a copy is included in the LICENSE file that
    1.16 + * accompanied this code).
    1.17 + *
    1.18 + * You should have received a copy of the GNU General Public License version
    1.19 + * 2 along with this work; if not, write to the Free Software Foundation,
    1.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    1.21 + *
    1.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    1.23 + * or visit www.oracle.com if you need additional information or have any
    1.24 + * questions.
    1.25 + *
    1.26 + */
    1.27 +
    1.28 +#ifndef SHARE_VM_OPTO_REGALLOC_HPP
    1.29 +#define SHARE_VM_OPTO_REGALLOC_HPP
    1.30 +
    1.31 +#include "code/vmreg.hpp"
    1.32 +#include "opto/block.hpp"
    1.33 +#include "opto/matcher.hpp"
    1.34 +#include "opto/phase.hpp"
    1.35 +
    1.36 +class Node;
    1.37 +class Matcher;
    1.38 +class PhaseCFG;
    1.39 +
    1.40 +#define  MAX_REG_ALLOCATORS   10
    1.41 +
    1.42 +//------------------------------PhaseRegAlloc------------------------------------
    1.43 +// Abstract register allocator
    1.44 +class PhaseRegAlloc : public Phase {
    1.45 +  friend class VMStructs;
    1.46 +  static void (*_alloc_statistics[MAX_REG_ALLOCATORS])();
    1.47 +  static int _num_allocators;
    1.48 +
    1.49 +protected:
    1.50 +  OptoRegPair  *_node_regs;
    1.51 +  uint         _node_regs_max_index;
    1.52 +  VectorSet    _node_oops;         // Mapping from node indices to oopiness
    1.53 +
    1.54 +  void alloc_node_regs(int size);  // allocate _node_regs table with at least "size" elements
    1.55 +
    1.56 +  PhaseRegAlloc( uint unique, PhaseCFG &cfg, Matcher &matcher,
    1.57 +                 void (*pr_stats)());
    1.58 +public:
    1.59 +  PhaseCFG &_cfg;               // Control flow graph
    1.60 +  uint _framesize;              // Size of frame in stack-slots. not counting preserve area
    1.61 +  OptoReg::Name _max_reg;       // Past largest register seen
    1.62 +  Matcher &_matcher;            // Convert Ideal to MachNodes
    1.63 +  uint node_regs_max_index() const { return _node_regs_max_index; }
    1.64 +
    1.65 +  // Get the register associated with the Node
    1.66 +  OptoReg::Name get_reg_first( const Node *n ) const {
    1.67 +    debug_only( if( n->_idx >= _node_regs_max_index ) n->dump(); );
    1.68 +    assert( n->_idx < _node_regs_max_index, "Exceeded _node_regs array");
    1.69 +    return _node_regs[n->_idx].first();
    1.70 +  }
    1.71 +  OptoReg::Name get_reg_second( const Node *n ) const {
    1.72 +    debug_only( if( n->_idx >= _node_regs_max_index ) n->dump(); );
    1.73 +    assert( n->_idx < _node_regs_max_index, "Exceeded _node_regs array");
    1.74 +    return _node_regs[n->_idx].second();
    1.75 +  }
    1.76 +
    1.77 +  // Do all the real work of allocate
    1.78 +  virtual void Register_Allocate() = 0;
    1.79 +
    1.80 +
    1.81 +  // notify the register allocator that "node" is a new reference
    1.82 +  // to the value produced by "old_node"
    1.83 +  virtual void add_reference( const Node *node, const Node *old_node) = 0;
    1.84 +
    1.85 +
    1.86 +  // Set the register associated with a new Node
    1.87 +  void set_bad( uint idx ) {
    1.88 +    assert( idx < _node_regs_max_index, "Exceeded _node_regs array");
    1.89 +    _node_regs[idx].set_bad();
    1.90 +  }
    1.91 +  void set1( uint idx, OptoReg::Name reg ) {
    1.92 +    assert( idx < _node_regs_max_index, "Exceeded _node_regs array");
    1.93 +    _node_regs[idx].set1(reg);
    1.94 +  }
    1.95 +  void set2( uint idx, OptoReg::Name reg ) {
    1.96 +    assert( idx < _node_regs_max_index, "Exceeded _node_regs array");
    1.97 +    _node_regs[idx].set2(reg);
    1.98 +  }
    1.99 +  void set_pair( uint idx, OptoReg::Name hi, OptoReg::Name lo ) {
   1.100 +    assert( idx < _node_regs_max_index, "Exceeded _node_regs array");
   1.101 +    _node_regs[idx].set_pair(hi, lo);
   1.102 +  }
   1.103 +  void set_ptr( uint idx, OptoReg::Name reg ) {
   1.104 +    assert( idx < _node_regs_max_index, "Exceeded _node_regs array");
   1.105 +    _node_regs[idx].set_ptr(reg);
   1.106 +  }
   1.107 +  // Set and query if a node produces an oop
   1.108 +  void set_oop( const Node *n, bool );
   1.109 +  bool is_oop( const Node *n ) const;
   1.110 +
   1.111 +  // Convert a register number to a stack offset
   1.112 +  int reg2offset          ( OptoReg::Name reg ) const;
   1.113 +  int reg2offset_unchecked( OptoReg::Name reg ) const;
   1.114 +
   1.115 +  // Convert a stack offset to a register number
   1.116 +  OptoReg::Name offset2reg( int stk_offset ) const;
   1.117 +
   1.118 +  // Get the register encoding associated with the Node
   1.119 +  int get_encode(const Node *n) const {
   1.120 +    assert( n->_idx < _node_regs_max_index, "Exceeded _node_regs array");
   1.121 +    OptoReg::Name first = _node_regs[n->_idx].first();
   1.122 +    OptoReg::Name second = _node_regs[n->_idx].second();
   1.123 +    assert( !OptoReg::is_valid(second) || second == first+1, "" );
   1.124 +    assert(OptoReg::is_reg(first), "out of range");
   1.125 +    return Matcher::_regEncode[first];
   1.126 +  }
   1.127 +
   1.128 +#ifndef PRODUCT
   1.129 +  static int _total_framesize;
   1.130 +  static int _max_framesize;
   1.131 +
   1.132 +  virtual void dump_frame() const = 0;
   1.133 +  virtual char *dump_register( const Node *n, char *buf  ) const = 0;
   1.134 +  static void print_statistics();
   1.135 +#endif
   1.136 +};
   1.137 +
   1.138 +#endif // SHARE_VM_OPTO_REGALLOC_HPP

mercurial