annotate src/share/vm/opto/regmask.cpp @ 4710:41406797186b

7113012: G1: rename not-fully-young GCs as "mixed" Summary: Renamed partially-young GCs as mixed and fully-young GCs as young. Change all external output that includes those terms (GC log and GC ergo log) as well as any comments, fields, methods, etc. The changeset also includes very minor code tidying up (added some curly brackets). Reviewed-by: johnc, brutisso
author tonyp
date Fri, 16 Dec 2011 02:14:27 -0500
parents 1d1603768966
children 8c92982cbbc4
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
2426
1d1603768966 7010070: Update all 2010 Oracle-changed OpenJDK files to have the proper copyright dates - second pass
trims
parents: 2192
diff changeset
2 * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
21 * questions.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
25 #include "precompiled.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
26 #include "opto/compile.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
27 #include "opto/regmask.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
28 #ifdef TARGET_ARCH_MODEL_x86_32
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
29 # include "adfiles/ad_x86_32.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
30 #endif
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
31 #ifdef TARGET_ARCH_MODEL_x86_64
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
32 # include "adfiles/ad_x86_64.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
33 #endif
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
34 #ifdef TARGET_ARCH_MODEL_sparc
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
35 # include "adfiles/ad_sparc.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
36 #endif
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
37 #ifdef TARGET_ARCH_MODEL_zero
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
38 # include "adfiles/ad_zero.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
39 #endif
2192
b92c45f2bc75 7016023: Enable building ARM and PPC from src/closed repository
bobv
parents: 1972
diff changeset
40 #ifdef TARGET_ARCH_MODEL_arm
b92c45f2bc75 7016023: Enable building ARM and PPC from src/closed repository
bobv
parents: 1972
diff changeset
41 # include "adfiles/ad_arm.hpp"
b92c45f2bc75 7016023: Enable building ARM and PPC from src/closed repository
bobv
parents: 1972
diff changeset
42 #endif
b92c45f2bc75 7016023: Enable building ARM and PPC from src/closed repository
bobv
parents: 1972
diff changeset
43 #ifdef TARGET_ARCH_MODEL_ppc
b92c45f2bc75 7016023: Enable building ARM and PPC from src/closed repository
bobv
parents: 1972
diff changeset
44 # include "adfiles/ad_ppc.hpp"
b92c45f2bc75 7016023: Enable building ARM and PPC from src/closed repository
bobv
parents: 1972
diff changeset
45 #endif
0
a61af66fc99e Initial load
duke
parents:
diff changeset
46
a61af66fc99e Initial load
duke
parents:
diff changeset
47 #define RM_SIZE _RM_SIZE /* a constant private to the class RegMask */
a61af66fc99e Initial load
duke
parents:
diff changeset
48
a61af66fc99e Initial load
duke
parents:
diff changeset
49 //-------------Non-zero bit search methods used by RegMask---------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
50 // Find lowest 1, or return 32 if empty
a61af66fc99e Initial load
duke
parents:
diff changeset
51 int find_lowest_bit( uint32 mask ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
52 int n = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
53 if( (mask & 0xffff) == 0 ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
54 mask >>= 16;
a61af66fc99e Initial load
duke
parents:
diff changeset
55 n += 16;
a61af66fc99e Initial load
duke
parents:
diff changeset
56 }
a61af66fc99e Initial load
duke
parents:
diff changeset
57 if( (mask & 0xff) == 0 ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
58 mask >>= 8;
a61af66fc99e Initial load
duke
parents:
diff changeset
59 n += 8;
a61af66fc99e Initial load
duke
parents:
diff changeset
60 }
a61af66fc99e Initial load
duke
parents:
diff changeset
61 if( (mask & 0xf) == 0 ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
62 mask >>= 4;
a61af66fc99e Initial load
duke
parents:
diff changeset
63 n += 4;
a61af66fc99e Initial load
duke
parents:
diff changeset
64 }
a61af66fc99e Initial load
duke
parents:
diff changeset
65 if( (mask & 0x3) == 0 ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
66 mask >>= 2;
a61af66fc99e Initial load
duke
parents:
diff changeset
67 n += 2;
a61af66fc99e Initial load
duke
parents:
diff changeset
68 }
a61af66fc99e Initial load
duke
parents:
diff changeset
69 if( (mask & 0x1) == 0 ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
70 mask >>= 1;
a61af66fc99e Initial load
duke
parents:
diff changeset
71 n += 1;
a61af66fc99e Initial load
duke
parents:
diff changeset
72 }
a61af66fc99e Initial load
duke
parents:
diff changeset
73 if( mask == 0 ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
74 n = 32;
a61af66fc99e Initial load
duke
parents:
diff changeset
75 }
a61af66fc99e Initial load
duke
parents:
diff changeset
76 return n;
a61af66fc99e Initial load
duke
parents:
diff changeset
77 }
a61af66fc99e Initial load
duke
parents:
diff changeset
78
a61af66fc99e Initial load
duke
parents:
diff changeset
79 // Find highest 1, or return 32 if empty
a61af66fc99e Initial load
duke
parents:
diff changeset
80 int find_hihghest_bit( uint32 mask ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
81 int n = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
82 if( mask > 0xffff ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
83 mask >>= 16;
a61af66fc99e Initial load
duke
parents:
diff changeset
84 n += 16;
a61af66fc99e Initial load
duke
parents:
diff changeset
85 }
a61af66fc99e Initial load
duke
parents:
diff changeset
86 if( mask > 0xff ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
87 mask >>= 8;
a61af66fc99e Initial load
duke
parents:
diff changeset
88 n += 8;
a61af66fc99e Initial load
duke
parents:
diff changeset
89 }
a61af66fc99e Initial load
duke
parents:
diff changeset
90 if( mask > 0xf ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
91 mask >>= 4;
a61af66fc99e Initial load
duke
parents:
diff changeset
92 n += 4;
a61af66fc99e Initial load
duke
parents:
diff changeset
93 }
a61af66fc99e Initial load
duke
parents:
diff changeset
94 if( mask > 0x3 ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
95 mask >>= 2;
a61af66fc99e Initial load
duke
parents:
diff changeset
96 n += 2;
a61af66fc99e Initial load
duke
parents:
diff changeset
97 }
a61af66fc99e Initial load
duke
parents:
diff changeset
98 if( mask > 0x1 ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
99 mask >>= 1;
a61af66fc99e Initial load
duke
parents:
diff changeset
100 n += 1;
a61af66fc99e Initial load
duke
parents:
diff changeset
101 }
a61af66fc99e Initial load
duke
parents:
diff changeset
102 if( mask == 0 ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
103 n = 32;
a61af66fc99e Initial load
duke
parents:
diff changeset
104 }
a61af66fc99e Initial load
duke
parents:
diff changeset
105 return n;
a61af66fc99e Initial load
duke
parents:
diff changeset
106 }
a61af66fc99e Initial load
duke
parents:
diff changeset
107
a61af66fc99e Initial load
duke
parents:
diff changeset
108 //------------------------------dump-------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
109
a61af66fc99e Initial load
duke
parents:
diff changeset
110 #ifndef PRODUCT
a61af66fc99e Initial load
duke
parents:
diff changeset
111 void OptoReg::dump( int r ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
112 switch( r ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
113 case Special: tty->print("r---"); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
114 case Bad: tty->print("rBAD"); break;
a61af66fc99e Initial load
duke
parents:
diff changeset
115 default:
a61af66fc99e Initial load
duke
parents:
diff changeset
116 if( r < _last_Mach_Reg ) tty->print(Matcher::regName[r]);
a61af66fc99e Initial load
duke
parents:
diff changeset
117 else tty->print("rS%d",r);
a61af66fc99e Initial load
duke
parents:
diff changeset
118 break;
a61af66fc99e Initial load
duke
parents:
diff changeset
119 }
a61af66fc99e Initial load
duke
parents:
diff changeset
120 }
a61af66fc99e Initial load
duke
parents:
diff changeset
121 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
122
a61af66fc99e Initial load
duke
parents:
diff changeset
123
a61af66fc99e Initial load
duke
parents:
diff changeset
124 //=============================================================================
a61af66fc99e Initial load
duke
parents:
diff changeset
125 const RegMask RegMask::Empty(
a61af66fc99e Initial load
duke
parents:
diff changeset
126 # define BODY(I) 0,
a61af66fc99e Initial load
duke
parents:
diff changeset
127 FORALL_BODY
a61af66fc99e Initial load
duke
parents:
diff changeset
128 # undef BODY
a61af66fc99e Initial load
duke
parents:
diff changeset
129 0
a61af66fc99e Initial load
duke
parents:
diff changeset
130 );
a61af66fc99e Initial load
duke
parents:
diff changeset
131
a61af66fc99e Initial load
duke
parents:
diff changeset
132 //------------------------------find_first_pair--------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
133 // Find the lowest-numbered register pair in the mask. Return the
a61af66fc99e Initial load
duke
parents:
diff changeset
134 // HIGHEST register number in the pair, or BAD if no pairs.
a61af66fc99e Initial load
duke
parents:
diff changeset
135 OptoReg::Name RegMask::find_first_pair() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
136 VerifyPairs();
a61af66fc99e Initial load
duke
parents:
diff changeset
137 for( int i = 0; i < RM_SIZE; i++ ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
138 if( _A[i] ) { // Found some bits
a61af66fc99e Initial load
duke
parents:
diff changeset
139 int bit = _A[i] & -_A[i]; // Extract low bit
a61af66fc99e Initial load
duke
parents:
diff changeset
140 // Convert to bit number, return hi bit in pair
a61af66fc99e Initial load
duke
parents:
diff changeset
141 return OptoReg::Name((i<<_LogWordBits)+find_lowest_bit(bit)+1);
a61af66fc99e Initial load
duke
parents:
diff changeset
142 }
a61af66fc99e Initial load
duke
parents:
diff changeset
143 }
a61af66fc99e Initial load
duke
parents:
diff changeset
144 return OptoReg::Bad;
a61af66fc99e Initial load
duke
parents:
diff changeset
145 }
a61af66fc99e Initial load
duke
parents:
diff changeset
146
a61af66fc99e Initial load
duke
parents:
diff changeset
147 //------------------------------ClearToPairs-----------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
148 // Clear out partial bits; leave only bit pairs
a61af66fc99e Initial load
duke
parents:
diff changeset
149 void RegMask::ClearToPairs() {
a61af66fc99e Initial load
duke
parents:
diff changeset
150 for( int i = 0; i < RM_SIZE; i++ ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
151 int bits = _A[i];
a61af66fc99e Initial load
duke
parents:
diff changeset
152 bits &= ((bits & 0x55555555)<<1); // 1 hi-bit set for each pair
a61af66fc99e Initial load
duke
parents:
diff changeset
153 bits |= (bits>>1); // Smear 1 hi-bit into a pair
a61af66fc99e Initial load
duke
parents:
diff changeset
154 _A[i] = bits;
a61af66fc99e Initial load
duke
parents:
diff changeset
155 }
a61af66fc99e Initial load
duke
parents:
diff changeset
156 VerifyPairs();
a61af66fc99e Initial load
duke
parents:
diff changeset
157 }
a61af66fc99e Initial load
duke
parents:
diff changeset
158
a61af66fc99e Initial load
duke
parents:
diff changeset
159 //------------------------------SmearToPairs-----------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
160 // Smear out partial bits; leave only bit pairs
a61af66fc99e Initial load
duke
parents:
diff changeset
161 void RegMask::SmearToPairs() {
a61af66fc99e Initial load
duke
parents:
diff changeset
162 for( int i = 0; i < RM_SIZE; i++ ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
163 int bits = _A[i];
a61af66fc99e Initial load
duke
parents:
diff changeset
164 bits |= ((bits & 0x55555555)<<1); // Smear lo bit hi per pair
a61af66fc99e Initial load
duke
parents:
diff changeset
165 bits |= ((bits & 0xAAAAAAAA)>>1); // Smear hi bit lo per pair
a61af66fc99e Initial load
duke
parents:
diff changeset
166 _A[i] = bits;
a61af66fc99e Initial load
duke
parents:
diff changeset
167 }
a61af66fc99e Initial load
duke
parents:
diff changeset
168 VerifyPairs();
a61af66fc99e Initial load
duke
parents:
diff changeset
169 }
a61af66fc99e Initial load
duke
parents:
diff changeset
170
a61af66fc99e Initial load
duke
parents:
diff changeset
171 //------------------------------is_aligned_pairs-------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
172 bool RegMask::is_aligned_Pairs() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
173 // Assert that the register mask contains only bit pairs.
a61af66fc99e Initial load
duke
parents:
diff changeset
174 for( int i = 0; i < RM_SIZE; i++ ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
175 int bits = _A[i];
a61af66fc99e Initial load
duke
parents:
diff changeset
176 while( bits ) { // Check bits for pairing
a61af66fc99e Initial load
duke
parents:
diff changeset
177 int bit = bits & -bits; // Extract low bit
a61af66fc99e Initial load
duke
parents:
diff changeset
178 // Low bit is not odd means its mis-aligned.
a61af66fc99e Initial load
duke
parents:
diff changeset
179 if( (bit & 0x55555555) == 0 ) return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
180 bits -= bit; // Remove bit from mask
a61af66fc99e Initial load
duke
parents:
diff changeset
181 // Check for aligned adjacent bit
a61af66fc99e Initial load
duke
parents:
diff changeset
182 if( (bits & (bit<<1)) == 0 ) return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
183 bits -= (bit<<1); // Remove other halve of pair
a61af66fc99e Initial load
duke
parents:
diff changeset
184 }
a61af66fc99e Initial load
duke
parents:
diff changeset
185 }
a61af66fc99e Initial load
duke
parents:
diff changeset
186 return true;
a61af66fc99e Initial load
duke
parents:
diff changeset
187 }
a61af66fc99e Initial load
duke
parents:
diff changeset
188
a61af66fc99e Initial load
duke
parents:
diff changeset
189 //------------------------------is_bound1--------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
190 // Return TRUE if the mask contains a single bit
a61af66fc99e Initial load
duke
parents:
diff changeset
191 int RegMask::is_bound1() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
192 if( is_AllStack() ) return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
193 int bit = -1; // Set to hold the one bit allowed
a61af66fc99e Initial load
duke
parents:
diff changeset
194 for( int i = 0; i < RM_SIZE; i++ ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
195 if( _A[i] ) { // Found some bits
a61af66fc99e Initial load
duke
parents:
diff changeset
196 if( bit != -1 ) return false; // Already had bits, so fail
a61af66fc99e Initial load
duke
parents:
diff changeset
197 bit = _A[i] & -_A[i]; // Extract 1 bit from mask
a61af66fc99e Initial load
duke
parents:
diff changeset
198 if( bit != _A[i] ) return false; // Found many bits, so fail
a61af66fc99e Initial load
duke
parents:
diff changeset
199 }
a61af66fc99e Initial load
duke
parents:
diff changeset
200 }
a61af66fc99e Initial load
duke
parents:
diff changeset
201 // True for both the empty mask and for a single bit
a61af66fc99e Initial load
duke
parents:
diff changeset
202 return true;
a61af66fc99e Initial load
duke
parents:
diff changeset
203 }
a61af66fc99e Initial load
duke
parents:
diff changeset
204
a61af66fc99e Initial load
duke
parents:
diff changeset
205 //------------------------------is_bound2--------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
206 // Return TRUE if the mask contains an adjacent pair of bits and no other bits.
a61af66fc99e Initial load
duke
parents:
diff changeset
207 int RegMask::is_bound2() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
208 if( is_AllStack() ) return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
209
a61af66fc99e Initial load
duke
parents:
diff changeset
210 int bit = -1; // Set to hold the one bit allowed
a61af66fc99e Initial load
duke
parents:
diff changeset
211 for( int i = 0; i < RM_SIZE; i++ ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
212 if( _A[i] ) { // Found some bits
a61af66fc99e Initial load
duke
parents:
diff changeset
213 if( bit != -1 ) return false; // Already had bits, so fail
a61af66fc99e Initial load
duke
parents:
diff changeset
214 bit = _A[i] & -(_A[i]); // Extract 1 bit from mask
a61af66fc99e Initial load
duke
parents:
diff changeset
215 if( (bit << 1) != 0 ) { // Bit pair stays in same word?
a61af66fc99e Initial load
duke
parents:
diff changeset
216 if( (bit | (bit<<1)) != _A[i] )
a61af66fc99e Initial load
duke
parents:
diff changeset
217 return false; // Require adjacent bit pair and no more bits
a61af66fc99e Initial load
duke
parents:
diff changeset
218 } else { // Else its a split-pair case
a61af66fc99e Initial load
duke
parents:
diff changeset
219 if( bit != _A[i] ) return false; // Found many bits, so fail
a61af66fc99e Initial load
duke
parents:
diff changeset
220 i++; // Skip iteration forward
a61af66fc99e Initial load
duke
parents:
diff changeset
221 if( _A[i] != 1 ) return false; // Require 1 lo bit in next word
a61af66fc99e Initial load
duke
parents:
diff changeset
222 }
a61af66fc99e Initial load
duke
parents:
diff changeset
223 }
a61af66fc99e Initial load
duke
parents:
diff changeset
224 }
a61af66fc99e Initial load
duke
parents:
diff changeset
225 // True for both the empty mask and for a bit pair
a61af66fc99e Initial load
duke
parents:
diff changeset
226 return true;
a61af66fc99e Initial load
duke
parents:
diff changeset
227 }
a61af66fc99e Initial load
duke
parents:
diff changeset
228
a61af66fc99e Initial load
duke
parents:
diff changeset
229 //------------------------------is_UP------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
230 // UP means register only, Register plus stack, or stack only is DOWN
a61af66fc99e Initial load
duke
parents:
diff changeset
231 bool RegMask::is_UP() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
232 // Quick common case check for DOWN (any stack slot is legal)
a61af66fc99e Initial load
duke
parents:
diff changeset
233 if( is_AllStack() )
a61af66fc99e Initial load
duke
parents:
diff changeset
234 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
235 // Slower check for any stack bits set (also DOWN)
a61af66fc99e Initial load
duke
parents:
diff changeset
236 if( overlap(Matcher::STACK_ONLY_mask) )
a61af66fc99e Initial load
duke
parents:
diff changeset
237 return false;
a61af66fc99e Initial load
duke
parents:
diff changeset
238 // Not DOWN, so must be UP
a61af66fc99e Initial load
duke
parents:
diff changeset
239 return true;
a61af66fc99e Initial load
duke
parents:
diff changeset
240 }
a61af66fc99e Initial load
duke
parents:
diff changeset
241
a61af66fc99e Initial load
duke
parents:
diff changeset
242 //------------------------------Size-------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
243 // Compute size of register mask in bits
a61af66fc99e Initial load
duke
parents:
diff changeset
244 uint RegMask::Size() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
245 extern uint8 bitsInByte[256];
a61af66fc99e Initial load
duke
parents:
diff changeset
246 uint sum = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
247 for( int i = 0; i < RM_SIZE; i++ )
a61af66fc99e Initial load
duke
parents:
diff changeset
248 sum +=
a61af66fc99e Initial load
duke
parents:
diff changeset
249 bitsInByte[(_A[i]>>24) & 0xff] +
a61af66fc99e Initial load
duke
parents:
diff changeset
250 bitsInByte[(_A[i]>>16) & 0xff] +
a61af66fc99e Initial load
duke
parents:
diff changeset
251 bitsInByte[(_A[i]>> 8) & 0xff] +
a61af66fc99e Initial load
duke
parents:
diff changeset
252 bitsInByte[ _A[i] & 0xff];
a61af66fc99e Initial load
duke
parents:
diff changeset
253 return sum;
a61af66fc99e Initial load
duke
parents:
diff changeset
254 }
a61af66fc99e Initial load
duke
parents:
diff changeset
255
a61af66fc99e Initial load
duke
parents:
diff changeset
256 #ifndef PRODUCT
a61af66fc99e Initial load
duke
parents:
diff changeset
257 //------------------------------print------------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
258 void RegMask::dump( ) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
259 tty->print("[");
a61af66fc99e Initial load
duke
parents:
diff changeset
260 RegMask rm = *this; // Structure copy into local temp
a61af66fc99e Initial load
duke
parents:
diff changeset
261
a61af66fc99e Initial load
duke
parents:
diff changeset
262 OptoReg::Name start = rm.find_first_elem(); // Get a register
a61af66fc99e Initial load
duke
parents:
diff changeset
263 if( OptoReg::is_valid(start) ) { // Check for empty mask
a61af66fc99e Initial load
duke
parents:
diff changeset
264 rm.Remove(start); // Yank from mask
a61af66fc99e Initial load
duke
parents:
diff changeset
265 OptoReg::dump(start); // Print register
a61af66fc99e Initial load
duke
parents:
diff changeset
266 OptoReg::Name last = start;
a61af66fc99e Initial load
duke
parents:
diff changeset
267
a61af66fc99e Initial load
duke
parents:
diff changeset
268 // Now I have printed an initial register.
a61af66fc99e Initial load
duke
parents:
diff changeset
269 // Print adjacent registers as "rX-rZ" instead of "rX,rY,rZ".
a61af66fc99e Initial load
duke
parents:
diff changeset
270 // Begin looping over the remaining registers.
a61af66fc99e Initial load
duke
parents:
diff changeset
271 while( 1 ) { //
a61af66fc99e Initial load
duke
parents:
diff changeset
272 OptoReg::Name reg = rm.find_first_elem(); // Get a register
a61af66fc99e Initial load
duke
parents:
diff changeset
273 if( !OptoReg::is_valid(reg) )
a61af66fc99e Initial load
duke
parents:
diff changeset
274 break; // Empty mask, end loop
a61af66fc99e Initial load
duke
parents:
diff changeset
275 rm.Remove(reg); // Yank from mask
a61af66fc99e Initial load
duke
parents:
diff changeset
276
a61af66fc99e Initial load
duke
parents:
diff changeset
277 if( last+1 == reg ) { // See if they are adjacent
a61af66fc99e Initial load
duke
parents:
diff changeset
278 // Adjacent registers just collect into long runs, no printing.
a61af66fc99e Initial load
duke
parents:
diff changeset
279 last = reg;
a61af66fc99e Initial load
duke
parents:
diff changeset
280 } else { // Ending some kind of run
a61af66fc99e Initial load
duke
parents:
diff changeset
281 if( start == last ) { // 1-register run; no special printing
a61af66fc99e Initial load
duke
parents:
diff changeset
282 } else if( start+1 == last ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
283 tty->print(","); // 2-register run; print as "rX,rY"
a61af66fc99e Initial load
duke
parents:
diff changeset
284 OptoReg::dump(last);
a61af66fc99e Initial load
duke
parents:
diff changeset
285 } else { // Multi-register run; print as "rX-rZ"
a61af66fc99e Initial load
duke
parents:
diff changeset
286 tty->print("-");
a61af66fc99e Initial load
duke
parents:
diff changeset
287 OptoReg::dump(last);
a61af66fc99e Initial load
duke
parents:
diff changeset
288 }
a61af66fc99e Initial load
duke
parents:
diff changeset
289 tty->print(","); // Seperate start of new run
a61af66fc99e Initial load
duke
parents:
diff changeset
290 start = last = reg; // Start a new register run
a61af66fc99e Initial load
duke
parents:
diff changeset
291 OptoReg::dump(start); // Print register
a61af66fc99e Initial load
duke
parents:
diff changeset
292 } // End of if ending a register run or not
a61af66fc99e Initial load
duke
parents:
diff changeset
293 } // End of while regmask not empty
a61af66fc99e Initial load
duke
parents:
diff changeset
294
a61af66fc99e Initial load
duke
parents:
diff changeset
295 if( start == last ) { // 1-register run; no special printing
a61af66fc99e Initial load
duke
parents:
diff changeset
296 } else if( start+1 == last ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
297 tty->print(","); // 2-register run; print as "rX,rY"
a61af66fc99e Initial load
duke
parents:
diff changeset
298 OptoReg::dump(last);
a61af66fc99e Initial load
duke
parents:
diff changeset
299 } else { // Multi-register run; print as "rX-rZ"
a61af66fc99e Initial load
duke
parents:
diff changeset
300 tty->print("-");
a61af66fc99e Initial load
duke
parents:
diff changeset
301 OptoReg::dump(last);
a61af66fc99e Initial load
duke
parents:
diff changeset
302 }
a61af66fc99e Initial load
duke
parents:
diff changeset
303 if( rm.is_AllStack() ) tty->print("...");
a61af66fc99e Initial load
duke
parents:
diff changeset
304 }
a61af66fc99e Initial load
duke
parents:
diff changeset
305 tty->print("]");
a61af66fc99e Initial load
duke
parents:
diff changeset
306 }
a61af66fc99e Initial load
duke
parents:
diff changeset
307 #endif