Skip to content

Commit fdbf255

Browse files
authored
[libc][NFC] Refactor FPBits and remove LongDoubleBits specialization (#78192)
This patch removes the `FPBits` specialization for x86 Extended Precision by moving it up to `FPRep`. It also introduces enums (`Exponent`, `BiasedExponent` and `Significand`) to represent the exponent and significant parts of the floating point numbers. These enums are used to construct and observe floating point representations. Additionally, we remove `LongDoubleBits.h` that is now unnecessary.
1 parent 6011d6b commit fdbf255

File tree

8 files changed

+618
-282
lines changed

8 files changed

+618
-282
lines changed

libc/src/__support/FPUtil/FPBits.h

Lines changed: 352 additions & 91 deletions
Large diffs are not rendered by default.

libc/src/__support/FPUtil/generic/sqrt_80_bit_long_double.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ LIBC_INLINE long double sqrt(long double x) {
131131
out.set_implicit_bit(1);
132132
out.set_mantissa((y & (ONE - 1)));
133133

134-
return out;
134+
return out.get_val();
135135
}
136136
}
137137
#endif // LIBC_LONG_DOUBLE_IS_X86_FLOAT80

libc/src/__support/FPUtil/x86_64/LongDoubleBits.h

Lines changed: 0 additions & 179 deletions
This file was deleted.

libc/src/__support/FPUtil/x86_64/NextAfterLongDouble.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ LIBC_INLINE long double nextafter(long double from, long double to) {
6161
from_bits.set_biased_exponent(from_bits.get_biased_exponent() + 1);
6262
if (from_bits.is_inf())
6363
raise_except_if_required(FE_OVERFLOW | FE_INEXACT);
64-
return from_bits;
64+
return from_bits.get_val();
6565
} else {
6666
++int_val;
6767
}
@@ -75,7 +75,7 @@ LIBC_INLINE long double nextafter(long double from, long double to) {
7575
// from == 0 is handled separately so decrementing the exponent will not
7676
// lead to underflow.
7777
from_bits.set_biased_exponent(from_bits.get_biased_exponent() - 1);
78-
return from_bits;
78+
return from_bits.get_val();
7979
} else {
8080
--int_val;
8181
}
@@ -94,7 +94,7 @@ LIBC_INLINE long double nextafter(long double from, long double to) {
9494
// from == 0 is handled separately so decrementing the exponent will not
9595
// lead to underflow.
9696
from_bits.set_biased_exponent(from_bits.get_biased_exponent() - 1);
97-
return from_bits;
97+
return from_bits.get_val();
9898
} else {
9999
--int_val;
100100
}
@@ -109,7 +109,7 @@ LIBC_INLINE long double nextafter(long double from, long double to) {
109109
from_bits.set_biased_exponent(from_bits.get_biased_exponent() + 1);
110110
if (from_bits.is_inf())
111111
raise_except_if_required(FE_OVERFLOW | FE_INEXACT);
112-
return from_bits;
112+
return from_bits.get_val();
113113
} else {
114114
++int_val;
115115
}

0 commit comments

Comments
 (0)