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

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

mercurial