[libc-commits] [libc] [libc][stdfix] Implement fixed point `countlsfx` functions in llvm-libc (PR #125356)
Nick Desaulniers via libc-commits
libc-commits at lists.llvm.org
Fri Feb 7 11:09:33 PST 2025
================
@@ -163,6 +176,26 @@ template <typename T> LIBC_INLINE constexpr T round(T x, int n) {
return bit_and((x + round_bit), rounding_mask);
}
+// count leading sign bits
+template <typename T>
+LIBC_INLINE constexpr cpp::enable_if_t<cpp::is_fixed_point_v<T>, int>
+countls(T f) {
+ using FXRep = FXRep<T>;
+ using BitType = typename FXRep::StorageType;
+ using FXBits = FXBits<T>;
+
+ constexpr int CONTAIN_LEN = cpp::numeric_limits<BitType>::digits;
+ constexpr int PADDING_LEN = CONTAIN_LEN - FXRep::TOTAL_LEN;
+
+ if constexpr (FXRep::SIGN_LEN != 0) {
+ if (x < 0)
----------------
nickdesaulniers wrote:
>From the buildbot failures:
```
libc/src/__support/fixed_point/fx_bits.h:191:9: error: use of undeclared identifier 'x'
191 | if (x < 0)
| ^
```
https://github.com/llvm/llvm-project/pull/125356
More information about the libc-commits
mailing list