|
24 | 24 |
|
25 | 25 | namespace llvm {
|
26 | 26 |
|
27 |
| -/// The behavior an operation has on an input of 0. |
28 |
| -enum ZeroBehavior { |
29 |
| - /// The returned value is undefined. |
30 |
| - ZB_Undefined, |
31 |
| - /// The returned value is numeric_limits<T>::max() |
32 |
| - ZB_Max |
33 |
| -}; |
34 |
| - |
35 | 27 | /// Mathematical constants.
|
36 | 28 | namespace numbers {
|
37 | 29 | // TODO: Track C++20 std::numbers.
|
@@ -92,19 +84,6 @@ template <typename T> unsigned countLeadingZeros(T Val) {
|
92 | 84 | return llvm::countl_zero(Val);
|
93 | 85 | }
|
94 | 86 |
|
95 |
| -/// Get the index of the first set bit starting from the least |
96 |
| -/// significant bit. |
97 |
| -/// |
98 |
| -/// Only unsigned integral types are allowed. |
99 |
| -/// |
100 |
| -/// \param ZB the behavior on an input of 0. |
101 |
| -template <typename T> T findFirstSet(T Val, ZeroBehavior ZB = ZB_Max) { |
102 |
| - if (ZB == ZB_Max && Val == 0) |
103 |
| - return std::numeric_limits<T>::max(); |
104 |
| - |
105 |
| - return llvm::countr_zero(Val); |
106 |
| -} |
107 |
| - |
108 | 87 | /// Create a bitmask with the N right-most bits set to 1, and all other
|
109 | 88 | /// bits set to 0. Only unsigned types are allowed.
|
110 | 89 | template <typename T> T maskTrailingOnes(unsigned N) {
|
@@ -132,21 +111,6 @@ template <typename T> T maskLeadingZeros(unsigned N) {
|
132 | 111 | return maskTrailingOnes<T>(CHAR_BIT * sizeof(T) - N);
|
133 | 112 | }
|
134 | 113 |
|
135 |
| -/// Get the index of the last set bit starting from the least |
136 |
| -/// significant bit. |
137 |
| -/// |
138 |
| -/// Only unsigned integral types are allowed. |
139 |
| -/// |
140 |
| -/// \param ZB the behavior on an input of 0. |
141 |
| -template <typename T> T findLastSet(T Val, ZeroBehavior ZB = ZB_Max) { |
142 |
| - if (ZB == ZB_Max && Val == 0) |
143 |
| - return std::numeric_limits<T>::max(); |
144 |
| - |
145 |
| - // Use ^ instead of - because both gcc and llvm can remove the associated ^ |
146 |
| - // in the __builtin_clz intrinsic on x86. |
147 |
| - return llvm::countl_zero(Val) ^ (std::numeric_limits<T>::digits - 1); |
148 |
| -} |
149 |
| - |
150 | 114 | /// Macro compressed bit reversal table for 256 bits.
|
151 | 115 | ///
|
152 | 116 | /// http://graphics.stanford.edu/~seander/bithacks.html#BitReverseTable
|
|
0 commit comments