author | iveresov |
Thu, 22 Jan 2015 11:25:23 -0800 | |
changeset 28723 | 0a36120cb225 |
parent 25715 | d5a8dbdc5150 |
child 30624 | 2e1803c8a26d |
permissions | -rw-r--r-- |
1 | 1 |
/* |
24424
2658d7834c6e
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
22807
diff
changeset
|
2 |
* Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. |
1 | 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 |
* |
|
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
7397 | 25 |
#include "precompiled.hpp" |
25715
d5a8dbdc5150
8049325: Introduce and clean up umbrella headers for the files in the cpu subdirectories.
goetz
parents:
24429
diff
changeset
|
26 |
#include "opto/ad.hpp" |
7397 | 27 |
#include "opto/compile.hpp" |
28 |
#include "opto/regmask.hpp" |
|
1 | 29 |
|
30 |
#define RM_SIZE _RM_SIZE /* a constant private to the class RegMask */ |
|
31 |
||
32 |
//-------------Non-zero bit search methods used by RegMask--------------------- |
|
33 |
// Find lowest 1, or return 32 if empty |
|
24425 | 34 |
int find_lowest_bit( uint32_t mask ) { |
1 | 35 |
int n = 0; |
36 |
if( (mask & 0xffff) == 0 ) { |
|
37 |
mask >>= 16; |
|
38 |
n += 16; |
|
39 |
} |
|
40 |
if( (mask & 0xff) == 0 ) { |
|
41 |
mask >>= 8; |
|
42 |
n += 8; |
|
43 |
} |
|
44 |
if( (mask & 0xf) == 0 ) { |
|
45 |
mask >>= 4; |
|
46 |
n += 4; |
|
47 |
} |
|
48 |
if( (mask & 0x3) == 0 ) { |
|
49 |
mask >>= 2; |
|
50 |
n += 2; |
|
51 |
} |
|
52 |
if( (mask & 0x1) == 0 ) { |
|
53 |
mask >>= 1; |
|
54 |
n += 1; |
|
55 |
} |
|
56 |
if( mask == 0 ) { |
|
57 |
n = 32; |
|
58 |
} |
|
59 |
return n; |
|
60 |
} |
|
61 |
||
62 |
// Find highest 1, or return 32 if empty |
|
24425 | 63 |
int find_hihghest_bit( uint32_t mask ) { |
1 | 64 |
int n = 0; |
65 |
if( mask > 0xffff ) { |
|
66 |
mask >>= 16; |
|
67 |
n += 16; |
|
68 |
} |
|
69 |
if( mask > 0xff ) { |
|
70 |
mask >>= 8; |
|
71 |
n += 8; |
|
72 |
} |
|
73 |
if( mask > 0xf ) { |
|
74 |
mask >>= 4; |
|
75 |
n += 4; |
|
76 |
} |
|
77 |
if( mask > 0x3 ) { |
|
78 |
mask >>= 2; |
|
79 |
n += 2; |
|
80 |
} |
|
81 |
if( mask > 0x1 ) { |
|
82 |
mask >>= 1; |
|
83 |
n += 1; |
|
84 |
} |
|
85 |
if( mask == 0 ) { |
|
86 |
n = 32; |
|
87 |
} |
|
88 |
return n; |
|
89 |
} |
|
90 |
||
91 |
//------------------------------dump------------------------------------------- |
|
92 |
||
93 |
#ifndef PRODUCT |
|
15241
87d217c2d183
8005055: pass outputStream to more opto debug routines
kvn
parents:
13104
diff
changeset
|
94 |
void OptoReg::dump(int r, outputStream *st) { |
87d217c2d183
8005055: pass outputStream to more opto debug routines
kvn
parents:
13104
diff
changeset
|
95 |
switch (r) { |
87d217c2d183
8005055: pass outputStream to more opto debug routines
kvn
parents:
13104
diff
changeset
|
96 |
case Special: st->print("r---"); break; |
87d217c2d183
8005055: pass outputStream to more opto debug routines
kvn
parents:
13104
diff
changeset
|
97 |
case Bad: st->print("rBAD"); break; |
1 | 98 |
default: |
24424
2658d7834c6e
8037816: Fix for 8036122 breaks build with Xcode5/clang
drchase
parents:
22807
diff
changeset
|
99 |
if (r < _last_Mach_Reg) st->print("%s", Matcher::regName[r]); |
15241
87d217c2d183
8005055: pass outputStream to more opto debug routines
kvn
parents:
13104
diff
changeset
|
100 |
else st->print("rS%d",r); |
1 | 101 |
break; |
102 |
} |
|
103 |
} |
|
104 |
#endif |
|
105 |
||
106 |
||
107 |
//============================================================================= |
|
108 |
const RegMask RegMask::Empty( |
|
109 |
# define BODY(I) 0, |
|
110 |
FORALL_BODY |
|
111 |
# undef BODY |
|
112 |
0 |
|
113 |
); |
|
114 |
||
13104
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
115 |
//============================================================================= |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
116 |
bool RegMask::is_vector(uint ireg) { |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
117 |
return (ireg == Op_VecS || ireg == Op_VecD || ireg == Op_VecX || ireg == Op_VecY); |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
118 |
} |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
119 |
|
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
120 |
int RegMask::num_registers(uint ireg) { |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
121 |
switch(ireg) { |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
122 |
case Op_VecY: |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
123 |
return 8; |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
124 |
case Op_VecX: |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
125 |
return 4; |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
126 |
case Op_VecD: |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
127 |
case Op_RegD: |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
128 |
case Op_RegL: |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
129 |
#ifdef _LP64 |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
130 |
case Op_RegP: |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
131 |
#endif |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
132 |
return 2; |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
133 |
} |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
134 |
// Op_VecS and the rest ideal registers. |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
135 |
return 1; |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
136 |
} |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
137 |
|
1 | 138 |
//------------------------------find_first_pair-------------------------------- |
139 |
// Find the lowest-numbered register pair in the mask. Return the |
|
140 |
// HIGHEST register number in the pair, or BAD if no pairs. |
|
141 |
OptoReg::Name RegMask::find_first_pair() const { |
|
13104
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
142 |
verify_pairs(); |
1 | 143 |
for( int i = 0; i < RM_SIZE; i++ ) { |
144 |
if( _A[i] ) { // Found some bits |
|
145 |
int bit = _A[i] & -_A[i]; // Extract low bit |
|
146 |
// Convert to bit number, return hi bit in pair |
|
147 |
return OptoReg::Name((i<<_LogWordBits)+find_lowest_bit(bit)+1); |
|
148 |
} |
|
149 |
} |
|
150 |
return OptoReg::Bad; |
|
151 |
} |
|
152 |
||
153 |
//------------------------------ClearToPairs----------------------------------- |
|
154 |
// Clear out partial bits; leave only bit pairs |
|
13104
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
155 |
void RegMask::clear_to_pairs() { |
1 | 156 |
for( int i = 0; i < RM_SIZE; i++ ) { |
157 |
int bits = _A[i]; |
|
158 |
bits &= ((bits & 0x55555555)<<1); // 1 hi-bit set for each pair |
|
159 |
bits |= (bits>>1); // Smear 1 hi-bit into a pair |
|
160 |
_A[i] = bits; |
|
161 |
} |
|
13104
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
162 |
verify_pairs(); |
1 | 163 |
} |
164 |
||
165 |
//------------------------------SmearToPairs----------------------------------- |
|
166 |
// Smear out partial bits; leave only bit pairs |
|
13104
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
167 |
void RegMask::smear_to_pairs() { |
1 | 168 |
for( int i = 0; i < RM_SIZE; i++ ) { |
169 |
int bits = _A[i]; |
|
170 |
bits |= ((bits & 0x55555555)<<1); // Smear lo bit hi per pair |
|
171 |
bits |= ((bits & 0xAAAAAAAA)>>1); // Smear hi bit lo per pair |
|
172 |
_A[i] = bits; |
|
173 |
} |
|
13104
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
174 |
verify_pairs(); |
1 | 175 |
} |
176 |
||
177 |
//------------------------------is_aligned_pairs------------------------------- |
|
13104
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
178 |
bool RegMask::is_aligned_pairs() const { |
1 | 179 |
// Assert that the register mask contains only bit pairs. |
180 |
for( int i = 0; i < RM_SIZE; i++ ) { |
|
181 |
int bits = _A[i]; |
|
182 |
while( bits ) { // Check bits for pairing |
|
183 |
int bit = bits & -bits; // Extract low bit |
|
184 |
// Low bit is not odd means its mis-aligned. |
|
185 |
if( (bit & 0x55555555) == 0 ) return false; |
|
186 |
bits -= bit; // Remove bit from mask |
|
187 |
// Check for aligned adjacent bit |
|
188 |
if( (bits & (bit<<1)) == 0 ) return false; |
|
189 |
bits -= (bit<<1); // Remove other halve of pair |
|
190 |
} |
|
191 |
} |
|
192 |
return true; |
|
193 |
} |
|
194 |
||
195 |
//------------------------------is_bound1-------------------------------------- |
|
196 |
// Return TRUE if the mask contains a single bit |
|
197 |
int RegMask::is_bound1() const { |
|
198 |
if( is_AllStack() ) return false; |
|
199 |
int bit = -1; // Set to hold the one bit allowed |
|
200 |
for( int i = 0; i < RM_SIZE; i++ ) { |
|
201 |
if( _A[i] ) { // Found some bits |
|
202 |
if( bit != -1 ) return false; // Already had bits, so fail |
|
203 |
bit = _A[i] & -_A[i]; // Extract 1 bit from mask |
|
204 |
if( bit != _A[i] ) return false; // Found many bits, so fail |
|
205 |
} |
|
206 |
} |
|
207 |
// True for both the empty mask and for a single bit |
|
208 |
return true; |
|
209 |
} |
|
210 |
||
211 |
//------------------------------is_bound2-------------------------------------- |
|
212 |
// Return TRUE if the mask contains an adjacent pair of bits and no other bits. |
|
13104
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
213 |
int RegMask::is_bound_pair() const { |
1 | 214 |
if( is_AllStack() ) return false; |
215 |
||
216 |
int bit = -1; // Set to hold the one bit allowed |
|
217 |
for( int i = 0; i < RM_SIZE; i++ ) { |
|
218 |
if( _A[i] ) { // Found some bits |
|
219 |
if( bit != -1 ) return false; // Already had bits, so fail |
|
220 |
bit = _A[i] & -(_A[i]); // Extract 1 bit from mask |
|
221 |
if( (bit << 1) != 0 ) { // Bit pair stays in same word? |
|
222 |
if( (bit | (bit<<1)) != _A[i] ) |
|
223 |
return false; // Require adjacent bit pair and no more bits |
|
224 |
} else { // Else its a split-pair case |
|
225 |
if( bit != _A[i] ) return false; // Found many bits, so fail |
|
226 |
i++; // Skip iteration forward |
|
15614
3d9afca22dc7
8007402: Code cleanup to remove Parfait false positive
drchase
parents:
15241
diff
changeset
|
227 |
if( i >= RM_SIZE || _A[i] != 1 ) |
3d9afca22dc7
8007402: Code cleanup to remove Parfait false positive
drchase
parents:
15241
diff
changeset
|
228 |
return false; // Require 1 lo bit in next word |
1 | 229 |
} |
230 |
} |
|
231 |
} |
|
232 |
// True for both the empty mask and for a bit pair |
|
233 |
return true; |
|
234 |
} |
|
235 |
||
13104
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
236 |
static int low_bits[3] = { 0x55555555, 0x11111111, 0x01010101 }; |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
237 |
//------------------------------find_first_set--------------------------------- |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
238 |
// Find the lowest-numbered register set in the mask. Return the |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
239 |
// HIGHEST register number in the set, or BAD if no sets. |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
240 |
// Works also for size 1. |
15614
3d9afca22dc7
8007402: Code cleanup to remove Parfait false positive
drchase
parents:
15241
diff
changeset
|
241 |
OptoReg::Name RegMask::find_first_set(const int size) const { |
13104
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
242 |
verify_sets(size); |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
243 |
for (int i = 0; i < RM_SIZE; i++) { |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
244 |
if (_A[i]) { // Found some bits |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
245 |
int bit = _A[i] & -_A[i]; // Extract low bit |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
246 |
// Convert to bit number, return hi bit in pair |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
247 |
return OptoReg::Name((i<<_LogWordBits)+find_lowest_bit(bit)+(size-1)); |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
248 |
} |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
249 |
} |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
250 |
return OptoReg::Bad; |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
251 |
} |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
252 |
|
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
253 |
//------------------------------clear_to_sets---------------------------------- |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
254 |
// Clear out partial bits; leave only aligned adjacent bit pairs |
15614
3d9afca22dc7
8007402: Code cleanup to remove Parfait false positive
drchase
parents:
15241
diff
changeset
|
255 |
void RegMask::clear_to_sets(const int size) { |
13104
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
256 |
if (size == 1) return; |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
257 |
assert(2 <= size && size <= 8, "update low bits table"); |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
258 |
assert(is_power_of_2(size), "sanity"); |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
259 |
int low_bits_mask = low_bits[size>>2]; |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
260 |
for (int i = 0; i < RM_SIZE; i++) { |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
261 |
int bits = _A[i]; |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
262 |
int sets = (bits & low_bits_mask); |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
263 |
for (int j = 1; j < size; j++) { |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
264 |
sets = (bits & (sets<<1)); // filter bits which produce whole sets |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
265 |
} |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
266 |
sets |= (sets>>1); // Smear 1 hi-bit into a set |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
267 |
if (size > 2) { |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
268 |
sets |= (sets>>2); // Smear 2 hi-bits into a set |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
269 |
if (size > 4) { |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
270 |
sets |= (sets>>4); // Smear 4 hi-bits into a set |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
271 |
} |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
272 |
} |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
273 |
_A[i] = sets; |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
274 |
} |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
275 |
verify_sets(size); |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
276 |
} |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
277 |
|
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
278 |
//------------------------------smear_to_sets---------------------------------- |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
279 |
// Smear out partial bits to aligned adjacent bit sets |
15614
3d9afca22dc7
8007402: Code cleanup to remove Parfait false positive
drchase
parents:
15241
diff
changeset
|
280 |
void RegMask::smear_to_sets(const int size) { |
13104
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
281 |
if (size == 1) return; |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
282 |
assert(2 <= size && size <= 8, "update low bits table"); |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
283 |
assert(is_power_of_2(size), "sanity"); |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
284 |
int low_bits_mask = low_bits[size>>2]; |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
285 |
for (int i = 0; i < RM_SIZE; i++) { |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
286 |
int bits = _A[i]; |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
287 |
int sets = 0; |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
288 |
for (int j = 0; j < size; j++) { |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
289 |
sets |= (bits & low_bits_mask); // collect partial bits |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
290 |
bits = bits>>1; |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
291 |
} |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
292 |
sets |= (sets<<1); // Smear 1 lo-bit into a set |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
293 |
if (size > 2) { |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
294 |
sets |= (sets<<2); // Smear 2 lo-bits into a set |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
295 |
if (size > 4) { |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
296 |
sets |= (sets<<4); // Smear 4 lo-bits into a set |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
297 |
} |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
298 |
} |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
299 |
_A[i] = sets; |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
300 |
} |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
301 |
verify_sets(size); |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
302 |
} |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
303 |
|
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
304 |
//------------------------------is_aligned_set-------------------------------- |
15614
3d9afca22dc7
8007402: Code cleanup to remove Parfait false positive
drchase
parents:
15241
diff
changeset
|
305 |
bool RegMask::is_aligned_sets(const int size) const { |
13104
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
306 |
if (size == 1) return true; |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
307 |
assert(2 <= size && size <= 8, "update low bits table"); |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
308 |
assert(is_power_of_2(size), "sanity"); |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
309 |
int low_bits_mask = low_bits[size>>2]; |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
310 |
// Assert that the register mask contains only bit sets. |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
311 |
for (int i = 0; i < RM_SIZE; i++) { |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
312 |
int bits = _A[i]; |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
313 |
while (bits) { // Check bits for pairing |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
314 |
int bit = bits & -bits; // Extract low bit |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
315 |
// Low bit is not odd means its mis-aligned. |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
316 |
if ((bit & low_bits_mask) == 0) return false; |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
317 |
// Do extra work since (bit << size) may overflow. |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
318 |
int hi_bit = bit << (size-1); // high bit |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
319 |
int set = hi_bit + ((hi_bit-1) & ~(bit-1)); |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
320 |
// Check for aligned adjacent bits in this set |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
321 |
if ((bits & set) != set) return false; |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
322 |
bits -= set; // Remove this set |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
323 |
} |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
324 |
} |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
325 |
return true; |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
326 |
} |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
327 |
|
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
328 |
//------------------------------is_bound_set----------------------------------- |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
329 |
// Return TRUE if the mask contains one adjacent set of bits and no other bits. |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
330 |
// Works also for size 1. |
15614
3d9afca22dc7
8007402: Code cleanup to remove Parfait false positive
drchase
parents:
15241
diff
changeset
|
331 |
int RegMask::is_bound_set(const int size) const { |
13104
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
332 |
if( is_AllStack() ) return false; |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
333 |
assert(1 <= size && size <= 8, "update low bits table"); |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
334 |
int bit = -1; // Set to hold the one bit allowed |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
335 |
for (int i = 0; i < RM_SIZE; i++) { |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
336 |
if (_A[i] ) { // Found some bits |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
337 |
if (bit != -1) |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
338 |
return false; // Already had bits, so fail |
15614
3d9afca22dc7
8007402: Code cleanup to remove Parfait false positive
drchase
parents:
15241
diff
changeset
|
339 |
bit = _A[i] & -_A[i]; // Extract low bit from mask |
13104
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
340 |
int hi_bit = bit << (size-1); // high bit |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
341 |
if (hi_bit != 0) { // Bit set stays in same word? |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
342 |
int set = hi_bit + ((hi_bit-1) & ~(bit-1)); |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
343 |
if (set != _A[i]) |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
344 |
return false; // Require adjacent bit set and no more bits |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
345 |
} else { // Else its a split-set case |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
346 |
if (((-1) & ~(bit-1)) != _A[i]) |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
347 |
return false; // Found many bits, so fail |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
348 |
i++; // Skip iteration forward and check high part |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
349 |
// The lower 24 bits should be 0 since it is split case and size <= 8. |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
350 |
int set = bit>>24; |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
351 |
set = set & -set; // Remove sign extension. |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
352 |
set = (((set << size) - 1) >> 8); |
15614
3d9afca22dc7
8007402: Code cleanup to remove Parfait false positive
drchase
parents:
15241
diff
changeset
|
353 |
if (i >= RM_SIZE || _A[i] != set) |
3d9afca22dc7
8007402: Code cleanup to remove Parfait false positive
drchase
parents:
15241
diff
changeset
|
354 |
return false; // Require expected low bits in next word |
13104
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
355 |
} |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
356 |
} |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
357 |
} |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
358 |
// True for both the empty mask and for a bit set |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
359 |
return true; |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
360 |
} |
657b387034fb
7119644: Increase superword's vector size up to 256 bits
kvn
parents:
8921
diff
changeset
|
361 |
|
1 | 362 |
//------------------------------is_UP------------------------------------------ |
363 |
// UP means register only, Register plus stack, or stack only is DOWN |
|
364 |
bool RegMask::is_UP() const { |
|
365 |
// Quick common case check for DOWN (any stack slot is legal) |
|
366 |
if( is_AllStack() ) |
|
367 |
return false; |
|
368 |
// Slower check for any stack bits set (also DOWN) |
|
369 |
if( overlap(Matcher::STACK_ONLY_mask) ) |
|
370 |
return false; |
|
371 |
// Not DOWN, so must be UP |
|
372 |
return true; |
|
373 |
} |
|
374 |
||
375 |
//------------------------------Size------------------------------------------- |
|
376 |
// Compute size of register mask in bits |
|
377 |
uint RegMask::Size() const { |
|
24425 | 378 |
extern uint8_t bitsInByte[256]; |
1 | 379 |
uint sum = 0; |
380 |
for( int i = 0; i < RM_SIZE; i++ ) |
|
381 |
sum += |
|
382 |
bitsInByte[(_A[i]>>24) & 0xff] + |
|
383 |
bitsInByte[(_A[i]>>16) & 0xff] + |
|
384 |
bitsInByte[(_A[i]>> 8) & 0xff] + |
|
385 |
bitsInByte[ _A[i] & 0xff]; |
|
386 |
return sum; |
|
387 |
} |
|
388 |
||
389 |
#ifndef PRODUCT |
|
390 |
//------------------------------print------------------------------------------ |
|
15241
87d217c2d183
8005055: pass outputStream to more opto debug routines
kvn
parents:
13104
diff
changeset
|
391 |
void RegMask::dump(outputStream *st) const { |
87d217c2d183
8005055: pass outputStream to more opto debug routines
kvn
parents:
13104
diff
changeset
|
392 |
st->print("["); |
1 | 393 |
RegMask rm = *this; // Structure copy into local temp |
394 |
||
395 |
OptoReg::Name start = rm.find_first_elem(); // Get a register |
|
15241
87d217c2d183
8005055: pass outputStream to more opto debug routines
kvn
parents:
13104
diff
changeset
|
396 |
if (OptoReg::is_valid(start)) { // Check for empty mask |
1 | 397 |
rm.Remove(start); // Yank from mask |
15241
87d217c2d183
8005055: pass outputStream to more opto debug routines
kvn
parents:
13104
diff
changeset
|
398 |
OptoReg::dump(start, st); // Print register |
1 | 399 |
OptoReg::Name last = start; |
400 |
||
401 |
// Now I have printed an initial register. |
|
402 |
// Print adjacent registers as "rX-rZ" instead of "rX,rY,rZ". |
|
403 |
// Begin looping over the remaining registers. |
|
15241
87d217c2d183
8005055: pass outputStream to more opto debug routines
kvn
parents:
13104
diff
changeset
|
404 |
while (1) { // |
1 | 405 |
OptoReg::Name reg = rm.find_first_elem(); // Get a register |
15241
87d217c2d183
8005055: pass outputStream to more opto debug routines
kvn
parents:
13104
diff
changeset
|
406 |
if (!OptoReg::is_valid(reg)) |
1 | 407 |
break; // Empty mask, end loop |
408 |
rm.Remove(reg); // Yank from mask |
|
409 |
||
15241
87d217c2d183
8005055: pass outputStream to more opto debug routines
kvn
parents:
13104
diff
changeset
|
410 |
if (last+1 == reg) { // See if they are adjacent |
1 | 411 |
// Adjacent registers just collect into long runs, no printing. |
412 |
last = reg; |
|
413 |
} else { // Ending some kind of run |
|
15241
87d217c2d183
8005055: pass outputStream to more opto debug routines
kvn
parents:
13104
diff
changeset
|
414 |
if (start == last) { // 1-register run; no special printing |
87d217c2d183
8005055: pass outputStream to more opto debug routines
kvn
parents:
13104
diff
changeset
|
415 |
} else if (start+1 == last) { |
87d217c2d183
8005055: pass outputStream to more opto debug routines
kvn
parents:
13104
diff
changeset
|
416 |
st->print(","); // 2-register run; print as "rX,rY" |
87d217c2d183
8005055: pass outputStream to more opto debug routines
kvn
parents:
13104
diff
changeset
|
417 |
OptoReg::dump(last, st); |
1 | 418 |
} else { // Multi-register run; print as "rX-rZ" |
15241
87d217c2d183
8005055: pass outputStream to more opto debug routines
kvn
parents:
13104
diff
changeset
|
419 |
st->print("-"); |
87d217c2d183
8005055: pass outputStream to more opto debug routines
kvn
parents:
13104
diff
changeset
|
420 |
OptoReg::dump(last, st); |
1 | 421 |
} |
15241
87d217c2d183
8005055: pass outputStream to more opto debug routines
kvn
parents:
13104
diff
changeset
|
422 |
st->print(","); // Seperate start of new run |
1 | 423 |
start = last = reg; // Start a new register run |
15241
87d217c2d183
8005055: pass outputStream to more opto debug routines
kvn
parents:
13104
diff
changeset
|
424 |
OptoReg::dump(start, st); // Print register |
1 | 425 |
} // End of if ending a register run or not |
426 |
} // End of while regmask not empty |
|
427 |
||
15241
87d217c2d183
8005055: pass outputStream to more opto debug routines
kvn
parents:
13104
diff
changeset
|
428 |
if (start == last) { // 1-register run; no special printing |
87d217c2d183
8005055: pass outputStream to more opto debug routines
kvn
parents:
13104
diff
changeset
|
429 |
} else if (start+1 == last) { |
87d217c2d183
8005055: pass outputStream to more opto debug routines
kvn
parents:
13104
diff
changeset
|
430 |
st->print(","); // 2-register run; print as "rX,rY" |
87d217c2d183
8005055: pass outputStream to more opto debug routines
kvn
parents:
13104
diff
changeset
|
431 |
OptoReg::dump(last, st); |
1 | 432 |
} else { // Multi-register run; print as "rX-rZ" |
15241
87d217c2d183
8005055: pass outputStream to more opto debug routines
kvn
parents:
13104
diff
changeset
|
433 |
st->print("-"); |
87d217c2d183
8005055: pass outputStream to more opto debug routines
kvn
parents:
13104
diff
changeset
|
434 |
OptoReg::dump(last, st); |
1 | 435 |
} |
15241
87d217c2d183
8005055: pass outputStream to more opto debug routines
kvn
parents:
13104
diff
changeset
|
436 |
if (rm.is_AllStack()) st->print("..."); |
1 | 437 |
} |
15241
87d217c2d183
8005055: pass outputStream to more opto debug routines
kvn
parents:
13104
diff
changeset
|
438 |
st->print("]"); |
1 | 439 |
} |
440 |
#endif |