src/share/vm/opto/regalloc.hpp

Wed, 27 Apr 2016 01:25:04 +0800

author
aoqi
date
Wed, 27 Apr 2016 01:25:04 +0800
changeset 0
f90c822e73f8
child 6876
710a3c8b516e
permissions
-rw-r--r--

Initial load
http://hg.openjdk.java.net/jdk8u/jdk8u/hotspot/
changeset: 6782:28b50d07f6f8
tag: jdk8u25-b17

aoqi@0 1 /*
aoqi@0 2 * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
aoqi@0 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
aoqi@0 4 *
aoqi@0 5 * This code is free software; you can redistribute it and/or modify it
aoqi@0 6 * under the terms of the GNU General Public License version 2 only, as
aoqi@0 7 * published by the Free Software Foundation.
aoqi@0 8 *
aoqi@0 9 * This code is distributed in the hope that it will be useful, but WITHOUT
aoqi@0 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
aoqi@0 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
aoqi@0 12 * version 2 for more details (a copy is included in the LICENSE file that
aoqi@0 13 * accompanied this code).
aoqi@0 14 *
aoqi@0 15 * You should have received a copy of the GNU General Public License version
aoqi@0 16 * 2 along with this work; if not, write to the Free Software Foundation,
aoqi@0 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
aoqi@0 18 *
aoqi@0 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
aoqi@0 20 * or visit www.oracle.com if you need additional information or have any
aoqi@0 21 * questions.
aoqi@0 22 *
aoqi@0 23 */
aoqi@0 24
aoqi@0 25 #ifndef SHARE_VM_OPTO_REGALLOC_HPP
aoqi@0 26 #define SHARE_VM_OPTO_REGALLOC_HPP
aoqi@0 27
aoqi@0 28 #include "code/vmreg.hpp"
aoqi@0 29 #include "opto/block.hpp"
aoqi@0 30 #include "opto/matcher.hpp"
aoqi@0 31 #include "opto/phase.hpp"
aoqi@0 32
aoqi@0 33 class Node;
aoqi@0 34 class Matcher;
aoqi@0 35 class PhaseCFG;
aoqi@0 36
aoqi@0 37 #define MAX_REG_ALLOCATORS 10
aoqi@0 38
aoqi@0 39 //------------------------------PhaseRegAlloc------------------------------------
aoqi@0 40 // Abstract register allocator
aoqi@0 41 class PhaseRegAlloc : public Phase {
aoqi@0 42 friend class VMStructs;
aoqi@0 43 static void (*_alloc_statistics[MAX_REG_ALLOCATORS])();
aoqi@0 44 static int _num_allocators;
aoqi@0 45
aoqi@0 46 protected:
aoqi@0 47 OptoRegPair *_node_regs;
aoqi@0 48 uint _node_regs_max_index;
aoqi@0 49 VectorSet _node_oops; // Mapping from node indices to oopiness
aoqi@0 50
aoqi@0 51 void alloc_node_regs(int size); // allocate _node_regs table with at least "size" elements
aoqi@0 52
aoqi@0 53 PhaseRegAlloc( uint unique, PhaseCFG &cfg, Matcher &matcher,
aoqi@0 54 void (*pr_stats)());
aoqi@0 55 public:
aoqi@0 56 PhaseCFG &_cfg; // Control flow graph
aoqi@0 57 uint _framesize; // Size of frame in stack-slots. not counting preserve area
aoqi@0 58 OptoReg::Name _max_reg; // Past largest register seen
aoqi@0 59 Matcher &_matcher; // Convert Ideal to MachNodes
aoqi@0 60 uint node_regs_max_index() const { return _node_regs_max_index; }
aoqi@0 61
aoqi@0 62 // Get the register associated with the Node
aoqi@0 63 OptoReg::Name get_reg_first( const Node *n ) const {
aoqi@0 64 debug_only( if( n->_idx >= _node_regs_max_index ) n->dump(); );
aoqi@0 65 assert( n->_idx < _node_regs_max_index, "Exceeded _node_regs array");
aoqi@0 66 return _node_regs[n->_idx].first();
aoqi@0 67 }
aoqi@0 68 OptoReg::Name get_reg_second( const Node *n ) const {
aoqi@0 69 debug_only( if( n->_idx >= _node_regs_max_index ) n->dump(); );
aoqi@0 70 assert( n->_idx < _node_regs_max_index, "Exceeded _node_regs array");
aoqi@0 71 return _node_regs[n->_idx].second();
aoqi@0 72 }
aoqi@0 73
aoqi@0 74 // Do all the real work of allocate
aoqi@0 75 virtual void Register_Allocate() = 0;
aoqi@0 76
aoqi@0 77
aoqi@0 78 // notify the register allocator that "node" is a new reference
aoqi@0 79 // to the value produced by "old_node"
aoqi@0 80 virtual void add_reference( const Node *node, const Node *old_node) = 0;
aoqi@0 81
aoqi@0 82
aoqi@0 83 // Set the register associated with a new Node
aoqi@0 84 void set_bad( uint idx ) {
aoqi@0 85 assert( idx < _node_regs_max_index, "Exceeded _node_regs array");
aoqi@0 86 _node_regs[idx].set_bad();
aoqi@0 87 }
aoqi@0 88 void set1( uint idx, OptoReg::Name reg ) {
aoqi@0 89 assert( idx < _node_regs_max_index, "Exceeded _node_regs array");
aoqi@0 90 _node_regs[idx].set1(reg);
aoqi@0 91 }
aoqi@0 92 void set2( uint idx, OptoReg::Name reg ) {
aoqi@0 93 assert( idx < _node_regs_max_index, "Exceeded _node_regs array");
aoqi@0 94 _node_regs[idx].set2(reg);
aoqi@0 95 }
aoqi@0 96 void set_pair( uint idx, OptoReg::Name hi, OptoReg::Name lo ) {
aoqi@0 97 assert( idx < _node_regs_max_index, "Exceeded _node_regs array");
aoqi@0 98 _node_regs[idx].set_pair(hi, lo);
aoqi@0 99 }
aoqi@0 100 void set_ptr( uint idx, OptoReg::Name reg ) {
aoqi@0 101 assert( idx < _node_regs_max_index, "Exceeded _node_regs array");
aoqi@0 102 _node_regs[idx].set_ptr(reg);
aoqi@0 103 }
aoqi@0 104 // Set and query if a node produces an oop
aoqi@0 105 void set_oop( const Node *n, bool );
aoqi@0 106 bool is_oop( const Node *n ) const;
aoqi@0 107
aoqi@0 108 // Convert a register number to a stack offset
aoqi@0 109 int reg2offset ( OptoReg::Name reg ) const;
aoqi@0 110 int reg2offset_unchecked( OptoReg::Name reg ) const;
aoqi@0 111
aoqi@0 112 // Convert a stack offset to a register number
aoqi@0 113 OptoReg::Name offset2reg( int stk_offset ) const;
aoqi@0 114
aoqi@0 115 // Get the register encoding associated with the Node
aoqi@0 116 int get_encode(const Node *n) const {
aoqi@0 117 assert( n->_idx < _node_regs_max_index, "Exceeded _node_regs array");
aoqi@0 118 OptoReg::Name first = _node_regs[n->_idx].first();
aoqi@0 119 OptoReg::Name second = _node_regs[n->_idx].second();
aoqi@0 120 assert( !OptoReg::is_valid(second) || second == first+1, "" );
aoqi@0 121 assert(OptoReg::is_reg(first), "out of range");
aoqi@0 122 return Matcher::_regEncode[first];
aoqi@0 123 }
aoqi@0 124
aoqi@0 125 #ifndef PRODUCT
aoqi@0 126 static int _total_framesize;
aoqi@0 127 static int _max_framesize;
aoqi@0 128
aoqi@0 129 virtual void dump_frame() const = 0;
aoqi@0 130 virtual char *dump_register( const Node *n, char *buf ) const = 0;
aoqi@0 131 static void print_statistics();
aoqi@0 132 #endif
aoqi@0 133 };
aoqi@0 134
aoqi@0 135 #endif // SHARE_VM_OPTO_REGALLOC_HPP

mercurial