diff --git a/libc/src/__support/FPUtil/Hypot.h b/libc/src/__support/FPUtil/Hypot.h --- a/libc/src/__support/FPUtil/Hypot.h +++ b/libc/src/__support/FPUtil/Hypot.h @@ -100,14 +100,14 @@ // template , int> = 0> LIBC_INLINE T hypot(T x, T y) { - using FPBits_t = FPBits; + using FPB = FPBits; using UIntType = typename FPBits::UIntType; using DUIntType = typename DoubleLength::Type; - FPBits_t x_bits(x), y_bits(y); + FPB x_bits(x), y_bits(y); if (x_bits.is_inf() || y_bits.is_inf()) { - return T(FPBits_t::inf()); + return T(FPB::inf()); } if (x_bits.is_nan()) { return x; @@ -189,11 +189,11 @@ sticky_bits = sticky_bits || ((sum & 0x3U) != 0); sum >>= 2; ++out_exp; - if (out_exp >= FPBits_t::MAX_EXPONENT) { + if (out_exp >= FPB::MAX_EXPONENT) { if (int round_mode = get_round(); round_mode == FE_TONEAREST || round_mode == FE_UPWARD) - return T(FPBits_t::inf()); - return T(FPBits_t(FPBits_t::MAX_NORMAL)); + return T(FPB::inf()); + return T(FPB(FPB::MAX_NORMAL)); } } else { // For denormal result, we simply move the leading bit of the result to @@ -247,10 +247,10 @@ if (y_new >= (ONE >> 1)) { y_new -= ONE >> 1; ++out_exp; - if (out_exp >= FPBits_t::MAX_EXPONENT) { + if (out_exp >= FPB::MAX_EXPONENT) { if (round_mode == FE_TONEAREST || round_mode == FE_UPWARD) - return T(FPBits_t::inf()); - return T(FPBits_t(FPBits_t::MAX_NORMAL)); + return T(FPB::inf()); + return T(FPB(FPB::MAX_NORMAL)); } } diff --git a/libc/src/__support/FPUtil/generic/FMA.h b/libc/src/__support/FPUtil/generic/FMA.h --- a/libc/src/__support/FPUtil/generic/FMA.h +++ b/libc/src/__support/FPUtil/generic/FMA.h @@ -92,7 +92,7 @@ } // namespace internal template <> LIBC_INLINE double fma(double x, double y, double z) { - using FPBits = fputil::FPBits; + using FPB = fputil::FPBits; using FloatProp = fputil::FloatProperties; if (unlikely(x == 0 || y == 0 || z == 0)) { @@ -104,20 +104,20 @@ int z_exp = 0; // Normalize denormal inputs. - if (unlikely(FPBits(x).get_unbiased_exponent() == 0)) { + if (unlikely(FPB(x).get_unbiased_exponent() == 0)) { x_exp -= 52; x *= 0x1.0p+52; } - if (unlikely(FPBits(y).get_unbiased_exponent() == 0)) { + if (unlikely(FPB(y).get_unbiased_exponent() == 0)) { y_exp -= 52; y *= 0x1.0p+52; } - if (unlikely(FPBits(z).get_unbiased_exponent() == 0)) { + if (unlikely(FPB(z).get_unbiased_exponent() == 0)) { z_exp -= 52; z *= 0x1.0p+52; } - FPBits x_bits(x), y_bits(y), z_bits(z); + FPB x_bits(x), y_bits(y), z_bits(z); bool x_sign = x_bits.get_sign(); bool y_sign = y_bits.get_sign(); bool z_sign = z_bits.get_sign(); @@ -126,14 +126,14 @@ y_exp += y_bits.get_unbiased_exponent(); z_exp += z_bits.get_unbiased_exponent(); - if (unlikely(x_exp == FPBits::MAX_EXPONENT || y_exp == FPBits::MAX_EXPONENT || - z_exp == FPBits::MAX_EXPONENT)) + if (unlikely(x_exp == FPB::MAX_EXPONENT || y_exp == FPB::MAX_EXPONENT || + z_exp == FPB::MAX_EXPONENT)) return x * y + z; // Extract mantissa and append hidden leading bits. - UInt128 x_mant = x_bits.get_mantissa() | FPBits::MIN_NORMAL; - UInt128 y_mant = y_bits.get_mantissa() | FPBits::MIN_NORMAL; - UInt128 z_mant = z_bits.get_mantissa() | FPBits::MIN_NORMAL; + UInt128 x_mant = x_bits.get_mantissa() | FPB::MIN_NORMAL; + UInt128 y_mant = y_bits.get_mantissa() | FPB::MIN_NORMAL; + UInt128 z_mant = z_bits.get_mantissa() | FPB::MIN_NORMAL; // If the exponent of the product x*y > the exponent of z, then no extra // precision beside the entire product x*y is needed. On the other hand, when @@ -157,7 +157,7 @@ UInt128 prod_mant = x_mant * y_mant << 10; int prod_lsb_exp = x_exp + y_exp - - (FPBits::EXPONENT_BIAS + 2 * MantissaWidth::VALUE + 10); + (FPB::EXPONENT_BIAS + 2 * MantissaWidth::VALUE + 10); z_mant <<= 64; int z_lsb_exp = z_exp - (MantissaWidth::VALUE + 64); @@ -253,16 +253,16 @@ // Finalize the result. int round_mode = fputil::get_round(); - if (unlikely(r_exp >= FPBits::MAX_EXPONENT)) { + if (unlikely(r_exp >= FPB::MAX_EXPONENT)) { if ((round_mode == FE_TOWARDZERO) || (round_mode == FE_UPWARD && prod_sign) || (round_mode == FE_DOWNWARD && !prod_sign)) { - result = FPBits::MAX_NORMAL; + result = FPB::MAX_NORMAL; return prod_sign ? -cpp::bit_cast(result) : cpp::bit_cast(result); } - return prod_sign ? static_cast(FPBits::neg_inf()) - : static_cast(FPBits::inf()); + return prod_sign ? static_cast(FPB::neg_inf()) + : static_cast(FPB::inf()); } // Remove hidden bit and append the exponent field and sign bit. diff --git a/libc/src/__support/FPUtil/x86_64/NextAfterLongDouble.h b/libc/src/__support/FPUtil/x86_64/NextAfterLongDouble.h --- a/libc/src/__support/FPUtil/x86_64/NextAfterLongDouble.h +++ b/libc/src/__support/FPUtil/x86_64/NextAfterLongDouble.h @@ -24,12 +24,12 @@ namespace fputil { LIBC_INLINE long double nextafter(long double from, long double to) { - using FPBits = FPBits; - FPBits from_bits(from); + using FPB = FPBits; + FPB from_bits(from); if (from_bits.is_nan()) return from; - FPBits to_bits(to); + FPB to_bits(to); if (to_bits.is_nan()) return to; @@ -42,17 +42,17 @@ from_bits.set_unbiased_exponent(1); } - using UIntType = FPBits::UIntType; + using UIntType = FPB::UIntType; constexpr UIntType SIGN_VAL = (UIntType(1) << 79); constexpr UIntType MANTISSA_MASK = (UIntType(1) << MantissaWidth::VALUE) - 1; UIntType int_val = from_bits.uintval(); if (from < 0.0l) { if (from > to) { - if (int_val == (SIGN_VAL + FPBits::MAX_SUBNORMAL)) { + if (int_val == (SIGN_VAL + FPB::MAX_SUBNORMAL)) { // We deal with normal/subnormal boundary separately to avoid // dealing with the implicit bit. - int_val = SIGN_VAL + FPBits::MIN_NORMAL; + int_val = SIGN_VAL + FPB::MIN_NORMAL; } else if ((int_val & MANTISSA_MASK) == MANTISSA_MASK) { from_bits.set_mantissa(0); // Incrementing exponent might overflow the value to infinity, @@ -64,10 +64,10 @@ ++int_val; } } else { - if (int_val == (SIGN_VAL + FPBits::MIN_NORMAL)) { + if (int_val == (SIGN_VAL + FPB::MIN_NORMAL)) { // We deal with normal/subnormal boundary separately to avoid // dealing with the implicit bit. - int_val = SIGN_VAL + FPBits::MAX_SUBNORMAL; + int_val = SIGN_VAL + FPB::MAX_SUBNORMAL; } else if ((int_val & MANTISSA_MASK) == 0) { from_bits.set_mantissa(MANTISSA_MASK); // from == 0 is handled separately so decrementing the exponent will not @@ -85,8 +85,8 @@ int_val = 1; } else { if (from > to) { - if (int_val == FPBits::MIN_NORMAL) { - int_val = FPBits::MAX_SUBNORMAL; + if (int_val == FPB::MIN_NORMAL) { + int_val = FPB::MAX_SUBNORMAL; } else if ((int_val & MANTISSA_MASK) == 0) { from_bits.set_mantissa(MANTISSA_MASK); // from == 0 is handled separately so decrementing the exponent will not @@ -97,8 +97,8 @@ --int_val; } } else { - if (int_val == FPBits::MAX_SUBNORMAL) { - int_val = FPBits::MIN_NORMAL; + if (int_val == FPB::MAX_SUBNORMAL) { + int_val = FPB::MIN_NORMAL; } else if ((int_val & MANTISSA_MASK) == MANTISSA_MASK) { from_bits.set_mantissa(0); // Incrementing exponent might overflow the value to infinity, diff --git a/libc/src/math/generic/acosf.cpp b/libc/src/math/generic/acosf.cpp --- a/libc/src/math/generic/acosf.cpp +++ b/libc/src/math/generic/acosf.cpp @@ -36,8 +36,8 @@ }}; LLVM_LIBC_FUNCTION(float, acosf, (float x)) { - using FPBits = typename fputil::FPBits; - FPBits xbits(x); + using FPB = typename fputil::FPBits; + FPB xbits(x); uint32_t x_uint = xbits.uintval(); uint32_t x_abs = xbits.uintval() & 0x7fff'ffffU; uint32_t x_sign = x_uint >> 31; @@ -78,8 +78,7 @@ errno = EDOM; fputil::set_except(FE_INVALID); } - return x + - FPBits::build_nan(1 << (fputil::MantissaWidth::VALUE - 1)); + return x + FPB::build_nan(1 << (fputil::MantissaWidth::VALUE - 1)); } // When 0.5 < |x| <= 1, we perform range reduction as follow: diff --git a/libc/src/math/generic/asinf.cpp b/libc/src/math/generic/asinf.cpp --- a/libc/src/math/generic/asinf.cpp +++ b/libc/src/math/generic/asinf.cpp @@ -42,8 +42,8 @@ }}; LLVM_LIBC_FUNCTION(float, asinf, (float x)) { - using FPBits = typename fputil::FPBits; - FPBits xbits(x); + using FPB = typename fputil::FPBits; + FPB xbits(x); uint32_t x_uint = xbits.uintval(); uint32_t x_abs = xbits.uintval() & 0x7fff'ffffU; constexpr double SIGN[2] = {1.0, -1.0}; @@ -107,8 +107,7 @@ errno = EDOM; fputil::set_except(FE_INVALID); } - return x + - FPBits::build_nan(1 << (fputil::MantissaWidth::VALUE - 1)); + return x + FPB::build_nan(1 << (fputil::MantissaWidth::VALUE - 1)); } // Check for exceptional values diff --git a/libc/src/math/generic/asinhf.cpp b/libc/src/math/generic/asinhf.cpp --- a/libc/src/math/generic/asinhf.cpp +++ b/libc/src/math/generic/asinhf.cpp @@ -17,10 +17,10 @@ namespace __llvm_libc { LLVM_LIBC_FUNCTION(float, asinhf, (float x)) { - using FPBits_t = typename fputil::FPBits; - FPBits_t xbits(x); + using FPB = typename fputil::FPBits; + FPB xbits(x); uint32_t x_u = xbits.uintval(); - uint32_t x_abs = x_u & FPBits_t::FloatProp::EXP_MANT_MASK; + uint32_t x_abs = x_u & FPB::FloatProp::EXP_MANT_MASK; // |x| <= 2^-3 if (unlikely(x_abs <= 0x3e80'0000U)) { diff --git a/libc/src/math/generic/atanf.cpp b/libc/src/math/generic/atanf.cpp --- a/libc/src/math/generic/atanf.cpp +++ b/libc/src/math/generic/atanf.cpp @@ -14,8 +14,8 @@ namespace __llvm_libc { LLVM_LIBC_FUNCTION(float, atanf, (float x)) { - using FPBits = typename fputil::FPBits; - FPBits xbits(x); + using FPB = typename fputil::FPBits; + FPB xbits(x); bool sign = xbits.get_sign(); xbits.set_sign(false); @@ -29,7 +29,7 @@ if (unlikely(xbits.uintval() == 0x3d8d6b23U)) { if (fputil::get_round() == FE_TONEAREST) { // 0.06894256919622421 - FPBits br(0x3d8d31c3U); + FPB br(0x3d8d31c3U); br.set_sign(sign); return br.get_val(); } @@ -41,12 +41,12 @@ if (sign) { if (rounding_mode == FE_DOWNWARD) { // -1.0790828466415405 - return FPBits(0xbf8a1f63U).get_val(); + return FPB(0xbf8a1f63U).get_val(); } } else { if (rounding_mode == FE_UPWARD) { // 1.0790828466415405 - return FPBits(0x3f8a1f63U).get_val(); + return FPB(0x3f8a1f63U).get_val(); } } } diff --git a/libc/src/math/generic/atanhf.cpp b/libc/src/math/generic/atanhf.cpp --- a/libc/src/math/generic/atanhf.cpp +++ b/libc/src/math/generic/atanhf.cpp @@ -13,10 +13,10 @@ namespace __llvm_libc { LLVM_LIBC_FUNCTION(float, atanhf, (float x)) { - using FPBits = typename fputil::FPBits; - FPBits xbits(x); + using FPB = typename fputil::FPBits; + FPB xbits(x); bool sign = xbits.get_sign(); - uint32_t x_abs = xbits.uintval() & FPBits::FloatProp::EXP_MANT_MASK; + uint32_t x_abs = xbits.uintval() & FPB::FloatProp::EXP_MANT_MASK; // |x| >= 1.0 if (unlikely(x_abs >= 0x3F80'0000U)) { @@ -26,12 +26,11 @@ // |x| == 0 if (x_abs == 0x3F80'0000U) { fputil::set_except(FE_DIVBYZERO); - return with_errno(FPBits::inf(sign).get_val(), ERANGE); + return with_errno(FPB::inf(sign).get_val(), ERANGE); } else { fputil::set_except(FE_INVALID); return with_errno( - FPBits::build_nan(1 << (fputil::MantissaWidth::VALUE - 1)), - EDOM); + FPB::build_nan(1 << (fputil::MantissaWidth::VALUE - 1)), EDOM); } } diff --git a/libc/src/math/generic/cosf.cpp b/libc/src/math/generic/cosf.cpp --- a/libc/src/math/generic/cosf.cpp +++ b/libc/src/math/generic/cosf.cpp @@ -40,8 +40,8 @@ }}; LLVM_LIBC_FUNCTION(float, cosf, (float x)) { - using FPBits = typename fputil::FPBits; - FPBits xbits(x); + using FPB = typename fputil::FPBits; + FPB xbits(x); xbits.set_sign(false); uint32_t x_abs = xbits.uintval(); @@ -116,8 +116,7 @@ errno = EDOM; fputil::set_except(FE_INVALID); } - return x + - FPBits::build_nan(1 << (fputil::MantissaWidth::VALUE - 1)); + return x + FPB::build_nan(1 << (fputil::MantissaWidth::VALUE - 1)); } // Combine the results with the sine of sum formula: diff --git a/libc/src/math/generic/coshf.cpp b/libc/src/math/generic/coshf.cpp --- a/libc/src/math/generic/coshf.cpp +++ b/libc/src/math/generic/coshf.cpp @@ -14,8 +14,8 @@ namespace __llvm_libc { LLVM_LIBC_FUNCTION(float, coshf, (float x)) { - using FPBits = typename fputil::FPBits; - FPBits xbits(x); + using FPB = typename fputil::FPBits; + FPB xbits(x); xbits.set_sign(false); x = xbits.get_val(); @@ -29,15 +29,15 @@ // When |x| >= 90, or x is inf or nan if (unlikely(x_u >= 0x42b4'0000U)) { if (xbits.is_inf_or_nan()) - return x + FPBits::inf().get_val(); + return x + FPB::inf().get_val(); int rounding = fputil::get_round(); if (unlikely(rounding == FE_DOWNWARD || rounding == FE_TOWARDZERO)) - return FPBits(FPBits::MAX_NORMAL).get_val(); + return FPB(FPB::MAX_NORMAL).get_val(); errno = ERANGE; - return x + FPBits::inf().get_val(); + return x + FPB::inf().get_val(); } // TODO: We should be able to reduce the latency and reciprocal throughput diff --git a/libc/src/math/generic/dp_trig.cpp b/libc/src/math/generic/dp_trig.cpp --- a/libc/src/math/generic/dp_trig.cpp +++ b/libc/src/math/generic/dp_trig.cpp @@ -11,7 +11,7 @@ #include "src/__support/FPUtil/UInt.h" #include "src/__support/FPUtil/XFloat.h" -using FPBits = __llvm_libc::fputil::FPBits; +using FPB = __llvm_libc::fputil::FPBits; namespace __llvm_libc { @@ -29,7 +29,7 @@ static double mod_impl(double x, const uint64_t y_bits[3], const uint64_t inv_y_bits[20], int y_exponent, int inv_y_exponent) { - FPBits bits(x); + FPB bits(x); int exponent = bits.get_exponent(); int bit_drop = (exponent - 52) + inv_y_exponent + 1; bit_drop = bit_drop >= 0 ? bit_drop : 0; diff --git a/libc/src/math/generic/exp10f.cpp b/libc/src/math/generic/exp10f.cpp --- a/libc/src/math/generic/exp10f.cpp +++ b/libc/src/math/generic/exp10f.cpp @@ -21,8 +21,8 @@ namespace __llvm_libc { LLVM_LIBC_FUNCTION(float, exp10f, (float x)) { - using FPBits = typename fputil::FPBits; - FPBits xbits(x); + using FPB = typename fputil::FPBits; + FPB xbits(x); uint32_t x_u = xbits.uintval(); uint32_t x_abs = x_u & 0x7fff'ffffU; @@ -38,7 +38,7 @@ if (xbits.is_nan()) return x; if (fputil::get_round() == FE_UPWARD) - return static_cast(FPBits(FPBits::MIN_SUBNORMAL)); + return static_cast(FPB(FPB::MIN_SUBNORMAL)); errno = ERANGE; return 0.0f; } @@ -48,12 +48,12 @@ if (x_u < 0x7f80'0000U) { int rounding = fputil::get_round(); if (rounding == FE_DOWNWARD || rounding == FE_TOWARDZERO) - return static_cast(FPBits(FPBits::MAX_NORMAL)); + return static_cast(FPB(FPB::MAX_NORMAL)); errno = ERANGE; } // x is +inf or nan - return x + static_cast(FPBits::inf()); + return x + static_cast(FPB::inf()); } } diff --git a/libc/src/math/generic/exp2f.cpp b/libc/src/math/generic/exp2f.cpp --- a/libc/src/math/generic/exp2f.cpp +++ b/libc/src/math/generic/exp2f.cpp @@ -25,8 +25,8 @@ constexpr uint32_t exval_mask = exval1 & exval2; LLVM_LIBC_FUNCTION(float, exp2f, (float x)) { - using FPBits = typename fputil::FPBits; - FPBits xbits(x); + using FPB = typename fputil::FPBits; + FPB xbits(x); uint32_t x_u = xbits.uintval(); uint32_t x_abs = x_u & 0x7fff'ffffU; @@ -45,12 +45,12 @@ if (x_u < 0x7f80'0000U) { int rounding = fputil::get_round(); if (rounding == FE_DOWNWARD || rounding == FE_TOWARDZERO) - return static_cast(FPBits(FPBits::MAX_NORMAL)); + return static_cast(FPB(FPB::MAX_NORMAL)); errno = ERANGE; } // x is +inf or nan - return x + FPBits::inf().get_val(); + return x + FPB::inf().get_val(); } // x <= -150 if (x_u >= 0xc316'0000U) { @@ -61,7 +61,7 @@ if (xbits.is_nan()) return x; if (fputil::get_round() == FE_UPWARD) - return FPBits(FPBits::MIN_SUBNORMAL).get_val(); + return FPB(FPB::MIN_SUBNORMAL).get_val(); if (x != 0.0f) errno = ERANGE; return 0.0f; diff --git a/libc/src/math/generic/expf.cpp b/libc/src/math/generic/expf.cpp --- a/libc/src/math/generic/expf.cpp +++ b/libc/src/math/generic/expf.cpp @@ -21,8 +21,8 @@ namespace __llvm_libc { LLVM_LIBC_FUNCTION(float, expf, (float x)) { - using FPBits = typename fputil::FPBits; - FPBits xbits(x); + using FPB = typename fputil::FPBits; + FPB xbits(x); uint32_t x_u = xbits.uintval(); uint32_t x_abs = x_u & 0x7fff'ffffU; @@ -48,7 +48,7 @@ if (xbits.is_nan()) return x; if (fputil::get_round() == FE_UPWARD) - return static_cast(FPBits(FPBits::MIN_SUBNORMAL)); + return static_cast(FPB(FPB::MIN_SUBNORMAL)); errno = ERANGE; return 0.0f; } @@ -58,12 +58,12 @@ if (xbits.uintval() < 0x7f80'0000U) { int rounding = fputil::get_round(); if (rounding == FE_DOWNWARD || rounding == FE_TOWARDZERO) - return static_cast(FPBits(FPBits::MAX_NORMAL)); + return static_cast(FPB(FPB::MAX_NORMAL)); errno = ERANGE; } // x is +inf or nan - return x + static_cast(FPBits::inf()); + return x + static_cast(FPB::inf()); } } // For -104 < x < 89, to compute exp(x), we perform the following range diff --git a/libc/src/math/generic/expm1f.cpp b/libc/src/math/generic/expm1f.cpp --- a/libc/src/math/generic/expm1f.cpp +++ b/libc/src/math/generic/expm1f.cpp @@ -23,8 +23,8 @@ namespace __llvm_libc { LLVM_LIBC_FUNCTION(float, expm1f, (float x)) { - using FPBits = typename fputil::FPBits; - FPBits xbits(x); + using FPB = typename fputil::FPBits; + FPB xbits(x); uint32_t x_u = xbits.uintval(); uint32_t x_abs = x_u & 0x7fff'ffffU; @@ -66,11 +66,11 @@ if (xbits.uintval() < 0x7f80'0000U) { int rounding = fputil::get_round(); if (rounding == FE_DOWNWARD || rounding == FE_TOWARDZERO) - return static_cast(FPBits(FPBits::MAX_NORMAL)); + return static_cast(FPB(FPB::MAX_NORMAL)); errno = ERANGE; } - return x + static_cast(FPBits::inf()); + return x + static_cast(FPB::inf()); } } } diff --git a/libc/src/math/generic/hypotf.cpp b/libc/src/math/generic/hypotf.cpp --- a/libc/src/math/generic/hypotf.cpp +++ b/libc/src/math/generic/hypotf.cpp @@ -15,9 +15,9 @@ LLVM_LIBC_FUNCTION(float, hypotf, (float x, float y)) { using DoubleBits = fputil::FPBits; - using FPBits = fputil::FPBits; + using FPB = fputil::FPBits; - FPBits x_bits(x), y_bits(y); + FPB x_bits(x), y_bits(y); uint16_t x_exp = x_bits.get_unbiased_exponent(); uint16_t y_exp = y_bits.get_unbiased_exponent(); @@ -57,10 +57,10 @@ result.bits -= 1ULL; } } else { - FPBits bits_x(x), bits_y(y); + FPB bits_x(x), bits_y(y); if (bits_x.is_inf_or_nan() || bits_y.is_inf_or_nan()) { if (bits_x.is_inf() || bits_y.is_inf()) - return static_cast(FPBits::inf()); + return static_cast(FPB::inf()); if (bits_x.is_nan()) return x; return y; diff --git a/libc/src/math/generic/log10.cpp b/libc/src/math/generic/log10.cpp --- a/libc/src/math/generic/log10.cpp +++ b/libc/src/math/generic/log10.cpp @@ -944,18 +944,18 @@ // TODO(lntue): Make the implementation correctly rounded for non-FMA targets. LLVM_LIBC_FUNCTION(double, log10, (double x)) { - using FPBits_t = typename fputil::FPBits; - FPBits_t xbits(x); + using FPB = typename fputil::FPBits; + FPB xbits(x); int x_e = -1023; - if (unlikely(xbits.uintval() < FPBits_t::MIN_NORMAL || - xbits.uintval() > FPBits_t::MAX_NORMAL)) { + if (unlikely(xbits.uintval() < FPB::MIN_NORMAL || + xbits.uintval() > FPB::MAX_NORMAL)) { if (xbits.is_zero()) { // return -Inf and raise FE_DIVBYZERO. return -1.0 / 0.0; } if (xbits.get_sign() && !xbits.is_nan()) { - return FPBits_t::build_quiet_nan(0); + return FPB::build_quiet_nan(0); } if (xbits.is_inf_or_nan()) { return x; @@ -1001,7 +1001,7 @@ fputil::DoubleDouble rr = fputil::exact_add(hi, lo); uint64_t x_m = (x_u & 0x000F'FFFF'FFFF'FFFFULL) | 0x3FF0'0000'0000'0000ULL; - double m = FPBits_t(x_m).get_val(); + double m = FPB(x_m).get_val(); double u = fputil::multiply_add(r, m, -1.0); // exact err = fputil::multiply_add(u, P_ERR, err); diff --git a/libc/src/math/generic/log10f.cpp b/libc/src/math/generic/log10f.cpp --- a/libc/src/math/generic/log10f.cpp +++ b/libc/src/math/generic/log10f.cpp @@ -104,8 +104,8 @@ LLVM_LIBC_FUNCTION(float, log10f, (float x)) { constexpr double LOG10_2 = 0x1.34413509f79ffp-2; - using FPBits = typename fputil::FPBits; - FPBits xbits(x); + using FPB = typename fputil::FPBits; + FPB xbits(x); double m = 0.0; // Exact powers of 10 and other hard-to-round cases. @@ -142,13 +142,12 @@ } } - if (xbits.uintval() < FPBits::MIN_NORMAL || - xbits.uintval() > FPBits::MAX_NORMAL) { + if (xbits.uintval() < FPB::MIN_NORMAL || xbits.uintval() > FPB::MAX_NORMAL) { if (xbits.is_zero()) { - return static_cast(FPBits::neg_inf()); + return static_cast(FPB::neg_inf()); } if (xbits.get_sign() && !xbits.is_nan()) { - return FPBits::build_nan(1 << (fputil::MantissaWidth::VALUE - 1)); + return FPB::build_nan(1 << (fputil::MantissaWidth::VALUE - 1)); } if (xbits.is_inf_or_nan()) { return x; @@ -163,7 +162,7 @@ xbits.set_unbiased_exponent(0x7F); int f_index = xbits.get_mantissa() >> 16; - FPBits f = xbits; + FPB f = xbits; f.bits &= ~0x0000'FFFF; double d = static_cast(xbits) - static_cast(f); diff --git a/libc/src/math/generic/log1pf.cpp b/libc/src/math/generic/log1pf.cpp --- a/libc/src/math/generic/log1pf.cpp +++ b/libc/src/math/generic/log1pf.cpp @@ -35,14 +35,14 @@ static inline float log(double x) { constexpr double LOG_2 = 0x1.62e42fefa39efp-1; - using FPBits = typename fputil::FPBits; - FPBits xbits(x); + using FPB = typename fputil::FPBits; + FPB xbits(x); if (xbits.is_zero()) { return static_cast(fputil::FPBits::neg_inf()); } - if (xbits.uintval() > FPBits::MAX_NORMAL) { + if (xbits.uintval() > FPB::MAX_NORMAL) { if (xbits.get_sign() && !xbits.is_nan()) { return fputil::FPBits::build_nan( 1 << (fputil::MantissaWidth::VALUE - 1)); @@ -59,7 +59,7 @@ int f_index = xbits.get_mantissa() >> 45; // fputil::MantissaWidth::VALUE - 7 - FPBits f = xbits; + FPB f = xbits; // Clear the lowest 45 bits. f.bits &= ~0x0000'1FFF'FFFF'FFFFULL; @@ -78,8 +78,8 @@ } // namespace internal LLVM_LIBC_FUNCTION(float, log1pf, (float x)) { - using FPBits = typename fputil::FPBits; - FPBits xbits(x); + using FPB = typename fputil::FPBits; + FPB xbits(x); double xd = static_cast(x); if (xbits.get_exponent() >= -8) { diff --git a/libc/src/math/generic/log2f.cpp b/libc/src/math/generic/log2f.cpp --- a/libc/src/math/generic/log2f.cpp +++ b/libc/src/math/generic/log2f.cpp @@ -99,12 +99,12 @@ 0x1.fa34e1177c233p-1, 0x1.fd1be4c7f2af9p-1}; LLVM_LIBC_FUNCTION(float, log2f, (float x)) { - using FPBits = typename fputil::FPBits; - FPBits xbits(x); + using FPB = typename fputil::FPBits; + FPB xbits(x); int m = 0; // Hard to round value(s). - switch (FPBits(x).uintval()) { + switch (FPB(x).uintval()) { case 0x3f81d0b5U: { int rounding_mode = fputil::get_round(); if (rounding_mode == FE_DOWNWARD || rounding_mode == FE_TOWARDZERO) { @@ -125,13 +125,12 @@ } // Exceptional inputs. - if (xbits.uintval() < FPBits::MIN_NORMAL || - xbits.uintval() > FPBits::MAX_NORMAL) { + if (xbits.uintval() < FPB::MIN_NORMAL || xbits.uintval() > FPB::MAX_NORMAL) { if (xbits.is_zero()) { - return static_cast(FPBits::neg_inf()); + return static_cast(FPB::neg_inf()); } if (xbits.get_sign() && !xbits.is_nan()) { - return FPBits::build_nan(1 << (fputil::MantissaWidth::VALUE - 1)); + return FPB::build_nan(1 << (fputil::MantissaWidth::VALUE - 1)); } if (xbits.is_inf_or_nan()) { return x; @@ -148,7 +147,7 @@ // lookup tables. int f_index = xbits.get_mantissa() >> 16; - FPBits f = xbits; + FPB f = xbits; // Clear the lowest 16 bits. f.bits &= ~0x0000'FFFF; diff --git a/libc/src/math/generic/logf.cpp b/libc/src/math/generic/logf.cpp --- a/libc/src/math/generic/logf.cpp +++ b/libc/src/math/generic/logf.cpp @@ -51,10 +51,10 @@ LLVM_LIBC_FUNCTION(float, logf, (float x)) { constexpr double LOG_2 = 0x1.62e42fefa39efp-1; - using FPBits = typename fputil::FPBits; - FPBits xbits(x); + using FPB = typename fputil::FPBits; + FPB xbits(x); - switch (FPBits(x).uintval()) { + switch (FPB(x).uintval()) { case 0x41178febU: // x = 0x1.2f1fd6p+3f if (fputil::get_round() == FE_TONEAREST) return 0x1.1fcbcep+1f; @@ -91,13 +91,12 @@ int m = 0; - if (xbits.uintval() < FPBits::MIN_NORMAL || - xbits.uintval() > FPBits::MAX_NORMAL) { + if (xbits.uintval() < FPB::MIN_NORMAL || xbits.uintval() > FPB::MAX_NORMAL) { if (xbits.is_zero()) { - return static_cast(FPBits::neg_inf()); + return static_cast(FPB::neg_inf()); } if (xbits.get_sign() && !xbits.is_nan()) { - return FPBits::build_nan(1 << (fputil::MantissaWidth::VALUE - 1)); + return FPB::build_nan(1 << (fputil::MantissaWidth::VALUE - 1)); } if (xbits.is_inf_or_nan()) { return x; @@ -112,7 +111,7 @@ xbits.set_unbiased_exponent(0x7F); int f_index = xbits.get_mantissa() >> 16; - FPBits f = xbits; + FPB f = xbits; f.bits &= ~0x0000'FFFF; double d = static_cast(xbits) - static_cast(f); diff --git a/libc/src/math/generic/sincosf.cpp b/libc/src/math/generic/sincosf.cpp --- a/libc/src/math/generic/sincosf.cpp +++ b/libc/src/math/generic/sincosf.cpp @@ -49,8 +49,8 @@ }; LLVM_LIBC_FUNCTION(void, sincosf, (float x, float *sinp, float *cosp)) { - using FPBits = typename fputil::FPBits; - FPBits xbits(x); + using FPB = typename fputil::FPBits; + FPB xbits(x); uint32_t x_abs = xbits.uintval() & 0x7fff'ffffU; double xd = static_cast(x); @@ -131,11 +131,11 @@ // emulated version of FMA. #if defined(LIBC_TARGET_HAS_FMA) *sinp = fputil::multiply_add(x, -0x1.0p-25f, x); - *cosp = fputil::multiply_add(FPBits(x_abs).get_val(), -0x1.0p-25f, 1.0f); + *cosp = fputil::multiply_add(FPB(x_abs).get_val(), -0x1.0p-25f, 1.0f); #else *sinp = static_cast(fputil::multiply_add(xd, -0x1.0p-25, xd)); *cosp = static_cast(fputil::multiply_add( - static_cast(FPBits(x_abs).get_val()), -0x1.0p-25, 1.0)); + static_cast(FPB(x_abs).get_val()), -0x1.0p-25, 1.0)); #endif // LIBC_TARGET_HAS_FMA return; } @@ -146,8 +146,7 @@ errno = EDOM; fputil::set_except(FE_INVALID); } - *sinp = - x + FPBits::build_nan(1 << (fputil::MantissaWidth::VALUE - 1)); + *sinp = x + FPB::build_nan(1 << (fputil::MantissaWidth::VALUE - 1)); *cosp = *sinp; return; } @@ -172,8 +171,8 @@ c += EXCEPT_OUTPUTS_COS[i][3]; break; } - *sinp = x_sign ? -FPBits(s).get_val() : FPBits(s).get_val(); - *cosp = FPBits(c).get_val(); + *sinp = x_sign ? -FPB(s).get_val() : FPB(s).get_val(); + *cosp = FPB(c).get_val(); return; } diff --git a/libc/src/math/generic/sinf.cpp b/libc/src/math/generic/sinf.cpp --- a/libc/src/math/generic/sinf.cpp +++ b/libc/src/math/generic/sinf.cpp @@ -27,8 +27,8 @@ namespace __llvm_libc { LLVM_LIBC_FUNCTION(float, sinf, (float x)) { - using FPBits = typename fputil::FPBits; - FPBits xbits(x); + using FPB = typename fputil::FPBits; + FPB xbits(x); uint32_t x_u = xbits.uintval(); uint32_t x_abs = x_u & 0x7fff'ffffU; @@ -137,8 +137,7 @@ errno = EDOM; fputil::set_except(FE_INVALID); } - return x + - FPBits::build_nan(1 << (fputil::MantissaWidth::VALUE - 1)); + return x + FPB::build_nan(1 << (fputil::MantissaWidth::VALUE - 1)); } // Combine the results with the sine of sum formula: diff --git a/libc/src/math/generic/sinhf.cpp b/libc/src/math/generic/sinhf.cpp --- a/libc/src/math/generic/sinhf.cpp +++ b/libc/src/math/generic/sinhf.cpp @@ -13,10 +13,10 @@ namespace __llvm_libc { LLVM_LIBC_FUNCTION(float, sinhf, (float x)) { - using FPBits = typename fputil::FPBits; - FPBits xbits(x); + using FPB = typename fputil::FPBits; + FPB xbits(x); bool sign = xbits.get_sign(); - uint32_t x_abs = xbits.uintval() & FPBits::FloatProp::EXP_MANT_MASK; + uint32_t x_abs = xbits.uintval() & FPB::FloatProp::EXP_MANT_MASK; // |x| <= 2^-26 if (unlikely(x_abs <= 0x3280'0000U)) { @@ -34,16 +34,15 @@ int rounding = fputil::get_round(); if (sign) { if (unlikely(rounding == FE_UPWARD || rounding == FE_TOWARDZERO)) - return FPBits(FPBits::MAX_NORMAL | FPBits::FloatProp::SIGN_MASK) - .get_val(); + return FPB(FPB::MAX_NORMAL | FPB::FloatProp::SIGN_MASK).get_val(); } else { if (unlikely(rounding == FE_DOWNWARD || rounding == FE_TOWARDZERO)) - return FPBits(FPBits::MAX_NORMAL).get_val(); + return FPB(FPB::MAX_NORMAL).get_val(); } errno = ERANGE; - return x + FPBits::inf(sign).get_val(); + return x + FPB::inf(sign).get_val(); } // |x| <= 0.078125 diff --git a/libc/src/math/generic/tanf.cpp b/libc/src/math/generic/tanf.cpp --- a/libc/src/math/generic/tanf.cpp +++ b/libc/src/math/generic/tanf.cpp @@ -41,8 +41,8 @@ }}; LLVM_LIBC_FUNCTION(float, tanf, (float x)) { - using FPBits = typename fputil::FPBits; - FPBits xbits(x); + using FPB = typename fputil::FPBits; + FPB xbits(x); bool x_sign = xbits.uintval() >> 31; uint32_t x_abs = xbits.uintval() & 0x7fff'ffffU; @@ -108,8 +108,7 @@ errno = EDOM; fputil::set_except(FE_INVALID); } - return x + - FPBits::build_nan(1 << (fputil::MantissaWidth::VALUE - 1)); + return x + FPB::build_nan(1 << (fputil::MantissaWidth::VALUE - 1)); } // Other large exceptional values if (auto r = TANF_EXCEPTS.lookup_odd(x_abs, x_sign); diff --git a/libc/src/math/generic/tanhf.cpp b/libc/src/math/generic/tanhf.cpp --- a/libc/src/math/generic/tanhf.cpp +++ b/libc/src/math/generic/tanhf.cpp @@ -14,10 +14,10 @@ namespace __llvm_libc { LLVM_LIBC_FUNCTION(float, tanhf, (float x)) { - using FPBits = typename fputil::FPBits; - FPBits xbits(x); + using FPB = typename fputil::FPBits; + FPB xbits(x); bool sign = xbits.get_sign(); - uint32_t x_abs = xbits.uintval() & FPBits::FloatProp::EXP_MANT_MASK; + uint32_t x_abs = xbits.uintval() & FPB::FloatProp::EXP_MANT_MASK; // |x| <= 2^-26 if (unlikely(x_abs <= 0x3280'0000U)) { @@ -33,9 +33,9 @@ return sign ? -1.0f : 1.0f; if (sign) { - return -1.0f + opt_barrier(FPBits(FPBits::MIN_NORMAL).get_val()); + return -1.0f + opt_barrier(FPB(FPB::MIN_NORMAL).get_val()); } else - return 1.0f - opt_barrier(FPBits(FPBits::MIN_NORMAL).get_val()); + return 1.0f - opt_barrier(FPB(FPB::MIN_NORMAL).get_val()); } // |x| <= 0.078125 @@ -51,7 +51,7 @@ if (unlikely(xbits.bits == 0x4058'e0a3U)) { if (fputil::get_round() == FE_DOWNWARD) - return FPBits(0x3f7f'6ad9U).get_val(); + return FPB(0x3f7f'6ad9U).get_val(); } // Range reduction: e^(2x) = 2^(mid + hi) * e^lo diff --git a/libc/test/src/math/CeilTest.h b/libc/test/src/math/CeilTest.h --- a/libc/test/src/math/CeilTest.h +++ b/libc/test/src/math/CeilTest.h @@ -67,7 +67,7 @@ constexpr UIntType COUNT = 10000000; constexpr UIntType STEP = UIntType(-1) / COUNT; for (UIntType i = 0, v = 0; i <= COUNT; ++i, v += STEP) { - T x = T(FPBits(v)); + T x = T(FPB(v)); if (isnan(x) || isinf(x)) continue; diff --git a/libc/test/src/math/CopySignTest.h b/libc/test/src/math/CopySignTest.h --- a/libc/test/src/math/CopySignTest.h +++ b/libc/test/src/math/CopySignTest.h @@ -36,7 +36,7 @@ constexpr UIntType COUNT = 10000000; constexpr UIntType STEP = UIntType(-1) / COUNT; for (UIntType i = 0, v = 0; i <= COUNT; ++i, v += STEP) { - T x = T(FPBits(v)); + T x = T(FPB(v)); if (isnan(x) || isinf(x)) continue; diff --git a/libc/test/src/math/FAbsTest.h b/libc/test/src/math/FAbsTest.h --- a/libc/test/src/math/FAbsTest.h +++ b/libc/test/src/math/FAbsTest.h @@ -35,7 +35,7 @@ constexpr UIntType COUNT = 10000000; constexpr UIntType STEP = UIntType(-1) / COUNT; for (UIntType i = 0, v = 0; i <= COUNT; ++i, v += STEP) { - T x = T(FPBits(v)); + T x = T(FPB(v)); if (isnan(x) || isinf(x)) continue; ASSERT_MPFR_MATCH(mpfr::Operation::Abs, x, func(x), 0.0); diff --git a/libc/test/src/math/FDimTest.h b/libc/test/src/math/FDimTest.h --- a/libc/test/src/math/FDimTest.h +++ b/libc/test/src/math/FDimTest.h @@ -16,8 +16,8 @@ class FDimTestTemplate : public __llvm_libc::testing::Test { public: using FuncPtr = T (*)(T, T); - using FPBits = __llvm_libc::fputil::FPBits; - using UIntType = typename FPBits::UIntType; + using FPB = __llvm_libc::fputil::FPBits; + using UIntType = typename FPB::UIntType; void test_na_n_arg(FuncPtr func) { EXPECT_FP_EQ(nan, func(nan, inf)); @@ -57,7 +57,7 @@ constexpr UIntType STEP = UIntType(-1) / COUNT; for (UIntType i = 0, v = 0, w = UIntType(-1); i <= COUNT; ++i, v += STEP, w -= STEP) { - T x = T(FPBits(v)), y = T(FPBits(w)); + T x = T(FPB(v)), y = T(FPB(w)); if (isnan(x) || isinf(x)) continue; if (isnan(y) || isinf(y)) @@ -72,7 +72,7 @@ } private: - // constexpr does not work on FPBits yet, so we cannot have these constants as + // constexpr does not work on FPB yet, so we cannot have these constants as // static. const T nan = T(__llvm_libc::fputil::FPBits::build_quiet_nan(1)); const T inf = T(__llvm_libc::fputil::FPBits::inf()); diff --git a/libc/test/src/math/FMaxTest.h b/libc/test/src/math/FMaxTest.h --- a/libc/test/src/math/FMaxTest.h +++ b/libc/test/src/math/FMaxTest.h @@ -59,7 +59,7 @@ constexpr UIntType STEP = UIntType(-1) / COUNT; for (UIntType i = 0, v = 0, w = UIntType(-1); i <= COUNT; ++i, v += STEP, w -= STEP) { - T x = T(FPBits(v)), y = T(FPBits(w)); + T x = T(FPB(v)), y = T(FPB(w)); if (isnan(x) || isinf(x)) continue; if (isnan(y) || isinf(y)) diff --git a/libc/test/src/math/FMinTest.h b/libc/test/src/math/FMinTest.h --- a/libc/test/src/math/FMinTest.h +++ b/libc/test/src/math/FMinTest.h @@ -59,7 +59,7 @@ constexpr UIntType STEP = UIntType(-1) / COUNT; for (UIntType i = 0, v = 0, w = UIntType(-1); i <= COUNT; ++i, v += STEP, w -= STEP) { - T x = T(FPBits(v)), y = T(FPBits(w)); + T x = T(FPB(v)), y = T(FPB(w)); if (isnan(x) || isinf(x)) continue; if (isnan(y) || isinf(y)) diff --git a/libc/test/src/math/FloorTest.h b/libc/test/src/math/FloorTest.h --- a/libc/test/src/math/FloorTest.h +++ b/libc/test/src/math/FloorTest.h @@ -67,7 +67,7 @@ constexpr UIntType COUNT = 10000000; constexpr UIntType STEP = UIntType(-1) / COUNT; for (UIntType i = 0, v = 0; i <= COUNT; ++i, v += STEP) { - T x = T(FPBits(v)); + T x = T(FPB(v)); if (isnan(x) || isinf(x)) continue; diff --git a/libc/test/src/math/FmaTest.h b/libc/test/src/math/FmaTest.h --- a/libc/test/src/math/FmaTest.h +++ b/libc/test/src/math/FmaTest.h @@ -21,8 +21,8 @@ class FmaTestTemplate : public __llvm_libc::testing::Test { private: using Func = T (*)(T, T, T); - using FPBits = __llvm_libc::fputil::FPBits; - using UIntType = typename FPBits::UIntType; + using FPB = __llvm_libc::fputil::FPBits; + using UIntType = typename FPB::UIntType; const T nan = T(__llvm_libc::fputil::FPBits::build_quiet_nan(1)); const T inf = T(__llvm_libc::fputil::FPBits::inf()); const T neg_inf = T(__llvm_libc::fputil::FPBits::neg_inf()); @@ -50,16 +50,15 @@ EXPECT_FP_EQ(func(inf, neg_inf, nan), nan); // Test underflow rounding up. - EXPECT_FP_EQ(func(T(0.5), T(FPBits(FPBits::MIN_SUBNORMAL)), - T(FPBits(FPBits::MIN_SUBNORMAL))), - T(FPBits(UIntType(2)))); + EXPECT_FP_EQ( + func(T(0.5), T(FPB(FPB::MIN_SUBNORMAL)), T(FPB(FPB::MIN_SUBNORMAL))), + T(FPB(UIntType(2)))); // Test underflow rounding down. - T v = T(FPBits(FPBits::MIN_NORMAL + UIntType(1))); - EXPECT_FP_EQ(func(T(1) / T(FPBits::MIN_NORMAL << 1), v, - T(FPBits(FPBits::MIN_NORMAL))), - v); + T v = T(FPB(FPB::MIN_NORMAL + UIntType(1))); + EXPECT_FP_EQ( + func(T(1) / T(FPB::MIN_NORMAL << 1), v, T(FPB(FPB::MIN_NORMAL))), v); // Test overflow. - T z = T(FPBits(FPBits::MAX_NORMAL)); + T z = T(FPB(FPB::MAX_NORMAL)); EXPECT_FP_EQ(func(T(1.75), z, -z), T(0.75) * z); // Exact cancellation. EXPECT_FP_EQ(func(T(3.0), T(5.0), -T(15.0)), T(0.0)); @@ -68,13 +67,11 @@ void test_subnormal_range(Func func) { constexpr UIntType COUNT = 1000001; - constexpr UIntType STEP = - (FPBits::MAX_SUBNORMAL - FPBits::MIN_SUBNORMAL) / COUNT; - for (UIntType v = FPBits::MIN_SUBNORMAL, w = FPBits::MAX_SUBNORMAL; - v <= FPBits::MAX_SUBNORMAL && w >= FPBits::MIN_SUBNORMAL; + constexpr UIntType STEP = (FPB::MAX_SUBNORMAL - FPB::MIN_SUBNORMAL) / COUNT; + for (UIntType v = FPB::MIN_SUBNORMAL, w = FPB::MAX_SUBNORMAL; + v <= FPB::MAX_SUBNORMAL && w >= FPB::MIN_SUBNORMAL; v += STEP, w -= STEP) { - T x = T(FPBits(get_random_bit_pattern())), y = T(FPBits(v)), - z = T(FPBits(w)); + T x = T(FPB(get_random_bit_pattern())), y = T(FPB(v)), z = T(FPB(w)); mpfr::TernaryInput input{x, y, z}; ASSERT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Fma, input, func(x, y, z), 0.5); @@ -83,12 +80,10 @@ void test_normal_range(Func func) { constexpr UIntType COUNT = 1000001; - constexpr UIntType STEP = (FPBits::MAX_NORMAL - FPBits::MIN_NORMAL) / COUNT; - for (UIntType v = FPBits::MIN_NORMAL, w = FPBits::MAX_NORMAL; - v <= FPBits::MAX_NORMAL && w >= FPBits::MIN_NORMAL; - v += STEP, w -= STEP) { - T x = T(FPBits(v)), y = T(FPBits(w)), - z = T(FPBits(get_random_bit_pattern())); + constexpr UIntType STEP = (FPB::MAX_NORMAL - FPB::MIN_NORMAL) / COUNT; + for (UIntType v = FPB::MIN_NORMAL, w = FPB::MAX_NORMAL; + v <= FPB::MAX_NORMAL && w >= FPB::MIN_NORMAL; v += STEP, w -= STEP) { + T x = T(FPB(v)), y = T(FPB(w)), z = T(FPB(get_random_bit_pattern())); mpfr::TernaryInput input{x, y, z}; ASSERT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Fma, input, func(x, y, z), 0.5); diff --git a/libc/test/src/math/FrexpTest.h b/libc/test/src/math/FrexpTest.h --- a/libc/test/src/math/FrexpTest.h +++ b/libc/test/src/math/FrexpTest.h @@ -92,11 +92,11 @@ } void testRange(FrexpFunc func) { - using UIntType = typename FPBits::UIntType; + using UIntType = typename FPB::UIntType; constexpr UIntType COUNT = 10000000; constexpr UIntType STEP = UIntType(-1) / COUNT; for (UIntType i = 0, v = 0; i <= COUNT; ++i, v += STEP) { - T x = static_cast(FPBits(v)); + T x = static_cast(FPB(v)); if (isnan(x) || isinf(x) || x == 0.0l) continue; diff --git a/libc/test/src/math/HypotTest.h b/libc/test/src/math/HypotTest.h --- a/libc/test/src/math/HypotTest.h +++ b/libc/test/src/math/HypotTest.h @@ -22,17 +22,17 @@ class HypotTestTemplate : public __llvm_libc::testing::Test { private: using Func = T (*)(T, T); - using FPBits = __llvm_libc::fputil::FPBits; - using UIntType = typename FPBits::UIntType; - const T nan = T(FPBits::build_quiet_nan(1)); - const T inf = T(FPBits::inf()); - const T neg_inf = T(FPBits::neg_inf()); - const T zero = T(FPBits::zero()); - const T neg_zero = T(FPBits::neg_zero()); - const T max_normal = T(FPBits(FPBits::MAX_NORMAL)); - const T min_normal = T(FPBits(FPBits::MIN_NORMAL)); - const T max_subnormal = T(FPBits(FPBits::MAX_SUBNORMAL)); - const T min_subnormal = T(FPBits(FPBits::MIN_SUBNORMAL)); + using FPB = __llvm_libc::fputil::FPBits; + using UIntType = typename FPB::UIntType; + const T nan = T(FPB::build_quiet_nan(1)); + const T inf = T(FPB::inf()); + const T neg_inf = T(FPB::neg_inf()); + const T zero = T(FPB::zero()); + const T neg_zero = T(FPB::neg_zero()); + const T max_normal = T(FPB(FPB::MAX_NORMAL)); + const T min_normal = T(FPB(FPB::MIN_NORMAL)); + const T max_subnormal = T(FPB(FPB::MAX_SUBNORMAL)); + const T min_subnormal = T(FPB(FPB::MIN_SUBNORMAL)); public: void test_special_numbers(Func func) { @@ -61,13 +61,12 @@ void test_subnormal_range(Func func) { constexpr UIntType COUNT = 1000001; for (unsigned scale = 0; scale < 4; ++scale) { - UIntType max_value = FPBits::MAX_SUBNORMAL << scale; - UIntType step = (max_value - FPBits::MIN_SUBNORMAL) / COUNT; + UIntType max_value = FPB::MAX_SUBNORMAL << scale; + UIntType step = (max_value - FPB::MIN_SUBNORMAL) / COUNT; for (int signs = 0; signs < 4; ++signs) { - for (UIntType v = FPBits::MIN_SUBNORMAL, w = max_value; - v <= max_value && w >= FPBits::MIN_SUBNORMAL; - v += step, w -= step) { - T x = T(FPBits(v)), y = T(FPBits(w)); + for (UIntType v = FPB::MIN_SUBNORMAL, w = max_value; + v <= max_value && w >= FPB::MIN_SUBNORMAL; v += step, w -= step) { + T x = T(FPB(v)), y = T(FPB(w)); if (signs % 2 == 1) { x = -x; } @@ -85,12 +84,11 @@ void test_normal_range(Func func) { constexpr UIntType COUNT = 1000001; - constexpr UIntType STEP = (FPBits::MAX_NORMAL - FPBits::MIN_NORMAL) / COUNT; + constexpr UIntType STEP = (FPB::MAX_NORMAL - FPB::MIN_NORMAL) / COUNT; for (int signs = 0; signs < 4; ++signs) { - for (UIntType v = FPBits::MIN_NORMAL, w = FPBits::MAX_NORMAL; - v <= FPBits::MAX_NORMAL && w >= FPBits::MIN_NORMAL; - v += STEP, w -= STEP) { - T x = T(FPBits(v)), y = T(FPBits(w)); + for (UIntType v = FPB::MIN_NORMAL, w = FPB::MAX_NORMAL; + v <= FPB::MAX_NORMAL && w >= FPB::MIN_NORMAL; v += STEP, w -= STEP) { + T x = T(FPB(v)), y = T(FPB(w)); if (signs % 2 == 1) { x = -x; } diff --git a/libc/test/src/math/ILogbTest.h b/libc/test/src/math/ILogbTest.h --- a/libc/test/src/math/ILogbTest.h +++ b/libc/test/src/math/ILogbTest.h @@ -73,14 +73,12 @@ template void test_subnormal_range(typename ILogbFunc::Func func) { - using FPBits = __llvm_libc::fputil::FPBits; - using UIntType = typename FPBits::UIntType; + using FPB = __llvm_libc::fputil::FPBits; + using UIntType = typename FPB::UIntType; constexpr UIntType COUNT = 1000001; - constexpr UIntType STEP = - (FPBits::MAX_SUBNORMAL - FPBits::MIN_SUBNORMAL) / COUNT; - for (UIntType v = FPBits::MIN_SUBNORMAL; v <= FPBits::MAX_SUBNORMAL; - v += STEP) { - T x = T(FPBits(v)); + constexpr UIntType STEP = (FPB::MAX_SUBNORMAL - FPB::MIN_SUBNORMAL) / COUNT; + for (UIntType v = FPB::MIN_SUBNORMAL; v <= FPB::MAX_SUBNORMAL; v += STEP) { + T x = T(FPB(v)); if (isnan(x) || isinf(x) || x == 0.0) continue; @@ -92,12 +90,12 @@ template void test_normal_range(typename ILogbFunc::Func func) { - using FPBits = __llvm_libc::fputil::FPBits; - using UIntType = typename FPBits::UIntType; + using FPB = __llvm_libc::fputil::FPBits; + using UIntType = typename FPB::UIntType; constexpr UIntType COUNT = 1000001; - constexpr UIntType STEP = (FPBits::MAX_NORMAL - FPBits::MIN_NORMAL) / COUNT; - for (UIntType v = FPBits::MIN_NORMAL; v <= FPBits::MAX_NORMAL; v += STEP) { - T x = T(FPBits(v)); + constexpr UIntType STEP = (FPB::MAX_NORMAL - FPB::MIN_NORMAL) / COUNT; + for (UIntType v = FPB::MIN_NORMAL; v <= FPB::MAX_NORMAL; v += STEP) { + T x = T(FPB(v)); if (isnan(x) || isinf(x) || x == 0.0) continue; diff --git a/libc/test/src/math/LdExpTest.h b/libc/test/src/math/LdExpTest.h --- a/libc/test/src/math/LdExpTest.h +++ b/libc/test/src/math/LdExpTest.h @@ -20,9 +20,9 @@ template class LdExpTestTemplate : public __llvm_libc::testing::Test { - using FPBits = __llvm_libc::fputil::FPBits; + using FPB = __llvm_libc::fputil::FPBits; using NormalFloat = __llvm_libc::fputil::NormalFloat; - using UIntType = typename FPBits::UIntType; + using UIntType = typename FPB::UIntType; static constexpr UIntType MANTISSA_WIDTH = __llvm_libc::fputil::MantissaWidth::VALUE; // A normalized mantissa to be used with tests. @@ -60,7 +60,7 @@ } void testOverflow(LdExpFunc func) { - NormalFloat x(FPBits::MAX_EXPONENT - 10, NormalFloat::ONE + 0xF00BA, 0); + NormalFloat x(FPB::MAX_EXPONENT - 10, NormalFloat::ONE + 0xF00BA, 0); for (int32_t exp = 10; exp < 100; ++exp) { ASSERT_FP_EQ(inf, func(T(x), exp)); ASSERT_FP_EQ(neg_inf, func(-T(x), exp)); @@ -70,7 +70,7 @@ void testUnderflowToZeroOnNormal(LdExpFunc func) { // In this test, we pass a normal nubmer to func and expect zero // to be returned due to underflow. - int32_t base_exponent = FPBits::EXPONENT_BIAS + MANTISSA_WIDTH; + int32_t base_exponent = FPB::EXPONENT_BIAS + MANTISSA_WIDTH; int32_t exp_array[] = {base_exponent + 5, base_exponent + 4, base_exponent + 3, base_exponent + 2, base_exponent + 1}; @@ -83,11 +83,11 @@ void testUnderflowToZeroOnSubnormal(LdExpFunc func) { // In this test, we pass a normal nubmer to func and expect zero // to be returned due to underflow. - int32_t base_exponent = FPBits::EXPONENT_BIAS + MANTISSA_WIDTH; + int32_t base_exponent = FPB::EXPONENT_BIAS + MANTISSA_WIDTH; int32_t exp_array[] = {base_exponent + 5, base_exponent + 4, base_exponent + 3, base_exponent + 2, base_exponent + 1}; - T x = NormalFloat(-FPBits::EXPONENT_BIAS, MANTISSA, 0); + T x = NormalFloat(-FPB::EXPONENT_BIAS, MANTISSA, 0); for (int32_t exp : exp_array) { ASSERT_FP_EQ(func(x, -exp), x > 0 ? zero : neg_zero); } @@ -99,8 +99,8 @@ NormalFloat(100, MANTISSA, 0), NormalFloat(-100, MANTISSA, 0), NormalFloat(100, MANTISSA, 1), NormalFloat(-100, MANTISSA, 1), // Subnormal numbers - NormalFloat(-FPBits::EXPONENT_BIAS, MANTISSA, 0), - NormalFloat(-FPBits::EXPONENT_BIAS, MANTISSA, 1)}; + NormalFloat(-FPB::EXPONENT_BIAS, MANTISSA, 0), + NormalFloat(-FPB::EXPONENT_BIAS, MANTISSA, 1)}; for (int32_t exp = 0; exp <= static_cast(MANTISSA_WIDTH); ++exp) { for (T x : val_array) { // We compare the result of ldexp with the result @@ -111,32 +111,32 @@ } // Normal which trigger mantissa overflow. - T x = NormalFloat(-FPBits::EXPONENT_BIAS + 1, 2 * NormalFloat::ONE - 1, 0); + T x = NormalFloat(-FPB::EXPONENT_BIAS + 1, 2 * NormalFloat::ONE - 1, 0); ASSERT_FP_EQ(func(x, -1), x / 2); ASSERT_FP_EQ(func(-x, -1), -x / 2); // Start with a normal number high exponent but pass a very low number for // exp. The result should be a subnormal number. - x = NormalFloat(FPBits::EXPONENT_BIAS, NormalFloat::ONE, 0); - int exp = -FPBits::MAX_EXPONENT - 5; + x = NormalFloat(FPB::EXPONENT_BIAS, NormalFloat::ONE, 0); + int exp = -FPB::MAX_EXPONENT - 5; T result = func(x, exp); - FPBits result_bits(result); + FPB result_bits(result); ASSERT_FALSE(result_bits.is_zero()); // Verify that the result is indeed subnormal. ASSERT_EQ(result_bits.get_unbiased_exponent(), uint16_t(0)); // But if the exp is so less that normalization leads to zero, then // the result should be zero. - result = func(x, -FPBits::MAX_EXPONENT - int(MANTISSA_WIDTH) - 5); - ASSERT_TRUE(FPBits(result).is_zero()); + result = func(x, -FPB::MAX_EXPONENT - int(MANTISSA_WIDTH) - 5); + ASSERT_TRUE(FPB(result).is_zero()); // Start with a subnormal number but pass a very high number for exponent. // The result should not be infinity. - x = NormalFloat(-FPBits::EXPONENT_BIAS + 1, NormalFloat::ONE >> 10, 0); - exp = FPBits::MAX_EXPONENT + 5; - ASSERT_FALSE(FPBits(func(x, exp)).is_inf()); + x = NormalFloat(-FPB::EXPONENT_BIAS + 1, NormalFloat::ONE >> 10, 0); + exp = FPB::MAX_EXPONENT + 5; + ASSERT_FALSE(FPB(func(x, exp)).is_inf()); // But if the exp is large enough to oversome than the normalization shift, // then it should result in infinity. - exp = FPBits::MAX_EXPONENT + 15; + exp = FPB::MAX_EXPONENT + 15; ASSERT_FP_EQ(func(x, exp), inf); } }; diff --git a/libc/test/src/math/LogbTest.h b/libc/test/src/math/LogbTest.h --- a/libc/test/src/math/LogbTest.h +++ b/libc/test/src/math/LogbTest.h @@ -71,11 +71,11 @@ } void testRange(LogbFunc func) { - using UIntType = typename FPBits::UIntType; + using UIntType = typename FPB::UIntType; constexpr UIntType COUNT = 10000000; constexpr UIntType STEP = UIntType(-1) / COUNT; for (UIntType i = 0, v = 0; i <= COUNT; ++i, v += STEP) { - T x = static_cast(FPBits(v)); + T x = static_cast(FPB(v)); if (isnan(x) || isinf(x) || x == 0.0l) continue; diff --git a/libc/test/src/math/ModfTest.h b/libc/test/src/math/ModfTest.h --- a/libc/test/src/math/ModfTest.h +++ b/libc/test/src/math/ModfTest.h @@ -87,7 +87,7 @@ constexpr UIntType COUNT = 10000000; constexpr UIntType STEP = UIntType(-1) / COUNT; for (UIntType i = 0, v = 0; i <= COUNT; ++i, v += STEP) { - T x = T(FPBits(v)); + T x = T(FPB(v)); if (isnan(x) || isinf(x) || x == T(0.0)) continue; diff --git a/libc/test/src/math/NextAfterTest.h b/libc/test/src/math/NextAfterTest.h --- a/libc/test/src/math/NextAfterTest.h +++ b/libc/test/src/math/NextAfterTest.h @@ -19,22 +19,22 @@ template class NextAfterTestTemplate : public __llvm_libc::testing::Test { - using FPBits = __llvm_libc::fputil::FPBits; + using FPB = __llvm_libc::fputil::FPBits; using MantissaWidth = __llvm_libc::fputil::MantissaWidth; - using UIntType = typename FPBits::UIntType; + using UIntType = typename FPB::UIntType; static constexpr int BIT_WIDTH_OF_TYPE = __llvm_libc::fputil::FloatProperties::BIT_WIDTH; - const T zero = T(FPBits::zero()); - const T neg_zero = T(FPBits::neg_zero()); - const T inf = T(FPBits::inf()); - const T neg_inf = T(FPBits::neg_inf()); - const T nan = T(FPBits::build_quiet_nan(1)); - const UIntType min_subnormal = FPBits::MIN_SUBNORMAL; - const UIntType max_subnormal = FPBits::MAX_SUBNORMAL; - const UIntType min_normal = FPBits::MIN_NORMAL; - const UIntType max_normal = FPBits::MAX_NORMAL; + const T zero = T(FPB::zero()); + const T neg_zero = T(FPB::neg_zero()); + const T inf = T(FPB::inf()); + const T neg_inf = T(FPB::neg_inf()); + const T nan = T(FPB::build_quiet_nan(1)); + const UIntType min_subnormal = FPB::MIN_SUBNORMAL; + const UIntType max_subnormal = FPB::MAX_SUBNORMAL; + const UIntType min_normal = FPB::MIN_NORMAL; + const UIntType max_normal = FPB::MAX_NORMAL; public: typedef T (*NextAfterFunc)(T, T); @@ -160,15 +160,15 @@ // 'from' is a power of 2. x = T(32.0); result = func(x, 0); - FPBits x_bits = FPBits(x); - FPBits result_bits = FPBits(result); + FPB x_bits = FPB(x); + FPB result_bits = FPB(result); ASSERT_EQ(result_bits.get_unbiased_exponent(), uint16_t(x_bits.get_unbiased_exponent() - 1)); ASSERT_EQ(result_bits.get_mantissa(), (UIntType(1) << MantissaWidth::VALUE) - 1); result = func(x, T(33.0)); - result_bits = FPBits(result); + result_bits = FPB(result); ASSERT_EQ(result_bits.get_unbiased_exponent(), x_bits.get_unbiased_exponent()); ASSERT_EQ(result_bits.get_mantissa(), x_bits.get_mantissa() + UIntType(1)); @@ -176,14 +176,14 @@ x = -x; result = func(x, 0); - result_bits = FPBits(result); + result_bits = FPB(result); ASSERT_EQ(result_bits.get_unbiased_exponent(), uint16_t(x_bits.get_unbiased_exponent() - 1)); ASSERT_EQ(result_bits.get_mantissa(), (UIntType(1) << MantissaWidth::VALUE) - 1); result = func(x, T(-33.0)); - result_bits = FPBits(result); + result_bits = FPB(result); ASSERT_EQ(result_bits.get_unbiased_exponent(), x_bits.get_unbiased_exponent()); ASSERT_EQ(result_bits.get_mantissa(), x_bits.get_mantissa() + UIntType(1)); diff --git a/libc/test/src/math/RIntTest.h b/libc/test/src/math/RIntTest.h --- a/libc/test/src/math/RIntTest.h +++ b/libc/test/src/math/RIntTest.h @@ -30,14 +30,14 @@ typedef T (*RIntFunc)(T); private: - using FPBits = __llvm_libc::fputil::FPBits; - using UIntType = typename FPBits::UIntType; + using FPB = __llvm_libc::fputil::FPBits; + using UIntType = typename FPB::UIntType; - const T zero = T(FPBits::zero()); - const T neg_zero = T(FPBits::neg_zero()); - const T inf = T(FPBits::inf()); - const T neg_inf = T(FPBits::neg_inf()); - const T nan = T(FPBits::build_quiet_nan(1)); + const T zero = T(FPB::zero()); + const T neg_zero = T(FPB::neg_zero()); + const T inf = T(FPB::inf()); + const T neg_inf = T(FPB::neg_inf()); + const T nan = T(FPB::build_quiet_nan(1)); static inline mpfr::RoundingMode to_mpfr_rounding_mode(int mode) { switch (mode) { @@ -94,11 +94,9 @@ void testSubnormalRange(RIntFunc func) { constexpr UIntType COUNT = 1000001; - constexpr UIntType STEP = - (FPBits::MAX_SUBNORMAL - FPBits::MIN_SUBNORMAL) / COUNT; - for (UIntType i = FPBits::MIN_SUBNORMAL; i <= FPBits::MAX_SUBNORMAL; - i += STEP) { - T x = T(FPBits(i)); + constexpr UIntType STEP = (FPB::MAX_SUBNORMAL - FPB::MIN_SUBNORMAL) / COUNT; + for (UIntType i = FPB::MIN_SUBNORMAL; i <= FPB::MAX_SUBNORMAL; i += STEP) { + T x = T(FPB(i)); for (int mode : ROUNDING_MODES) { __llvm_libc::fputil::set_round(mode); mpfr::RoundingMode mpfr_mode = to_mpfr_rounding_mode(mode); @@ -109,9 +107,9 @@ void testNormalRange(RIntFunc func) { constexpr UIntType COUNT = 1000001; - constexpr UIntType STEP = (FPBits::MAX_NORMAL - FPBits::MIN_NORMAL) / COUNT; - for (UIntType i = FPBits::MIN_NORMAL; i <= FPBits::MAX_NORMAL; i += STEP) { - T x = T(FPBits(i)); + constexpr UIntType STEP = (FPB::MAX_NORMAL - FPB::MIN_NORMAL) / COUNT; + for (UIntType i = FPB::MIN_NORMAL; i <= FPB::MAX_NORMAL; i += STEP) { + T x = T(FPB(i)); // In normal range on x86 platforms, the long double implicit 1 bit can be // zero making the numbers NaN. We will skip them. if (isnan(x)) { diff --git a/libc/test/src/math/RemQuoTest.h b/libc/test/src/math/RemQuoTest.h --- a/libc/test/src/math/RemQuoTest.h +++ b/libc/test/src/math/RemQuoTest.h @@ -20,8 +20,8 @@ template class RemQuoTestTemplate : public __llvm_libc::testing::Test { - using FPBits = __llvm_libc::fputil::FPBits; - using UIntType = typename FPBits::UIntType; + using FPB = __llvm_libc::fputil::FPBits; + using UIntType = typename FPB::UIntType; const T zero = T(__llvm_libc::fputil::FPBits::zero()); const T neg_zero = T(__llvm_libc::fputil::FPBits::neg_zero()); @@ -96,12 +96,11 @@ void testSubnormalRange(RemQuoFunc func) { constexpr UIntType COUNT = 1000001; - constexpr UIntType STEP = - (FPBits::MAX_SUBNORMAL - FPBits::MIN_SUBNORMAL) / COUNT; - for (UIntType v = FPBits::MIN_SUBNORMAL, w = FPBits::MAX_SUBNORMAL; - v <= FPBits::MAX_SUBNORMAL && w >= FPBits::MIN_SUBNORMAL; + constexpr UIntType STEP = (FPB::MAX_SUBNORMAL - FPB::MIN_SUBNORMAL) / COUNT; + for (UIntType v = FPB::MIN_SUBNORMAL, w = FPB::MAX_SUBNORMAL; + v <= FPB::MAX_SUBNORMAL && w >= FPB::MIN_SUBNORMAL; v += STEP, w -= STEP) { - T x = T(FPBits(v)), y = T(FPBits(w)); + T x = T(FPB(v)), y = T(FPB(w)); mpfr::BinaryOutput result; mpfr::BinaryInput input{x, y}; result.f = func(x, y, &result.i); @@ -111,11 +110,10 @@ void testNormalRange(RemQuoFunc func) { constexpr UIntType COUNT = 1000001; - constexpr UIntType STEP = (FPBits::MAX_NORMAL - FPBits::MIN_NORMAL) / COUNT; - for (UIntType v = FPBits::MIN_NORMAL, w = FPBits::MAX_NORMAL; - v <= FPBits::MAX_NORMAL && w >= FPBits::MIN_NORMAL; - v += STEP, w -= STEP) { - T x = T(FPBits(v)), y = T(FPBits(w)); + constexpr UIntType STEP = (FPB::MAX_NORMAL - FPB::MIN_NORMAL) / COUNT; + for (UIntType v = FPB::MIN_NORMAL, w = FPB::MAX_NORMAL; + v <= FPB::MAX_NORMAL && w >= FPB::MIN_NORMAL; v += STEP, w -= STEP) { + T x = T(FPB(v)), y = T(FPB(w)); mpfr::BinaryOutput result; mpfr::BinaryInput input{x, y}; result.f = func(x, y, &result.i); diff --git a/libc/test/src/math/RoundTest.h b/libc/test/src/math/RoundTest.h --- a/libc/test/src/math/RoundTest.h +++ b/libc/test/src/math/RoundTest.h @@ -67,7 +67,7 @@ constexpr UIntType COUNT = 10000000; constexpr UIntType STEP = UIntType(-1) / COUNT; for (UIntType i = 0, v = 0; i <= COUNT; ++i, v += STEP) { - T x = T(FPBits(v)); + T x = T(FPB(v)); if (isnan(x) || isinf(x)) continue; diff --git a/libc/test/src/math/RoundToIntegerTest.h b/libc/test/src/math/RoundToIntegerTest.h --- a/libc/test/src/math/RoundToIntegerTest.h +++ b/libc/test/src/math/RoundToIntegerTest.h @@ -29,8 +29,8 @@ typedef I (*RoundToIntegerFunc)(F); private: - using FPBits = __llvm_libc::fputil::FPBits; - using UIntType = typename FPBits::UIntType; + using FPB = __llvm_libc::fputil::FPBits; + using UIntType = typename FPB::UIntType; const F zero = F(__llvm_libc::fputil::FPBits::zero()); const F neg_zero = F(__llvm_libc::fputil::FPBits::neg_zero()); @@ -122,8 +122,8 @@ constexpr int EXPONENT_LIMIT = sizeof(I) * 8 - 1; // We start with 1.0 so that the implicit bit for x86 long doubles // is set. - FPBits bits(F(1.0)); - bits.set_unbiased_exponent(EXPONENT_LIMIT + FPBits::EXPONENT_BIAS); + FPB bits(F(1.0)); + bits.set_unbiased_exponent(EXPONENT_LIMIT + FPB::EXPONENT_BIAS); bits.set_sign(1); bits.set_mantissa(0); @@ -186,8 +186,8 @@ constexpr int EXPONENT_LIMIT = sizeof(I) * 8 - 1; // We start with 1.0 so that the implicit bit for x86 long doubles // is set. - FPBits bits(F(1.0)); - bits.set_unbiased_exponent(EXPONENT_LIMIT + FPBits::EXPONENT_BIAS); + FPB bits(F(1.0)); + bits.set_unbiased_exponent(EXPONENT_LIMIT + FPB::EXPONENT_BIAS); bits.set_sign(1); bits.set_mantissa(UIntType(0x1) << (__llvm_libc::fputil::MantissaWidth::VALUE - 1)); @@ -212,11 +212,9 @@ void testSubnormalRange(RoundToIntegerFunc func) { constexpr UIntType COUNT = 1000001; - constexpr UIntType STEP = - (FPBits::MAX_SUBNORMAL - FPBits::MIN_SUBNORMAL) / COUNT; - for (UIntType i = FPBits::MIN_SUBNORMAL; i <= FPBits::MAX_SUBNORMAL; - i += STEP) { - F x = F(FPBits(i)); + constexpr UIntType STEP = (FPB::MAX_SUBNORMAL - FPB::MIN_SUBNORMAL) / COUNT; + for (UIntType i = FPB::MIN_SUBNORMAL; i <= FPB::MAX_SUBNORMAL; i += STEP) { + F x = F(FPB(i)); if (x == F(0.0)) continue; // All subnormal numbers should round to zero. @@ -256,9 +254,9 @@ return; constexpr UIntType COUNT = 1000001; - constexpr UIntType STEP = (FPBits::MAX_NORMAL - FPBits::MIN_NORMAL) / COUNT; - for (UIntType i = FPBits::MIN_NORMAL; i <= FPBits::MAX_NORMAL; i += STEP) { - F x = F(FPBits(i)); + constexpr UIntType STEP = (FPB::MAX_NORMAL - FPB::MIN_NORMAL) / COUNT; + for (UIntType i = FPB::MIN_NORMAL; i <= FPB::MAX_NORMAL; i += STEP) { + F x = F(FPB(i)); // In normal range on x86 platforms, the long double implicit 1 bit can be // zero making the numbers NaN. We will skip them. if (isnan(x)) { diff --git a/libc/test/src/math/SqrtTest.h b/libc/test/src/math/SqrtTest.h --- a/libc/test/src/math/SqrtTest.h +++ b/libc/test/src/math/SqrtTest.h @@ -39,7 +39,7 @@ void test_denormal_values(SqrtFunc func) { for (UIntType mant = 1; mant < HIDDEN_BIT; mant <<= 1) { - FPBits denormal(T(0.0)); + FPB denormal(T(0.0)); denormal.set_mantissa(mant); test_all_rounding_modes(func, T(denormal)); diff --git a/libc/test/src/math/TruncTest.h b/libc/test/src/math/TruncTest.h --- a/libc/test/src/math/TruncTest.h +++ b/libc/test/src/math/TruncTest.h @@ -67,7 +67,7 @@ constexpr UIntType COUNT = 10000000; constexpr UIntType STEP = UIntType(-1) / COUNT; for (UIntType i = 0, v = 0; i <= COUNT; ++i, v += STEP) { - T x = T(FPBits(v)); + T x = T(FPB(v)); if (isnan(x) || isinf(x)) continue; diff --git a/libc/test/src/math/acosf_test.cpp b/libc/test/src/math/acosf_test.cpp --- a/libc/test/src/math/acosf_test.cpp +++ b/libc/test/src/math/acosf_test.cpp @@ -16,7 +16,7 @@ #include #include -using FPBits = __llvm_libc::fputil::FPBits; +using FPB = __llvm_libc::fputil::FPBits; namespace mpfr = __llvm_libc::testing::mpfr; @@ -39,7 +39,7 @@ constexpr uint32_t COUNT = 1000000; constexpr uint32_t STEP = UINT32_MAX / COUNT; for (uint32_t i = 0, v = 0; i <= COUNT; ++i, v += STEP) { - float x = float(FPBits(v)); + float x = float(FPB(v)); if (isnan(x) || isinf(x)) continue; ASSERT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Acos, x, @@ -66,7 +66,7 @@ }; for (int i = 0; i < N; ++i) { - float x = float(FPBits(INPUTS[i])); + float x = float(FPB(INPUTS[i])); EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Acos, x, __llvm_libc::acosf(x), 0.5); EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Acos, -x, diff --git a/libc/test/src/math/asin_test.cpp b/libc/test/src/math/asin_test.cpp --- a/libc/test/src/math/asin_test.cpp +++ b/libc/test/src/math/asin_test.cpp @@ -15,7 +15,7 @@ #include #include -using FPBits = __llvm_libc::fputil::FPBits; +using FPB = __llvm_libc::fputil::FPBits; namespace mpfr = __llvm_libc::testing::mpfr; diff --git a/libc/test/src/math/asinf_test.cpp b/libc/test/src/math/asinf_test.cpp --- a/libc/test/src/math/asinf_test.cpp +++ b/libc/test/src/math/asinf_test.cpp @@ -17,7 +17,7 @@ #include #include -using FPBits = __llvm_libc::fputil::FPBits; +using FPB = __llvm_libc::fputil::FPBits; namespace mpfr = __llvm_libc::testing::mpfr; @@ -46,7 +46,7 @@ constexpr uint32_t COUNT = 1000000; constexpr uint32_t STEP = UINT32_MAX / COUNT; for (uint32_t i = 0, v = 0; i <= COUNT; ++i, v += STEP) { - float x = float(FPBits(v)); + float x = float(FPB(v)); if (isnan(x) || isinf(x)) continue; ASSERT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Asin, x, @@ -71,7 +71,7 @@ }; for (int i = 0; i < N; ++i) { - float x = float(FPBits(INPUTS[i])); + float x = float(FPB(INPUTS[i])); EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Asin, x, __llvm_libc::asinf(x), 0.5); EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Asin, -x, diff --git a/libc/test/src/math/asinhf_test.cpp b/libc/test/src/math/asinhf_test.cpp --- a/libc/test/src/math/asinhf_test.cpp +++ b/libc/test/src/math/asinhf_test.cpp @@ -16,7 +16,7 @@ #include #include -using FPBits_t = __llvm_libc::fputil::FPBits; +using FPB = __llvm_libc::fputil::FPBits; namespace mpfr = __llvm_libc::testing::mpfr; @@ -45,7 +45,7 @@ constexpr uint32_t COUNT = 1000000; constexpr uint32_t STEP = UINT32_MAX / COUNT; for (uint32_t i = 0, v = 0; i <= COUNT; ++i, v += STEP) { - float x = float(FPBits_t(v)); + float x = float(FPB(v)); if (isnan(x) || isinf(x)) continue; ASSERT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Asinh, x, @@ -72,7 +72,7 @@ }; for (int i = 0; i < N; ++i) { - float x = float(FPBits_t(INPUTS[i])); + float x = float(FPB(INPUTS[i])); EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Asinh, x, __llvm_libc::asinhf(x), 0.5); EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Asinh, -x, diff --git a/libc/test/src/math/atanf_test.cpp b/libc/test/src/math/atanf_test.cpp --- a/libc/test/src/math/atanf_test.cpp +++ b/libc/test/src/math/atanf_test.cpp @@ -18,7 +18,7 @@ #include -using FPBits = __llvm_libc::fputil::FPBits; +using FPB = __llvm_libc::fputil::FPBits; namespace mpfr = __llvm_libc::testing::mpfr; @@ -44,9 +44,9 @@ TEST(LlvmLibcAtanfTest, InFloatRange) { constexpr uint32_t COUNT = 1000000; - const uint32_t STEP = FPBits(inf).uintval() / COUNT; + const uint32_t STEP = FPB(inf).uintval() / COUNT; for (uint32_t i = 0, v = 0; i <= COUNT; ++i, v += STEP) { - float x = float(FPBits(v)); + float x = float(FPB(v)); EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Atan, x, __llvm_libc::atanf(x), 0.5); EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Atan, -x, @@ -58,7 +58,7 @@ TEST(LlvmLibcAtanfTest, SpecialValues) { for (uint32_t v : {0x3d8d6b23U, 0x3feefcfbU, 0xbd8d6b23U, 0xbfeefcfbU, 0x7F800000U, 0xFF800000U}) { - float x = float(FPBits(v)); + float x = float(FPB(v)); EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Atan, x, __llvm_libc::atanf(x), 0.5); } diff --git a/libc/test/src/math/atanhf_test.cpp b/libc/test/src/math/atanhf_test.cpp --- a/libc/test/src/math/atanhf_test.cpp +++ b/libc/test/src/math/atanhf_test.cpp @@ -16,7 +16,7 @@ #include #include -using FPBits = __llvm_libc::fputil::FPBits; +using FPB = __llvm_libc::fputil::FPBits; namespace mpfr = __llvm_libc::testing::mpfr; @@ -49,7 +49,7 @@ EXPECT_FP_EXCEPTION(FE_DIVBYZERO); EXPECT_MATH_ERRNO(ERANGE); - auto bt = FPBits(1.0f); + auto bt = FPB(1.0f); bt.bits += 1; __llvm_libc::fputil::clear_except(FE_ALL_EXCEPT); @@ -86,9 +86,9 @@ TEST(LlvmLibcAtanhfTest, InFloatRange) { constexpr uint32_t COUNT = 1000000; - const uint32_t STEP = FPBits(1.0f).uintval() / COUNT; + const uint32_t STEP = FPB(1.0f).uintval() / COUNT; for (uint32_t i = 0, v = 0; i <= COUNT; ++i, v += STEP) { - float x = float(FPBits(v)); + float x = float(FPB(v)); ASSERT_MPFR_MATCH(mpfr::Operation::Atanh, x, __llvm_libc::atanhf(x), 0.5); ASSERT_MPFR_MATCH(mpfr::Operation::Atanh, -x, __llvm_libc::atanhf(-x), 0.5); } @@ -96,12 +96,12 @@ // For small values, atanh(x) is x. TEST(LlvmLibcAtanhfTest, SmallValues) { - float x = float(FPBits(uint32_t(0x17800000))); + float x = float(FPB(uint32_t(0x17800000))); float result = __llvm_libc::atanhf(x); EXPECT_MPFR_MATCH(mpfr::Operation::Atanh, x, result, 0.5); EXPECT_FP_EQ(x, result); - x = float(FPBits(uint32_t(0x00400000))); + x = float(FPB(uint32_t(0x00400000))); result = __llvm_libc::atanhf(x); EXPECT_MPFR_MATCH(mpfr::Operation::Atanh, x, result, 0.5); EXPECT_FP_EQ(x, result); diff --git a/libc/test/src/math/cos_test.cpp b/libc/test/src/math/cos_test.cpp --- a/libc/test/src/math/cos_test.cpp +++ b/libc/test/src/math/cos_test.cpp @@ -22,7 +22,7 @@ constexpr UIntType COUNT = 10000000; constexpr UIntType STEP = UIntType(-1) / COUNT; for (UIntType i = 0, v = 0; i <= COUNT; ++i, v += STEP) { - double x = double(FPBits(v)); + double x = double(FPB(v)); // TODO: Expand the range of testing after range reduction is implemented. if (isnan(x) || isinf(x) || x > _2pi || x < -_2pi) continue; diff --git a/libc/test/src/math/cosf_test.cpp b/libc/test/src/math/cosf_test.cpp --- a/libc/test/src/math/cosf_test.cpp +++ b/libc/test/src/math/cosf_test.cpp @@ -18,7 +18,7 @@ #include using __llvm_libc::testing::SDCOMP26094_VALUES; -using FPBits = __llvm_libc::fputil::FPBits; +using FPB = __llvm_libc::fputil::FPBits; namespace mpfr = __llvm_libc::testing::mpfr; @@ -47,7 +47,7 @@ constexpr uint32_t COUNT = 1000000; constexpr uint32_t STEP = UINT32_MAX / COUNT; for (uint32_t i = 0, v = 0; i <= COUNT; ++i, v += STEP) { - float x = float(FPBits(v)); + float x = float(FPB(v)); if (isnan(x) || isinf(x)) continue; ASSERT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Cos, x, @@ -103,7 +103,7 @@ }; for (int i = 0; i < N; ++i) { - float x = float(FPBits(INPUTS[i])); + float x = float(FPB(INPUTS[i])); EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Cos, x, __llvm_libc::cosf(x), 0.5); EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Cos, -x, @@ -115,7 +115,7 @@ // returns values furthest beyond its nominal upper bound of pi/4. TEST(LlvmLibcCosfTest, SDCOMP_26094) { for (uint32_t v : SDCOMP26094_VALUES) { - float x = float(FPBits(v)); + float x = float(FPB(v)); ASSERT_MPFR_MATCH(mpfr::Operation::Cos, x, __llvm_libc::cosf(x), 0.5); } } diff --git a/libc/test/src/math/coshf_test.cpp b/libc/test/src/math/coshf_test.cpp --- a/libc/test/src/math/coshf_test.cpp +++ b/libc/test/src/math/coshf_test.cpp @@ -17,7 +17,7 @@ #include #include -using FPBits = __llvm_libc::fputil::FPBits; +using FPB = __llvm_libc::fputil::FPBits; namespace mpfr = __llvm_libc::testing::mpfr; @@ -44,13 +44,13 @@ TEST(LlvmLibcCoshfTest, Overflow) { errno = 0; - EXPECT_FP_EQ(inf, __llvm_libc::coshf(float(FPBits(0x7f7fffffU)))); + EXPECT_FP_EQ(inf, __llvm_libc::coshf(float(FPB(0x7f7fffffU)))); EXPECT_MATH_ERRNO(ERANGE); - EXPECT_FP_EQ(inf, __llvm_libc::coshf(float(FPBits(0x42cffff8U)))); + EXPECT_FP_EQ(inf, __llvm_libc::coshf(float(FPB(0x42cffff8U)))); EXPECT_MATH_ERRNO(ERANGE); - EXPECT_FP_EQ(inf, __llvm_libc::coshf(float(FPBits(0x42d00008U)))); + EXPECT_FP_EQ(inf, __llvm_libc::coshf(float(FPB(0x42d00008U)))); EXPECT_MATH_ERRNO(ERANGE); } @@ -58,7 +58,7 @@ constexpr uint32_t COUNT = 1000000; constexpr uint32_t STEP = UINT32_MAX / COUNT; for (uint32_t i = 0, v = 0; i <= COUNT; ++i, v += STEP) { - float x = float(FPBits(v)); + float x = float(FPB(v)); if (isnan(x) || isinf(x)) continue; ASSERT_MPFR_MATCH(mpfr::Operation::Cosh, x, __llvm_libc::coshf(x), 0.5); @@ -66,12 +66,12 @@ } TEST(LlvmLibcCoshfTest, SmallValues) { - float x = float(FPBits(0x17800000U)); + float x = float(FPB(0x17800000U)); float result = __llvm_libc::coshf(x); EXPECT_MPFR_MATCH(mpfr::Operation::Cosh, x, result, 0.5); EXPECT_FP_EQ(1.0f, result); - x = float(FPBits(0x0040000U)); + x = float(FPB(0x0040000U)); result = __llvm_libc::coshf(x); EXPECT_MPFR_MATCH(mpfr::Operation::Cosh, x, result, 0.5); EXPECT_FP_EQ(1.0f, result); diff --git a/libc/test/src/math/differential_testing/BinaryOpSingleOutputDiff.h b/libc/test/src/math/differential_testing/BinaryOpSingleOutputDiff.h --- a/libc/test/src/math/differential_testing/BinaryOpSingleOutputDiff.h +++ b/libc/test/src/math/differential_testing/BinaryOpSingleOutputDiff.h @@ -14,8 +14,8 @@ namespace testing { template class BinaryOpSingleOutputDiff { - using FPBits = fputil::FPBits; - using UIntType = typename FPBits::UIntType; + using FPB = fputil::FPBits; + using UIntType = typename FPB::UIntType; static constexpr UIntType MSBIT = UIntType(1) << (8 * sizeof(UIntType) - 1); static constexpr UIntType UINTMAX = (MSBIT - 1) + MSBIT; @@ -34,10 +34,10 @@ UIntType step = (endingBit - startingBit) / N; for (UIntType bitsX = startingBit, bitsY = endingBit;; bitsX += step, bitsY -= step) { - T x = T(FPBits(bitsX)); - T y = T(FPBits(bitsY)); - FPBits myBits = FPBits(myFunc(x, y)); - FPBits otherBits = FPBits(otherFunc(x, y)); + T x = T(FPB(bitsX)); + T y = T(FPB(bitsY)); + FPB myBits = FPB(myFunc(x, y)); + FPB otherBits = FPB(otherFunc(x, y)); if (myBits.uintval() != otherBits.uintval()) { result++; log << " Input: " << bitsX << ", " << bitsY << " (" << x << ", " @@ -68,8 +68,8 @@ UIntType step = (endingBit - startingBit) / N; for (UIntType bitsX = startingBit, bitsY = endingBit;; bitsX += step, bitsY -= step) { - T x = T(FPBits(bitsX)); - T y = T(FPBits(bitsY)); + T x = T(FPB(bitsX)); + T y = T(FPB(bitsY)); result = func(x, y); if (endingBit - bitsX < step) { break; @@ -108,33 +108,33 @@ testutils::OutputFileStream log(logFile); log << " Performance tests with inputs in denormal range:\n"; run_perf_in_range(myFunc, otherFunc, /* startingBit= */ UIntType(0), - /* endingBit= */ FPBits::MAX_SUBNORMAL, 1'000'001, log); + /* endingBit= */ FPB::MAX_SUBNORMAL, 1'000'001, log); log << "\n Performance tests with inputs in normal range:\n"; - run_perf_in_range(myFunc, otherFunc, /* startingBit= */ FPBits::MIN_NORMAL, - /* endingBit= */ FPBits::MAX_NORMAL, 100'000'001, log); + run_perf_in_range(myFunc, otherFunc, /* startingBit= */ FPB::MIN_NORMAL, + /* endingBit= */ FPB::MAX_NORMAL, 100'000'001, log); log << "\n Performance tests with inputs in normal range with exponents " "close to each other:\n"; run_perf_in_range( - myFunc, otherFunc, /* startingBit= */ FPBits(T(0x1.0p-10)).uintval(), - /* endingBit= */ FPBits(T(0x1.0p+10)).uintval(), 10'000'001, log); + myFunc, otherFunc, /* startingBit= */ FPB(T(0x1.0p-10)).uintval(), + /* endingBit= */ FPB(T(0x1.0p+10)).uintval(), 10'000'001, log); } static void run_diff(Func myFunc, Func otherFunc, const char *logFile) { uint64_t diffCount = 0; testutils::OutputFileStream log(logFile); log << " Diff tests with inputs in denormal range:\n"; - diffCount += run_diff_in_range( - myFunc, otherFunc, /* startingBit= */ UIntType(0), - /* endingBit= */ FPBits::MAX_SUBNORMAL, 1'000'001, log); + diffCount += + run_diff_in_range(myFunc, otherFunc, /* startingBit= */ UIntType(0), + /* endingBit= */ FPB::MAX_SUBNORMAL, 1'000'001, log); log << "\n Diff tests with inputs in normal range:\n"; - diffCount += run_diff_in_range( - myFunc, otherFunc, /* startingBit= */ FPBits::MIN_NORMAL, - /* endingBit= */ FPBits::MAX_NORMAL, 100'000'001, log); + diffCount += + run_diff_in_range(myFunc, otherFunc, /* startingBit= */ FPB::MIN_NORMAL, + /* endingBit= */ FPB::MAX_NORMAL, 100'000'001, log); log << "\n Diff tests with inputs in normal range with exponents " "close to each other:\n"; diffCount += run_diff_in_range( - myFunc, otherFunc, /* startingBit= */ FPBits(T(0x1.0p-10)).uintval(), - /* endingBit= */ FPBits(T(0x1.0p+10)).uintval(), 10'000'001, log); + myFunc, otherFunc, /* startingBit= */ FPB(T(0x1.0p-10)).uintval(), + /* endingBit= */ FPB(T(0x1.0p+10)).uintval(), 10'000'001, log); log << "Total number of differing results: " << diffCount << '\n'; } diff --git a/libc/test/src/math/differential_testing/SingleInputSingleOutputDiff.h b/libc/test/src/math/differential_testing/SingleInputSingleOutputDiff.h --- a/libc/test/src/math/differential_testing/SingleInputSingleOutputDiff.h +++ b/libc/test/src/math/differential_testing/SingleInputSingleOutputDiff.h @@ -14,8 +14,8 @@ namespace testing { template class SingleInputSingleOutputDiff { - using FPBits = fputil::FPBits; - using UIntType = typename FPBits::UIntType; + using FPB = fputil::FPBits; + using UIntType = typename FPB::UIntType; static constexpr UIntType MSBit = UIntType(1) << (8 * sizeof(UIntType) - 1); static constexpr UIntType UIntMax = (MSBit - 1) + MSBit; @@ -28,11 +28,11 @@ log << "Starting diff for values from 0 to " << UIntMax << '\n' << "Only differing results will be logged.\n\n"; for (UIntType bits = 0;; ++bits) { - T x = T(FPBits(bits)); + T x = T(FPB(bits)); T myResult = myFunc(x); T otherResult = otherFunc(x); - UIntType myBits = FPBits(myResult).uintval(); - UIntType otherBits = FPBits(otherResult).uintval(); + UIntType myBits = FPB(myResult).uintval(); + UIntType otherBits = FPB(otherResult).uintval(); if (myBits != otherBits) { ++diffCount; log << " Input: " << bits << " (" << x << ")\n" @@ -52,7 +52,7 @@ auto runner = [=](Func func) { volatile T result; for (UIntType bits = startingBit;; ++bits) { - T x = T(FPBits(bits)); + T x = T(FPB(bits)); result = func(x); if (bits == endingBit) break; @@ -92,10 +92,10 @@ testutils::OutputFileStream log(logFile); log << " Performance tests with inputs in denormal range:\n"; runPerfInRange(myFunc, otherFunc, /* startingBit= */ UIntType(0), - /* endingBit= */ FPBits::MAX_SUBNORMAL, log); + /* endingBit= */ FPB::MAX_SUBNORMAL, log); log << "\n Performance tests with inputs in normal range:\n"; - runPerfInRange(myFunc, otherFunc, /* startingBit= */ FPBits::MIN_NORMAL, - /* endingBit= */ FPBits::MAX_NORMAL, log); + runPerfInRange(myFunc, otherFunc, /* startingBit= */ FPB::MIN_NORMAL, + /* endingBit= */ FPB::MAX_NORMAL, log); } }; diff --git a/libc/test/src/math/exhaustive/acosf_test.cpp b/libc/test/src/math/exhaustive/acosf_test.cpp --- a/libc/test/src/math/exhaustive/acosf_test.cpp +++ b/libc/test/src/math/exhaustive/acosf_test.cpp @@ -13,7 +13,7 @@ #include -using FPBits = __llvm_libc::fputil::FPBits; +using FPB = __llvm_libc::fputil::FPBits; namespace mpfr = __llvm_libc::testing::mpfr; @@ -24,7 +24,7 @@ uint32_t bits = start; bool result = true; do { - FPBits xbits(bits); + FPB xbits(bits); float x = float(xbits); result &= EXPECT_MPFR_MATCH(mpfr::Operation::Acos, x, __llvm_libc::acosf(x), 0.5, rounding); diff --git a/libc/test/src/math/exhaustive/asinf_test.cpp b/libc/test/src/math/exhaustive/asinf_test.cpp --- a/libc/test/src/math/exhaustive/asinf_test.cpp +++ b/libc/test/src/math/exhaustive/asinf_test.cpp @@ -13,7 +13,7 @@ #include -using FPBits = __llvm_libc::fputil::FPBits; +using FPB = __llvm_libc::fputil::FPBits; namespace mpfr = __llvm_libc::testing::mpfr; @@ -24,7 +24,7 @@ uint32_t bits = start; bool result = true; do { - FPBits xbits(bits); + FPB xbits(bits); float x = float(xbits); result &= EXPECT_MPFR_MATCH(mpfr::Operation::Asin, x, __llvm_libc::asinf(x), 0.5, rounding); diff --git a/libc/test/src/math/exhaustive/asinhf_test.cpp b/libc/test/src/math/exhaustive/asinhf_test.cpp --- a/libc/test/src/math/exhaustive/asinhf_test.cpp +++ b/libc/test/src/math/exhaustive/asinhf_test.cpp @@ -13,7 +13,7 @@ #include -using FPBits = __llvm_libc::fputil::FPBits; +using FPB = __llvm_libc::fputil::FPBits; namespace mpfr = __llvm_libc::testing::mpfr; @@ -24,7 +24,7 @@ uint32_t bits = start; bool result = true; do { - FPBits xbits(bits); + FPB xbits(bits); float x = float(xbits); result &= EXPECT_MPFR_MATCH(mpfr::Operation::Asinh, x, __llvm_libc::asinhf(x), 0.5, rounding); diff --git a/libc/test/src/math/exhaustive/atanf_test.cpp b/libc/test/src/math/exhaustive/atanf_test.cpp --- a/libc/test/src/math/exhaustive/atanf_test.cpp +++ b/libc/test/src/math/exhaustive/atanf_test.cpp @@ -13,7 +13,7 @@ #include -using FPBits = __llvm_libc::fputil::FPBits; +using FPB = __llvm_libc::fputil::FPBits; namespace mpfr = __llvm_libc::testing::mpfr; @@ -24,7 +24,7 @@ uint32_t bits = start; bool result = true; do { - FPBits xbits(bits); + FPB xbits(bits); float x = float(xbits); result &= EXPECT_MPFR_MATCH(mpfr::Operation::Atan, x, __llvm_libc::atanf(x), 0.5, rounding); @@ -37,7 +37,7 @@ // Range: [0, 1.0]; static const uint32_t POS_START = 0x0000'0000U; -static const uint32_t POS_STOP = FPBits::inf().uintval(); +static const uint32_t POS_STOP = FPB::inf().uintval(); TEST_F(LlvmLibcAtanfExhaustiveTest, PostiveRangeRoundNearestTieToEven) { test_full_range(POS_START, POS_STOP, mpfr::RoundingMode::Nearest); @@ -57,7 +57,7 @@ // Range: [-1.0, 0]; static const uint32_t NEG_START = 0x8000'0000U; -static const uint32_t NEG_STOP = FPBits::neg_inf().uintval(); +static const uint32_t NEG_STOP = FPB::neg_inf().uintval(); TEST_F(LlvmLibcAtanfExhaustiveTest, NegativeRangeRoundNearestTieToEven) { test_full_range(NEG_START, NEG_STOP, mpfr::RoundingMode::Nearest); diff --git a/libc/test/src/math/exhaustive/atanhf_test.cpp b/libc/test/src/math/exhaustive/atanhf_test.cpp --- a/libc/test/src/math/exhaustive/atanhf_test.cpp +++ b/libc/test/src/math/exhaustive/atanhf_test.cpp @@ -13,7 +13,7 @@ #include -using FPBits = __llvm_libc::fputil::FPBits; +using FPB = __llvm_libc::fputil::FPBits; namespace mpfr = __llvm_libc::testing::mpfr; @@ -24,7 +24,7 @@ uint32_t bits = start; bool result = true; do { - FPBits xbits(bits); + FPB xbits(bits); float x = float(xbits); result &= EXPECT_MPFR_MATCH(mpfr::Operation::Atanh, x, __llvm_libc::atanhf(x), 0.5, rounding); @@ -37,7 +37,7 @@ // Range: [0, 1.0]; static const uint32_t POS_START = 0x0000'0000U; -static const uint32_t POS_STOP = FPBits(1.0f).uintval(); +static const uint32_t POS_STOP = FPB(1.0f).uintval(); TEST_F(LlvmLibcAtanhfExhaustiveTest, PostiveRangeRoundNearestTieToEven) { test_full_range(POS_START, POS_STOP, mpfr::RoundingMode::Nearest); @@ -57,7 +57,7 @@ // Range: [-1.0, 0]; static const uint32_t NEG_START = 0x8000'0000U; -static const uint32_t NEG_STOP = FPBits(-1.0f).uintval(); +static const uint32_t NEG_STOP = FPB(-1.0f).uintval(); TEST_F(LlvmLibcAtanhfExhaustiveTest, NegativeRangeRoundNearestTieToEven) { test_full_range(NEG_START, NEG_STOP, mpfr::RoundingMode::Nearest); diff --git a/libc/test/src/math/exhaustive/cosf_test.cpp b/libc/test/src/math/exhaustive/cosf_test.cpp --- a/libc/test/src/math/exhaustive/cosf_test.cpp +++ b/libc/test/src/math/exhaustive/cosf_test.cpp @@ -14,7 +14,7 @@ #include -using FPBits = __llvm_libc::fputil::FPBits; +using FPB = __llvm_libc::fputil::FPBits; namespace mpfr = __llvm_libc::testing::mpfr; @@ -25,7 +25,7 @@ uint32_t bits = start; bool result = true; do { - FPBits xbits(bits); + FPB xbits(bits); float x = float(xbits); bool r = EXPECT_MPFR_MATCH(mpfr::Operation::Cos, x, __llvm_libc::cosf(x), 0.5, rounding); diff --git a/libc/test/src/math/exhaustive/coshf_test.cpp b/libc/test/src/math/exhaustive/coshf_test.cpp --- a/libc/test/src/math/exhaustive/coshf_test.cpp +++ b/libc/test/src/math/exhaustive/coshf_test.cpp @@ -14,7 +14,7 @@ #include -using FPBits = __llvm_libc::fputil::FPBits; +using FPB = __llvm_libc::fputil::FPBits; namespace mpfr = __llvm_libc::testing::mpfr; @@ -25,7 +25,7 @@ uint32_t bits = start; bool result = true; do { - FPBits xbits(bits); + FPB xbits(bits); float x = float(xbits); result &= EXPECT_MPFR_MATCH(mpfr::Operation::Cosh, x, __llvm_libc::coshf(x), 0.5, rounding); diff --git a/libc/test/src/math/exhaustive/exp10f_test.cpp b/libc/test/src/math/exhaustive/exp10f_test.cpp --- a/libc/test/src/math/exhaustive/exp10f_test.cpp +++ b/libc/test/src/math/exhaustive/exp10f_test.cpp @@ -14,7 +14,7 @@ #include -using FPBits = __llvm_libc::fputil::FPBits; +using FPB = __llvm_libc::fputil::FPBits; namespace mpfr = __llvm_libc::testing::mpfr; @@ -25,7 +25,7 @@ uint32_t bits = start; bool result = true; do { - FPBits xbits(bits); + FPB xbits(bits); float x = float(xbits); result &= EXPECT_MPFR_MATCH(mpfr::Operation::Exp10, x, __llvm_libc::exp10f(x), 0.5, rounding); diff --git a/libc/test/src/math/exhaustive/exp2f_test.cpp b/libc/test/src/math/exhaustive/exp2f_test.cpp --- a/libc/test/src/math/exhaustive/exp2f_test.cpp +++ b/libc/test/src/math/exhaustive/exp2f_test.cpp @@ -12,7 +12,7 @@ #include "utils/MPFRWrapper/MPFRUtils.h" #include "utils/UnitTest/FPMatcher.h" -using FPBits = __llvm_libc::fputil::FPBits; +using FPB = __llvm_libc::fputil::FPBits; namespace mpfr = __llvm_libc::testing::mpfr; @@ -23,7 +23,7 @@ uint32_t bits = start; bool result = true; do { - FPBits xbits(bits); + FPB xbits(bits); float x = float(xbits); result &= EXPECT_MPFR_MATCH(mpfr::Operation::Exp2, x, __llvm_libc::exp2f(x), 0.5, rounding); diff --git a/libc/test/src/math/exhaustive/expf_test.cpp b/libc/test/src/math/exhaustive/expf_test.cpp --- a/libc/test/src/math/exhaustive/expf_test.cpp +++ b/libc/test/src/math/exhaustive/expf_test.cpp @@ -14,7 +14,7 @@ #include -using FPBits = __llvm_libc::fputil::FPBits; +using FPB = __llvm_libc::fputil::FPBits; namespace mpfr = __llvm_libc::testing::mpfr; @@ -25,7 +25,7 @@ uint32_t bits = start; bool result = true; do { - FPBits xbits(bits); + FPB xbits(bits); float x = float(xbits); result &= EXPECT_MPFR_MATCH(mpfr::Operation::Exp, x, __llvm_libc::expf(x), 0.5, rounding); diff --git a/libc/test/src/math/exhaustive/expm1f_test.cpp b/libc/test/src/math/exhaustive/expm1f_test.cpp --- a/libc/test/src/math/exhaustive/expm1f_test.cpp +++ b/libc/test/src/math/exhaustive/expm1f_test.cpp @@ -14,7 +14,7 @@ #include -using FPBits = __llvm_libc::fputil::FPBits; +using FPB = __llvm_libc::fputil::FPBits; namespace mpfr = __llvm_libc::testing::mpfr; @@ -25,7 +25,7 @@ uint32_t bits = stop; bool result = true; do { - FPBits xbits(bits); + FPB xbits(bits); float x = float(xbits); result &= EXPECT_MPFR_MATCH(mpfr::Operation::Expm1, x, __llvm_libc::expm1f(x), 0.5, rounding); diff --git a/libc/test/src/math/exhaustive/hypotf_test.cpp b/libc/test/src/math/exhaustive/hypotf_test.cpp --- a/libc/test/src/math/exhaustive/hypotf_test.cpp +++ b/libc/test/src/math/exhaustive/hypotf_test.cpp @@ -13,7 +13,7 @@ #include "utils/MPFRWrapper/MPFRUtils.h" #include "utils/UnitTest/FPMatcher.h" -using FPBits = __llvm_libc::fputil::FPBits; +using FPB = __llvm_libc::fputil::FPBits; namespace mpfr = __llvm_libc::testing::mpfr; @@ -28,10 +28,10 @@ uint32_t xbits = start; bool result = true; do { - float x = float(FPBits(xbits)); + float x = float(FPB(xbits)); uint32_t ybits = Y_START; do { - float y = float(FPBits(ybits)); + float y = float(FPB(ybits)); result &= EXPECT_FP_EQ(__llvm_libc::fputil::hypot(x, y), __llvm_libc::hypotf(x, y)); // Using MPFR will be much slower. diff --git a/libc/test/src/math/exhaustive/log10f_test.cpp b/libc/test/src/math/exhaustive/log10f_test.cpp --- a/libc/test/src/math/exhaustive/log10f_test.cpp +++ b/libc/test/src/math/exhaustive/log10f_test.cpp @@ -12,7 +12,7 @@ #include "utils/MPFRWrapper/MPFRUtils.h" #include "utils/UnitTest/FPMatcher.h" -using FPBits = __llvm_libc::fputil::FPBits; +using FPB = __llvm_libc::fputil::FPBits; namespace mpfr = __llvm_libc::testing::mpfr; @@ -23,7 +23,7 @@ uint32_t bits = start; bool result = true; do { - FPBits xbits(bits); + FPB xbits(bits); float x = float(xbits); result &= EXPECT_MPFR_MATCH(mpfr::Operation::Log10, x, __llvm_libc::log10f(x), 0.5, rounding); diff --git a/libc/test/src/math/exhaustive/log1pf_test.cpp b/libc/test/src/math/exhaustive/log1pf_test.cpp --- a/libc/test/src/math/exhaustive/log1pf_test.cpp +++ b/libc/test/src/math/exhaustive/log1pf_test.cpp @@ -12,7 +12,7 @@ #include "utils/MPFRWrapper/MPFRUtils.h" #include "utils/UnitTest/FPMatcher.h" -using FPBits = __llvm_libc::fputil::FPBits; +using FPB = __llvm_libc::fputil::FPBits; namespace mpfr = __llvm_libc::testing::mpfr; @@ -23,7 +23,7 @@ uint32_t bits = start; bool result = true; do { - FPBits xbits(bits); + FPB xbits(bits); float x = float(xbits); result &= EXPECT_MPFR_MATCH(mpfr::Operation::Log1p, x, __llvm_libc::log1pf(x), 0.5, rounding); diff --git a/libc/test/src/math/exhaustive/log2f_test.cpp b/libc/test/src/math/exhaustive/log2f_test.cpp --- a/libc/test/src/math/exhaustive/log2f_test.cpp +++ b/libc/test/src/math/exhaustive/log2f_test.cpp @@ -12,7 +12,7 @@ #include "utils/MPFRWrapper/MPFRUtils.h" #include "utils/UnitTest/FPMatcher.h" -using FPBits = __llvm_libc::fputil::FPBits; +using FPB = __llvm_libc::fputil::FPBits; namespace mpfr = __llvm_libc::testing::mpfr; @@ -23,7 +23,7 @@ uint32_t bits = start; bool result = true; do { - FPBits xbits(bits); + FPB xbits(bits); float x = float(xbits); result &= EXPECT_MPFR_MATCH(mpfr::Operation::Log2, x, __llvm_libc::log2f(x), 0.5, rounding); diff --git a/libc/test/src/math/exhaustive/logf_test.cpp b/libc/test/src/math/exhaustive/logf_test.cpp --- a/libc/test/src/math/exhaustive/logf_test.cpp +++ b/libc/test/src/math/exhaustive/logf_test.cpp @@ -12,7 +12,7 @@ #include "utils/MPFRWrapper/MPFRUtils.h" #include "utils/UnitTest/FPMatcher.h" -using FPBits = __llvm_libc::fputil::FPBits; +using FPB = __llvm_libc::fputil::FPBits; namespace mpfr = __llvm_libc::testing::mpfr; @@ -23,7 +23,7 @@ uint32_t bits = start; bool result = true; do { - FPBits xbits(bits); + FPB xbits(bits); float x = float(xbits); result &= EXPECT_MPFR_MATCH(mpfr::Operation::Log, x, __llvm_libc::logf(x), 0.5, rounding); diff --git a/libc/test/src/math/exhaustive/sincosf_test.cpp b/libc/test/src/math/exhaustive/sincosf_test.cpp --- a/libc/test/src/math/exhaustive/sincosf_test.cpp +++ b/libc/test/src/math/exhaustive/sincosf_test.cpp @@ -14,7 +14,7 @@ #include -using FPBits = __llvm_libc::fputil::FPBits; +using FPB = __llvm_libc::fputil::FPBits; namespace mpfr = __llvm_libc::testing::mpfr; @@ -25,7 +25,7 @@ uint32_t bits = start; bool result = true; do { - FPBits xbits(bits); + FPB xbits(bits); float x = float(xbits); float sinx, cosx; __llvm_libc::sincosf(x, &sinx, &cosx); diff --git a/libc/test/src/math/exhaustive/sinf_test.cpp b/libc/test/src/math/exhaustive/sinf_test.cpp --- a/libc/test/src/math/exhaustive/sinf_test.cpp +++ b/libc/test/src/math/exhaustive/sinf_test.cpp @@ -14,7 +14,7 @@ #include -using FPBits = __llvm_libc::fputil::FPBits; +using FPB = __llvm_libc::fputil::FPBits; namespace mpfr = __llvm_libc::testing::mpfr; @@ -25,7 +25,7 @@ uint32_t bits = start; bool result = true; do { - FPBits xbits(bits); + FPB xbits(bits); float x = float(xbits); bool r = EXPECT_MPFR_MATCH(mpfr::Operation::Sin, x, __llvm_libc::sinf(x), 0.5, rounding); diff --git a/libc/test/src/math/exhaustive/sinhf_test.cpp b/libc/test/src/math/exhaustive/sinhf_test.cpp --- a/libc/test/src/math/exhaustive/sinhf_test.cpp +++ b/libc/test/src/math/exhaustive/sinhf_test.cpp @@ -14,7 +14,7 @@ #include -using FPBits = __llvm_libc::fputil::FPBits; +using FPB = __llvm_libc::fputil::FPBits; namespace mpfr = __llvm_libc::testing::mpfr; @@ -25,7 +25,7 @@ uint32_t bits = start; bool result = true; do { - FPBits xbits(bits); + FPB xbits(bits); float x = float(xbits); result &= EXPECT_MPFR_MATCH(mpfr::Operation::Sinh, x, __llvm_libc::sinhf(x), 0.5, rounding); diff --git a/libc/test/src/math/exhaustive/sqrtf_test.cpp b/libc/test/src/math/exhaustive/sqrtf_test.cpp --- a/libc/test/src/math/exhaustive/sqrtf_test.cpp +++ b/libc/test/src/math/exhaustive/sqrtf_test.cpp @@ -11,14 +11,14 @@ #include "utils/MPFRWrapper/MPFRUtils.h" #include -using FPBits = __llvm_libc::fputil::FPBits; +using FPB = __llvm_libc::fputil::FPBits; namespace mpfr = __llvm_libc::testing::mpfr; TEST(LlvmLibcSqrtfExhaustiveTest, AllValues) { uint32_t bits = 0; do { - FPBits xbits(bits); + FPB xbits(bits); float x = float(xbits); ASSERT_MPFR_MATCH(mpfr::Operation::Sqrt, x, __llvm_libc::sqrtf(x), 0.5); } while (bits++ < 0xffff'ffffU); diff --git a/libc/test/src/math/exhaustive/tanf_test.cpp b/libc/test/src/math/exhaustive/tanf_test.cpp --- a/libc/test/src/math/exhaustive/tanf_test.cpp +++ b/libc/test/src/math/exhaustive/tanf_test.cpp @@ -15,7 +15,7 @@ #include -using FPBits = __llvm_libc::fputil::FPBits; +using FPB = __llvm_libc::fputil::FPBits; namespace mpfr = __llvm_libc::testing::mpfr; @@ -29,7 +29,7 @@ bool result = true; int tol = TOLERANCE; do { - FPBits xbits(bits); + FPB xbits(bits); float x = float(xbits); bool r = EXPECT_MPFR_MATCH(mpfr::Operation::Tan, x, __llvm_libc::tanf(x), 0.5, rounding); diff --git a/libc/test/src/math/exhaustive/tanhf_test.cpp b/libc/test/src/math/exhaustive/tanhf_test.cpp --- a/libc/test/src/math/exhaustive/tanhf_test.cpp +++ b/libc/test/src/math/exhaustive/tanhf_test.cpp @@ -13,7 +13,7 @@ #include -using FPBits = __llvm_libc::fputil::FPBits; +using FPB = __llvm_libc::fputil::FPBits; namespace mpfr = __llvm_libc::testing::mpfr; @@ -24,7 +24,7 @@ uint32_t bits = start; bool result = true; do { - FPBits xbits(bits); + FPB xbits(bits); float x = float(xbits); result &= EXPECT_MPFR_MATCH(mpfr::Operation::Tanh, x, __llvm_libc::tanhf(x), 0.5, rounding); @@ -37,7 +37,7 @@ // Range: [0, INF]; static const uint32_t POS_START = 0x0000'0000U; -static const uint32_t POS_STOP = FPBits::inf(false).uintval(); +static const uint32_t POS_STOP = FPB::inf(false).uintval(); TEST_F(LlvmLibcTanhfExhaustiveTest, PostiveRangeRoundNearestTieToEven) { test_full_range(POS_START, POS_STOP, mpfr::RoundingMode::Nearest); @@ -57,7 +57,7 @@ // Range: [-INF, 0]; static const uint32_t NEG_START = 0x8000'0000U; -static const uint32_t NEG_STOP = FPBits::inf(true).uintval(); +static const uint32_t NEG_STOP = FPB::inf(true).uintval(); TEST_F(LlvmLibcTanhfExhaustiveTest, NegativeRangeRoundNearestTieToEven) { test_full_range(NEG_START, NEG_STOP, mpfr::RoundingMode::Nearest); diff --git a/libc/test/src/math/exp10f_test.cpp b/libc/test/src/math/exp10f_test.cpp --- a/libc/test/src/math/exp10f_test.cpp +++ b/libc/test/src/math/exp10f_test.cpp @@ -41,13 +41,13 @@ TEST(LlvmLibcExp10fTest, Overflow) { errno = 0; - EXPECT_FP_EQ(inf, __llvm_libc::exp10f(float(FPBits(0x7f7fffffU)))); + EXPECT_FP_EQ(inf, __llvm_libc::exp10f(float(FPB(0x7f7fffffU)))); EXPECT_MATH_ERRNO(ERANGE); - EXPECT_FP_EQ(inf, __llvm_libc::exp10f(float(FPBits(0x43000000U)))); + EXPECT_FP_EQ(inf, __llvm_libc::exp10f(float(FPB(0x43000000U)))); EXPECT_MATH_ERRNO(ERANGE); - EXPECT_FP_EQ(inf, __llvm_libc::exp10f(float(FPBits(0x43000001U)))); + EXPECT_FP_EQ(inf, __llvm_libc::exp10f(float(FPB(0x43000001U)))); EXPECT_MATH_ERRNO(ERANGE); } @@ -77,7 +77,7 @@ }; for (int i = 0; i < N; ++i) { errno = 0; - float x = float(FPBits(INPUTS[i])); + float x = float(FPB(INPUTS[i])); EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Exp10, x, __llvm_libc::exp10f(x), 0.5); EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Exp10, -x, @@ -89,7 +89,7 @@ constexpr uint32_t COUNT = 1000000; constexpr uint32_t STEP = UINT32_MAX / COUNT; for (uint32_t i = 0, v = 0; i <= COUNT; ++i, v += STEP) { - float x = float(FPBits(v)); + float x = float(FPB(v)); if (isnan(x) || isinf(x)) continue; errno = 0; diff --git a/libc/test/src/math/exp2f_test.cpp b/libc/test/src/math/exp2f_test.cpp --- a/libc/test/src/math/exp2f_test.cpp +++ b/libc/test/src/math/exp2f_test.cpp @@ -41,13 +41,13 @@ TEST(LlvmLibcExp2fTest, Overflow) { errno = 0; - EXPECT_FP_EQ(inf, __llvm_libc::exp2f(float(FPBits(0x7f7fffffU)))); + EXPECT_FP_EQ(inf, __llvm_libc::exp2f(float(FPB(0x7f7fffffU)))); EXPECT_MATH_ERRNO(ERANGE); - EXPECT_FP_EQ(inf, __llvm_libc::exp2f(float(FPBits(0x43000000U)))); + EXPECT_FP_EQ(inf, __llvm_libc::exp2f(float(FPB(0x43000000U)))); EXPECT_MATH_ERRNO(ERANGE); - EXPECT_FP_EQ(inf, __llvm_libc::exp2f(float(FPBits(0x43000001U)))); + EXPECT_FP_EQ(inf, __llvm_libc::exp2f(float(FPB(0x43000001U)))); EXPECT_MATH_ERRNO(ERANGE); } @@ -69,7 +69,7 @@ }; for (int i = 0; i < N; ++i) { errno = 0; - float x = float(FPBits(INPUTS[i])); + float x = float(FPB(INPUTS[i])); EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Exp2, x, __llvm_libc::exp2f(x), 0.5); EXPECT_MATH_ERRNO(0); @@ -78,20 +78,20 @@ TEST(LlvmLibcExp2fTest, Underflow) { errno = 0; - EXPECT_FP_EQ(0.0f, __llvm_libc::exp2f(float(FPBits(0xff7fffffU)))); + EXPECT_FP_EQ(0.0f, __llvm_libc::exp2f(float(FPB(0xff7fffffU)))); EXPECT_MATH_ERRNO(ERANGE); - float x = float(FPBits(0xc3158000U)); + float x = float(FPB(0xc3158000U)); EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Exp2, x, __llvm_libc::exp2f(x), 0.5); EXPECT_MATH_ERRNO(0); - x = float(FPBits(0xc3160000U)); + x = float(FPB(0xc3160000U)); EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Exp2, x, __llvm_libc::exp2f(x), 0.5); EXPECT_MATH_ERRNO(ERANGE); - x = float(FPBits(0xc3165432U)); + x = float(FPB(0xc3165432U)); EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Exp2, x, __llvm_libc::exp2f(x), 0.5); EXPECT_MATH_ERRNO(ERANGE); @@ -101,7 +101,7 @@ constexpr uint32_t COUNT = 1000000; constexpr uint32_t STEP = UINT32_MAX / COUNT; for (uint32_t i = 0, v = 0; i <= COUNT; ++i, v += STEP) { - float x = float(FPBits(v)); + float x = float(FPB(v)); if (isnan(x) || isinf(x)) continue; errno = 0; diff --git a/libc/test/src/math/expf_test.cpp b/libc/test/src/math/expf_test.cpp --- a/libc/test/src/math/expf_test.cpp +++ b/libc/test/src/math/expf_test.cpp @@ -41,27 +41,27 @@ TEST(LlvmLibcExpfTest, Overflow) { errno = 0; - EXPECT_FP_EQ(inf, __llvm_libc::expf(float(FPBits(0x7f7fffffU)))); + EXPECT_FP_EQ(inf, __llvm_libc::expf(float(FPB(0x7f7fffffU)))); EXPECT_MATH_ERRNO(ERANGE); - EXPECT_FP_EQ(inf, __llvm_libc::expf(float(FPBits(0x42cffff8U)))); + EXPECT_FP_EQ(inf, __llvm_libc::expf(float(FPB(0x42cffff8U)))); EXPECT_MATH_ERRNO(ERANGE); - EXPECT_FP_EQ(inf, __llvm_libc::expf(float(FPBits(0x42d00008U)))); + EXPECT_FP_EQ(inf, __llvm_libc::expf(float(FPB(0x42d00008U)))); EXPECT_MATH_ERRNO(ERANGE); } TEST(LlvmLibcExpfTest, Underflow) { errno = 0; - EXPECT_FP_EQ(0.0f, __llvm_libc::expf(float(FPBits(0xff7fffffU)))); + EXPECT_FP_EQ(0.0f, __llvm_libc::expf(float(FPB(0xff7fffffU)))); EXPECT_MATH_ERRNO(ERANGE); - float x = float(FPBits(0xc2cffff8U)); + float x = float(FPB(0xc2cffff8U)); EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Exp, x, __llvm_libc::expf(x), 0.5); EXPECT_MATH_ERRNO(ERANGE); - x = float(FPBits(0xc2d00008U)); + x = float(FPB(0xc2d00008U)); EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Exp, x, __llvm_libc::expf(x), 0.5); EXPECT_MATH_ERRNO(ERANGE); @@ -73,27 +73,27 @@ float x; errno = 0; - x = float(FPBits(0x42affff8U)); + x = float(FPB(0x42affff8U)); ASSERT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Exp, x, __llvm_libc::expf(x), 0.5); EXPECT_MATH_ERRNO(0); - x = float(FPBits(0x42b00008U)); + x = float(FPB(0x42b00008U)); ASSERT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Exp, x, __llvm_libc::expf(x), 0.5); EXPECT_MATH_ERRNO(0); - x = float(FPBits(0xc2affff8U)); + x = float(FPB(0xc2affff8U)); ASSERT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Exp, x, __llvm_libc::expf(x), 0.5); EXPECT_MATH_ERRNO(0); - x = float(FPBits(0xc2b00008U)); + x = float(FPB(0xc2b00008U)); ASSERT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Exp, x, __llvm_libc::expf(x), 0.5); EXPECT_MATH_ERRNO(0); - x = float(FPBits(0xc236bd8cU)); + x = float(FPB(0xc236bd8cU)); EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Exp, x, __llvm_libc::expf(x), 0.5); EXPECT_MATH_ERRNO(0); @@ -103,7 +103,7 @@ constexpr uint32_t COUNT = 1000000; constexpr uint32_t STEP = UINT32_MAX / COUNT; for (uint32_t i = 0, v = 0; i <= COUNT; ++i, v += STEP) { - float x = float(FPBits(v)); + float x = float(FPB(v)); if (isnan(x) || isinf(x)) continue; errno = 0; diff --git a/libc/test/src/math/expm1f_test.cpp b/libc/test/src/math/expm1f_test.cpp --- a/libc/test/src/math/expm1f_test.cpp +++ b/libc/test/src/math/expm1f_test.cpp @@ -41,24 +41,24 @@ TEST(LlvmLibcExpm1fTest, Overflow) { errno = 0; - EXPECT_FP_EQ(inf, __llvm_libc::expm1f(float(FPBits(0x7f7fffffU)))); + EXPECT_FP_EQ(inf, __llvm_libc::expm1f(float(FPB(0x7f7fffffU)))); EXPECT_MATH_ERRNO(ERANGE); - EXPECT_FP_EQ(inf, __llvm_libc::expm1f(float(FPBits(0x42cffff8U)))); + EXPECT_FP_EQ(inf, __llvm_libc::expm1f(float(FPB(0x42cffff8U)))); EXPECT_MATH_ERRNO(ERANGE); - EXPECT_FP_EQ(inf, __llvm_libc::expm1f(float(FPBits(0x42d00008U)))); + EXPECT_FP_EQ(inf, __llvm_libc::expm1f(float(FPB(0x42d00008U)))); EXPECT_MATH_ERRNO(ERANGE); } TEST(LlvmLibcExpm1fTest, Underflow) { errno = 0; - EXPECT_FP_EQ(-1.0f, __llvm_libc::expm1f(float(FPBits(0xff7fffffU)))); + EXPECT_FP_EQ(-1.0f, __llvm_libc::expm1f(float(FPB(0xff7fffffU)))); - float x = float(FPBits(0xc2cffff8U)); + float x = float(FPB(0xc2cffff8U)); EXPECT_FP_EQ(-1.0f, __llvm_libc::expm1f(x)); - x = float(FPBits(0xc2d00008U)); + x = float(FPB(0xc2d00008U)); EXPECT_FP_EQ(-1.0f, __llvm_libc::expm1f(x)); } @@ -68,42 +68,42 @@ float x; errno = 0; - x = float(FPBits(0x42affff8U)); + x = float(FPB(0x42affff8U)); ASSERT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Expm1, x, __llvm_libc::expm1f(x), 0.5); EXPECT_MATH_ERRNO(0); - x = float(FPBits(0x42b00008U)); + x = float(FPB(0x42b00008U)); ASSERT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Expm1, x, __llvm_libc::expm1f(x), 0.5); EXPECT_MATH_ERRNO(0); - x = float(FPBits(0xc2affff8U)); + x = float(FPB(0xc2affff8U)); ASSERT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Expm1, x, __llvm_libc::expm1f(x), 0.5); EXPECT_MATH_ERRNO(0); - x = float(FPBits(0xc2b00008U)); + x = float(FPB(0xc2b00008U)); ASSERT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Expm1, x, __llvm_libc::expm1f(x), 0.5); EXPECT_MATH_ERRNO(0); - x = float(FPBits(0x3dc252ddU)); + x = float(FPB(0x3dc252ddU)); ASSERT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Expm1, x, __llvm_libc::expm1f(x), 0.5); EXPECT_MATH_ERRNO(0); - x = float(FPBits(0x3e35bec5U)); + x = float(FPB(0x3e35bec5U)); ASSERT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Expm1, x, __llvm_libc::expm1f(x), 0.5); EXPECT_MATH_ERRNO(0); - x = float(FPBits(0x942ed494U)); + x = float(FPB(0x942ed494U)); ASSERT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Expm1, x, __llvm_libc::expm1f(x), 0.5); EXPECT_MATH_ERRNO(0); - x = float(FPBits(0xbdc1c6cbU)); + x = float(FPB(0xbdc1c6cbU)); ASSERT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Expm1, x, __llvm_libc::expm1f(x), 0.5); EXPECT_MATH_ERRNO(0); @@ -113,7 +113,7 @@ constexpr uint32_t COUNT = 1000000; constexpr uint32_t STEP = UINT32_MAX / COUNT; for (uint32_t i = 0, v = 0; i <= COUNT; ++i, v += STEP) { - float x = float(FPBits(v)); + float x = float(FPB(v)); if (isnan(x) || isinf(x)) continue; errno = 0; diff --git a/libc/test/src/math/in_float_range_test_helper.h b/libc/test/src/math/in_float_range_test_helper.h --- a/libc/test/src/math/in_float_range_test_helper.h +++ b/libc/test/src/math/in_float_range_test_helper.h @@ -9,13 +9,13 @@ #define CHECK_DATA(start, stop, mfp_op, f, f_check, count, prec) \ { \ - uint64_t ustart = FPBits(start).uintval(); \ - uint64_t ustop = FPBits(stop).uintval(); \ + uint64_t ustart = FPB(start).uintval(); \ + uint64_t ustop = FPB(stop).uintval(); \ for (uint64_t i = 0;; ++i) { \ uint64_t v = ustart + (ustop - ustart) * i / count; \ if (v > ustop) \ break; \ - float x = FPBits(uint32_t(v)).get_val(); \ + float x = FPB(uint32_t(v)).get_val(); \ if ((f_check)(x)) { \ EXPECT_MPFR_MATCH_ALL_ROUNDING(mfp_op, x, static_cast((f)(x)), \ (prec)); \ diff --git a/libc/test/src/math/log10_test.cpp b/libc/test/src/math/log10_test.cpp --- a/libc/test/src/math/log10_test.cpp +++ b/libc/test/src/math/log10_test.cpp @@ -25,10 +25,10 @@ TEST(LlvmLibcLog10Test, SpecialNumbers) { EXPECT_FP_EQ(aNaN, __llvm_libc::log10(aNaN)); EXPECT_FP_EQ(inf, __llvm_libc::log10(inf)); - EXPECT_TRUE(FPBits(__llvm_libc::log10(neg_inf)).is_nan()); + EXPECT_TRUE(FPB(__llvm_libc::log10(neg_inf)).is_nan()); EXPECT_FP_EQ(neg_inf, __llvm_libc::log10(0.0)); EXPECT_FP_EQ(neg_inf, __llvm_libc::log10(-0.0)); - EXPECT_TRUE(FPBits(__llvm_libc::log10(-1.0)).is_nan()); + EXPECT_TRUE(FPB(__llvm_libc::log10(-1.0)).is_nan()); EXPECT_FP_EQ(zero, __llvm_libc::log10(1.0)); } @@ -62,7 +62,7 @@ 0x225e7812faadb32f, 0x3fee1076964c2903, }; for (int i = 0; i < N; ++i) { - double x = double(FPBits(INPUTS[i])); + double x = double(FPB(INPUTS[i])); EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Log10, x, __llvm_libc::log10(x), 0.5); } @@ -81,7 +81,7 @@ double tol = 0.5; for (uint64_t i = 0, v = 0; i <= COUNT; ++i, v += STEP) { - double x = FPBits(v).get_val(); + double x = FPB(v).get_val(); if (isnan(x) || isinf(x) || x < 0.0) continue; errno = 0; diff --git a/libc/test/src/math/log10f_test.cpp b/libc/test/src/math/log10f_test.cpp --- a/libc/test/src/math/log10f_test.cpp +++ b/libc/test/src/math/log10f_test.cpp @@ -23,10 +23,10 @@ TEST(LlvmLibcLog10fTest, SpecialNumbers) { EXPECT_FP_EQ(aNaN, __llvm_libc::log10f(aNaN)); EXPECT_FP_EQ(inf, __llvm_libc::log10f(inf)); - EXPECT_TRUE(FPBits(__llvm_libc::log10f(neg_inf)).is_nan()); + EXPECT_TRUE(FPB(__llvm_libc::log10f(neg_inf)).is_nan()); EXPECT_FP_EQ(neg_inf, __llvm_libc::log10f(0.0f)); EXPECT_FP_EQ(neg_inf, __llvm_libc::log10f(-0.0f)); - EXPECT_TRUE(FPBits(__llvm_libc::log10f(-1.0f)).is_nan()); + EXPECT_TRUE(FPB(__llvm_libc::log10f(-1.0f)).is_nan()); EXPECT_FP_EQ(zero, __llvm_libc::log10f(1.0f)); } @@ -47,7 +47,7 @@ 0x7956ba5eU /*69683218960000541503257137270226944.0f*/}; for (int i = 0; i < N; ++i) { - float x = float(FPBits(INPUTS[i])); + float x = float(FPB(INPUTS[i])); EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Log10, x, __llvm_libc::log10f(x), 0.5); } @@ -57,7 +57,7 @@ constexpr uint32_t COUNT = 1000000; constexpr uint32_t STEP = UINT32_MAX / COUNT; for (uint32_t i = 0, v = 0; i <= COUNT; ++i, v += STEP) { - float x = float(FPBits(v)); + float x = float(FPB(v)); if (isnan(x) || isinf(x)) continue; errno = 0; diff --git a/libc/test/src/math/log1pf_test.cpp b/libc/test/src/math/log1pf_test.cpp --- a/libc/test/src/math/log1pf_test.cpp +++ b/libc/test/src/math/log1pf_test.cpp @@ -23,7 +23,7 @@ TEST(LlvmLibclog1pfTest, SpecialNumbers) { EXPECT_FP_EQ(aNaN, __llvm_libc::log1pf(aNaN)); EXPECT_FP_EQ(inf, __llvm_libc::log1pf(inf)); - EXPECT_TRUE(FPBits((__llvm_libc::log1pf(neg_inf))).is_nan()); + EXPECT_TRUE(FPB((__llvm_libc::log1pf(neg_inf))).is_nan()); EXPECT_FP_EQ(zero, __llvm_libc::log1pf(0.0f)); EXPECT_FP_EQ(neg_zero, __llvm_libc::log1pf(-0.0f)); EXPECT_FP_EQ(neg_inf, __llvm_libc::log1pf(-1.0f)); @@ -54,7 +54,7 @@ 0xbd1d20afU, /*-0x1.3a415ep-5f*/ }; for (int i = 0; i < N; ++i) { - float x = float(FPBits(INPUTS[i])); + float x = float(FPB(INPUTS[i])); EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Log1p, x, __llvm_libc::log1pf(x), 0.5); } @@ -64,7 +64,7 @@ constexpr uint32_t COUNT = 1000000; constexpr uint32_t STEP = UINT32_MAX / COUNT; for (uint32_t i = 0, v = 0; i <= COUNT; ++i, v += STEP) { - float x = float(FPBits(v)); + float x = float(FPB(v)); if (isnan(x) || isinf(x)) continue; errno = 0; diff --git a/libc/test/src/math/log2f_test.cpp b/libc/test/src/math/log2f_test.cpp --- a/libc/test/src/math/log2f_test.cpp +++ b/libc/test/src/math/log2f_test.cpp @@ -23,10 +23,10 @@ TEST(LlvmLibcLog2fTest, SpecialNumbers) { EXPECT_FP_EQ(aNaN, __llvm_libc::log2f(aNaN)); EXPECT_FP_EQ(inf, __llvm_libc::log2f(inf)); - EXPECT_TRUE(FPBits(__llvm_libc::log2f(neg_inf)).is_nan()); + EXPECT_TRUE(FPB(__llvm_libc::log2f(neg_inf)).is_nan()); EXPECT_FP_EQ(neg_inf, __llvm_libc::log2f(0.0f)); EXPECT_FP_EQ(neg_inf, __llvm_libc::log2f(-0.0f)); - EXPECT_TRUE(FPBits(__llvm_libc::log2f(-1.0f)).is_nan()); + EXPECT_TRUE(FPB(__llvm_libc::log2f(-1.0f)).is_nan()); EXPECT_FP_EQ(zero, __llvm_libc::log2f(1.0f)); } @@ -37,7 +37,7 @@ 0x3f80079bU, 0x3f81d0b5U, 0x3f82e602U, 0x3f83c98dU, 0x3f8cba39U}; for (int i = 0; i < N; ++i) { - float x = float(FPBits(INPUTS[i])); + float x = float(FPB(INPUTS[i])); EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Log2, x, __llvm_libc::log2f(x), 0.5); } @@ -47,7 +47,7 @@ constexpr uint32_t COUNT = 1000000; constexpr uint32_t STEP = UINT32_MAX / COUNT; for (uint32_t i = 0, v = 0; i <= COUNT; ++i, v += STEP) { - float x = float(FPBits(v)); + float x = float(FPB(v)); if (isnan(x) || isinf(x)) continue; errno = 0; diff --git a/libc/test/src/math/logf_test.cpp b/libc/test/src/math/logf_test.cpp --- a/libc/test/src/math/logf_test.cpp +++ b/libc/test/src/math/logf_test.cpp @@ -23,10 +23,10 @@ TEST(LlvmLibcLogfTest, SpecialNumbers) { EXPECT_FP_EQ(aNaN, __llvm_libc::logf(aNaN)); EXPECT_FP_EQ(inf, __llvm_libc::logf(inf)); - EXPECT_TRUE(FPBits((__llvm_libc::logf(neg_inf))).is_nan()); + EXPECT_TRUE(FPB((__llvm_libc::logf(neg_inf))).is_nan()); EXPECT_FP_EQ(neg_inf, __llvm_libc::logf(0.0f)); EXPECT_FP_EQ(neg_inf, __llvm_libc::logf(-0.0f)); - EXPECT_TRUE(FPBits(__llvm_libc::logf(-1.0f)).is_nan()); + EXPECT_TRUE(FPB(__llvm_libc::logf(-1.0f)).is_nan()); EXPECT_FP_EQ(zero, __llvm_libc::logf(1.0f)); } @@ -63,7 +63,7 @@ 0x7a17f30aU, /*0x1.2fe614p+117f*/ }; for (int i = 0; i < N; ++i) { - float x = float(FPBits(INPUTS[i])); + float x = float(FPB(INPUTS[i])); EXPECT_MPFR_MATCH(mpfr::Operation::Log, x, __llvm_libc::logf(x), 0.5); } } @@ -72,7 +72,7 @@ constexpr uint32_t COUNT = 1000000; constexpr uint32_t STEP = UINT32_MAX / COUNT; for (uint32_t i = 0, v = 0; i <= COUNT; ++i, v += STEP) { - float x = float(FPBits(v)); + float x = float(FPB(v)); if (isnan(x) || isinf(x)) continue; errno = 0; diff --git a/libc/test/src/math/mod_k_pi_test.cpp b/libc/test/src/math/mod_k_pi_test.cpp --- a/libc/test/src/math/mod_k_pi_test.cpp +++ b/libc/test/src/math/mod_k_pi_test.cpp @@ -14,14 +14,14 @@ #include namespace mpfr = __llvm_libc::testing::mpfr; -using FPBits = __llvm_libc::fputil::FPBits; -using UIntType = FPBits::UIntType; +using FPB = __llvm_libc::fputil::FPBits; +using UIntType = FPB::UIntType; TEST(LlvmLibcMod2PITest, Range) { constexpr UIntType count = 1000000000; constexpr UIntType step = UIntType(-1) / count; for (UIntType i = 0, v = 0; i <= count; ++i, v += step) { - double x = double(FPBits(v)); + double x = double(FPB(v)); if (isnan(x) || isinf(x) || x <= 0.0) continue; @@ -33,7 +33,7 @@ constexpr UIntType count = 1000000000; constexpr UIntType step = UIntType(-1) / count; for (UIntType i = 0, v = 0; i <= count; ++i, v += step) { - double x = double(FPBits(v)); + double x = double(FPB(v)); if (isnan(x) || isinf(x) || x <= 0.0) continue; @@ -46,7 +46,7 @@ constexpr UIntType count = 1000000000; constexpr UIntType step = UIntType(-1) / count; for (UIntType i = 0, v = 0; i <= count; ++i, v += step) { - double x = double(FPBits(v)); + double x = double(FPB(v)); if (isnan(x) || isinf(x) || x <= 0.0) continue; diff --git a/libc/test/src/math/pow_test.cpp b/libc/test/src/math/pow_test.cpp --- a/libc/test/src/math/pow_test.cpp +++ b/libc/test/src/math/pow_test.cpp @@ -15,7 +15,7 @@ #include #include -using FPBits = __llvm_libc::fputil::FPBits; +using FPB = __llvm_libc::fputil::FPBits; namespace mpfr = __llvm_libc::testing::mpfr; diff --git a/libc/test/src/math/sin_test.cpp b/libc/test/src/math/sin_test.cpp --- a/libc/test/src/math/sin_test.cpp +++ b/libc/test/src/math/sin_test.cpp @@ -23,7 +23,7 @@ constexpr UIntType COUNT = 10000000; constexpr UIntType STEP = UIntType(-1) / COUNT; for (UIntType i = 0, v = 0; i <= COUNT; ++i, v += STEP) { - double x = double(FPBits(v)); + double x = double(FPB(v)); // TODO: Expand the range of testing after range reduction is implemented. if (isnan(x) || isinf(x) || x > _2pi || x < -_2pi) continue; diff --git a/libc/test/src/math/sincosf_test.cpp b/libc/test/src/math/sincosf_test.cpp --- a/libc/test/src/math/sincosf_test.cpp +++ b/libc/test/src/math/sincosf_test.cpp @@ -18,7 +18,7 @@ #include using __llvm_libc::testing::SDCOMP26094_VALUES; -using FPBits = __llvm_libc::fputil::FPBits; +using FPB = __llvm_libc::fputil::FPBits; namespace mpfr = __llvm_libc::testing::mpfr; @@ -92,7 +92,7 @@ constexpr uint32_t COUNT = 1000000; constexpr uint32_t STEP = UINT32_MAX / COUNT; for (uint32_t i = 0, v = 0; i <= COUNT; ++i, v += STEP) { - float x = float(FPBits((v))); + float x = float(FPB((v))); if (isnan(x) || isinf(x)) continue; @@ -151,7 +151,7 @@ }; for (int i = 0; i < N; ++i) { - float x = float(FPBits(INPUTS[i])); + float x = float(FPB(INPUTS[i])); EXPECT_SINCOS_MATCH_ALL_ROUNDING(x); EXPECT_SINCOS_MATCH_ALL_ROUNDING(-x); } @@ -161,7 +161,7 @@ // returns values furthest beyond its nominal upper bound of pi/4. TEST(LlvmLibcSinCosfTest, SDCOMP_26094) { for (uint32_t v : SDCOMP26094_VALUES) { - float x = float(FPBits((v))); + float x = float(FPB((v))); EXPECT_SINCOS_MATCH_ALL_ROUNDING(x); EXPECT_SINCOS_MATCH_ALL_ROUNDING(-x); } diff --git a/libc/test/src/math/sinf_test.cpp b/libc/test/src/math/sinf_test.cpp --- a/libc/test/src/math/sinf_test.cpp +++ b/libc/test/src/math/sinf_test.cpp @@ -18,7 +18,7 @@ #include using __llvm_libc::testing::SDCOMP26094_VALUES; -using FPBits = __llvm_libc::fputil::FPBits; +using FPB = __llvm_libc::fputil::FPBits; namespace mpfr = __llvm_libc::testing::mpfr; @@ -47,7 +47,7 @@ constexpr uint32_t COUNT = 1000000; constexpr uint32_t STEP = UINT32_MAX / COUNT; for (uint32_t i = 0, v = 0; i <= COUNT; ++i, v += STEP) { - float x = float(FPBits(v)); + float x = float(FPB(v)); if (isnan(x) || isinf(x)) continue; ASSERT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Sin, x, @@ -97,7 +97,7 @@ }; for (int i = 0; i < N; ++i) { - float x = float(FPBits(INPUTS[i])); + float x = float(FPB(INPUTS[i])); EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Sin, x, __llvm_libc::sinf(x), 0.5); EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Sin, -x, @@ -107,11 +107,11 @@ // For small values, sin(x) is x. TEST(LlvmLibcSinfTest, SmallValues) { - float x = float(FPBits(0x1780'0000U)); + float x = float(FPB(0x1780'0000U)); EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Sin, x, __llvm_libc::sinf(x), 0.5); - x = float(FPBits(0x0040'0000U)); + x = float(FPB(0x0040'0000U)); EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Sin, x, __llvm_libc::sinf(x), 0.5); } @@ -120,7 +120,7 @@ // returns values furthest beyond its nominal upper bound of pi/4. TEST(LlvmLibcSinfTest, SDCOMP_26094) { for (uint32_t v : SDCOMP26094_VALUES) { - float x = float(FPBits((v))); + float x = float(FPB((v))); EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Sin, x, __llvm_libc::sinf(x), 0.5); } diff --git a/libc/test/src/math/sinhf_test.cpp b/libc/test/src/math/sinhf_test.cpp --- a/libc/test/src/math/sinhf_test.cpp +++ b/libc/test/src/math/sinhf_test.cpp @@ -17,7 +17,7 @@ #include #include -using FPBits = __llvm_libc::fputil::FPBits; +using FPB = __llvm_libc::fputil::FPBits; namespace mpfr = __llvm_libc::testing::mpfr; @@ -46,7 +46,7 @@ constexpr uint32_t COUNT = 1000000; constexpr uint32_t STEP = UINT32_MAX / COUNT; for (uint32_t i = 0, v = 0; i <= COUNT; ++i, v += STEP) { - float x = float(FPBits(v)); + float x = float(FPB(v)); if (isnan(x) || isinf(x)) continue; ASSERT_MPFR_MATCH(mpfr::Operation::Sinh, x, __llvm_libc::sinhf(x), 0.5); @@ -55,12 +55,12 @@ // For small values, sinh(x) is x. TEST(LlvmLibcSinhfTest, SmallValues) { - float x = float(FPBits(uint32_t(0x17800000))); + float x = float(FPB(uint32_t(0x17800000))); float result = __llvm_libc::sinhf(x); EXPECT_MPFR_MATCH(mpfr::Operation::Sinh, x, result, 0.5); EXPECT_FP_EQ(x, result); - x = float(FPBits(uint32_t(0x00400000))); + x = float(FPB(uint32_t(0x00400000))); result = __llvm_libc::sinhf(x); EXPECT_MPFR_MATCH(mpfr::Operation::Sinh, x, result, 0.5); EXPECT_FP_EQ(x, result); @@ -68,22 +68,22 @@ TEST(LlvmLibcSinhfTest, Overflow) { errno = 0; - EXPECT_FP_EQ(inf, __llvm_libc::sinhf(float(FPBits(0x7f7fffffU)))); + EXPECT_FP_EQ(inf, __llvm_libc::sinhf(float(FPB(0x7f7fffffU)))); EXPECT_MATH_ERRNO(ERANGE); - EXPECT_FP_EQ(inf, __llvm_libc::sinhf(float(FPBits(0x42cffff8U)))); + EXPECT_FP_EQ(inf, __llvm_libc::sinhf(float(FPB(0x42cffff8U)))); EXPECT_MATH_ERRNO(ERANGE); - EXPECT_FP_EQ(inf, __llvm_libc::sinhf(float(FPBits(0x42d00008U)))); + EXPECT_FP_EQ(inf, __llvm_libc::sinhf(float(FPB(0x42d00008U)))); EXPECT_MATH_ERRNO(ERANGE); } TEST(LlvmLibcSinhfTest, ExceptionalValues) { - float x = float(FPBits(uint32_t(0x3a12'85ffU))); + float x = float(FPB(uint32_t(0x3a12'85ffU))); EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Sinh, x, __llvm_libc::sinhf(x), 0.5); - x = -float(FPBits(uint32_t(0x3a12'85ffU))); + x = -float(FPB(uint32_t(0x3a12'85ffU))); EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Sinh, x, __llvm_libc::sinhf(x), 0.5); } diff --git a/libc/test/src/math/tan_test.cpp b/libc/test/src/math/tan_test.cpp --- a/libc/test/src/math/tan_test.cpp +++ b/libc/test/src/math/tan_test.cpp @@ -22,7 +22,7 @@ constexpr UIntType COUNT = 10000000; constexpr UIntType STEP = UIntType(-1) / COUNT; for (UIntType i = 0, v = 0; i <= COUNT; ++i, v += STEP) { - double x = double(FPBits(v)); + double x = double(FPB(v)); // TODO: Expand the range of testing after range reduction is implemented. if (isnan(x) || isinf(x) || x > _2pi || x < -_2pi) continue; diff --git a/libc/test/src/math/tanf_test.cpp b/libc/test/src/math/tanf_test.cpp --- a/libc/test/src/math/tanf_test.cpp +++ b/libc/test/src/math/tanf_test.cpp @@ -18,7 +18,7 @@ #include using __llvm_libc::testing::SDCOMP26094_VALUES; -using FPBits = __llvm_libc::fputil::FPBits; +using FPB = __llvm_libc::fputil::FPBits; namespace mpfr = __llvm_libc::testing::mpfr; @@ -47,7 +47,7 @@ constexpr uint32_t COUNT = 1000000; constexpr uint32_t STEP = UINT32_MAX / COUNT; for (uint32_t i = 0, v = 0; i <= COUNT; ++i, v += STEP) { - float x = float(FPBits(v)); + float x = float(FPB(v)); if (isnan(x) || isinf(x)) continue; ASSERT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Tan, x, @@ -115,7 +115,7 @@ }; for (int i = 0; i < N; ++i) { - float x = float(FPBits(INPUTS[i])); + float x = float(FPB(INPUTS[i])); EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Tan, x, __llvm_libc::tanf(x), 0.5); EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Tan, -x, @@ -127,7 +127,7 @@ // returns values furthest beyond its nominal upper bound of pi/4. TEST(LlvmLibcTanfTest, SDCOMP_26094) { for (uint32_t v : SDCOMP26094_VALUES) { - float x = float(FPBits(v)); + float x = float(FPB(v)); ASSERT_MPFR_MATCH(mpfr::Operation::Tan, x, __llvm_libc::tanf(x), 0.5); } } diff --git a/libc/test/src/math/tanhf_test.cpp b/libc/test/src/math/tanhf_test.cpp --- a/libc/test/src/math/tanhf_test.cpp +++ b/libc/test/src/math/tanhf_test.cpp @@ -16,7 +16,7 @@ #include #include -using FPBits = __llvm_libc::fputil::FPBits; +using FPB = __llvm_libc::fputil::FPBits; namespace mpfr = __llvm_libc::testing::mpfr; @@ -45,7 +45,7 @@ constexpr uint32_t COUNT = 1000000; constexpr uint32_t STEP = UINT32_MAX / COUNT; for (uint32_t i = 0, v = 0; i <= COUNT; ++i, v += STEP) { - float x = float(FPBits(v)); + float x = float(FPB(v)); if (isnan(x) || isinf(x)) continue; ASSERT_MPFR_MATCH(mpfr::Operation::Tanh, x, __llvm_libc::tanhf(x), 0.5); @@ -54,23 +54,23 @@ // For small values, tanh(x) is x. TEST(LlvmLibcTanhfTest, SmallValues) { - float x = float(FPBits(uint32_t(0x17800000))); + float x = float(FPB(uint32_t(0x17800000))); float result = __llvm_libc::tanhf(x); EXPECT_MPFR_MATCH(mpfr::Operation::Tanh, x, result, 0.5); EXPECT_FP_EQ(x, result); - x = float(FPBits(uint32_t(0x00400000))); + x = float(FPB(uint32_t(0x00400000))); result = __llvm_libc::tanhf(x); EXPECT_MPFR_MATCH(mpfr::Operation::Tanh, x, result, 0.5); EXPECT_FP_EQ(x, result); } TEST(LlvmLibcTanhfTest, ExceptionalValues) { - float x = float(FPBits(uint32_t(0x3a12'85ffU))); + float x = float(FPB(uint32_t(0x3a12'85ffU))); EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Tanh, x, __llvm_libc::tanhf(x), 0.5); - x = -float(FPBits(uint32_t(0x3a12'85ffU))); + x = -float(FPB(uint32_t(0x3a12'85ffU))); EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Tanh, x, __llvm_libc::tanhf(x), 0.5); } diff --git a/libc/test/utils/FPUtil/x86_long_double_test.cpp b/libc/test/utils/FPUtil/x86_long_double_test.cpp --- a/libc/test/utils/FPUtil/x86_long_double_test.cpp +++ b/libc/test/utils/FPUtil/x86_long_double_test.cpp @@ -11,7 +11,7 @@ #include -using FPBits = __llvm_libc::fputil::FPBits; +using FPB = __llvm_libc::fputil::FPBits; TEST(X86LongDoubleTest, is_nan) { // In the nan checks below, we use the macro isnan from math.h to ensure that @@ -20,8 +20,8 @@ // isnan result ensures that LLVM-libc's behavior matches the compiler's // behavior. - FPBits bits(0.0l); - bits.exponent = FPBits::MAX_EXPONENT; + FPB bits(0.0l); + bits.exponent = FPB::MAX_EXPONENT; for (unsigned int i = 0; i < 1000000; ++i) { // If exponent has the max value and the implicit bit is 0, // then the number is a NaN for all values of mantissa. diff --git a/libc/utils/MPFRWrapper/MPFRUtils.cpp b/libc/utils/MPFRWrapper/MPFRUtils.cpp --- a/libc/utils/MPFRWrapper/MPFRUtils.cpp +++ b/libc/utils/MPFRWrapper/MPFRUtils.cpp @@ -31,8 +31,6 @@ #include #endif -template using FPBits = __llvm_libc::fputil::FPBits; - namespace __llvm_libc { namespace testing { namespace mpfr { @@ -800,8 +798,8 @@ unsigned int precision = get_precision(ulp_tolerance); MPFRNumber mpfrX(input.x, precision); MPFRNumber mpfrY(input.y, precision); - FPBits xbits(input.x); - FPBits ybits(input.y); + fputil::FPBits xbits(input.x); + fputil::FPBits ybits(input.y); MPFRNumber mpfr_result = binary_operation_one_output(op, input.x, input.y, precision, rounding); MPFRNumber mpfrMatchValue(libc_result); @@ -841,9 +839,9 @@ MPFRNumber mpfrX(input.x, precision); MPFRNumber mpfrY(input.y, precision); MPFRNumber mpfrZ(input.z, precision); - FPBits xbits(input.x); - FPBits ybits(input.y); - FPBits zbits(input.z); + fputil::FPBits xbits(input.x); + fputil::FPBits ybits(input.y); + fputil::FPBits zbits(input.z); MPFRNumber mpfr_result = ternary_operation_one_output( op, input.x, input.y, input.z, precision, rounding); MPFRNumber mpfrMatchValue(libc_result); diff --git a/libc/utils/UnitTest/FPMatcher.h b/libc/utils/UnitTest/FPMatcher.h --- a/libc/utils/UnitTest/FPMatcher.h +++ b/libc/utils/UnitTest/FPMatcher.h @@ -69,13 +69,13 @@ } // namespace __llvm_libc #define DECLARE_SPECIAL_CONSTANTS(T) \ - using FPBits = __llvm_libc::fputil::FPBits; \ - using UIntType = typename FPBits::UIntType; \ - const T zero = T(FPBits::zero()); \ - const T neg_zero = T(FPBits::neg_zero()); \ - const T aNaN = T(FPBits::build_quiet_nan(1)); \ - const T inf = T(FPBits::inf()); \ - const T neg_inf = T(FPBits::neg_inf()); + using FPB = __llvm_libc::fputil::FPBits; \ + using UIntType = typename FPB::UIntType; \ + const T zero = T(FPB::zero()); \ + const T neg_zero = T(FPB::neg_zero()); \ + const T aNaN = T(FPB::build_quiet_nan(1)); \ + const T inf = T(FPB::inf()); \ + const T neg_inf = T(FPB::neg_inf()); #define EXPECT_FP_EQ(expected, actual) \ EXPECT_THAT( \