[libc] [llvm] [libc][NFC] Refactor FPBits and remove LongDoubleBits specialization (PR #78192)

Guillaume Chatelet via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 16 02:19:59 PST 2024


================
@@ -132,6 +132,70 @@ struct FPRepBase : public internal::FPLayout<fp_type> {
   static_assert((SIG_MASK & EXP_MASK & SIGN_MASK) == 0, "masks disjoint");
   static_assert((SIG_MASK | EXP_MASK | SIGN_MASK) == FP_MASK, "masks cover");
 
+protected:
+  enum class Exp : int32_t {
+    ZERO = 0,
+    // The exponent value for denormal numbers.
+    SUBNORMAL = -EXP_BIAS,
+    // The minimum exponent value for normal numbers.
+    MIN = SUBNORMAL + 1,
+    // The maximum exponent value for normal numbers.
+    MAX = EXP_BIAS,
+    // Special value all ones.
+    INF = MAX + 1,
+    // Aliases
+    BITS_ALL_ZEROES = SUBNORMAL,
+    BITS_ALL_ONES = INF,
+  };
+
+  enum class Sig : StorageType {
----------------
gchatelet wrote:

I went for `Significand` although it's a bit verbose.

I also clarified that `enum` is used as a typed integer to prevent mixing and matching between parts of the representation.

I've also turned `Exp` into `BiasedExponent` as it's more about the bit pattern than the actual semantics. Hopefully, this is now clearer.

https://github.com/llvm/llvm-project/pull/78192


More information about the llvm-commits mailing list