1 /* |
1 /* |
2 * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
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 |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
26 #include "opto/ad.hpp" |
26 #include "opto/ad.hpp" |
27 #include "opto/compile.hpp" |
27 #include "opto/compile.hpp" |
28 #include "opto/matcher.hpp" |
28 #include "opto/matcher.hpp" |
29 #include "opto/node.hpp" |
29 #include "opto/node.hpp" |
30 #include "opto/regmask.hpp" |
30 #include "opto/regmask.hpp" |
|
31 #include "utilities/population_count.hpp" |
31 |
32 |
32 #define RM_SIZE _RM_SIZE /* a constant private to the class RegMask */ |
33 #define RM_SIZE _RM_SIZE /* a constant private to the class RegMask */ |
33 |
34 |
34 //-------------Non-zero bit search methods used by RegMask--------------------- |
35 //-------------Non-zero bit search methods used by RegMask--------------------- |
35 // Find lowest 1, or return 32 if empty |
36 // Find lowest 1, or return 32 if empty |
138 } |
139 } |
139 // Op_VecS and the rest ideal registers. |
140 // Op_VecS and the rest ideal registers. |
140 return 1; |
141 return 1; |
141 } |
142 } |
142 |
143 |
143 //------------------------------find_first_pair-------------------------------- |
|
144 // Find the lowest-numbered register pair in the mask. Return the |
|
145 // HIGHEST register number in the pair, or BAD if no pairs. |
|
146 OptoReg::Name RegMask::find_first_pair() const { |
|
147 verify_pairs(); |
|
148 for( int i = 0; i < RM_SIZE; i++ ) { |
|
149 if( _A[i] ) { // Found some bits |
|
150 int bit = _A[i] & -_A[i]; // Extract low bit |
|
151 // Convert to bit number, return hi bit in pair |
|
152 return OptoReg::Name((i<<_LogWordBits)+find_lowest_bit(bit)+1); |
|
153 } |
|
154 } |
|
155 return OptoReg::Bad; |
|
156 } |
|
157 |
|
158 //------------------------------ClearToPairs----------------------------------- |
144 //------------------------------ClearToPairs----------------------------------- |
159 // Clear out partial bits; leave only bit pairs |
145 // Clear out partial bits; leave only bit pairs |
160 void RegMask::clear_to_pairs() { |
146 void RegMask::clear_to_pairs() { |
161 for( int i = 0; i < RM_SIZE; i++ ) { |
147 for( int i = 0; i < RM_SIZE; i++ ) { |
162 int bits = _A[i]; |
148 int bits = _A[i]; |
163 bits &= ((bits & 0x55555555)<<1); // 1 hi-bit set for each pair |
149 bits &= ((bits & 0x55555555)<<1); // 1 hi-bit set for each pair |
164 bits |= (bits>>1); // Smear 1 hi-bit into a pair |
150 bits |= (bits>>1); // Smear 1 hi-bit into a pair |
165 _A[i] = bits; |
|
166 } |
|
167 verify_pairs(); |
|
168 } |
|
169 |
|
170 //------------------------------SmearToPairs----------------------------------- |
|
171 // Smear out partial bits; leave only bit pairs |
|
172 void RegMask::smear_to_pairs() { |
|
173 for( int i = 0; i < RM_SIZE; i++ ) { |
|
174 int bits = _A[i]; |
|
175 bits |= ((bits & 0x55555555)<<1); // Smear lo bit hi per pair |
|
176 bits |= ((bits & 0xAAAAAAAA)>>1); // Smear hi bit lo per pair |
|
177 _A[i] = bits; |
151 _A[i] = bits; |
178 } |
152 } |
179 verify_pairs(); |
153 verify_pairs(); |
180 } |
154 } |
181 |
155 |
387 } |
361 } |
388 |
362 |
389 //------------------------------Size------------------------------------------- |
363 //------------------------------Size------------------------------------------- |
390 // Compute size of register mask in bits |
364 // Compute size of register mask in bits |
391 uint RegMask::Size() const { |
365 uint RegMask::Size() const { |
392 extern uint8_t bitsInByte[BITS_IN_BYTE_ARRAY_SIZE]; |
|
393 uint sum = 0; |
366 uint sum = 0; |
394 for( int i = 0; i < RM_SIZE; i++ ) |
367 for (int i = 0; i < RM_SIZE; i++) { |
395 sum += |
368 sum += population_count(_A[i]); |
396 bitsInByte[(_A[i]>>24) & 0xff] + |
369 } |
397 bitsInByte[(_A[i]>>16) & 0xff] + |
|
398 bitsInByte[(_A[i]>> 8) & 0xff] + |
|
399 bitsInByte[ _A[i] & 0xff]; |
|
400 return sum; |
370 return sum; |
401 } |
371 } |
402 |
372 |
403 #ifndef PRODUCT |
373 #ifndef PRODUCT |
404 //------------------------------print------------------------------------------ |
374 //------------------------------print------------------------------------------ |