Skip to content

Commit cab041f

Browse files
authored
[reland][libc][NFC] Refactor FPBits and remove LongDoubleBits specialization (#78447)
- [reland] #78192 - Make the implementation work when `__uint128_t` is not available on the plaftorm.
1 parent 656bf13 commit cab041f

File tree

9 files changed

+659
-287
lines changed

9 files changed

+659
-287
lines changed

libc/src/__support/FPUtil/FPBits.h

Lines changed: 392 additions & 95 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
}

libc/src/__support/UInt.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ template <size_t Bits, bool Signed> struct BigInt {
197197
return d.borrow;
198198
}
199199

200-
LIBC_INLINE BigInt<Bits, Signed>
200+
LIBC_INLINE constexpr BigInt<Bits, Signed>
201201
operator-(const BigInt<Bits, Signed> &other) const {
202202
BigInt<Bits, Signed> result;
203203
DiffBorrow<uint64_t> d{0, 0};

0 commit comments

Comments
 (0)