-
Notifications
You must be signed in to change notification settings - Fork 12k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[libc][NFC] Use user defined literals to build 128 and 256 bit constants. #81746
Conversation
@llvm/pr-subscribers-libc Author: Guillaume Chatelet (gchatelet) ChangesPatch is 363.98 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/81746.diff 15 Files Affected:
diff --git a/libc/src/__support/integer_literals.h b/libc/src/__support/integer_literals.h
index c8e965c1a03a05..ace8a948b57aca 100644
--- a/libc/src/__support/integer_literals.h
+++ b/libc/src/__support/integer_literals.h
@@ -22,19 +22,19 @@
namespace LIBC_NAMESPACE {
LIBC_INLINE constexpr uint8_t operator""_u8(unsigned long long value) {
- return value;
+ return static_cast<uint8_t>(value);
}
LIBC_INLINE constexpr uint16_t operator""_u16(unsigned long long value) {
- return value;
+ return static_cast<uint16_t>(value);
}
LIBC_INLINE constexpr uint32_t operator""_u32(unsigned long long value) {
- return value;
+ return static_cast<uint32_t>(value);
}
LIBC_INLINE constexpr uint64_t operator""_u64(unsigned long long value) {
- return value;
+ return static_cast<uint64_t>(value);
}
namespace internal {
diff --git a/libc/src/math/generic/CMakeLists.txt b/libc/src/math/generic/CMakeLists.txt
index fdf383f070697e..ab7f5a91ab7bac 100644
--- a/libc/src/math/generic/CMakeLists.txt
+++ b/libc/src/math/generic/CMakeLists.txt
@@ -622,6 +622,8 @@ add_entrypoint_object(
DEPENDS
.common_constants
.explogxf
+ libc.include.errno
+ libc.include.math
libc.src.__support.CPP.bit
libc.src.__support.CPP.optional
libc.src.__support.FPUtil.dyadic_float
@@ -632,10 +634,9 @@ add_entrypoint_object(
libc.src.__support.FPUtil.polyeval
libc.src.__support.FPUtil.rounding_mode
libc.src.__support.FPUtil.triple_double
+ libc.src.__support.integer_literals
libc.src.__support.macros.optimization
- libc.include.errno
libc.src.errno.errno
- libc.include.math
COMPILE_OPTIONS
-O3
)
@@ -672,6 +673,8 @@ add_entrypoint_object(
DEPENDS
.common_constants
.explogxf
+ libc.include.errno
+ libc.include.math
libc.src.__support.CPP.bit
libc.src.__support.CPP.optional
libc.src.__support.FPUtil.dyadic_float
@@ -682,10 +685,9 @@ add_entrypoint_object(
libc.src.__support.FPUtil.polyeval
libc.src.__support.FPUtil.rounding_mode
libc.src.__support.FPUtil.triple_double
+ libc.src.__support.integer_literals
libc.src.__support.macros.optimization
- libc.include.errno
libc.src.errno.errno
- libc.include.math
COMPILE_OPTIONS
-O3
)
@@ -731,6 +733,8 @@ add_entrypoint_object(
DEPENDS
.common_constants
.explogxf
+ libc.include.errno
+ libc.include.math
libc.src.__support.CPP.bit
libc.src.__support.CPP.optional
libc.src.__support.FPUtil.dyadic_float
@@ -741,10 +745,9 @@ add_entrypoint_object(
libc.src.__support.FPUtil.polyeval
libc.src.__support.FPUtil.rounding_mode
libc.src.__support.FPUtil.triple_double
+ libc.src.__support.integer_literals
libc.src.__support.macros.optimization
- libc.include.errno
libc.src.errno.errno
- libc.include.math
COMPILE_OPTIONS
-O3
)
@@ -791,6 +794,8 @@ add_entrypoint_object(
DEPENDS
.common_constants
.explogxf
+ libc.include.errno
+ libc.include.math
libc.src.__support.CPP.bit
libc.src.__support.CPP.optional
libc.src.__support.FPUtil.dyadic_float
@@ -801,10 +806,9 @@ add_entrypoint_object(
libc.src.__support.FPUtil.polyeval
libc.src.__support.FPUtil.rounding_mode
libc.src.__support.FPUtil.triple_double
+ libc.src.__support.integer_literals
libc.src.__support.macros.optimization
- libc.include.errno
libc.src.errno.errno
- libc.include.math
COMPILE_OPTIONS
-O3
)
@@ -1061,12 +1065,13 @@ add_entrypoint_object(
DEPENDS
.common_constants
.log_range_reduction
+ libc.src.__support.FPUtil.double_double
+ libc.src.__support.FPUtil.dyadic_float
libc.src.__support.FPUtil.fenv_impl
libc.src.__support.FPUtil.fp_bits
libc.src.__support.FPUtil.multiply_add
libc.src.__support.FPUtil.polyeval
- libc.src.__support.FPUtil.double_double
- libc.src.__support.FPUtil.dyadic_float
+ libc.src.__support.integer_literals
libc.src.__support.macros.optimization
COMPILE_OPTIONS
-O3
@@ -1097,12 +1102,13 @@ add_entrypoint_object(
../log1p.h
DEPENDS
.common_constants
+ libc.src.__support.FPUtil.double_double
+ libc.src.__support.FPUtil.dyadic_float
libc.src.__support.FPUtil.fenv_impl
libc.src.__support.FPUtil.fp_bits
libc.src.__support.FPUtil.multiply_add
libc.src.__support.FPUtil.polyeval
- libc.src.__support.FPUtil.double_double
- libc.src.__support.FPUtil.dyadic_float
+ libc.src.__support.integer_literals
libc.src.__support.macros.optimization
COMPILE_OPTIONS
-O3
@@ -1135,12 +1141,13 @@ add_entrypoint_object(
DEPENDS
.common_constants
.log_range_reduction
+ libc.src.__support.FPUtil.double_double
+ libc.src.__support.FPUtil.dyadic_float
libc.src.__support.FPUtil.fenv_impl
libc.src.__support.FPUtil.fp_bits
libc.src.__support.FPUtil.multiply_add
libc.src.__support.FPUtil.polyeval
- libc.src.__support.FPUtil.double_double
- libc.src.__support.FPUtil.dyadic_float
+ libc.src.__support.integer_literals
libc.src.__support.macros.optimization
COMPILE_OPTIONS
-O3
@@ -1173,12 +1180,13 @@ add_entrypoint_object(
DEPENDS
.common_constants
.log_range_reduction
+ libc.src.__support.FPUtil.double_double
+ libc.src.__support.FPUtil.dyadic_float
libc.src.__support.FPUtil.fenv_impl
libc.src.__support.FPUtil.fp_bits
libc.src.__support.FPUtil.multiply_add
libc.src.__support.FPUtil.polyeval
- libc.src.__support.FPUtil.double_double
- libc.src.__support.FPUtil.dyadic_float
+ libc.src.__support.integer_literals
libc.src.__support.macros.optimization
COMPILE_OPTIONS
-O3
diff --git a/libc/src/math/generic/exp.cpp b/libc/src/math/generic/exp.cpp
index f23170f8ed4259..ccb77fc6c8f70a 100644
--- a/libc/src/math/generic/exp.cpp
+++ b/libc/src/math/generic/exp.cpp
@@ -21,6 +21,7 @@
#include "src/__support/FPUtil/rounding_mode.h"
#include "src/__support/FPUtil/triple_double.h"
#include "src/__support/common.h"
+#include "src/__support/integer_literals.h"
#include "src/__support/macros/optimization.h" // LIBC_UNLIKELY
#include <errno.h>
@@ -31,6 +32,7 @@ using fputil::DoubleDouble;
using fputil::TripleDouble;
using Float128 = typename fputil::DyadicFloat<128>;
using Sign = fputil::Sign;
+using LIBC_NAMESPACE::operator""_u128;
// log2(e)
constexpr double LOG2_E = 0x1.71547652b82fep+0;
@@ -97,21 +99,15 @@ DoubleDouble poly_approx_dd(const DoubleDouble &dx) {
// For |dx| < 2^-13 + 2^-30:
// | output - exp(dx) | < 2^-126.
Float128 poly_approx_f128(const Float128 &dx) {
- using MType = typename Float128::MantissaType;
-
constexpr Float128 COEFFS_128[]{
- {Sign::POS, -127, MType({0, 0x8000000000000000})}, // 1.0
- {Sign::POS, -127, MType({0, 0x8000000000000000})}, // 1.0
- {Sign::POS, -128, MType({0, 0x8000000000000000})}, // 0.5
- {Sign::POS, -130, MType({0xaaaaaaaaaaaaaaab, 0xaaaaaaaaaaaaaaaa})}, // 1/6
- {Sign::POS, -132,
- MType({0xaaaaaaaaaaaaaaab, 0xaaaaaaaaaaaaaaaa})}, // 1/24
- {Sign::POS, -134,
- MType({0x8888888888888889, 0x8888888888888888})}, // 1/120
- {Sign::POS, -137,
- MType({0x60b60b60b60b60b6, 0xb60b60b60b60b60b})}, // 1/720
- {Sign::POS, -140,
- MType({0x00d00d00d00d00d0, 0xd00d00d00d00d00d})}, // 1/5040
+ {Sign::POS, -127, 0x80000000000000000000000000000000_u128}, // 1.0
+ {Sign::POS, -127, 0x80000000000000000000000000000000_u128}, // 1.0
+ {Sign::POS, -128, 0x80000000000000000000000000000000_u128}, // 0.5
+ {Sign::POS, -130, 0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab_u128}, // 1/6
+ {Sign::POS, -132, 0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab_u128}, // 1/24
+ {Sign::POS, -134, 0x88888888888888888888888888888889_u128}, // 1/120
+ {Sign::POS, -137, 0xb60b60b60b60b60b60b60b60b60b60b6_u128}, // 1/720
+ {Sign::POS, -140, 0xd00d00d00d00d00d00d00d00d00d00d0_u128}, // 1/5040
};
Float128 p = fputil::polyeval(dx, COEFFS_128[0], COEFFS_128[1], COEFFS_128[2],
diff --git a/libc/src/math/generic/exp10.cpp b/libc/src/math/generic/exp10.cpp
index 6b40f5561845d8..069141a2eeabb6 100644
--- a/libc/src/math/generic/exp10.cpp
+++ b/libc/src/math/generic/exp10.cpp
@@ -21,6 +21,7 @@
#include "src/__support/FPUtil/rounding_mode.h"
#include "src/__support/FPUtil/triple_double.h"
#include "src/__support/common.h"
+#include "src/__support/integer_literals.h"
#include "src/__support/macros/optimization.h" // LIBC_UNLIKELY
#include <errno.h>
@@ -31,6 +32,7 @@ using fputil::DoubleDouble;
using fputil::TripleDouble;
using Float128 = typename fputil::DyadicFloat<128>;
using Sign = fputil::Sign;
+using LIBC_NAMESPACE::operator""_u128;
// log2(10)
constexpr double LOG2_10 = 0x1.a934f0979a371p+1;
@@ -99,17 +101,15 @@ DoubleDouble poly_approx_dd(const DoubleDouble &dx) {
// For |dx| < 2^-14:
// | output - 10^dx | < 1.5 * 2^-124.
Float128 poly_approx_f128(const Float128 &dx) {
- using MType = typename Float128::MantissaType;
-
constexpr Float128 COEFFS_128[]{
- {Sign::POS, -127, MType({0, 0x8000000000000000})}, // 1.0
- {Sign::POS, -126, MType({0xea56d62b82d30a2d, 0x935d8dddaaa8ac16})},
- {Sign::POS, -126, MType({0x80a99ce75f4d5bdb, 0xa9a92639e753443a})},
- {Sign::POS, -126, MType({0x6a4f9d7dbf6c9635, 0x82382c8ef1652304})},
- {Sign::POS, -124, MType({0x345787019216c7af, 0x12bd7609fd98c44c})},
- {Sign::POS, -127, MType({0xcc41ed7e0d27aee5, 0x450a7ff47535d889})},
- {Sign::POS, -130, MType({0x8326bb91a6e7601d, 0xd3f6b844702d636b})},
- {Sign::POS, -130, MType({0xfa7b46df314112a9, 0x45b937f0d05bb1cd})},
+ {Sign::POS, -127, 0x00000000000000080000000000000000_u128}, // 1.0
+ {Sign::POS, -126, 0x935d8dddaaa8ac16ea56d62b82d30a2d_u128},
+ {Sign::POS, -126, 0xa9a92639e753443a80a99ce75f4d5bdb_u128},
+ {Sign::POS, -126, 0x82382c8ef16523046a4f9d7dbf6c9635_u128},
+ {Sign::POS, -124, 0x12bd7609fd98c44c345787019216c7af_u128},
+ {Sign::POS, -127, 0x450a7ff47535d889cc41ed7e0d27aee5_u128},
+ {Sign::POS, -130, 0xd3f6b844702d636b8326bb91a6e7601d_u128},
+ {Sign::POS, -130, 0x45b937f0d05bb1cdfa7b46df314112a9_u128},
};
Float128 p = fputil::polyeval(dx, COEFFS_128[0], COEFFS_128[1], COEFFS_128[2],
diff --git a/libc/src/math/generic/exp2.cpp b/libc/src/math/generic/exp2.cpp
index 01e66d1ae00f70..e9d4623b2faf21 100644
--- a/libc/src/math/generic/exp2.cpp
+++ b/libc/src/math/generic/exp2.cpp
@@ -21,6 +21,7 @@
#include "src/__support/FPUtil/rounding_mode.h"
#include "src/__support/FPUtil/triple_double.h"
#include "src/__support/common.h"
+#include "src/__support/integer_literals.h"
#include "src/__support/macros/optimization.h" // LIBC_UNLIKELY
#include <errno.h>
@@ -31,6 +32,7 @@ using fputil::DoubleDouble;
using fputil::TripleDouble;
using Float128 = typename fputil::DyadicFloat<128>;
using Sign = fputil::Sign;
+using LIBC_NAMESPACE::operator""_u128;
// Error bounds:
// Errors when using double precision.
@@ -88,17 +90,15 @@ DoubleDouble poly_approx_dd(const DoubleDouble &dx) {
// For |dx| < 2^-13 + 2^-30:
// | output - exp(dx) | < 2^-126.
Float128 poly_approx_f128(const Float128 &dx) {
- using MType = typename Float128::MantissaType;
-
constexpr Float128 COEFFS_128[]{
- {Sign::POS, -127, MType({0, 0x8000000000000000})}, // 1.0
- {Sign::POS, -128, MType({0xc9e3b39803f2f6af, 0xb17217f7d1cf79ab})},
- {Sign::POS, -128, MType({0xde2d60dd9c9a1d9f, 0x3d7f7bff058b1d50})},
- {Sign::POS, -132, MType({0x9d3b15d9e7fb6897, 0xe35846b82505fc59})},
- {Sign::POS, -134, MType({0x184462f6bcd2b9e7, 0x9d955b7dd273b94e})},
- {Sign::POS, -137, MType({0x39ea1bb964c51a89, 0xaec3ff3c53398883})},
- {Sign::POS, -138, MType({0x842c53418fa8ae61, 0x2861225f345c396a})},
- {Sign::POS, -144, MType({0x7abeb5abd5ad2079, 0xffe5fe2d109a319d})},
+ {Sign::POS, -127, 0x80000000000000000000000000000000_u128}, // 1.0
+ {Sign::POS, -128, 0xb17217f7d1cf79abc9e3b39803f2f6af_u128},
+ {Sign::POS, -128, 0x3d7f7bff058b1d50de2d60dd9c9a1d9f_u128},
+ {Sign::POS, -132, 0xe35846b82505fc599d3b15d9e7fb6897_u128},
+ {Sign::POS, -134, 0x9d955b7dd273b94e184462f6bcd2b9e7_u128},
+ {Sign::POS, -137, 0xaec3ff3c5339888339ea1bb964c51a89_u128},
+ {Sign::POS, -138, 0x2861225f345c396a842c53418fa8ae61_u128},
+ {Sign::POS, -144, 0xffe5fe2d109a319d7abeb5abd5ad2079_u128},
};
Float128 p = fputil::polyeval(dx, COEFFS_128[0], COEFFS_128[1], COEFFS_128[2],
diff --git a/libc/src/math/generic/expm1.cpp b/libc/src/math/generic/expm1.cpp
index c1fb80309d7b46..cde09578d15726 100644
--- a/libc/src/math/generic/expm1.cpp
+++ b/libc/src/math/generic/expm1.cpp
@@ -22,6 +22,7 @@
#include "src/__support/FPUtil/rounding_mode.h"
#include "src/__support/FPUtil/triple_double.h"
#include "src/__support/common.h"
+#include "src/__support/integer_literals.h"
#include "src/__support/macros/optimization.h" // LIBC_UNLIKELY
#include <errno.h>
@@ -39,6 +40,7 @@ using fputil::DoubleDouble;
using fputil::TripleDouble;
using Float128 = typename fputil::DyadicFloat<128>;
using Sign = fputil::Sign;
+using LIBC_NAMESPACE::operator""_u128;
// log2(e)
constexpr double LOG2_E = 0x1.71547652b82fep+0;
@@ -107,20 +109,14 @@ DoubleDouble poly_approx_dd(const DoubleDouble &dx) {
// For |dx| < 2^-13 + 2^-30:
// | output - exp(dx) | < 2^-126.
Float128 poly_approx_f128(const Float128 &dx) {
- using MType = typename Float128::MantissaType;
-
constexpr Float128 COEFFS_128[]{
- {Sign::POS, -127, MType({0, 0x8000000000000000})}, // 1.0
- {Sign::POS, -128, MType({0, 0x8000000000000000})}, // 0.5
- {Sign::POS, -130, MType({0xaaaaaaaaaaaaaaab, 0xaaaaaaaaaaaaaaaa})}, // 1/6
- {Sign::POS, -132,
- MType({0xaaaaaaaaaaaaaaab, 0xaaaaaaaaaaaaaaaa})}, // 1/24
- {Sign::POS, -134,
- MType({0x8888888888888889, 0x8888888888888888})}, // 1/120
- {Sign::POS, -137,
- MType({0x60b60b60b60b60b6, 0xb60b60b60b60b60b})}, // 1/720
- {Sign::POS, -140,
- MType({0x00d00d00d00d00d0, 0xd00d00d00d00d00d})}, // 1/5040
+ {Sign::POS, -127, 0x80000000000000000000000000000000_u128}, // 1.0
+ {Sign::POS, -128, 0x80000000000000000000000000000000_u128}, // 0.5
+ {Sign::POS, -130, 0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab_u128}, // 1/6
+ {Sign::POS, -132, 0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaab_u128}, // 1/24
+ {Sign::POS, -134, 0x88888888888888888888888888888889_u128}, // 1/120
+ {Sign::POS, -137, 0xb60b60b60b60b60b60b60b60b60b60b6_u128}, // 1/720
+ {Sign::POS, -140, 0xd00d00d00d00d00d00d00d00d00d00d0_u128}, // 1/5040
};
Float128 p = fputil::polyeval(dx, COEFFS_128[0], COEFFS_128[1], COEFFS_128[2],
@@ -146,7 +142,6 @@ std::ostream &operator<<(std::ostream &OS, const DoubleDouble &r) {
// TODO(lntue): investigate triple-double precision implementation for this
// step.
Float128 expm1_f128(double x, double kd, int idx1, int idx2) {
- using MType = typename Float128::MantissaType;
// Recalculate dx:
double t1 = fputil::multiply_add(kd, MLOG_2_EXP2_M12_HI, x); // exact
@@ -170,7 +165,8 @@ Float128 expm1_f128(double x, double kd, int idx1, int idx2) {
Float128 exp_mid = fputil::quick_mul(exp_mid1, exp_mid2);
int hi = static_cast<int>(kd) >> 12;
- Float128 minus_one{Sign::NEG, -127 - hi, MType({0, 0x8000000000000000})};
+ Float128 minus_one{Sign::NEG, -127 - hi,
+ 0x80000000000000000000000000000000_u128};
Float128 exp_mid_m1 = fputil::quick_add(exp_mid, minus_one);
diff --git a/libc/src/math/generic/log.cpp b/libc/src/math/generic/log.cpp
index 9edc52b8a8e24c..a4b6aba160fdce 100644
--- a/libc/src/math/generic/log.cpp
+++ b/libc/src/math/generic/log.cpp
@@ -14,6 +14,7 @@
#include "src/__support/FPUtil/dyadic_float.h"
#include "src/__support/FPUtil/multiply_add.h"
#include "src/__support/common.h"
+#include "src/__support/integer_literals.h"
#include "src/__support/macros/optimization.h" // LIBC_UNLIKELY
#include "common_constants.h"
@@ -23,8 +24,8 @@ namespace LIBC_NAMESPACE {
// 128-bit precision dyadic floating point numbers.
using Float128 = typename fputil::DyadicFloat<128>;
-using MType = typename Float128::MantissaType;
using Sign = fputil::Sign;
+using LIBC_NAMESPACE::operator""_u128;
namespace {
@@ -36,9 +37,9 @@ constexpr double P_ERR = 0x1.0p-50;
// log(2) with 128-bit prepcision generated by SageMath with:
// sage: (s, m, e) = RealField(128)(2).log().sign_mantissa_exponent();
-// sage: print("MType({", hex(m % 2^64), ",", hex((m >> 64) % 2^64), "})");
+// sage: print(hex(m), "_u128");
const Float128 LOG_2(Sign::POS, /*exponent=*/-128, /*mantissa=*/
- MType({0xc9e3b39803f2f6af, 0xb17217f7d1cf79ab}));
+ 0xb17217f7d1cf79abc9e3b39803f2f6af_u128);
alignas(64) const LogRR LOG_TABLE = {
// -log(r) with 128-bit precision generated by SageMath with:
@@ -46,138 +47,136 @@ alignas(64) const LogRR LOG_TABLE = {
// for i in range(128):
// r = 2^-8 * ceil( 2^8 * (1 - 2^(-8)) / (1 + i*2^(-7)) );
// s, m, e = RealField(128)(r).log().sign_mantissa_exponent();
- // print("{Sign::POS,", e, ", MType({", hex(m % 2^64), ",", hex((m >> 64)
- // % 2^64),
- // "})},");
+ // print("{Sign::POS,", e, ", hex(m), "_u128},");
/* .step_1= */ {
- {Sign::POS, 0, MType(0)},
- {Sign::POS, -134, MType({0x662d417ced007a46, 0x8080abac46f38946})},
- {Sign::POS, -133, MType({0x91d082dce3ddcd38, 0x8102b2c49ac23a4f})},
- {Sign::POS, -133, MType({0xda5f3cc0b3251dbd, 0xc24929464655f45c})},
- {Sign::POS, -132, MType({0xb9e3aea6c444ef07, 0x820aec4f3a222380})},
- {Sign::POS, -132, MType({0x521016bd904dc968, 0xa33576a16f1f4c64})},
- {Sign::POS, -132, MType({0xbe97660a23cc540d, 0xc4a550a4fd9a19a8})},
- {Sign::POS, -132, MType({0xe09f5fe2058d6006, 0xe65b9e6eed965c36})},
- {Sign::POS, -131, MType({0x1fecdfa819b96098, 0x842cc5acf1d03445})},
- {Sign::POS, -131, MType({0xa7c9859530a45153, 0x8cb9de8a32ab368a})},
- {Sign::POS, -131, MType({0x976d3b5b45f6ca0b, 0x9defad3e8f73217a})},
- {Sign::POS, -131, MType({0xe8b8b88a14ff0ce, 0xaf4ad26cbc8e5be7})},
- {Sign::POS, -131, MType({0x6a677b4c8bec22e1, 0xb8069857560707a3})},
- {Sign::POS, -131, MType({0xeaf51f66692844ba, 0xc99af2eaca4c4570})},
- {Sign::POS, -131, MType({0xa8112e35a60e6375, 0xdb56446d6ad8deff})},
- {Sign::POS, -131, MType({0x196ab34ce0bccd12, 0xe442c00de2591b47})},
- {Sign::POS, -131, MType({0x4066e87f2c0f7340, 0xf639cc185088fe5d})},
- {Sign::POS, -131, MType({0xc17bd40d8d9291ec, 0xff4489cedeab2ca6})},
- {Sign::POS, -130, MType({0x9c5a0fe396f40f1e, 0x88bc74113f23def1})},
- {Sign::POS, -130, MType({0x88713268840cbcc0, 0x8d515bf11fb94f1c})},
- {Sign::POS, -130, MType({0x65c0da506a088484, 0x968b08643409ceb6})},
- {Sign::POS, -130, MType({0x411a5b944aca8708, 0x9b2fe580ac80b17d})},
- {Sign::POS, -130, MType({0xa9fb6cf0ecb411b7, 0xa489ec199dab06f2})},
- {Sign::POS, -130, MType({0xcad2fb8d48054ae0, 0xa93f2f250dac67d1})},
- {Sign::POS, -130, MType({0x2c3c2e77904afa78, 0xb2ba75f46099cf8b})},
- {Sign::POS, -130, MType({0x34c7bc3d32750fde, 0xb780945bab55dce4})},
- {Sign::POS, -130, MType({0x9a631e830fd30904, 0xc11e0b2a8d1e0ddb})},
- {Sign::POS, -130, MType({0xaa8b6997a402bf30, 0xc5f57f59c7f46155})},
- {Sign::POS, -130, MType({0x2c507fb7a3d0bf6a, 0xcad2d6e7b80bf914})},
- {Sign::POS, -130, MType({0x5f53bd2e406e66e7, 0xd49f69e456cf1b79})},
- {Sign::POS, -130, MType({0x58a98f2ad65bee9b, 0xd98ec2bade71e539})},
- {Sign::POS, -130, MType({0x4d57da945b5d0aaa, 0xde8439c1dec56877})},
- {Sign::POS, -130, MType({0xc524848e3443e040, 0xe881bf932af3dac0})},
- {Sign::POS, -130, MType({0x11d49f96cb88317b, 0xed89ed86a44a01aa})},
- {Sign::POS, -130, MType({0x3b020fa1820c9492, 0xf29877ff38809091})},
- {Sign::POS, -130, MType({0x54d2238f75f969b1, 0xf7ad6f26e7ff2ef7})},
- {Sign::POS, -130, MType({0xca0cdf301431b60f, 0xfcc8e3659d9bcbec})},
- {Sign::POS, -129, MType({0x62dda9d2270fa1f4, 0x8389c3026ac3139b})},
- {Sign::POS, -129, MType({0x163ceae88f720f1e, 0x86216b3b0b17188b})}...
[truncated]
|
Most of the change is done via |
I'm sorry for asking a bit late, but is it easy to add |
Sure no worries, which one do you want 64 or 32? |
I prefer 32-bit chunks if it does not push the constants to the next line. Otherwise, 64-bit chunks works fine too. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for cleaning this up! It looks much better now!
I used this function and updated the documentation I haven't checked the scripts but they should be just a typo away from working 😅 |
@@ -76,7 +76,7 @@ template <typename T, int base> struct DigitBuffer { | |||
// Returns the digit for a particular character. | |||
// Returns 255 if the character is invalid. | |||
LIBC_INLINE static constexpr uint8_t get_digit_value(const char c) { | |||
const auto to_lower = [](char c) { return c | 32; }; | |||
const auto to_lower = [](char c) -> uint8_t { return c | 32; }; | |||
const auto is_digit = [](char c) { return c >= '0' && c <= '9'; }; | |||
const auto is_alpha = [](char c) { | |||
return ('a' <= c && c <= 'z') || ('A' <= c && c <= 'Z'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like this is producing an error on the gcc build bots:
/home/llvm-libc-buildbot/buildbot-worker/libc-x86_64-debian-fullbuild/libc-x86_64-debian-gcc-fullbuild-dbg/llvm-project/libc/src/__support/integer_literals.h:85:16: error: conversion from ‘int’ to ‘uint8_t’ {aka ‘unsigned char’} may change value [-Werror=conversion]
85 | return c - '0';
| ~~^~~~~
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes just noticed, I'll revert, I don't have time to fix it now.
…t constants This is a reland of llvm#81746
…t constants (llvm#81835) This is a reland of llvm#81746
No description provided.