Skip to content

Commit ace383d

Browse files
authored
[libc][NFC] Rename FPBits nan functions (#79998)
- [libc][NFC] Rename FPBits nan functions - rename build_signaling_nan in signaling_nan - rename build_quiet_nan to quiet_nan
1 parent 7565ae6 commit ace383d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+105
-107
lines changed

libc/src/__support/FPUtil/DivisionAndRemainderOperations.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ LIBC_INLINE T remquo(T x, T y, int &q) {
3131
if (ybits.is_nan())
3232
return y;
3333
if (xbits.is_inf() || ybits.is_zero())
34-
return FPBits<T>::build_quiet_nan().get_val();
34+
return FPBits<T>::quiet_nan().get_val();
3535

3636
if (xbits.is_zero()) {
3737
q = 0;

libc/src/__support/FPUtil/FPBits.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -359,13 +359,13 @@ struct FPRepSem : public FPStorage<fp_type> {
359359
LIBC_INLINE static constexpr RetT inf(Sign sign = Sign::POS) {
360360
return RetT(encode(sign, BiasedExp::BITS_ALL_ONES(), Sig::ZERO()));
361361
}
362-
LIBC_INLINE static constexpr RetT build_nan(Sign sign = Sign::POS,
363-
StorageType v = 0) {
362+
LIBC_INLINE static constexpr RetT signaling_nan(Sign sign = Sign::POS,
363+
StorageType v = 0) {
364364
return RetT(encode(sign, BiasedExp::BITS_ALL_ONES(),
365365
(v ? Sig(v) : (Sig::MSB() >> 1))));
366366
}
367-
LIBC_INLINE static constexpr RetT build_quiet_nan(Sign sign = Sign::POS,
368-
StorageType v = 0) {
367+
LIBC_INLINE static constexpr RetT quiet_nan(Sign sign = Sign::POS,
368+
StorageType v = 0) {
369369
return RetT(encode(sign, BiasedExp::BITS_ALL_ONES(), Sig::MSB() | Sig(v)));
370370
}
371371

@@ -448,13 +448,13 @@ struct FPRepSem<FPType::X86_Binary80, RetT>
448448
LIBC_INLINE static constexpr RetT inf(Sign sign = Sign::POS) {
449449
return RetT(encode(sign, BiasedExp::BITS_ALL_ONES(), Sig::MSB()));
450450
}
451-
LIBC_INLINE static constexpr RetT build_nan(Sign sign = Sign::POS,
452-
StorageType v = 0) {
451+
LIBC_INLINE static constexpr RetT signaling_nan(Sign sign = Sign::POS,
452+
StorageType v = 0) {
453453
return RetT(encode(sign, BiasedExp::BITS_ALL_ONES(),
454454
Sig::MSB() | (v ? Sig(v) : (Sig::MSB() >> 2))));
455455
}
456-
LIBC_INLINE static constexpr RetT build_quiet_nan(Sign sign = Sign::POS,
457-
StorageType v = 0) {
456+
LIBC_INLINE static constexpr RetT quiet_nan(Sign sign = Sign::POS,
457+
StorageType v = 0) {
458458
return RetT(encode(sign, BiasedExp::BITS_ALL_ONES(),
459459
Sig::MSB() | (Sig::MSB() >> 1) | Sig(v)));
460460
}
@@ -577,14 +577,14 @@ struct FPRep : public FPRepSem<fp_type, RetT> {
577577
LIBC_INLINE static constexpr RetT zero(Sign sign = Sign::POS) {
578578
return RetT(encode(sign, BiasedExp::BITS_ALL_ZEROES(), Sig::ZERO()));
579579
}
580-
using UP::build_nan;
581-
using UP::build_quiet_nan;
582580
using UP::inf;
583581
using UP::max_normal;
584582
using UP::max_subnormal;
585583
using UP::min_normal;
586584
using UP::min_subnormal;
587585
using UP::one;
586+
using UP::quiet_nan;
587+
using UP::signaling_nan;
588588

589589
// Modifiers
590590
LIBC_INLINE constexpr RetT abs() const {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ template <typename T> struct FModExceptionalInputHandler {
124124

125125
LIBC_INLINE static bool pre_check(T x, T y, T &out) {
126126
using FPB = fputil::FPBits<T>;
127-
const T quiet_nan = FPB::build_quiet_nan().get_val();
127+
const T quiet_nan = FPB::quiet_nan().get_val();
128128
FPB sx(x), sy(y);
129129
if (LIBC_LIKELY(!sy.is_zero() && !sy.is_inf_or_nan() &&
130130
!sx.is_inf_or_nan())) {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ LIBC_INLINE cpp::enable_if_t<cpp::is_floating_point_v<T>, T> sqrt(T x) {
7474
using FPBits_t = typename fputil::FPBits<T>;
7575
using StorageType = typename FPBits_t::StorageType;
7676
constexpr StorageType ONE = StorageType(1) << FPBits_t::FRACTION_LEN;
77-
constexpr auto FLT_NAN = FPBits_t::build_quiet_nan().get_val();
77+
constexpr auto FLT_NAN = FPBits_t::quiet_nan().get_val();
7878

7979
FPBits_t bits(x);
8080

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
@@ -39,7 +39,7 @@ LIBC_INLINE long double sqrt(long double x) {
3939
using LDBits = FPBits<long double>;
4040
using StorageType = typename LDBits::StorageType;
4141
constexpr StorageType ONE = StorageType(1) << int(LDBits::FRACTION_LEN);
42-
constexpr auto LDNAN = LDBits::build_quiet_nan().get_val();
42+
constexpr auto LDNAN = LDBits::quiet_nan().get_val();
4343

4444
LDBits bits(x);
4545

libc/src/__support/str_to_float.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1167,7 +1167,7 @@ LIBC_INLINE StrToNumResult<T> strtofloatingpoint(const char *__restrict src) {
11671167
index = left_paren;
11681168
}
11691169
}
1170-
result = FPBits(result.build_quiet_nan(result.sign(), nan_mantissa));
1170+
result = FPBits(result.quiet_nan(result.sign(), nan_mantissa));
11711171
}
11721172
} else if (tolower(src[index]) == 'i') { // INF
11731173
if (tolower(src[index + 1]) == inf_string[1] &&
@@ -1215,7 +1215,7 @@ template <class T> LIBC_INLINE StrToNumResult<T> strtonan(const char *arg) {
12151215
nan_mantissa = static_cast<StorageType>(nan_mantissa_result);
12161216
}
12171217

1218-
result = FPBits::build_quiet_nan(fputil::Sign::POS, nan_mantissa);
1218+
result = FPBits::quiet_nan(fputil::Sign::POS, nan_mantissa);
12191219
return {result.get_val(), 0, error};
12201220
}
12211221

libc/src/math/generic/acosf.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ LLVM_LIBC_FUNCTION(float, acosf, (float x)) {
8585
fputil::set_errno_if_required(EDOM);
8686
fputil::raise_except_if_required(FE_INVALID);
8787
}
88-
return x + FPBits::build_quiet_nan().get_val();
88+
return x + FPBits::quiet_nan().get_val();
8989
}
9090

9191
// When 0.5 < |x| < 1, we perform range reduction as follow:

libc/src/math/generic/acoshf.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ LLVM_LIBC_FUNCTION(float, acoshf, (float x)) {
2929
// x < 1.
3030
fputil::set_errno_if_required(EDOM);
3131
fputil::raise_except_if_required(FE_INVALID);
32-
return FPBits_t::build_quiet_nan().get_val();
32+
return FPBits_t::quiet_nan().get_val();
3333
}
3434

3535
if (LIBC_UNLIKELY(x_u >= 0x4f8ffb03)) {

libc/src/math/generic/asinf.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ LLVM_LIBC_FUNCTION(float, asinf, (float x)) {
109109
fputil::set_errno_if_required(EDOM);
110110
fputil::raise_except_if_required(FE_INVALID);
111111
}
112-
return FPBits::build_quiet_nan().get_val();
112+
return FPBits::quiet_nan().get_val();
113113
}
114114

115115
// Check for exceptional values

libc/src/math/generic/atanhf.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ LLVM_LIBC_FUNCTION(float, atanhf, (float x)) {
3333
} else {
3434
fputil::set_errno_if_required(EDOM);
3535
fputil::raise_except_if_required(FE_INVALID);
36-
return FPBits::build_quiet_nan().get_val();
36+
return FPBits::quiet_nan().get_val();
3737
}
3838
}
3939

libc/src/math/generic/cosf.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ LLVM_LIBC_FUNCTION(float, cosf, (float x)) {
118118
fputil::set_errno_if_required(EDOM);
119119
fputil::raise_except_if_required(FE_INVALID);
120120
}
121-
return x + FPBits::build_quiet_nan().get_val();
121+
return x + FPBits::quiet_nan().get_val();
122122
}
123123

124124
// Combine the results with the sine of sum formula:

libc/src/math/generic/log.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -754,7 +754,7 @@ LLVM_LIBC_FUNCTION(double, log, (double x)) {
754754
if (xbits.is_neg() && !xbits.is_nan()) {
755755
fputil::set_errno_if_required(EDOM);
756756
fputil::raise_except_if_required(FE_INVALID);
757-
return FPBits_t::build_quiet_nan().get_val();
757+
return FPBits_t::quiet_nan().get_val();
758758
}
759759
if (xbits.is_inf_or_nan()) {
760760
return x;

libc/src/math/generic/log10.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -755,7 +755,7 @@ LLVM_LIBC_FUNCTION(double, log10, (double x)) {
755755
if (xbits.is_neg() && !xbits.is_nan()) {
756756
fputil::set_errno_if_required(EDOM);
757757
fputil::raise_except_if_required(FE_INVALID);
758-
return FPBits_t::build_quiet_nan().get_val();
758+
return FPBits_t::quiet_nan().get_val();
759759
}
760760
if (xbits.is_inf_or_nan()) {
761761
return x;

libc/src/math/generic/log10f.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ LLVM_LIBC_FUNCTION(float, log10f, (float x)) {
173173
// Return NaN and raise FE_INVALID
174174
fputil::set_errno_if_required(EDOM);
175175
fputil::raise_except_if_required(FE_INVALID);
176-
return FPBits::build_quiet_nan().get_val();
176+
return FPBits::quiet_nan().get_val();
177177
}
178178
if (xbits.is_inf_or_nan()) {
179179
return x;

libc/src/math/generic/log1p.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -900,7 +900,7 @@ LLVM_LIBC_FUNCTION(double, log1p, (double x)) {
900900
// x < -1.0
901901
fputil::set_errno_if_required(EDOM);
902902
fputil::raise_except_if_required(FE_INVALID);
903-
return FPBits_t::build_quiet_nan().get_val();
903+
return FPBits_t::quiet_nan().get_val();
904904
}
905905
// x is +Inf or NaN
906906
return x;

libc/src/math/generic/log1pf.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ LIBC_INLINE float log(double x) {
4747
if (xbits.is_neg() && !xbits.is_nan()) {
4848
fputil::set_errno_if_required(EDOM);
4949
fputil::raise_except_if_required(FE_INVALID);
50-
return fputil::FPBits<float>::build_quiet_nan().get_val();
50+
return fputil::FPBits<float>::quiet_nan().get_val();
5151
}
5252
return static_cast<float>(x);
5353
}

libc/src/math/generic/log2.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -876,7 +876,7 @@ LLVM_LIBC_FUNCTION(double, log2, (double x)) {
876876
if (xbits.is_neg() && !xbits.is_nan()) {
877877
fputil::set_errno_if_required(EDOM);
878878
fputil::raise_except_if_required(FE_INVALID);
879-
return FPBits_t::build_quiet_nan().get_val();
879+
return FPBits_t::quiet_nan().get_val();
880880
}
881881
if (xbits.is_inf_or_nan()) {
882882
return x;

libc/src/math/generic/log2f.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ LLVM_LIBC_FUNCTION(float, log2f, (float x)) {
7979
if (xbits.is_neg() && !xbits.is_nan()) {
8080
fputil::set_errno_if_required(EDOM);
8181
fputil::raise_except(FE_INVALID);
82-
return FPBits::build_quiet_nan().get_val();
82+
return FPBits::quiet_nan().get_val();
8383
}
8484
if (xbits.is_inf_or_nan()) {
8585
return x;

libc/src/math/generic/logf.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ LLVM_LIBC_FUNCTION(float, logf, (float x)) {
124124
// Return NaN and raise FE_INVALID
125125
fputil::set_errno_if_required(EDOM);
126126
fputil::raise_except_if_required(FE_INVALID);
127-
return FPBits::build_quiet_nan().get_val();
127+
return FPBits::quiet_nan().get_val();
128128
}
129129
// x is +inf or nan
130130
return x;

libc/src/math/generic/powf.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -657,7 +657,7 @@ LLVM_LIBC_FUNCTION(float, powf, (float x, float y)) {
657657
// pow( negative, non-integer ) = NaN
658658
fputil::set_errno_if_required(EDOM);
659659
fputil::raise_except_if_required(FE_INVALID);
660-
return FloatBits::build_quiet_nan().get_val();
660+
return FloatBits::quiet_nan().get_val();
661661
}
662662
}
663663
}

libc/src/math/generic/sincosf.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ LLVM_LIBC_FUNCTION(void, sincosf, (float x, float *sinp, float *cosp)) {
148148
fputil::set_errno_if_required(EDOM);
149149
fputil::raise_except_if_required(FE_INVALID);
150150
}
151-
*sinp = FPBits::build_quiet_nan().get_val();
151+
*sinp = FPBits::quiet_nan().get_val();
152152
*cosp = *sinp;
153153
return;
154154
}

libc/src/math/generic/sinf.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ LLVM_LIBC_FUNCTION(float, sinf, (float x)) {
139139
fputil::set_errno_if_required(EDOM);
140140
fputil::raise_except_if_required(FE_INVALID);
141141
}
142-
return x + FPBits::build_quiet_nan().get_val();
142+
return x + FPBits::quiet_nan().get_val();
143143
}
144144

145145
// Combine the results with the sine of sum formula:

libc/src/math/generic/tanf.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ LLVM_LIBC_FUNCTION(float, tanf, (float x)) {
114114
fputil::set_errno_if_required(EDOM);
115115
fputil::raise_except_if_required(FE_INVALID);
116116
}
117-
return x + FPBits::build_quiet_nan().get_val();
117+
return x + FPBits::quiet_nan().get_val();
118118
}
119119
// Other large exceptional values
120120
if (auto r = TANF_EXCEPTS.lookup_odd(x_abs, x_sign);

libc/test/UnitTest/FPMatcher.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ template <typename T> struct FPTest : public Test {
6868
LIBC_NAMESPACE::cpp::numeric_limits<StorageType>::max();
6969
static constexpr T zero = FPBits::zero(Sign::POS).get_val();
7070
static constexpr T neg_zero = FPBits::zero(Sign::NEG).get_val();
71-
static constexpr T aNaN = FPBits::build_quiet_nan().get_val();
72-
static constexpr T sNaN = FPBits::build_nan().get_val();
71+
static constexpr T aNaN = FPBits::quiet_nan().get_val();
72+
static constexpr T sNaN = FPBits::signaling_nan().get_val();
7373
static constexpr T inf = FPBits::inf(Sign::POS).get_val();
7474
static constexpr T neg_inf = FPBits::inf(Sign::NEG).get_val();
7575
static constexpr T min_normal = FPBits::min_normal().get_val();
@@ -97,8 +97,8 @@ template <typename T> struct FPTest : public Test {
9797
LIBC_NAMESPACE::cpp::numeric_limits<StorageType>::max(); \
9898
const T zero = FPBits::zero(Sign::POS).get_val(); \
9999
const T neg_zero = FPBits::zero(Sign::NEG).get_val(); \
100-
const T aNaN = FPBits::build_quiet_nan().get_val(); \
101-
const T sNaN = FPBits::build_nan().get_val(); \
100+
const T aNaN = FPBits::quiet_nan().get_val(); \
101+
const T sNaN = FPBits::signaling_nan().get_val(); \
102102
const T inf = FPBits::inf(Sign::POS).get_val(); \
103103
const T neg_inf = FPBits::inf(Sign::NEG).get_val(); \
104104
const T min_normal = FPBits::min_normal().get_val(); \

0 commit comments

Comments
 (0)