@@ -90,13 +90,12 @@ template <typename T, size_t count> static constexpr T mask_trailing_ones() {
90
90
return count == 0 ? 0 : ((~T (0 )) >> (t_bits - count));
91
91
}
92
92
93
- // Derives more properties from 'FPBaseProperties' above.
94
- // This class serves as a halfway point between 'FPBaseProperties' and
95
- // 'FPProperties' below.
93
+ } // namespace internal
94
+
96
95
template <FPType fp_type>
97
- struct FPCommonProperties : private FPBaseProperties <fp_type> {
96
+ struct FPProperties : public internal :: FPBaseProperties<fp_type> {
98
97
private:
99
- using UP = FPBaseProperties<fp_type>;
98
+ using UP = internal:: FPBaseProperties<fp_type>;
100
99
using UP::EXP_BITS;
101
100
using UP::SIG_BITS;
102
101
using UP::TOTAL_BITS;
@@ -123,15 +122,15 @@ struct FPCommonProperties : private FPBaseProperties<fp_type> {
123
122
124
123
// Masks
125
124
LIBC_INLINE_VAR static constexpr UIntType SIG_MASK =
126
- mask_trailing_ones<UIntType, SIG_BITS>() << SIG_MASK_SHIFT;
125
+ internal:: mask_trailing_ones<UIntType, SIG_BITS>() << SIG_MASK_SHIFT;
127
126
LIBC_INLINE_VAR static constexpr UIntType EXP_MASK =
128
- mask_trailing_ones<UIntType, EXP_BITS>() << EXP_MASK_SHIFT;
127
+ internal:: mask_trailing_ones<UIntType, EXP_BITS>() << EXP_MASK_SHIFT;
129
128
// Trailing underscore on SIGN_MASK_ is temporary - it will be removed
130
129
// once we can replace the public part below with the private one.
131
130
LIBC_INLINE_VAR static constexpr UIntType SIGN_MASK_ =
132
- mask_trailing_ones<UIntType, SIGN_BITS>() << SIGN_MASK_SHIFT;
131
+ internal:: mask_trailing_ones<UIntType, SIGN_BITS>() << SIGN_MASK_SHIFT;
133
132
LIBC_INLINE_VAR static constexpr UIntType FP_MASK =
134
- mask_trailing_ones<UIntType, TOTAL_BITS>();
133
+ internal:: mask_trailing_ones<UIntType, TOTAL_BITS>();
135
134
static_assert ((SIG_MASK & EXP_MASK & SIGN_MASK_) == 0 , " masks disjoint" );
136
135
static_assert ((SIG_MASK | EXP_MASK | SIGN_MASK_) == FP_MASK, " masks cover" );
137
136
@@ -140,19 +139,19 @@ struct FPCommonProperties : private FPBaseProperties<fp_type> {
140
139
}
141
140
142
141
LIBC_INLINE_VAR static constexpr UIntType QNAN_MASK =
143
- UP::ENCODING == FPEncoding::X86_ExtendedPrecision
142
+ UP::ENCODING == internal:: FPEncoding::X86_ExtendedPrecision
144
143
? bit_at(SIG_BITS - 1 ) | bit_at(SIG_BITS - 2 ) // 0b1100...
145
144
: bit_at(SIG_BITS - 1 ); // 0b1000...
146
145
147
146
LIBC_INLINE_VAR static constexpr UIntType SNAN_MASK =
148
- UP::ENCODING == FPEncoding::X86_ExtendedPrecision
147
+ UP::ENCODING == internal:: FPEncoding::X86_ExtendedPrecision
149
148
? bit_at(SIG_BITS - 1 ) | bit_at(SIG_BITS - 3 ) // 0b1010...
150
149
: bit_at(SIG_BITS - 2 ); // 0b0100...
151
150
152
151
// The number of bits after the decimal dot when the number if in normal form.
153
152
LIBC_INLINE_VAR static constexpr int FRACTION_BITS =
154
- UP::ENCODING == FPEncoding::X86_ExtendedPrecision ? SIG_BITS - 1
155
- : SIG_BITS;
153
+ UP::ENCODING == internal:: FPEncoding::X86_ExtendedPrecision ? SIG_BITS - 1
154
+ : SIG_BITS;
156
155
157
156
public:
158
157
// Public facing API to keep the change local to this file.
@@ -163,7 +162,7 @@ struct FPCommonProperties : private FPBaseProperties<fp_type> {
163
162
LIBC_INLINE_VAR static constexpr uint32_t MANTISSA_PRECISION =
164
163
MANTISSA_WIDTH + 1 ;
165
164
LIBC_INLINE_VAR static constexpr BitsType MANTISSA_MASK =
166
- mask_trailing_ones<UIntType, MANTISSA_WIDTH>();
165
+ internal:: mask_trailing_ones<UIntType, MANTISSA_WIDTH>();
167
166
LIBC_INLINE_VAR static constexpr uint32_t EXPONENT_WIDTH = EXP_BITS;
168
167
LIBC_INLINE_VAR static constexpr int32_t EXPONENT_BIAS = EXP_BIAS;
169
168
LIBC_INLINE_VAR static constexpr BitsType SIGN_MASK = SIGN_MASK_;
@@ -176,29 +175,6 @@ struct FPCommonProperties : private FPBaseProperties<fp_type> {
176
175
static constexpr BitsType QUIET_NAN_MASK = QNAN_MASK;
177
176
};
178
177
179
- } // namespace internal
180
-
181
- template <FPType fp_type>
182
- struct FPProperties : public internal ::FPCommonProperties<fp_type> {};
183
-
184
- // ----------------
185
- // Work In Progress
186
- // ----------------
187
- // The 'FPProperties' template specializations below are being slowly replaced
188
- // with properties from 'FPCommonProperties' above. Once specializations are
189
- // empty, 'FPProperties' declaration can be fully replace with
190
- // 'FPCommonProperties' implementation.
191
-
192
- // Properties for numbers represented in 80 bits long double on non-Windows x86
193
- // platforms.
194
- template <>
195
- struct FPProperties <FPType::X86_Binary80>
196
- : public internal::FPCommonProperties<FPType::X86_Binary80> {
197
- // The x86 80 bit float represents the leading digit of the mantissa
198
- // explicitly. This is the mask for that bit.
199
- static constexpr BitsType EXPLICIT_BIT_MASK = (BitsType(1 ) << MANTISSA_WIDTH);
200
- };
201
-
202
178
// -----------------------------------------------------------------------------
203
179
template <typename FP> LIBC_INLINE static constexpr FPType get_fp_type () {
204
180
if constexpr (cpp::is_same_v<FP, float > && __FLT_MANT_DIG__ == 24 )
0 commit comments