equal
deleted
inserted
replaced
31 #include "utilities/population_count.hpp" |
31 #include "utilities/population_count.hpp" |
32 |
32 |
33 #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 */ |
34 |
34 |
35 //-------------Non-zero bit search methods used by RegMask--------------------- |
35 //-------------Non-zero bit search methods used by RegMask--------------------- |
36 // Find lowest 1, or return 32 if empty |
|
37 int find_lowest_bit( uint32_t mask ) { |
|
38 int n = 0; |
|
39 if( (mask & 0xffff) == 0 ) { |
|
40 mask >>= 16; |
|
41 n += 16; |
|
42 } |
|
43 if( (mask & 0xff) == 0 ) { |
|
44 mask >>= 8; |
|
45 n += 8; |
|
46 } |
|
47 if( (mask & 0xf) == 0 ) { |
|
48 mask >>= 4; |
|
49 n += 4; |
|
50 } |
|
51 if( (mask & 0x3) == 0 ) { |
|
52 mask >>= 2; |
|
53 n += 2; |
|
54 } |
|
55 if( (mask & 0x1) == 0 ) { |
|
56 mask >>= 1; |
|
57 n += 1; |
|
58 } |
|
59 if( mask == 0 ) { |
|
60 n = 32; |
|
61 } |
|
62 return n; |
|
63 } |
|
64 |
|
65 // Find highest 1, or return 32 if empty |
36 // Find highest 1, or return 32 if empty |
66 int find_highest_bit( uint32_t mask ) { |
37 int find_highest_bit( uint32_t mask ) { |
67 int n = 0; |
38 int n = 0; |
68 if( mask > 0xffff ) { |
39 if( mask > 0xffff ) { |
69 mask >>= 16; |
40 mask >>= 16; |