1111
1212#include " include/llvm-libc-macros/stdfix-macros.h"
1313#include " src/__support/CPP/bit.h"
14- #include " src/__support/CPP/limits.h" // numeric_limits
1514#include " src/__support/CPP/type_traits.h"
16- #include " src/__support/macros/attributes.h" // LIBC_INLINE
17- #include " src/__support/macros/config.h" // LIBC_NAMESPACE_DECL
15+ #include " src/__support/macros/attributes.h" // LIBC_INLINE
16+ #include " src/__support/macros/config.h"
1817#include " src/__support/macros/optimization.h" // LIBC_UNLIKELY
1918#include " src/__support/math_extras.h"
2019
@@ -51,12 +50,6 @@ template <typename T> struct FXBits {
5150 static constexpr StorageType SIGN_MASK =
5251 (fx_rep::SIGN_LEN == 0 ? 0 : StorageType(1 ) << SIGN_OFFSET);
5352
54- // mask for <integral | fraction>
55- static constexpr StorageType VALUE_MASK = INTEGRAL_MASK | FRACTION_MASK;
56-
57- // mask for <sign | integral | fraction>
58- static constexpr StorageType TOTAL_MASK = SIGN_MASK | VALUE_MASK;
59-
6053public:
6154 LIBC_INLINE constexpr FXBits () = default;
6255
@@ -81,12 +74,6 @@ template <typename T> struct FXBits {
8174 return (value & INTEGRAL_MASK) >> INTEGRAL_OFFSET;
8275 }
8376
84- // returns complete bitstring representation the fixed point number
85- // the bitstring is of the form: padding | sign | integral | fraction
86- LIBC_INLINE constexpr StorageType get_bits () {
87- return (value & TOTAL_MASK) >> FRACTION_OFFSET;
88- }
89-
9077 // TODO: replace bool with Sign
9178 LIBC_INLINE constexpr bool get_sign () {
9279 return static_cast <bool >((value & SIGN_MASK) >> SIGN_OFFSET);
@@ -176,25 +163,6 @@ template <typename T> LIBC_INLINE constexpr T round(T x, int n) {
176163 return bit_and ((x + round_bit), rounding_mask);
177164}
178165
179- // count leading sign bits
180- template <typename T>
181- LIBC_INLINE constexpr cpp::enable_if_t <cpp::is_fixed_point_v<T>, int >
182- countls (T f) {
183- using FXRep = FXRep<T>;
184- using BitType = typename FXRep::StorageType;
185- using FXBits = FXBits<T>;
186-
187- constexpr int CONTAIN_LEN = cpp::numeric_limits<BitType>::digits;
188- constexpr int PADDING_LEN = CONTAIN_LEN - FXRep::TOTAL_LEN;
189-
190- if constexpr (FXRep::SIGN_LEN != 0 )
191- if (f < 0 )
192- f = bit_not (f);
193-
194- BitType value_bits = FXBits (f)::get_bits ();
195- return cpp::countl_zero (value_bits) - PADDING_LEN;
196- }
197-
198166} // namespace fixed_point
199167} // namespace LIBC_NAMESPACE_DECL
200168
0 commit comments