8217629: RegMask::find_lowest_bit can reuse count_trailing_zeros utility
Reviewed-by: thartmann, neliasso
This commit is contained in:
parent
d783c7a2d8
commit
199b29c58e
@ -33,35 +33,6 @@
|
|||||||
#define RM_SIZE _RM_SIZE /* a constant private to the class RegMask */
|
#define RM_SIZE _RM_SIZE /* a constant private to the class RegMask */
|
||||||
|
|
||||||
//-------------Non-zero bit search methods used by RegMask---------------------
|
//-------------Non-zero bit search methods used by RegMask---------------------
|
||||||
// Find lowest 1, or return 32 if empty
|
|
||||||
int find_lowest_bit( uint32_t mask ) {
|
|
||||||
int n = 0;
|
|
||||||
if( (mask & 0xffff) == 0 ) {
|
|
||||||
mask >>= 16;
|
|
||||||
n += 16;
|
|
||||||
}
|
|
||||||
if( (mask & 0xff) == 0 ) {
|
|
||||||
mask >>= 8;
|
|
||||||
n += 8;
|
|
||||||
}
|
|
||||||
if( (mask & 0xf) == 0 ) {
|
|
||||||
mask >>= 4;
|
|
||||||
n += 4;
|
|
||||||
}
|
|
||||||
if( (mask & 0x3) == 0 ) {
|
|
||||||
mask >>= 2;
|
|
||||||
n += 2;
|
|
||||||
}
|
|
||||||
if( (mask & 0x1) == 0 ) {
|
|
||||||
mask >>= 1;
|
|
||||||
n += 1;
|
|
||||||
}
|
|
||||||
if( mask == 0 ) {
|
|
||||||
n = 32;
|
|
||||||
}
|
|
||||||
return n;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Find highest 1, or return 32 if empty
|
// Find highest 1, or return 32 if empty
|
||||||
int find_highest_bit( uint32_t mask ) {
|
int find_highest_bit( uint32_t mask ) {
|
||||||
int n = 0;
|
int n = 0;
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
|
|
||||||
#include "code/vmreg.hpp"
|
#include "code/vmreg.hpp"
|
||||||
#include "opto/optoreg.hpp"
|
#include "opto/optoreg.hpp"
|
||||||
|
#include "utilities/count_trailing_zeros.hpp"
|
||||||
|
|
||||||
// Some fun naming (textual) substitutions:
|
// Some fun naming (textual) substitutions:
|
||||||
//
|
//
|
||||||
@ -45,8 +46,10 @@
|
|||||||
// numregs in chaitin ==> proper degree in chaitin
|
// numregs in chaitin ==> proper degree in chaitin
|
||||||
|
|
||||||
//-------------Non-zero bit search methods used by RegMask---------------------
|
//-------------Non-zero bit search methods used by RegMask---------------------
|
||||||
// Find lowest 1, or return 32 if empty
|
// Find lowest 1, undefined if empty/0
|
||||||
int find_lowest_bit( uint32_t mask );
|
static int find_lowest_bit(uint32_t mask) {
|
||||||
|
return count_trailing_zeros(mask);
|
||||||
|
}
|
||||||
// Find highest 1, or return 32 if empty
|
// Find highest 1, or return 32 if empty
|
||||||
int find_highest_bit( uint32_t mask );
|
int find_highest_bit( uint32_t mask );
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user