[libc-commits] [libc] [libc][stdfix] Implement `countlsfx` functions (PR #114318)
via libc-commits
libc-commits at lists.llvm.org
Sat Nov 2 21:55:48 PDT 2024
================
@@ -66,6 +67,23 @@ template <typename T> struct FXBits {
}
}
+ // Clause 6.2.6.3 of ISO/IEC TR 18037 defines the value bits of a fixed-point
+ // type to include the integral and fraction bits but not padding nor sign
+ // bits.
+ //
+ // This function returns the value bits, right-aligned, as an unsigned integer
+ // type which is at least large enough to hold them all.
+ //
+ // Note the integral and fraction bits are contiguous. The rightmost bits in
+ // the returned value are the fraciton bits, then immediately left of those
+ // are the integral bits.
+ //
+ // Any left-padding in the return value is guaranteed to be zero.
+ LIBC_INLINE constexpr StorageType get_value_bits() {
+ constexpr StorageType VALUE_MASK = INTEGRAL_MASK | FRACTION_MASK;
----------------
duncpro wrote:
This is fixed in [cc87a9a](https://github.com/llvm/llvm-project/commit/cc87a9ac973131db1047a22ebfb2b0db2d2f1926).
https://github.com/llvm/llvm-project/blob/cc87a9ac973131db1047a22ebfb2b0db2d2f1926/libc/src/__support/fixed_point/fx_bits.h#L54-L57
https://github.com/llvm/llvm-project/pull/114318
More information about the libc-commits
mailing list