[libc-commits] [libc] 823e3e0 - [libc][math] Resolve size issues on baremetal and cleanup code. (#179707)
via libc-commits
libc-commits at lists.llvm.org
Thu Feb 5 05:08:38 PST 2026
Author: Muhammad Bassiouni
Date: 2026-02-05T15:08:33+02:00
New Revision: 823e3e001724ca2e93ce410a675f3b538f8a74b3
URL: https://github.com/llvm/llvm-project/commit/823e3e001724ca2e93ce410a675f3b538f8a74b3
DIFF: https://github.com/llvm/llvm-project/commit/823e3e001724ca2e93ce410a675f3b538f8a74b3.diff
LOG: [libc][math] Resolve size issues on baremetal and cleanup code. (#179707)
Added:
Modified:
libc/src/__support/math/acos.h
libc/src/__support/math/acosf.h
libc/src/__support/math/acosf16.h
libc/src/__support/math/acosh_float_constants.h
libc/src/__support/math/acoshf.h
libc/src/__support/math/acoshf16.h
libc/src/__support/math/acoshf_utils.h
libc/src/__support/math/acospif16.h
libc/src/__support/math/asin.h
libc/src/__support/math/asin_utils.h
libc/src/__support/math/asinf.h
libc/src/__support/math/asinf16.h
libc/src/__support/math/asinhf.h
libc/src/__support/math/asinhf16.h
libc/src/__support/math/atan.h
libc/src/__support/math/atan2f.h
libc/src/__support/math/atan2f128.h
libc/src/__support/math/atan2f_float.h
libc/src/__support/math/atan_utils.h
libc/src/__support/math/atanf.h
libc/src/__support/math/atanf16.h
libc/src/__support/math/atanf_float.h
libc/src/__support/math/atanhf.h
libc/src/__support/math/atanhf16.h
libc/src/__support/math/cbrt.h
libc/src/__support/math/cbrtf.h
libc/src/__support/math/cosf.h
libc/src/__support/math/cosf16.h
libc/src/__support/math/coshf.h
libc/src/__support/math/coshf16.h
libc/src/__support/math/cospif.h
libc/src/__support/math/cospif16.h
libc/src/__support/math/dfmaf128.h
libc/src/__support/math/dfmal.h
libc/src/__support/math/dsqrtl.h
libc/src/__support/math/erff.h
libc/src/__support/math/exp.h
libc/src/__support/math/exp10.h
libc/src/__support/math/exp10_float16_constants.h
libc/src/__support/math/exp10f.h
libc/src/__support/math/exp10f16.h
libc/src/__support/math/exp10f16_utils.h
libc/src/__support/math/exp10f_utils.h
libc/src/__support/math/exp10m1f.h
libc/src/__support/math/exp10m1f16.h
libc/src/__support/math/exp2.h
libc/src/__support/math/exp2f.h
libc/src/__support/math/exp2f16.h
libc/src/__support/math/exp2m1f.h
libc/src/__support/math/exp2m1f16.h
libc/src/__support/math/exp_constants.h
libc/src/__support/math/exp_float_constants.h
libc/src/__support/math/exp_utils.h
libc/src/__support/math/expf.h
libc/src/__support/math/expf16.h
libc/src/__support/math/expf16_utils.h
libc/src/__support/math/expm1.h
libc/src/__support/math/expm1f.h
libc/src/__support/math/expm1f16.h
libc/src/__support/math/expxf16_utils.h
libc/src/__support/math/f16fma.h
libc/src/__support/math/f16fmal.h
libc/src/__support/math/f16sqrt.h
libc/src/__support/math/f16sqrtl.h
libc/src/__support/math/frexpf.h
libc/src/__support/math/frexpf128.h
libc/src/__support/math/frexpf16.h
libc/src/__support/math/fsqrt.h
libc/src/__support/math/fsqrtf128.h
libc/src/__support/math/fsqrtl.h
libc/src/__support/math/hypotf.h
libc/src/__support/math/ilogb.h
libc/src/__support/math/ilogbf128.h
libc/src/__support/math/ilogbl.h
libc/src/__support/math/inv_trigf_utils.h
libc/src/__support/math/ldexpf.h
libc/src/__support/math/ldexpf128.h
libc/src/__support/math/ldexpf16.h
libc/src/__support/math/llogb.h
libc/src/__support/math/llogbf.h
libc/src/__support/math/llogbf128.h
libc/src/__support/math/llogbf16.h
libc/src/__support/math/log.h
libc/src/__support/math/log10.h
libc/src/__support/math/log1p.h
libc/src/__support/math/log2.h
libc/src/__support/math/logbf.h
libc/src/__support/math/logbf128.h
libc/src/__support/math/logbf16.h
libc/src/__support/math/logf.h
libc/src/__support/math/logf16.h
libc/src/__support/math/range_reduction.h
libc/src/__support/math/range_reduction_double_common.h
libc/src/__support/math/range_reduction_double_fma.h
libc/src/__support/math/range_reduction_double_nofma.h
libc/src/__support/math/range_reduction_fma.h
libc/src/__support/math/rsqrtf.h
libc/src/__support/math/rsqrtf16.h
libc/src/__support/math/sincos_eval.h
libc/src/__support/math/sincosf.h
libc/src/__support/math/sincosf16_utils.h
libc/src/__support/math/sincosf_utils.h
libc/src/__support/math/sinf.h
libc/src/__support/math/sinf16.h
libc/src/__support/math/sinhf.h
libc/src/__support/math/sinhf16.h
libc/src/__support/math/sinpif.h
libc/src/__support/math/sqrt.h
libc/src/__support/math/sqrtf.h
libc/src/__support/math/sqrtf16.h
libc/src/__support/math/tan.h
libc/src/__support/math/tanf.h
libc/src/math/generic/sinpif16.cpp
libc/src/math/generic/tanf16.cpp
libc/src/math/generic/tanpif.cpp
libc/src/math/generic/tanpif16.cpp
Removed:
################################################################################
diff --git a/libc/src/__support/math/acos.h b/libc/src/__support/math/acos.h
index 0e1e413870844..6b419449176fd 100644
--- a/libc/src/__support/math/acos.h
+++ b/libc/src/__support/math/acos.h
@@ -24,7 +24,7 @@ namespace LIBC_NAMESPACE_DECL {
namespace math {
-LIBC_INLINE static constexpr double acos(double x) {
+LIBC_INLINE constexpr double acos(double x) {
using DoubleDouble = fputil::DoubleDouble;
using namespace asin_internal;
using FPBits = fputil::FPBits<double>;
diff --git a/libc/src/__support/math/acosf.h b/libc/src/__support/math/acosf.h
index 7a0c0e535a8a1..4cdf8ef704f25 100644
--- a/libc/src/__support/math/acosf.h
+++ b/libc/src/__support/math/acosf.h
@@ -26,26 +26,27 @@ namespace acosf_internal {
#ifndef LIBC_MATH_HAS_SKIP_ACCURATE_PASS
-static constexpr size_t N_EXCEPTS = 4;
+LIBC_INLINE_VAR constexpr size_t N_EXCEPTS = 4;
// Exceptional values when |x| <= 0.5
-static constexpr fputil::ExceptValues<float, N_EXCEPTS> ACOSF_EXCEPTS = {{
- // (inputs, RZ output, RU offset, RD offset, RN offset)
- // x = 0x1.110b46p-26, acosf(x) = 0x1.921fb4p0 (RZ)
- {0x328885a3, 0x3fc90fda, 1, 0, 1},
- // x = -0x1.110b46p-26, acosf(x) = 0x1.921fb4p0 (RZ)
- {0xb28885a3, 0x3fc90fda, 1, 0, 1},
- // x = 0x1.04c444p-12, acosf(x) = 0x1.920f68p0 (RZ)
- {0x39826222, 0x3fc907b4, 1, 0, 1},
- // x = -0x1.04c444p-12, acosf(x) = 0x1.923p0 (RZ)
- {0xb9826222, 0x3fc91800, 1, 0, 1},
-}};
+LIBC_INLINE_VAR constexpr fputil::ExceptValues<float, N_EXCEPTS> ACOSF_EXCEPTS =
+ {{
+ // (inputs, RZ output, RU offset, RD offset, RN offset)
+ // x = 0x1.110b46p-26, acosf(x) = 0x1.921fb4p0 (RZ)
+ {0x328885a3, 0x3fc90fda, 1, 0, 1},
+ // x = -0x1.110b46p-26, acosf(x) = 0x1.921fb4p0 (RZ)
+ {0xb28885a3, 0x3fc90fda, 1, 0, 1},
+ // x = 0x1.04c444p-12, acosf(x) = 0x1.920f68p0 (RZ)
+ {0x39826222, 0x3fc907b4, 1, 0, 1},
+ // x = -0x1.04c444p-12, acosf(x) = 0x1.923p0 (RZ)
+ {0xb9826222, 0x3fc91800, 1, 0, 1},
+ }};
#endif // !LIBC_MATH_HAS_SKIP_ACCURATE_PASS
} // namespace acosf_internal
-LIBC_INLINE static constexpr float acosf(float x) {
+LIBC_INLINE constexpr float acosf(float x) {
using namespace acosf_internal;
using namespace inv_trigf_utils_internal;
using FPBits = typename fputil::FPBits<float>;
diff --git a/libc/src/__support/math/acosf16.h b/libc/src/__support/math/acosf16.h
index 3f0e002a590e0..49cd203919aeb 100644
--- a/libc/src/__support/math/acosf16.h
+++ b/libc/src/__support/math/acosf16.h
@@ -26,7 +26,7 @@ namespace LIBC_NAMESPACE_DECL {
namespace math {
-LIBC_INLINE static constexpr float16 acosf16(float16 x) {
+LIBC_INLINE constexpr float16 acosf16(float16 x) {
// Generated by Sollya using the following command:
// > round(pi/2, SG, RN);
diff --git a/libc/src/__support/math/acosh_float_constants.h b/libc/src/__support/math/acosh_float_constants.h
index 2eb245d8265e0..f27e126099c7c 100644
--- a/libc/src/__support/math/acosh_float_constants.h
+++ b/libc/src/__support/math/acosh_float_constants.h
@@ -9,6 +9,7 @@
#ifndef LLVM_LIBC_SRC___SUPPORT_MATH_ACOSH_FLOAT_CONSTANTS_H
#define LLVM_LIBC_SRC___SUPPORT_MATH_ACOSH_FLOAT_CONSTANTS_H
+#include "src/__support/macros/attributes.h"
#include "src/__support/macros/config.h"
namespace LIBC_NAMESPACE_DECL {
@@ -16,7 +17,7 @@ namespace LIBC_NAMESPACE_DECL {
namespace acoshf_internal {
// Lookup table for (1/f) where f = 1 + n*2^(-7), n = 0..127.
-static constexpr double ONE_OVER_F[128] = {
+LIBC_INLINE_VAR constexpr double ONE_OVER_F[128] = {
0x1.0000000000000p+0, 0x1.fc07f01fc07f0p-1, 0x1.f81f81f81f820p-1,
0x1.f44659e4a4271p-1, 0x1.f07c1f07c1f08p-1, 0x1.ecc07b301ecc0p-1,
0x1.e9131abf0b767p-1, 0x1.e573ac901e574p-1, 0x1.e1e1e1e1e1e1ep-1,
@@ -62,7 +63,7 @@ static constexpr double ONE_OVER_F[128] = {
0x1.0204081020408p-1, 0x1.0101010101010p-1};
// Lookup table for log(f) = log(1 + n*2^(-7)) where n = 0..127.
-static constexpr double LOG_F[128] = {
+LIBC_INLINE_VAR constexpr double LOG_F[128] = {
0x0.0000000000000p+0, 0x1.fe02a6b106788p-8, 0x1.fc0a8b0fc03e3p-7,
0x1.7b91b07d5b11ap-6, 0x1.f829b0e783300p-6, 0x1.39e87b9febd5fp-5,
0x1.77458f632dcfcp-5, 0x1.b42dd711971bep-5, 0x1.f0a30c01162a6p-5,
diff --git a/libc/src/__support/math/acoshf.h b/libc/src/__support/math/acoshf.h
index 4e003110efafb..acc6fde1378de 100644
--- a/libc/src/__support/math/acoshf.h
+++ b/libc/src/__support/math/acoshf.h
@@ -21,7 +21,7 @@ namespace LIBC_NAMESPACE_DECL {
namespace math {
-LIBC_INLINE static constexpr float acoshf(float x) {
+LIBC_INLINE constexpr float acoshf(float x) {
using namespace acoshf_internal;
using FPBits_t = typename fputil::FPBits<float>;
FPBits_t xbits(x);
diff --git a/libc/src/__support/math/acoshf16.h b/libc/src/__support/math/acoshf16.h
index e5be2a8dd915c..eeb9e9f7afa9d 100644
--- a/libc/src/__support/math/acoshf16.h
+++ b/libc/src/__support/math/acoshf16.h
@@ -28,7 +28,7 @@ namespace LIBC_NAMESPACE_DECL {
namespace math {
-LIBC_INLINE static constexpr float16 acoshf16(float16 x) {
+LIBC_INLINE constexpr float16 acoshf16(float16 x) {
using namespace acoshf_internal;
constexpr size_t N_EXCEPTS = 2;
diff --git a/libc/src/__support/math/acoshf_utils.h b/libc/src/__support/math/acoshf_utils.h
index 808c3dd41cfe4..a0002f404a19f 100644
--- a/libc/src/__support/math/acoshf_utils.h
+++ b/libc/src/__support/math/acoshf_utils.h
@@ -19,7 +19,7 @@ namespace LIBC_NAMESPACE_DECL {
namespace acoshf_internal {
// x should be positive, normal finite value
-LIBC_INLINE static double log_eval(double x) {
+LIBC_INLINE double log_eval(double x) {
// For x = 2^ex * (1 + mx)
// log(x) = ex * log(2) + log(1 + mx)
using FPB = fputil::FPBits<double>;
diff --git a/libc/src/__support/math/acospif16.h b/libc/src/__support/math/acospif16.h
index cf29c7654abc2..4b5c28084f709 100644
--- a/libc/src/__support/math/acospif16.h
+++ b/libc/src/__support/math/acospif16.h
@@ -25,7 +25,7 @@ namespace LIBC_NAMESPACE_DECL {
namespace math {
-LIBC_INLINE static constexpr float16 acospif16(float16 x) {
+LIBC_INLINE constexpr float16 acospif16(float16 x) {
using FPBits = fputil::FPBits<float16>;
FPBits xbits(x);
diff --git a/libc/src/__support/math/asin.h b/libc/src/__support/math/asin.h
index 396a5355b9b3b..98e77d0b97454 100644
--- a/libc/src/__support/math/asin.h
+++ b/libc/src/__support/math/asin.h
@@ -25,7 +25,7 @@ namespace LIBC_NAMESPACE_DECL {
namespace math {
-LIBC_INLINE static double asin(double x) {
+LIBC_INLINE double asin(double x) {
using namespace asin_internal;
using FPBits = fputil::FPBits<double>;
diff --git a/libc/src/__support/math/asin_utils.h b/libc/src/__support/math/asin_utils.h
index efe779c8a81fd..2feb1485ec667 100644
--- a/libc/src/__support/math/asin_utils.h
+++ b/libc/src/__support/math/asin_utils.h
@@ -24,10 +24,11 @@ namespace asin_internal {
using DoubleDouble = fputil::DoubleDouble;
using Float128 = fputil::DyadicFloat<128>;
-static constexpr DoubleDouble PI = {0x1.1a62633145c07p-53, 0x1.921fb54442d18p1};
+LIBC_INLINE_VAR constexpr DoubleDouble PI = {0x1.1a62633145c07p-53,
+ 0x1.921fb54442d18p1};
-static constexpr DoubleDouble PI_OVER_TWO = {0x1.1a62633145c07p-54,
- 0x1.921fb54442d18p0};
+LIBC_INLINE_VAR constexpr DoubleDouble PI_OVER_TWO = {0x1.1a62633145c07p-54,
+ 0x1.921fb54442d18p0};
#ifdef LIBC_MATH_HAS_SKIP_ACCURATE_PASS
@@ -38,7 +39,7 @@ static constexpr DoubleDouble PI_OVER_TWO = {0x1.1a62633145c07p-54,
// > dirtyinfnorm(asin(x)/x - P, [0, 0.5]);
// 0x1.1a71ef0a0f26a9fb7ed7e41dee788b13d1770db3dp-52
-static constexpr double ASIN_COEFFS[12] = {
+LIBC_INLINE_VAR constexpr double ASIN_COEFFS[12] = {
0x1.0000000000000p0, 0x1.5555555556dcfp-3, 0x1.3333333082e11p-4,
0x1.6db6dd14099edp-5, 0x1.f1c69b35bf81fp-6, 0x1.6e97194225a67p-6,
0x1.1babddb82ce12p-6, 0x1.d55bd078600d6p-7, 0x1.33328959e63d6p-7,
@@ -123,7 +124,7 @@ LIBC_INLINE double asin_eval(double u) {
// > dirtyinfnorm(asin(x)/x - P, [-1/64, 1/64]);
// 0x1.999075402cafp-83
-static constexpr double ASIN_COEFFS[9][12] = {
+LIBC_INLINE_VAR constexpr double ASIN_COEFFS[9][12] = {
{1.0, 0.0, 0x1.5555555555555p-3, 0x1.5555555555555p-57,
0x1.3333333333333p-4, 0x1.6db6db6db6db7p-5, 0x1.f1c71c71c71c7p-6,
0x1.6e8ba2e8ba2e9p-6, 0x1.1c4ec4ec4ec4fp-6, 0x1.c99999999999ap-7,
@@ -163,8 +164,8 @@ static constexpr double ASIN_COEFFS[9][12] = {
};
// We calculate the lower part of the approximation P(u).
-LIBC_INLINE static DoubleDouble asin_eval(const DoubleDouble &u, unsigned &idx,
- double &err) {
+LIBC_INLINE DoubleDouble asin_eval(const DoubleDouble &u, unsigned &idx,
+ double &err) {
using fputil::multiply_add;
// k = round(u * 32).
double k = fputil::nearest_integer(u.hi * 0x1.0p5);
@@ -238,7 +239,7 @@ LIBC_INLINE static DoubleDouble asin_eval(const DoubleDouble &u, unsigned &idx,
// + (676039 x^24)/104857600 + (1300075 x^26)/226492416 +
// + (5014575 x^28)/973078528 + (9694845 x^30)/2080374784.
-static constexpr Float128 ASIN_COEFFS_F128[17][16] = {
+LIBC_INLINE_VAR constexpr Float128 ASIN_COEFFS_F128[17][16] = {
{
{Sign::POS, -127, 0x80000000'00000000'00000000'00000000_u128},
{Sign::POS, -130, 0xaaaaaaaa'aaaaaaaa'aaaaaaaa'aaaaaaab_u128},
@@ -547,14 +548,13 @@ static constexpr Float128 ASIN_COEFFS_F128[17][16] = {
},
};
-static constexpr Float128 PI_OVER_TWO_F128 = {
+LIBC_INLINE_VAR constexpr Float128 PI_OVER_TWO_F128 = {
Sign::POS, -127, 0xc90fdaa2'2168c234'c4c6628b'80dc1cd1_u128};
-static constexpr Float128 PI_F128 = {
+LIBC_INLINE_VAR constexpr Float128 PI_F128 = {
Sign::POS, -126, 0xc90fdaa2'2168c234'c4c6628b'80dc1cd1_u128};
-LIBC_INLINE static constexpr Float128 asin_eval(const Float128 &u,
- unsigned idx) {
+LIBC_INLINE constexpr Float128 asin_eval(const Float128 &u, unsigned idx) {
return fputil::polyeval(u, ASIN_COEFFS_F128[idx][0], ASIN_COEFFS_F128[idx][1],
ASIN_COEFFS_F128[idx][2], ASIN_COEFFS_F128[idx][3],
ASIN_COEFFS_F128[idx][4], ASIN_COEFFS_F128[idx][5],
diff --git a/libc/src/__support/math/asinf.h b/libc/src/__support/math/asinf.h
index bfa0dc31ecf4c..c00b764a41853 100644
--- a/libc/src/__support/math/asinf.h
+++ b/libc/src/__support/math/asinf.h
@@ -23,7 +23,7 @@ namespace LIBC_NAMESPACE_DECL {
namespace math {
-LIBC_INLINE static constexpr float asinf(float x) {
+LIBC_INLINE constexpr float asinf(float x) {
using namespace inv_trigf_utils_internal;
#ifndef LIBC_MATH_HAS_SKIP_ACCURATE_PASS
diff --git a/libc/src/__support/math/asinf16.h b/libc/src/__support/math/asinf16.h
index 3d032a41a2bb3..e9c9c6fca9184 100644
--- a/libc/src/__support/math/asinf16.h
+++ b/libc/src/__support/math/asinf16.h
@@ -25,7 +25,7 @@ namespace LIBC_NAMESPACE_DECL {
namespace math {
-LIBC_INLINE static constexpr float16 asinf16(float16 x) {
+LIBC_INLINE constexpr float16 asinf16(float16 x) {
// Generated by Sollya using the following command:
// > round(pi/2, D, RN);
diff --git a/libc/src/__support/math/asinhf.h b/libc/src/__support/math/asinhf.h
index 1c08a6e6651b7..b08d30b97b9f1 100644
--- a/libc/src/__support/math/asinhf.h
+++ b/libc/src/__support/math/asinhf.h
@@ -21,7 +21,7 @@ namespace LIBC_NAMESPACE_DECL {
namespace math {
-LIBC_INLINE static constexpr float asinhf(float x) {
+LIBC_INLINE constexpr float asinhf(float x) {
using namespace acoshf_internal;
using FPBits_t = typename fputil::FPBits<float>;
FPBits_t xbits(x);
diff --git a/libc/src/__support/math/asinhf16.h b/libc/src/__support/math/asinhf16.h
index 3c5171e59c11f..39118d9357043 100644
--- a/libc/src/__support/math/asinhf16.h
+++ b/libc/src/__support/math/asinhf16.h
@@ -29,7 +29,7 @@ namespace LIBC_NAMESPACE_DECL {
namespace math {
-LIBC_INLINE static constexpr float16 asinhf16(float16 x) {
+LIBC_INLINE constexpr float16 asinhf16(float16 x) {
#ifndef LIBC_MATH_HAS_SKIP_ACCURATE_PASS
constexpr size_t N_EXCEPTS = 8;
diff --git a/libc/src/__support/math/atan.h b/libc/src/__support/math/atan.h
index 62190b092429a..db60311bd746d 100644
--- a/libc/src/__support/math/atan.h
+++ b/libc/src/__support/math/atan.h
@@ -52,7 +52,7 @@ namespace math {
// So we can return:
// atan(x) = sign(x) * (pi/2 - epsilon)
-LIBC_INLINE static constexpr double atan(double x) {
+LIBC_INLINE constexpr double atan(double x) {
using namespace atan_internal;
using FPBits = fputil::FPBits<double>;
diff --git a/libc/src/__support/math/atan2f.h b/libc/src/__support/math/atan2f.h
index 0133d12c1e071..15d1fce2b707c 100644
--- a/libc/src/__support/math/atan2f.h
+++ b/libc/src/__support/math/atan2f.h
@@ -17,7 +17,7 @@
#include "src/__support/FPUtil/multiply_add.h"
#include "src/__support/FPUtil/nearest_integer.h"
#include "src/__support/macros/config.h"
-#include "src/__support/macros/optimization.h" // LIBC_UNLIKELY
+#include "src/__support/macros/optimization.h" // LIBC_UNLIKELY
#include "src/__support/macros/properties/cpu_features.h" // LIBC_TARGET_CPU_HAS_FMA
#if defined(LIBC_MATH_HAS_SKIP_ACCURATE_PASS) && \
@@ -45,7 +45,7 @@ namespace atan2f_internal {
// b = round(atan(i/16) - a, D, RN);
// print("{", b, ",", a, "},");
// };
-static constexpr fputil::DoubleDouble ATAN_I[17] = {
+LIBC_INLINE_VAR constexpr fputil::DoubleDouble ATAN_I[17] = {
{0.0, 0.0},
{-0x1.c934d86d23f1dp-60, 0x1.ff55bb72cfdeap-5},
{-0x1.cd37686760c17p-59, 0x1.fd5ba9aac2f6ep-4},
@@ -72,7 +72,7 @@ static constexpr fputil::DoubleDouble ATAN_I[17] = {
// b = round(j - a, D, RN);
// print("{", b, ",", a, "},");
// };
-static constexpr fputil::DoubleDouble COEFFS[9] = {
+LIBC_INLINE_VAR constexpr fputil::DoubleDouble COEFFS[9] = {
{0.0, 1.0}, // 1
{-0x1.5555555555555p-56, -0x1.5555555555555p-2}, // -1/3
{-0x1.999999999999ap-57, 0x1.999999999999ap-3}, // 1/5
@@ -98,8 +98,7 @@ static constexpr fputil::DoubleDouble COEFFS[9] = {
// = 33.
// Thus, the Veltkamp splitting constant is C = 2^33 + 1.
// This is used when FMA instruction is not available.
-[[maybe_unused]] LIBC_INLINE static constexpr fputil::DoubleDouble
-split_d(double a) {
+[[maybe_unused]] LIBC_INLINE constexpr fputil::DoubleDouble split_d(double a) {
fputil::DoubleDouble r{0.0, 0.0};
constexpr double C = 0x1.0p33 + 1.0;
double t1 = C * a;
@@ -116,10 +115,9 @@ split_d(double a) {
// idx, k_d = round( 2^4 * num_d / den_d )
// final_sign = sign of the final result
// const_term = the constant term in the final expression.
-LIBC_INLINE static float
-atan2f_double_double(double num_d, double den_d, double q_d, int idx,
- double k_d, double final_sign,
- const fputil::DoubleDouble &const_term) {
+LIBC_INLINE float atan2f_double_double(double num_d, double den_d, double q_d,
+ int idx, double k_d, double final_sign,
+ const fputil::DoubleDouble &const_term) {
fputil::DoubleDouble q;
double num_r = 0, den_r = 0;
@@ -241,7 +239,7 @@ atan2f_double_double(double num_d, double den_d, double q_d, int idx,
// 0x1.aec6f...p-100
// which is about rounding errors of double-double (2^-104).
-LIBC_INLINE static constexpr float atan2f(float y, float x) {
+LIBC_INLINE constexpr float atan2f(float y, float x) {
using namespace atan2f_internal;
using namespace inv_trigf_utils_internal;
using FPBits = typename fputil::FPBits<float>;
diff --git a/libc/src/__support/math/atan2f128.h b/libc/src/__support/math/atan2f128.h
index 89efaf1fd72a0..b2891bdec4c76 100644
--- a/libc/src/__support/math/atan2f128.h
+++ b/libc/src/__support/math/atan2f128.h
@@ -81,7 +81,7 @@ namespace math {
// and relative errors bounded by:
// |(atan(u) - P(u)) / P(u)| < 2^-114.
-LIBC_INLINE static constexpr float128 atan2f128(float128 y, float128 x) {
+LIBC_INLINE constexpr float128 atan2f128(float128 y, float128 x) {
using Float128 = fputil::DyadicFloat<128>;
constexpr Float128 ZERO = {Sign::POS, 0, 0_u128};
diff --git a/libc/src/__support/math/atan2f_float.h b/libc/src/__support/math/atan2f_float.h
index cc5ea77d5dd36..1f44b67749964 100644
--- a/libc/src/__support/math/atan2f_float.h
+++ b/libc/src/__support/math/atan2f_float.h
@@ -30,7 +30,7 @@ using FloatFloat = fputil::FloatFloat;
// b = round(atan(i/16) - a, SG, RN);
// print("{", b, ",", a, "},");
// };
-static constexpr FloatFloat ATAN_I[17] = {
+LIBC_INLINE_VAR constexpr FloatFloat ATAN_I[17] = {
{0.0f, 0.0f},
{-0x1.1a6042p-30f, 0x1.ff55bcp-5f},
{-0x1.54f424p-30f, 0x1.fd5baap-4f},
@@ -60,7 +60,7 @@ static constexpr FloatFloat ATAN_I[17] = {
// For x = x_hi + x_lo, fully expand the polynomial and drop any terms less than
// ulp(x_hi^3 / 3) gives us:
// P(x) ~ x_hi - x_hi^3/3 + x_lo * (1 - x_hi^2)
-LIBC_INLINE static constexpr FloatFloat atan_eval(const FloatFloat &x) {
+LIBC_INLINE constexpr FloatFloat atan_eval(const FloatFloat &x) {
FloatFloat p;
p.hi = x.hi;
float x_hi_sq = x.hi * x.hi;
@@ -124,7 +124,7 @@ LIBC_INLINE static constexpr FloatFloat atan_eval(const FloatFloat &x) {
// > dirtyinfnorm(atan(x) - P, [-2^-5, 2^-5]);
// 0x1.995...p-28.
-LIBC_INLINE static constexpr float atan2f(float y, float x) {
+LIBC_INLINE constexpr float atan2f(float y, float x) {
using namespace atan2f_internal;
using FPBits = typename fputil::FPBits<float>;
constexpr float IS_NEG[2] = {1.0f, -1.0f};
diff --git a/libc/src/__support/math/atan_utils.h b/libc/src/__support/math/atan_utils.h
index 9e8d7d6569c8f..e752af3568373 100644
--- a/libc/src/__support/math/atan_utils.h
+++ b/libc/src/__support/math/atan_utils.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLVM_LIBC_SRC_MATH_GENERIC_ATAN_UTILS_H
-#define LLVM_LIBC_SRC_MATH_GENERIC_ATAN_UTILS_H
+#ifndef LLVM_LIBC_SRC___SUPPORT_MATH_ATAN_UTILS_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_ATAN_UTILS_H
#include "src/__support/FPUtil/PolyEval.h"
#include "src/__support/FPUtil/double_double.h"
@@ -29,7 +29,7 @@ using Float128 = fputil::DyadicFloat<128>;
// b = round(atan(i/64) - a, D, RN);
// print("{", b, ",", a, "},");
// };
-static constexpr DoubleDouble ATAN_I[65] = {
+LIBC_INLINE_VAR constexpr DoubleDouble ATAN_I[65] = {
{0.0, 0.0},
{-0x1.220c39d4dff5p-61, 0x1.fff555bbb729bp-7},
{-0x1.5ec431444912cp-60, 0x1.ffd55bba97625p-6},
@@ -110,8 +110,7 @@ static constexpr DoubleDouble ATAN_I[65] = {
// + x_lo * (1 - x_hi^2 + x_hi^4)
// Since p.lo is ~ x^3/3, the relative error from rounding is bounded by:
// |(atan(x) - P(x))/atan(x)| < ulp(x^2) <= 2^(-14-52) = 2^-66.
-[[maybe_unused]] LIBC_INLINE static DoubleDouble
-atan_eval(const DoubleDouble &x) {
+[[maybe_unused]] LIBC_INLINE DoubleDouble atan_eval(const DoubleDouble &x) {
DoubleDouble p;
p.hi = x.hi;
double x_hi_sq = x.hi * x.hi;
@@ -143,7 +142,7 @@ atan_eval(const DoubleDouble &x) {
// b = 2^ll + a;
// print("{Sign::POS, ", 2^(ll - 128), ",", b, "},");
// };
-static constexpr Float128 ATAN_I_F128[65] = {
+LIBC_INLINE_VAR constexpr Float128 ATAN_I_F128[65] = {
{Sign::POS, 0, 0_u128},
{Sign::POS, -134, 0xfffaaadd'db94d5bb'e78c5640'15f76048_u128},
{Sign::POS, -133, 0xffeaaddd'4bb12542'779d776d'da8c6214_u128},
@@ -216,7 +215,7 @@ static constexpr Float128 ATAN_I_F128[65] = {
// [0, 2^-7]);
// > dirtyinfnorm(atan(x) - P, [0, 2^-7]);
// 0x1.26016ad97f323875760f869684c0898d7b7bb8bep-122
-static constexpr Float128 ATAN_POLY_F128[] = {
+LIBC_INLINE_VAR constexpr Float128 ATAN_POLY_F128[] = {
{Sign::NEG, -129, 0xaaaaaaaa'aaaaaaaa'aaaaaaa6'003c5d1d_u128},
{Sign::POS, -130, 0xcccccccc'cccccccc'cca00232'8776b063_u128},
{Sign::NEG, -130, 0x92492492'49249201'27f5268a'cb24aec0_u128},
@@ -226,8 +225,7 @@ static constexpr Float128 ATAN_POLY_F128[] = {
};
// Approximate atan for |x| <= 2^-7.
-[[maybe_unused]] LIBC_INLINE static constexpr Float128
-atan_eval(const Float128 &x) {
+[[maybe_unused]] LIBC_INLINE constexpr Float128 atan_eval(const Float128 &x) {
Float128 x_sq = fputil::quick_mul(x, x);
Float128 x3 = fputil::quick_mul(x, x_sq);
Float128 p = fputil::polyeval(x_sq, ATAN_POLY_F128[0], ATAN_POLY_F128[1],
@@ -240,4 +238,4 @@ atan_eval(const Float128 &x) {
} // namespace LIBC_NAMESPACE_DECL
-#endif // LLVM_LIBC_SRC_MATH_GENERIC_ATAN_UTILS_H
+#endif // LLVM_LIBC_SRC___SUPPORT_MATH_ATAN_UTILS_H
diff --git a/libc/src/__support/math/atanf.h b/libc/src/__support/math/atanf.h
index a16e386d58106..633a95b02d5ff 100644
--- a/libc/src/__support/math/atanf.h
+++ b/libc/src/__support/math/atanf.h
@@ -30,7 +30,7 @@ namespace LIBC_NAMESPACE_DECL {
namespace math {
-LIBC_INLINE static constexpr float atanf(float x) {
+LIBC_INLINE constexpr float atanf(float x) {
using namespace inv_trigf_utils_internal;
using FPBits = typename fputil::FPBits<float>;
diff --git a/libc/src/__support/math/atanf16.h b/libc/src/__support/math/atanf16.h
index f75d145f36852..01eb8770591eb 100644
--- a/libc/src/__support/math/atanf16.h
+++ b/libc/src/__support/math/atanf16.h
@@ -26,7 +26,7 @@ namespace LIBC_NAMESPACE_DECL {
namespace math {
-LIBC_INLINE static constexpr float16 atanf16(float16 x) {
+LIBC_INLINE constexpr float16 atanf16(float16 x) {
// Generated by Solly using the following command:
// > round(pi/2, SG, RN);
constexpr float PI_2 = 0x1.921fb6p0;
diff --git a/libc/src/__support/math/atanf_float.h b/libc/src/__support/math/atanf_float.h
index 8794cec54f7a5..56db2ad2955e6 100644
--- a/libc/src/__support/math/atanf_float.h
+++ b/libc/src/__support/math/atanf_float.h
@@ -30,7 +30,7 @@ using fputil::FloatFloat;
// b = round(atan(i/16) - a, SG, RN);
// print("{", b, ",", a, "},");
// };
-static constexpr FloatFloat ATAN_I[17] = {
+LIBC_INLINE_VAR constexpr FloatFloat ATAN_I[17] = {
{0.0f, 0.0f},
{-0x1.1a6042p-30f, 0x1.ff55bcp-5f},
{-0x1.54f424p-30f, 0x1.fd5baap-4f},
@@ -55,7 +55,7 @@ static constexpr FloatFloat ATAN_I[17] = {
// a = round(1 / (1 + (i/16)^2), SG, RN);
// print(a, ",");
// };
-static constexpr float ATANF_REDUCED_ARG[17] = {
+LIBC_INLINE_VAR constexpr float ATANF_REDUCED_ARG[17] = {
0x1.0p0f, 0x1.fe01fep-1f, 0x1.f81f82p-1f, 0x1.ee9c8p-1f,
0x1.e1e1e2p-1f, 0x1.d272cap-1f, 0x1.c0e07p-1f, 0x1.adbe88p-1f,
0x1.99999ap-1f, 0x1.84f00cp-1f, 0x1.702e06p-1f, 0x1.5babccp-1f,
@@ -66,7 +66,7 @@ static constexpr float ATANF_REDUCED_ARG[17] = {
// Approximating atan( u / (1 + u * k/16) )
// atan( u / (1 + u * k/16) ) / u ~ 1 - k/16 * u + (k^2/256 - 1/3) * u^2 +
// + (k/16 - (k/16)^3) * u^3 + O(u^4)
-LIBC_INLINE static float atanf_eval(float u, float k_over_16) {
+LIBC_INLINE float atanf_eval(float u, float k_over_16) {
// (k/16)^2
float c2 = k_over_16 * k_over_16;
// -(k/16)^3
@@ -85,7 +85,7 @@ LIBC_INLINE static float atanf_eval(float u, float k_over_16) {
// There are several range reduction steps we can take for atan2(y, x) as
// follow:
-LIBC_INLINE static float atanf(float x) {
+LIBC_INLINE float atanf(float x) {
using namespace atanf_internal;
using FPBits = typename fputil::FPBits<float>;
using FPBits = typename fputil::FPBits<float>;
diff --git a/libc/src/__support/math/atanhf.h b/libc/src/__support/math/atanhf.h
index b3ee5bbb4d408..607bc51e73709 100644
--- a/libc/src/__support/math/atanhf.h
+++ b/libc/src/__support/math/atanhf.h
@@ -19,7 +19,7 @@ namespace LIBC_NAMESPACE_DECL {
namespace math {
-LIBC_INLINE static constexpr float atanhf(float x) {
+LIBC_INLINE constexpr float atanhf(float x) {
using namespace acoshf_internal;
using FPBits = typename fputil::FPBits<float>;
diff --git a/libc/src/__support/math/atanhf16.h b/libc/src/__support/math/atanhf16.h
index 80929dd30fa34..0787e126b2691 100644
--- a/libc/src/__support/math/atanhf16.h
+++ b/libc/src/__support/math/atanhf16.h
@@ -33,7 +33,7 @@ namespace atanhf16_internal {
// Generated by Sollya with the following commands:
// display = hexadecimal;
// for n from 0 to 127 do { print(single(1 / (1 + n / 128.0))); };
-static constexpr float ONE_OVER_F_FLOAT[128] = {
+LIBC_INLINE_VAR constexpr float ONE_OVER_F_FLOAT[128] = {
0x1p0f, 0x1.fc07fp-1f, 0x1.f81f82p-1f, 0x1.f4465ap-1f,
0x1.f07c2p-1f, 0x1.ecc07cp-1f, 0x1.e9131ap-1f, 0x1.e573acp-1f,
0x1.e1e1e2p-1f, 0x1.de5d6ep-1f, 0x1.dae608p-1f, 0x1.d77b66p-1f,
@@ -72,7 +72,7 @@ static constexpr float ONE_OVER_F_FLOAT[128] = {
// Generated by Sollya with the following commands:
// display = hexadecimal;
// for n from 0 to 127 do { print(single(log(1 + n / 128.0))); };
-static constexpr float LOG_F_FLOAT[128] = {
+LIBC_INLINE_VAR constexpr float LOG_F_FLOAT[128] = {
0.0f, 0x1.fe02a6p-8f, 0x1.fc0a8cp-7f, 0x1.7b91bp-6f,
0x1.f829bp-6f, 0x1.39e87cp-5f, 0x1.77459p-5f, 0x1.b42dd8p-5f,
0x1.f0a30cp-5f, 0x1.16536ep-4f, 0x1.341d7ap-4f, 0x1.51b074p-4f,
@@ -109,7 +109,7 @@ static constexpr float LOG_F_FLOAT[128] = {
// x should be positive, normal finite value
// TODO: Simplify range reduction and polynomial degree for float16.
// See issue #137190.
-LIBC_INLINE static float log_eval_f(float x) {
+LIBC_INLINE float log_eval_f(float x) {
// For x = 2^ex * (1 + mx), logf(x) = ex * logf(2) + logf(1 + mx).
using FPBits = fputil::FPBits<float>;
FPBits xbits(x);
@@ -151,7 +151,7 @@ LIBC_INLINE static float log_eval_f(float x) {
} // namespace atanhf16_internal
-LIBC_INLINE static constexpr float16 atanhf16(float16 x) {
+LIBC_INLINE constexpr float16 atanhf16(float16 x) {
constexpr size_t N_EXCEPTS = 1;
constexpr fputil::ExceptValues<float16, N_EXCEPTS> ATANHF16_EXCEPTS{{
// (input, RZ output, RU offset, RD offset, RN offset)
diff --git a/libc/src/__support/math/cbrt.h b/libc/src/__support/math/cbrt.h
index 38df9fbfd6579..a781ed36238b8 100644
--- a/libc/src/__support/math/cbrt.h
+++ b/libc/src/__support/math/cbrt.h
@@ -35,7 +35,7 @@ using namespace fputil;
// > P = fpminimax(x^(-2/3), 7, [|D...|], [1, 2]);
// > dirtyinfnorm(P/x^(-2/3) - 1, [1, 2]);
// 0x1.28...p-21
-LIBC_INLINE static double initial_approximation(double x) {
+LIBC_INLINE double initial_approximation(double x) {
constexpr double COEFFS[8] = {
0x1.bc52aedead5c6p1, -0x1.b52bfebf110b3p2, 0x1.1d8d71d53d126p3,
-0x1.de2db9e81cf87p2, 0x1.0154ca06153bdp2, -0x1.5973c66ee6da7p0,
@@ -59,14 +59,14 @@ LIBC_INLINE static double initial_approximation(double x) {
// Get the error term for Newton iteration:
// h(x) = x^3 * a^2 - 1,
#ifdef LIBC_TARGET_CPU_HAS_FMA_DOUBLE
-LIBC_INLINE static double get_error(const DoubleDouble &x_3,
- const DoubleDouble &a_sq) {
+LIBC_INLINE double get_error(const DoubleDouble &x_3,
+ const DoubleDouble &a_sq) {
return fputil::multiply_add(x_3.hi, a_sq.hi, -1.0) +
fputil::multiply_add(x_3.lo, a_sq.hi, x_3.hi * a_sq.lo);
}
#else
-LIBC_INLINE static constexpr double get_error(const DoubleDouble &x_3,
- const DoubleDouble &a_sq) {
+LIBC_INLINE constexpr double get_error(const DoubleDouble &x_3,
+ const DoubleDouble &a_sq) {
DoubleDouble x_3_a_sq = fputil::quick_mult(a_sq, x_3);
return (x_3_a_sq.hi - 1.0) + x_3_a_sq.lo;
}
@@ -144,7 +144,7 @@ LIBC_INLINE static constexpr double get_error(const DoubleDouble &x_3,
// exceptional handling, similar to what was done in the CORE-MATH project:
// https://gitlab.inria.fr/core-math/core-math/-/blob/master/src/binary64/cbrt/cbrt.c
-LIBC_INLINE static constexpr double cbrt(double x) {
+LIBC_INLINE constexpr double cbrt(double x) {
using DoubleDouble = fputil::DoubleDouble;
using namespace cbrt_internal;
using FPBits = fputil::FPBits<double>;
diff --git a/libc/src/__support/math/cbrtf.h b/libc/src/__support/math/cbrtf.h
index d7ff1cd61af1d..35e60562a39c0 100644
--- a/libc/src/__support/math/cbrtf.h
+++ b/libc/src/__support/math/cbrtf.h
@@ -19,7 +19,7 @@ namespace LIBC_NAMESPACE_DECL {
namespace math {
-LIBC_INLINE static constexpr float cbrtf(float x) {
+LIBC_INLINE constexpr float cbrtf(float x) {
// Look up table for 2^(i/3) for i = 0, 1, 2.
constexpr double CBRT2[3] = {1.0, 0x1.428a2f98d728bp0, 0x1.965fea53d6e3dp0};
diff --git a/libc/src/__support/math/cosf.h b/libc/src/__support/math/cosf.h
index e635d30819719..4893a436e331e 100644
--- a/libc/src/__support/math/cosf.h
+++ b/libc/src/__support/math/cosf.h
@@ -26,7 +26,7 @@
namespace LIBC_NAMESPACE_DECL {
namespace math {
-LIBC_INLINE static constexpr float cosf(float x) {
+LIBC_INLINE constexpr float cosf(float x) {
return sincosf_float_eval::sincosf_eval</*IS_SIN*/ false>(x);
}
@@ -41,7 +41,8 @@ namespace LIBC_NAMESPACE_DECL {
namespace math {
-LIBC_INLINE static constexpr float cosf(float x) {
+LIBC_INLINE constexpr float cosf(float x) {
+ using namespace sincosf_utils_internal;
#ifndef LIBC_MATH_HAS_SKIP_ACCURATE_PASS
// Exceptional cases for cosf.
diff --git a/libc/src/__support/math/cosf16.h b/libc/src/__support/math/cosf16.h
index 50c9a8f765c2a..f7485a074ac63 100644
--- a/libc/src/__support/math/cosf16.h
+++ b/libc/src/__support/math/cosf16.h
@@ -25,7 +25,7 @@ namespace LIBC_NAMESPACE_DECL {
namespace math {
-LIBC_INLINE static constexpr float16 cosf16(float16 x) {
+LIBC_INLINE constexpr float16 cosf16(float16 x) {
#ifndef LIBC_MATH_HAS_SKIP_ACCURATE_PASS
constexpr size_t N_EXCEPTS = 4;
diff --git a/libc/src/__support/math/coshf.h b/libc/src/__support/math/coshf.h
index 0f233b87c5e2c..aa0988f9711f1 100644
--- a/libc/src/__support/math/coshf.h
+++ b/libc/src/__support/math/coshf.h
@@ -20,7 +20,7 @@ namespace LIBC_NAMESPACE_DECL {
namespace math {
-LIBC_INLINE static constexpr float coshf(float x) {
+LIBC_INLINE constexpr float coshf(float x) {
using namespace sinhfcoshf_internal;
using FPBits = typename fputil::FPBits<float>;
diff --git a/libc/src/__support/math/coshf16.h b/libc/src/__support/math/coshf16.h
index 4c96a78fa5254..dc39944d89f85 100644
--- a/libc/src/__support/math/coshf16.h
+++ b/libc/src/__support/math/coshf16.h
@@ -25,7 +25,7 @@ namespace LIBC_NAMESPACE_DECL {
namespace math {
-LIBC_INLINE static constexpr float16 coshf16(float16 x) {
+LIBC_INLINE constexpr float16 coshf16(float16 x) {
#ifndef LIBC_MATH_HAS_SKIP_ACCURATE_PASS
constexpr fputil::ExceptValues<float16, 9> COSHF16_EXCEPTS_POS = {{
diff --git a/libc/src/__support/math/cospif.h b/libc/src/__support/math/cospif.h
index e921090459769..08c9f9e7b14b9 100644
--- a/libc/src/__support/math/cospif.h
+++ b/libc/src/__support/math/cospif.h
@@ -22,7 +22,8 @@ namespace LIBC_NAMESPACE_DECL {
namespace math {
-LIBC_INLINE static constexpr float cospif(float x) {
+LIBC_INLINE constexpr float cospif(float x) {
+ using namespace sincosf_utils_internal;
using FPBits = typename fputil::FPBits<float>;
FPBits xbits(x);
diff --git a/libc/src/__support/math/cospif16.h b/libc/src/__support/math/cospif16.h
index d07236cccac75..c763c27db102c 100644
--- a/libc/src/__support/math/cospif16.h
+++ b/libc/src/__support/math/cospif16.h
@@ -24,7 +24,7 @@ namespace LIBC_NAMESPACE_DECL {
namespace math {
-LIBC_INLINE static constexpr float16 cospif16(float16 x) {
+LIBC_INLINE constexpr float16 cospif16(float16 x) {
using namespace sincosf16_internal;
using FPBits = typename fputil::FPBits<float16>;
diff --git a/libc/src/__support/math/dfmaf128.h b/libc/src/__support/math/dfmaf128.h
index 0a266d4aacb98..54c8761af85f8 100644
--- a/libc/src/__support/math/dfmaf128.h
+++ b/libc/src/__support/math/dfmaf128.h
@@ -20,7 +20,7 @@
namespace LIBC_NAMESPACE_DECL {
namespace math {
-LIBC_INLINE static double dfmaf128(float128 x, float128 y, float128 z) {
+LIBC_INLINE double dfmaf128(float128 x, float128 y, float128 z) {
return fputil::fma<double>(x, y, z);
}
diff --git a/libc/src/__support/math/dfmal.h b/libc/src/__support/math/dfmal.h
index ffe94bc4abcc6..0331d59a2c962 100644
--- a/libc/src/__support/math/dfmal.h
+++ b/libc/src/__support/math/dfmal.h
@@ -16,7 +16,7 @@
namespace LIBC_NAMESPACE_DECL {
namespace math {
-LIBC_INLINE static double dfmal(long double x, long double y, long double z) {
+LIBC_INLINE double dfmal(long double x, long double y, long double z) {
return fputil::fma<double>(x, y, z);
}
diff --git a/libc/src/__support/math/dsqrtl.h b/libc/src/__support/math/dsqrtl.h
index e66b6502d27c4..14decf8c6ed77 100644
--- a/libc/src/__support/math/dsqrtl.h
+++ b/libc/src/__support/math/dsqrtl.h
@@ -15,7 +15,7 @@ namespace LIBC_NAMESPACE_DECL {
namespace math {
-LIBC_INLINE static constexpr double dsqrtl(long double x) {
+LIBC_INLINE constexpr double dsqrtl(long double x) {
return fputil::sqrt<double>(x);
}
diff --git a/libc/src/__support/math/erff.h b/libc/src/__support/math/erff.h
index b81be30f7b8f9..a40b927c60a26 100644
--- a/libc/src/__support/math/erff.h
+++ b/libc/src/__support/math/erff.h
@@ -19,7 +19,7 @@ namespace LIBC_NAMESPACE_DECL {
namespace math {
-LIBC_INLINE static constexpr float erff(float x) {
+LIBC_INLINE constexpr float erff(float x) {
// Polynomials approximating erf(x)/x on ( k/8, (k + 1)/8 ) generated by
// Sollya with: > P = fpminimax(erf(x)/x, [|0, 2, 4, 6, 8, 10, 12, 14|],
diff --git a/libc/src/__support/math/exp.h b/libc/src/__support/math/exp.h
index 83638e85c400a..8444a59bdf999 100644
--- a/libc/src/__support/math/exp.h
+++ b/libc/src/__support/math/exp.h
@@ -29,6 +29,10 @@
namespace LIBC_NAMESPACE_DECL {
+namespace math {
+
+namespace exp_internal {
+
using fputil::DoubleDouble;
using fputil::TripleDouble;
using Float128 = typename fputil::DyadicFloat<128>;
@@ -36,15 +40,15 @@ using Float128 = typename fputil::DyadicFloat<128>;
using LIBC_NAMESPACE::operator""_u128;
// log2(e)
-static constexpr double LOG2_E = 0x1.71547652b82fep+0;
+LIBC_INLINE_VAR constexpr double LOG2_E = 0x1.71547652b82fep+0;
// Error bounds:
// Errors when using double precision.
-static constexpr double EXP_ERR_D = 0x1.8p-63;
+LIBC_INLINE_VAR constexpr double EXP_ERR_D = 0x1.8p-63;
#ifndef LIBC_MATH_HAS_SKIP_ACCURATE_PASS
// Errors when using double-double precision.
-static constexpr double EXP_ERR_DD = 0x1.0p-99;
+LIBC_INLINE_VAR constexpr double EXP_ERR_DD = 0x1.0p-99;
#endif // LIBC_MATH_HAS_SKIP_ACCURATE_PASS
// -2^-12 * log(2)
@@ -53,21 +57,19 @@ static constexpr double EXP_ERR_DD = 0x1.0p-99;
// > c = round(a - b, 30, RN);
// > d = round(a - b - c, D, RN);
// Errors < 1.5 * 2^-133
-static constexpr double MLOG_2_EXP2_M12_HI = -0x1.62e42ffp-13;
-static constexpr double MLOG_2_EXP2_M12_MID = 0x1.718432a1b0e26p-47;
+LIBC_INLINE_VAR constexpr double MLOG_2_EXP2_M12_HI = -0x1.62e42ffp-13;
+LIBC_INLINE_VAR constexpr double MLOG_2_EXP2_M12_MID = 0x1.718432a1b0e26p-47;
#ifndef LIBC_MATH_HAS_SKIP_ACCURATE_PASS
-static constexpr double MLOG_2_EXP2_M12_MID_30 = 0x1.718432ap-47;
-static constexpr double MLOG_2_EXP2_M12_LO = 0x1.b0e2633fe0685p-79;
+LIBC_INLINE_VAR constexpr double MLOG_2_EXP2_M12_MID_30 = 0x1.718432ap-47;
+LIBC_INLINE_VAR constexpr double MLOG_2_EXP2_M12_LO = 0x1.b0e2633fe0685p-79;
#endif // LIBC_MATH_HAS_SKIP_ACCURATE_PASS
-namespace {
-
// Polynomial approximations with double precision:
// Return expm1(dx) / x ~ 1 + dx / 2 + dx^2 / 6 + dx^3 / 24.
// For |dx| < 2^-13 + 2^-30:
// | output - expm1(dx) / dx | < 2^-51.
-LIBC_INLINE static double poly_approx_d(double dx) {
+LIBC_INLINE double poly_approx_d(double dx) {
// dx^2
double dx2 = dx * dx;
// c0 = 1 + dx / 2
@@ -85,7 +87,7 @@ LIBC_INLINE static double poly_approx_d(double dx) {
// Return exp(dx) ~ 1 + dx + dx^2 / 2 + ... + dx^6 / 720
// For |dx| < 2^-13 + 2^-30:
// | output - exp(dx) | < 2^-101
-LIBC_INLINE static DoubleDouble poly_approx_dd(const DoubleDouble &dx) {
+LIBC_INLINE DoubleDouble poly_approx_dd(const DoubleDouble &dx) {
// Taylor polynomial.
constexpr DoubleDouble COEFFS[] = {
{0, 0x1p0}, // 1
@@ -106,7 +108,7 @@ LIBC_INLINE static DoubleDouble poly_approx_dd(const DoubleDouble &dx) {
// Return exp(dx) ~ 1 + dx + dx^2 / 2 + ... + dx^7 / 5040
// For |dx| < 2^-13 + 2^-30:
// | output - exp(dx) | < 2^-126.
-LIBC_INLINE static Float128 poly_approx_f128(const Float128 &dx) {
+LIBC_INLINE Float128 poly_approx_f128(const Float128 &dx) {
constexpr Float128 COEFFS_128[]{
{Sign::POS, -127, 0x80000000'00000000'00000000'00000000_u128}, // 1.0
{Sign::POS, -127, 0x80000000'00000000'00000000'00000000_u128}, // 1.0
@@ -127,7 +129,7 @@ LIBC_INLINE static Float128 poly_approx_f128(const Float128 &dx) {
// Compute exp(x) using 128-bit precision.
// TODO(lntue): investigate triple-double precision implementation for this
// step.
-LIBC_INLINE static Float128 exp_f128(double x, double kd, int idx1, int idx2) {
+LIBC_INLINE Float128 exp_f128(double x, double kd, int idx1, int idx2) {
// Recalculate dx:
double t1 = fputil::multiply_add(kd, MLOG_2_EXP2_M12_HI, x); // exact
@@ -160,8 +162,8 @@ LIBC_INLINE static Float128 exp_f128(double x, double kd, int idx1, int idx2) {
}
// Compute exp(x) with double-double precision.
-LIBC_INLINE static DoubleDouble exp_double_double(double x, double kd,
- const DoubleDouble &exp_mid) {
+LIBC_INLINE DoubleDouble exp_double_double(double x, double kd,
+ const DoubleDouble &exp_mid) {
// Recalculate dx:
// dx = x - k * 2^-12 * log(2)
double t1 = fputil::multiply_add(kd, MLOG_2_EXP2_M12_HI, x); // exact
@@ -184,7 +186,7 @@ LIBC_INLINE static DoubleDouble exp_double_double(double x, double kd,
// Check for exceptional cases when
// |x| <= 2^-53 or x < log(2^-1075) or x >= 0x1.6232bdd7abcd3p+9
-LIBC_INLINE static double set_exceptional(double x) {
+LIBC_INLINE double set_exceptional(double x) {
using FPBits = typename fputil::FPBits<double>;
FPBits xbits(x);
@@ -230,11 +232,10 @@ LIBC_INLINE static double set_exceptional(double x) {
return x + FPBits::inf().get_val();
}
-} // namespace
-
-namespace math {
+} // namespace exp_internal
-LIBC_INLINE static double exp(double x) {
+LIBC_INLINE double exp(double x) {
+ using namespace exp_internal;
using FPBits = typename fputil::FPBits<double>;
FPBits xbits(x);
diff --git a/libc/src/__support/math/exp10.h b/libc/src/__support/math/exp10.h
index 12a09d7492457..4a761b01ae13e 100644
--- a/libc/src/__support/math/exp10.h
+++ b/libc/src/__support/math/exp10.h
@@ -36,7 +36,7 @@ using Float128 = typename fputil::DyadicFloat<128>;
using LIBC_NAMESPACE::operator""_u128;
// log2(10)
-static constexpr double LOG2_10 = 0x1.a934f0979a371p+1;
+LIBC_INLINE_VAR constexpr double LOG2_10 = 0x1.a934f0979a371p+1;
// -2^-12 * log10(2)
// > a = -2^-12 * log10(2);
@@ -44,21 +44,21 @@ static constexpr double LOG2_10 = 0x1.a934f0979a371p+1;
// > c = round(a - b, 32, RN);
// > d = round(a - b - c, D, RN);
// Errors < 1.5 * 2^-144
-static constexpr double MLOG10_2_EXP2_M12_HI = -0x1.3441350ap-14;
-static constexpr double MLOG10_2_EXP2_M12_MID = 0x1.0c0219dc1da99p-51;
+LIBC_INLINE_VAR constexpr double MLOG10_2_EXP2_M12_HI = -0x1.3441350ap-14;
+LIBC_INLINE_VAR constexpr double MLOG10_2_EXP2_M12_MID = 0x1.0c0219dc1da99p-51;
#ifndef LIBC_MATH_HAS_SKIP_ACCURATE_PASS
-static constexpr double MLOG10_2_EXP2_M12_MID_32 = 0x1.0c0219dcp-51;
-static constexpr double MLOG10_2_EXP2_M12_LO = 0x1.da994fd20dba2p-87;
+LIBC_INLINE_VAR constexpr double MLOG10_2_EXP2_M12_MID_32 = 0x1.0c0219dcp-51;
+LIBC_INLINE_VAR constexpr double MLOG10_2_EXP2_M12_LO = 0x1.da994fd20dba2p-87;
#endif // LIBC_MATH_HAS_SKIP_ACCURATE_PASS
// Error bounds:
// Errors when using double precision.
-constexpr double EXP10_ERR_D = 0x1.8p-63;
+LIBC_INLINE_VAR constexpr double EXP10_ERR_D = 0x1.8p-63;
#ifndef LIBC_MATH_HAS_SKIP_ACCURATE_PASS
// Errors when using double-double precision.
-static constexpr double EXP10_ERR_DD = 0x1.8p-99;
+LIBC_INLINE_VAR constexpr double EXP10_ERR_DD = 0x1.8p-99;
#endif // LIBC_MATH_HAS_SKIP_ACCURATE_PASS
// Polynomial approximations with double precision. Generated by Sollya with:
@@ -66,7 +66,7 @@ static constexpr double EXP10_ERR_DD = 0x1.8p-99;
// > P;
// Error bounds:
// | output - (10^dx - 1) / dx | < 2^-52.
-LIBC_INLINE static double exp10_poly_approx_d(double dx) {
+LIBC_INLINE double exp10_poly_approx_d(double dx) {
// dx^2
double dx2 = dx * dx;
double c0 =
@@ -83,7 +83,7 @@ LIBC_INLINE static double exp10_poly_approx_d(double dx) {
// > P = fpminimax((10^x - 1)/x, 5, [|DD...|], [-2^-14, 2^-14]);
// Error bounds:
// | output - 10^(dx) | < 2^-101
-LIBC_INLINE static constexpr DoubleDouble
+LIBC_INLINE constexpr DoubleDouble
exp10_poly_approx_dd(const DoubleDouble &dx) {
// Taylor polynomial.
constexpr DoubleDouble COEFFS[] = {
@@ -106,8 +106,7 @@ exp10_poly_approx_dd(const DoubleDouble &dx) {
// Return exp(dx) ~ 1 + a0 * dx + a1 * dx^2 + ... + a6 * dx^7
// For |dx| < 2^-14:
// | output - 10^dx | < 1.5 * 2^-124.
-LIBC_INLINE static constexpr Float128
-exp10_poly_approx_f128(const Float128 &dx) {
+LIBC_INLINE constexpr Float128 exp10_poly_approx_f128(const Float128 &dx) {
constexpr Float128 COEFFS_128[]{
{Sign::POS, -127, 0x80000000'00000000'00000000'00000000_u128}, // 1.0
{Sign::POS, -126, 0x935d8ddd'aaa8ac16'ea56d62b'82d30a2d_u128},
@@ -128,8 +127,7 @@ exp10_poly_approx_f128(const Float128 &dx) {
// Compute 10^(x) using 128-bit precision.
// TODO(lntue): investigate triple-double precision implementation for this
// step.
-LIBC_INLINE static Float128 exp10_f128(double x, double kd, int idx1,
- int idx2) {
+LIBC_INLINE Float128 exp10_f128(double x, double kd, int idx1, int idx2) {
double t1 = fputil::multiply_add(kd, MLOG10_2_EXP2_M12_HI, x); // exact
double t2 = kd * MLOG10_2_EXP2_M12_MID_32; // exact
double t3 = kd * MLOG10_2_EXP2_M12_LO; // Error < 2^-144
@@ -160,8 +158,8 @@ LIBC_INLINE static Float128 exp10_f128(double x, double kd, int idx1,
}
// Compute 10^x with double-double precision.
-LIBC_INLINE static DoubleDouble
-exp10_double_double(double x, double kd, const DoubleDouble &exp_mid) {
+LIBC_INLINE DoubleDouble exp10_double_double(double x, double kd,
+ const DoubleDouble &exp_mid) {
// Recalculate dx:
// dx = x - k * 2^-12 * log10(2)
double t1 = fputil::multiply_add(kd, MLOG10_2_EXP2_M12_HI, x); // exact
@@ -183,7 +181,7 @@ exp10_double_double(double x, double kd, const DoubleDouble &exp_mid) {
#endif // LIBC_MATH_HAS_SKIP_ACCURATE_PASS
// When output is denormal.
-LIBC_INLINE static double exp10_denorm(double x) {
+LIBC_INLINE double exp10_denorm(double x) {
// Range reduction.
double tmp = fputil::multiply_add(x, LOG2_10, 0x1.8000'0000'4p21);
int k = static_cast<int>(cpp::bit_cast<uint64_t>(tmp) >> 19);
@@ -237,7 +235,7 @@ LIBC_INLINE static double exp10_denorm(double x) {
// * x >= log10(2^1024)
// * x <= log10(2^-1022)
// * x is inf or nan
-LIBC_INLINE static constexpr double exp10_set_exceptional(double x) {
+LIBC_INLINE constexpr double exp10_set_exceptional(double x) {
using FPBits = typename fputil::FPBits<double>;
FPBits xbits(x);
@@ -288,7 +286,7 @@ LIBC_INLINE static constexpr double exp10_set_exceptional(double x) {
namespace math {
-LIBC_INLINE static constexpr double exp10(double x) {
+LIBC_INLINE constexpr double exp10(double x) {
using FPBits = typename fputil::FPBits<double>;
FPBits xbits(x);
diff --git a/libc/src/__support/math/exp10_float16_constants.h b/libc/src/__support/math/exp10_float16_constants.h
index ef501857e25e5..cf8bb7f25b41c 100644
--- a/libc/src/__support/math/exp10_float16_constants.h
+++ b/libc/src/__support/math/exp10_float16_constants.h
@@ -21,7 +21,7 @@ namespace LIBC_NAMESPACE_DECL {
// Generated by Sollya with the following commands:
// > display = hexadecimal;
// > for i from 0 to 7 do printsingle(round(2^(i * 2^-3), SG, RN));
-static constexpr cpp::array<uint32_t, 8> EXP2_MID_BITS = {
+LIBC_INLINE_VAR constexpr cpp::array<uint32_t, 8> EXP2_MID_BITS = {
0x3f80'0000U, 0x3f8b'95c2U, 0x3f98'37f0U, 0x3fa5'fed7U,
0x3fb5'04f3U, 0x3fc5'672aU, 0x3fd7'44fdU, 0x3fea'c0c7U,
};
@@ -29,12 +29,12 @@ static constexpr cpp::array<uint32_t, 8> EXP2_MID_BITS = {
// Generated by Sollya with the following commands:
// > display = hexadecimal;
// > round(log2(10), SG, RN);
-static constexpr float LOG2F_10 = 0x1.a934fp+1f;
+LIBC_INLINE_VAR constexpr float LOG2F_10 = 0x1.a934fp+1f;
// Generated by Sollya with the following commands:
// > display = hexadecimal;
// > round(log10(2), SG, RN);
-static constexpr float LOG10F_2 = 0x1.344136p-2f;
+LIBC_INLINE_VAR constexpr float LOG10F_2 = 0x1.344136p-2f;
} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/__support/math/exp10f.h b/libc/src/__support/math/exp10f.h
index 76ae197d7fd24..31d3492d56a5e 100644
--- a/libc/src/__support/math/exp10f.h
+++ b/libc/src/__support/math/exp10f.h
@@ -20,7 +20,7 @@
namespace LIBC_NAMESPACE_DECL {
namespace math {
-LIBC_INLINE static constexpr float exp10f(float x) {
+LIBC_INLINE constexpr float exp10f(float x) {
using FPBits = typename fputil::FPBits<float>;
FPBits xbits(x);
diff --git a/libc/src/__support/math/exp10f16.h b/libc/src/__support/math/exp10f16.h
index 3eca867376bf9..935a301544edf 100644
--- a/libc/src/__support/math/exp10f16.h
+++ b/libc/src/__support/math/exp10f16.h
@@ -29,12 +29,12 @@ namespace math {
#ifndef LIBC_MATH_HAS_SKIP_ACCURATE_PASS
#ifdef LIBC_TARGET_CPU_HAS_FMA_FLOAT
-static constexpr size_t N_EXP10F16_EXCEPTS = 5;
+LIBC_INLINE_VAR constexpr size_t N_EXP10F16_EXCEPTS = 5;
#else
-static constexpr size_t N_EXP10F16_EXCEPTS = 8;
+LIBC_INLINE_VAR constexpr size_t N_EXP10F16_EXCEPTS = 8;
#endif
-static constexpr fputil::ExceptValues<float16, N_EXP10F16_EXCEPTS>
+LIBC_INLINE_VAR constexpr fputil::ExceptValues<float16, N_EXP10F16_EXCEPTS>
EXP10F16_EXCEPTS = {{
// x = 0x1.8f4p-2, exp10f16(x) = 0x1.3ap+1 (RZ)
{0x363dU, 0x40e8U, 1U, 0U, 1U},
@@ -57,7 +57,7 @@ static constexpr fputil::ExceptValues<float16, N_EXP10F16_EXCEPTS>
}};
#endif // !LIBC_MATH_HAS_SKIP_ACCURATE_PASS
-LIBC_INLINE static constexpr float16 exp10f16(float16 x) {
+LIBC_INLINE constexpr float16 exp10f16(float16 x) {
using FPBits = fputil::FPBits<float16>;
FPBits x_bits(x);
diff --git a/libc/src/__support/math/exp10f16_utils.h b/libc/src/__support/math/exp10f16_utils.h
index 5952a4160511d..a0fca6399a78f 100644
--- a/libc/src/__support/math/exp10f16_utils.h
+++ b/libc/src/__support/math/exp10f16_utils.h
@@ -19,7 +19,7 @@
namespace LIBC_NAMESPACE_DECL {
-LIBC_INLINE static ExpRangeReduction exp10_range_reduction(float16 x) {
+LIBC_INLINE ExpRangeReduction exp10_range_reduction(float16 x) {
// For -8 < x < 5, to compute 10^x, we perform the following range reduction:
// find hi, mid, lo, such that:
// x = (hi + mid) * log2(10) + lo, in which
diff --git a/libc/src/__support/math/exp10f_utils.h b/libc/src/__support/math/exp10f_utils.h
index 010a2f1445be5..6134f3e6a8ab1 100644
--- a/libc/src/__support/math/exp10f_utils.h
+++ b/libc/src/__support/math/exp10f_utils.h
@@ -132,7 +132,7 @@ struct exp_b_reduc_t {
// Return:
// { 2^(hi + mid), lo }
template <class Base>
-LIBC_INLINE static constexpr exp_b_reduc_t exp_b_range_reduc(float x) {
+LIBC_INLINE constexpr exp_b_reduc_t exp_b_range_reduc(float x) {
double xd = static_cast<double>(x);
// kd = round((hi + mid) * log2(b) * 2^MID_BITS)
double kd = fputil::nearest_integer(Base::LOG2_B * xd);
diff --git a/libc/src/__support/math/exp10m1f.h b/libc/src/__support/math/exp10m1f.h
index 9fe4ff774ec68..3b05c2479b32e 100644
--- a/libc/src/__support/math/exp10m1f.h
+++ b/libc/src/__support/math/exp10m1f.h
@@ -28,10 +28,10 @@ namespace math {
namespace exp10m1f_internal {
#ifndef LIBC_MATH_HAS_SKIP_ACCURATE_PASS
-static constexpr size_t N_EXCEPTS_LO = 11;
+LIBC_INLINE_VAR constexpr size_t N_EXCEPTS_LO = 11;
-static constexpr fputil::ExceptValues<float, N_EXCEPTS_LO> EXP10M1F_EXCEPTS_LO =
- {{
+LIBC_INLINE_VAR constexpr fputil::ExceptValues<float, N_EXCEPTS_LO>
+ EXP10M1F_EXCEPTS_LO = {{
// x = 0x1.0fe54ep-11, exp10m1f(x) = 0x1.3937eep-10 (RZ)
{0x3a07'f2a7U, 0x3a9c'9bf7U, 1U, 0U, 1U},
// x = 0x1.80e6eap-11, exp10m1f(x) = 0x1.bb8272p-10 (RZ)
@@ -56,10 +56,10 @@ static constexpr fputil::ExceptValues<float, N_EXCEPTS_LO> EXP10M1F_EXCEPTS_LO =
{0xbb65'b4a6U, 0xbc03'b272U, 0U, 1U, 0U},
}};
-static constexpr size_t N_EXCEPTS_HI = 19;
+LIBC_INLINE_VAR constexpr size_t N_EXCEPTS_HI = 19;
-static constexpr fputil::ExceptValues<float, N_EXCEPTS_HI> EXP10M1F_EXCEPTS_HI =
- {{
+LIBC_INLINE_VAR constexpr fputil::ExceptValues<float, N_EXCEPTS_HI>
+ EXP10M1F_EXCEPTS_HI = {{
// (input, RZ output, RU offset, RD offset, RN offset)
// x = 0x1.8d31eep-8, exp10m1f(x) = 0x1.cc7e4cp-7 (RZ)
{0x3bc6'98f7U, 0x3c66'3f26U, 1U, 0U, 1U},
@@ -104,7 +104,7 @@ static constexpr fputil::ExceptValues<float, N_EXCEPTS_HI> EXP10M1F_EXCEPTS_HI =
} // namespace exp10m1f_internal
-LIBC_INLINE static constexpr float exp10m1f(float x) {
+LIBC_INLINE constexpr float exp10m1f(float x) {
using namespace exp10m1f_internal;
using FPBits = fputil::FPBits<float>;
FPBits xbits(x);
diff --git a/libc/src/__support/math/exp10m1f16.h b/libc/src/__support/math/exp10m1f16.h
index 6367a857fa98a..7ee43a0092476 100644
--- a/libc/src/__support/math/exp10m1f16.h
+++ b/libc/src/__support/math/exp10m1f16.h
@@ -30,7 +30,7 @@ namespace LIBC_NAMESPACE_DECL {
namespace math {
-LIBC_INLINE static constexpr float16 exp10m1f16(float16 x) {
+LIBC_INLINE constexpr float16 exp10m1f16(float16 x) {
#ifndef LIBC_MATH_HAS_SKIP_ACCURATE_PASS
constexpr fputil::ExceptValues<float16, 3> EXP10M1F16_EXCEPTS_LO = {{
diff --git a/libc/src/__support/math/exp2.h b/libc/src/__support/math/exp2.h
index 7eaa465f93841..90c91c109874d 100644
--- a/libc/src/__support/math/exp2.h
+++ b/libc/src/__support/math/exp2.h
@@ -45,14 +45,14 @@ using LIBC_NAMESPACE::operator""_u128;
// Error bounds:
// Errors when using double precision.
#ifdef LIBC_TARGET_CPU_HAS_FMA_DOUBLE
-constexpr double ERR_D = 0x1.0p-63;
+LIBC_INLINE_VAR constexpr double ERR_D = 0x1.0p-63;
#else
-constexpr double ERR_D = 0x1.8p-63;
+LIBC_INLINE_VAR constexpr double ERR_D = 0x1.8p-63;
#endif // LIBC_TARGET_CPU_HAS_FMA_DOUBLE
#ifndef LIBC_MATH_HAS_SKIP_ACCURATE_PASS
// Errors when using double-double precision.
-constexpr double ERR_DD = 0x1.0p-100;
+LIBC_INLINE_VAR constexpr double ERR_DD = 0x1.0p-100;
#endif // LIBC_MATH_HAS_SKIP_ACCURATE_PASS
// Polynomial approximations with double precision. Generated by Sollya with:
@@ -60,7 +60,7 @@ constexpr double ERR_DD = 0x1.0p-100;
// > P;
// Error bounds:
// | output - (2^dx - 1) / dx | < 1.5 * 2^-52.
-LIBC_INLINE static double poly_approx_d(double dx) {
+LIBC_INLINE double poly_approx_d(double dx) {
// dx^2
double dx2 = dx * dx;
double c0 =
@@ -77,8 +77,7 @@ LIBC_INLINE static double poly_approx_d(double dx) {
// > P = fpminimax((2^x - 1)/x, 5, [|DD...|], [-2^-13 - 2^-30, 2^-13 + 2^-30]);
// Error bounds:
// | output - 2^(dx) | < 2^-101
-LIBC_INLINE static constexpr DoubleDouble
-poly_approx_dd(const DoubleDouble &dx) {
+LIBC_INLINE constexpr DoubleDouble poly_approx_dd(const DoubleDouble &dx) {
// Taylor polynomial.
constexpr DoubleDouble COEFFS[] = {
{0, 0x1p0},
@@ -99,7 +98,7 @@ poly_approx_dd(const DoubleDouble &dx) {
// Return exp(dx) ~ 1 + a0 * dx + a1 * dx^2 + ... + a6 * dx^7
// For |dx| < 2^-13 + 2^-30:
// | output - exp(dx) | < 2^-126.
-LIBC_INLINE static constexpr Float128 poly_approx_f128(const Float128 &dx) {
+LIBC_INLINE constexpr Float128 poly_approx_f128(const Float128 &dx) {
constexpr Float128 COEFFS_128[]{
{Sign::POS, -127, 0x80000000'00000000'00000000'00000000_u128}, // 1.0
{Sign::POS, -128, 0xb17217f7'd1cf79ab'c9e3b398'03f2f6af_u128},
@@ -120,8 +119,7 @@ LIBC_INLINE static constexpr Float128 poly_approx_f128(const Float128 &dx) {
// Compute 2^(x) using 128-bit precision.
// TODO(lntue): investigate triple-double precision implementation for this
// step.
-LIBC_INLINE static constexpr Float128 exp2_f128(double x, int hi, int idx1,
- int idx2) {
+LIBC_INLINE constexpr Float128 exp2_f128(double x, int hi, int idx1, int idx2) {
Float128 dx = Float128(x);
// TODO: Skip recalculating exp_mid1 and exp_mid2.
@@ -147,8 +145,8 @@ LIBC_INLINE static constexpr Float128 exp2_f128(double x, int hi, int idx1,
}
// Compute 2^x with double-double precision.
-LIBC_INLINE static DoubleDouble
-exp2_double_double(double x, const DoubleDouble &exp_mid) {
+LIBC_INLINE DoubleDouble exp2_double_double(double x,
+ const DoubleDouble &exp_mid) {
DoubleDouble dx({0, x});
// Degree-6 polynomial approximation in double-double precision.
@@ -163,7 +161,7 @@ exp2_double_double(double x, const DoubleDouble &exp_mid) {
#endif // LIBC_MATH_HAS_SKIP_ACCURATE_PASS
// When output is denormal.
-LIBC_INLINE static double exp2_denorm(double x) {
+LIBC_INLINE double exp2_denorm(double x) {
// Range reduction.
int k =
static_cast<int>(cpp::bit_cast<uint64_t>(x + 0x1.8000'0000'4p21) >> 19);
@@ -215,7 +213,7 @@ LIBC_INLINE static double exp2_denorm(double x) {
// * x >= 1024
// * x <= -1022
// * x is inf or nan
-LIBC_INLINE static constexpr double set_exceptional(double x) {
+LIBC_INLINE constexpr double set_exceptional(double x) {
using FPBits = typename fputil::FPBits<double>;
FPBits xbits(x);
@@ -266,7 +264,7 @@ LIBC_INLINE static constexpr double set_exceptional(double x) {
} // namespace exp2_internal
-LIBC_INLINE static constexpr double exp2(double x) {
+LIBC_INLINE constexpr double exp2(double x) {
using namespace exp2_internal;
using FPBits = typename fputil::FPBits<double>;
FPBits xbits(x);
diff --git a/libc/src/__support/math/exp2f.h b/libc/src/__support/math/exp2f.h
index ef2aad051b8a9..a231fcedda034 100644
--- a/libc/src/__support/math/exp2f.h
+++ b/libc/src/__support/math/exp2f.h
@@ -26,7 +26,7 @@ namespace LIBC_NAMESPACE_DECL {
namespace math {
-LIBC_INLINE static constexpr float exp2f(float x) {
+LIBC_INLINE constexpr float exp2f(float x) {
using FPBits = typename fputil::FPBits<float>;
FPBits xbits(x);
diff --git a/libc/src/__support/math/exp2f16.h b/libc/src/__support/math/exp2f16.h
index 599ba0f5411bd..8ff918b665a6f 100644
--- a/libc/src/__support/math/exp2f16.h
+++ b/libc/src/__support/math/exp2f16.h
@@ -27,7 +27,7 @@ namespace LIBC_NAMESPACE_DECL {
namespace math {
-LIBC_INLINE static constexpr float16 exp2f16(float16 x) {
+LIBC_INLINE constexpr float16 exp2f16(float16 x) {
#ifndef LIBC_MATH_HAS_SKIP_ACCURATE_PASS
constexpr fputil::ExceptValues<float16, 3> EXP2F16_EXCEPTS = {{
diff --git a/libc/src/__support/math/exp2m1f.h b/libc/src/__support/math/exp2m1f.h
index e95076c9eac22..f1acde27ac0e1 100644
--- a/libc/src/__support/math/exp2m1f.h
+++ b/libc/src/__support/math/exp2m1f.h
@@ -26,7 +26,7 @@ namespace LIBC_NAMESPACE_DECL {
namespace math {
-LIBC_INLINE static constexpr float exp2m1f(float x) {
+LIBC_INLINE constexpr float exp2m1f(float x) {
#ifndef LIBC_MATH_HAS_SKIP_ACCURATE_PASS
constexpr size_t N_EXCEPTS_LO = 8;
diff --git a/libc/src/__support/math/exp2m1f16.h b/libc/src/__support/math/exp2m1f16.h
index 0424af4aa953d..196fc52158cfc 100644
--- a/libc/src/__support/math/exp2m1f16.h
+++ b/libc/src/__support/math/exp2m1f16.h
@@ -29,7 +29,7 @@ namespace LIBC_NAMESPACE_DECL {
namespace math {
-LIBC_INLINE static constexpr float16 exp2m1f16(float16 x) {
+LIBC_INLINE constexpr float16 exp2m1f16(float16 x) {
#ifndef LIBC_MATH_HAS_SKIP_ACCURATE_PASS
constexpr fputil::ExceptValues<float16, 6> EXP2M1F16_EXCEPTS_LO = {{
// (input, RZ output, RU offset, RD offset, RN offset)
diff --git a/libc/src/__support/math/exp_constants.h b/libc/src/__support/math/exp_constants.h
index 1abb4479e0848..2a5d585efff1f 100644
--- a/libc/src/__support/math/exp_constants.h
+++ b/libc/src/__support/math/exp_constants.h
@@ -10,6 +10,7 @@
#define LLVM_LIBC_SRC___SUPPORT_MATH_EXP_CONSTANTS_H
#include "src/__support/FPUtil/triple_double.h"
+#include "src/__support/macros/attributes.h"
namespace LIBC_NAMESPACE_DECL {
@@ -24,7 +25,7 @@ namespace LIBC_NAMESPACE_DECL {
// d = round(a - b - c, D, RN);
// print("{", d, ",", c, ",", b, "},");
// };
-static constexpr fputil::TripleDouble EXP2_MID1[64] = {
+LIBC_INLINE_VAR constexpr fputil::TripleDouble EXP2_MID1[64] = {
{0, 0, 0x1p0},
{-0x1.9085b0a3d74d5p-110, -0x1.19083535b085dp-56, 0x1.02c9a3e778061p0},
{0x1.05ff94f8d257ep-110, 0x1.d73e2a475b465p-55, 0x1.059b0d3158574p0},
@@ -102,7 +103,7 @@ static constexpr fputil::TripleDouble EXP2_MID1[64] = {
// d = round(a - b - c, D, RN);
// print("{", d, ",", c, ",", b, "},");
// };
-static constexpr fputil::TripleDouble EXP2_MID2[64] = {
+LIBC_INLINE_VAR constexpr fputil::TripleDouble EXP2_MID2[64] = {
{0, 0, 0x1p0},
{0x1.39726694630e3p-108, 0x1.ae8e38c59c72ap-54, 0x1.000b175effdc7p0},
{0x1.e5e06ddd31156p-112, -0x1.7b5d0d58ea8f4p-58, 0x1.00162f3904052p0},
diff --git a/libc/src/__support/math/exp_float_constants.h b/libc/src/__support/math/exp_float_constants.h
index cabb227a034b5..86cc0f5fbee35 100644
--- a/libc/src/__support/math/exp_float_constants.h
+++ b/libc/src/__support/math/exp_float_constants.h
@@ -9,6 +9,7 @@
#ifndef LLVM_LIBC_SRC___SUPPORT_MATH_EXP_FLOAT_CONSTANTS_H
#define LLVM_LIBC_SRC___SUPPORT_MATH_EXP_FLOAT_CONSTANTS_H
+#include "src/__support/macros/attributes.h"
#include "src/__support/macros/config.h"
namespace LIBC_NAMESPACE_DECL {
@@ -20,7 +21,7 @@ namespace math {
// Table is generated with Sollya as follow:
// > display = hexadecimal;
// > for i from -104 to 89 do { D(exp(i)); };
-static constexpr double EXP_M1[195] = {
+LIBC_INLINE_VAR constexpr double EXP_M1[195] = {
0x1.f1e6b68529e33p-151, 0x1.525be4e4e601dp-149, 0x1.cbe0a45f75eb1p-148,
0x1.3884e838aea68p-146, 0x1.a8c1f14e2af5dp-145, 0x1.20a717e64a9bdp-143,
0x1.8851d84118908p-142, 0x1.0a9bdfb02d240p-140, 0x1.6a5bea046b42ep-139,
@@ -92,7 +93,7 @@ static constexpr double EXP_M1[195] = {
// Table is generated with Sollya as follow:
// > display = hexadecimal;
// > for i from 0 to 127 do { D(exp(i / 128)); };
-static constexpr double EXP_M2[128] = {
+LIBC_INLINE_VAR constexpr double EXP_M2[128] = {
0x1.0000000000000p0, 0x1.0202015600446p0, 0x1.04080ab55de39p0,
0x1.06122436410ddp0, 0x1.08205601127edp0, 0x1.0a32a84e9c1f6p0,
0x1.0c49236829e8cp0, 0x1.0e63cfa7ab09dp0, 0x1.1082b577d34edp0,
diff --git a/libc/src/__support/math/exp_utils.h b/libc/src/__support/math/exp_utils.h
index ef408edbc9931..abb97a74a9de8 100644
--- a/libc/src/__support/math/exp_utils.h
+++ b/libc/src/__support/math/exp_utils.h
@@ -22,7 +22,7 @@ namespace LIBC_NAMESPACE_DECL {
// So if we scale x up by 2^1022, we can use
// double(1.0 + 2^1022 * x) - 1.0 to test how x is rounded in denormal range.
template <bool SKIP_ZIV_TEST = false>
-LIBC_INLINE static constexpr cpp::optional<double>
+LIBC_INLINE constexpr cpp::optional<double>
ziv_test_denorm(int hi, double mid, double lo, double err) {
using FPBits = typename fputil::FPBits<double>;
diff --git a/libc/src/__support/math/expf.h b/libc/src/__support/math/expf.h
index f7e11be81a7c9..5fcf0ffa97d5c 100644
--- a/libc/src/__support/math/expf.h
+++ b/libc/src/__support/math/expf.h
@@ -24,7 +24,7 @@ namespace LIBC_NAMESPACE_DECL {
namespace math {
-LIBC_INLINE static constexpr float expf(float x) {
+LIBC_INLINE constexpr float expf(float x) {
using FPBits = typename fputil::FPBits<float>;
FPBits xbits(x);
diff --git a/libc/src/__support/math/expf16.h b/libc/src/__support/math/expf16.h
index 14302a7c4891e..2ca7c021e36b9 100644
--- a/libc/src/__support/math/expf16.h
+++ b/libc/src/__support/math/expf16.h
@@ -13,6 +13,7 @@
#ifdef LIBC_TYPES_HAS_FLOAT16
+#include "expf16_utils.h"
#include "hdr/errno_macros.h"
#include "hdr/fenv_macros.h"
#include "src/__support/FPUtil/FEnvImpl.h"
@@ -25,13 +26,11 @@
#include "src/__support/macros/config.h"
#include "src/__support/macros/optimization.h"
-#include "expf16_utils.h"
-
namespace LIBC_NAMESPACE_DECL {
namespace math {
-LIBC_INLINE static constexpr float16 expf16(float16 x) {
+LIBC_INLINE constexpr float16 expf16(float16 x) {
#ifndef LIBC_MATH_HAS_SKIP_ACCURATE_PASS
constexpr fputil::ExceptValues<float16, 2> EXPF16_EXCEPTS_LO = {{
// (input, RZ output, RU offset, RD offset, RN offset)
diff --git a/libc/src/__support/math/expf16_utils.h b/libc/src/__support/math/expf16_utils.h
index 4204dab72a0c3..de7add4ecf731 100644
--- a/libc/src/__support/math/expf16_utils.h
+++ b/libc/src/__support/math/expf16_utils.h
@@ -23,7 +23,7 @@ namespace LIBC_NAMESPACE_DECL {
// Generated by Sollya with the following commands:
// > display = hexadecimal;
// > for i from -18 to 12 do print(round(exp(i), SG, RN));
-static constexpr cpp::array<float, 31> EXP_HI = {
+LIBC_INLINE_VAR constexpr cpp::array<float, 31> EXP_HI = {
0x1.05a628p-26f, 0x1.639e32p-25f, 0x1.e355bcp-24f, 0x1.4875cap-22f,
0x1.be6c7p-21f, 0x1.2f6054p-19f, 0x1.9c54c4p-18f, 0x1.183542p-16f,
0x1.7cd79cp-15f, 0x1.02cf22p-13f, 0x1.5fc21p-12f, 0x1.de16bap-11f,
@@ -37,7 +37,7 @@ static constexpr cpp::array<float, 31> EXP_HI = {
// Generated by Sollya with the following commands:
// > display = hexadecimal;
// > for i from 0 to 7 do print(round(exp(i * 2^-3), SG, RN));
-static constexpr cpp::array<float, 8> EXP_MID = {
+LIBC_INLINE_VAR constexpr cpp::array<float, 8> EXP_MID = {
0x1p+0f, 0x1.221604p+0f, 0x1.48b5e4p+0f, 0x1.747a52p+0f,
0x1.a61298p+0f, 0x1.de455ep+0f, 0x1.0ef9dcp+1f, 0x1.330e58p+1f,
};
@@ -47,8 +47,7 @@ struct ExpRangeReduction {
float exp_lo;
};
-[[maybe_unused]] LIBC_INLINE static ExpRangeReduction
-exp_range_reduction(float16 x) {
+[[maybe_unused]] LIBC_INLINE ExpRangeReduction exp_range_reduction(float16 x) {
// For -18 < x < 12, to compute exp(x), we perform the following range
// reduction: find hi, mid, lo, such that:
// x = hi + mid + lo, in which
diff --git a/libc/src/__support/math/expm1.h b/libc/src/__support/math/expm1.h
index 4bbb20ffbf7a1..7066997ebcc09 100644
--- a/libc/src/__support/math/expm1.h
+++ b/libc/src/__support/math/expm1.h
@@ -43,15 +43,15 @@ using Float128 = typename fputil::DyadicFloat<128>;
using LIBC_NAMESPACE::operator""_u128;
// log2(e)
-static constexpr double LOG2_E = 0x1.71547652b82fep+0;
+LIBC_INLINE_VAR constexpr double LOG2_E = 0x1.71547652b82fep+0;
// Error bounds:
// Errors when using double precision.
// 0x1.8p-63;
-static constexpr uint64_t ERR_D = 0x3c08000000000000;
+LIBC_INLINE_VAR constexpr uint64_t ERR_D = 0x3c08000000000000;
// Errors when using double-double precision.
// 0x1.0p-99
-[[maybe_unused]] static constexpr uint64_t ERR_DD = 0x39c0000000000000;
+[[maybe_unused]] LIBC_INLINE_VAR constexpr uint64_t ERR_DD = 0x39c0000000000000;
// -2^-12 * log(2)
// > a = -2^-12 * log(2);
@@ -59,10 +59,10 @@ static constexpr uint64_t ERR_D = 0x3c08000000000000;
// > c = round(a - b, 30, RN);
// > d = round(a - b - c, D, RN);
// Errors < 1.5 * 2^-133
-static constexpr double MLOG_2_EXP2_M12_HI = -0x1.62e42ffp-13;
-static constexpr double MLOG_2_EXP2_M12_MID = 0x1.718432a1b0e26p-47;
-static constexpr double MLOG_2_EXP2_M12_MID_30 = 0x1.718432ap-47;
-static constexpr double MLOG_2_EXP2_M12_LO = 0x1.b0e2633fe0685p-79;
+LIBC_INLINE_VAR constexpr double MLOG_2_EXP2_M12_HI = -0x1.62e42ffp-13;
+LIBC_INLINE_VAR constexpr double MLOG_2_EXP2_M12_MID = 0x1.718432a1b0e26p-47;
+LIBC_INLINE_VAR constexpr double MLOG_2_EXP2_M12_MID_30 = 0x1.718432ap-47;
+LIBC_INLINE_VAR constexpr double MLOG_2_EXP2_M12_LO = 0x1.b0e2633fe0685p-79;
using namespace common_constants_internal;
@@ -70,7 +70,7 @@ using namespace common_constants_internal;
// Return expm1(dx) / x ~ 1 + dx / 2 + dx^2 / 6 + dx^3 / 24.
// For |dx| < 2^-13 + 2^-30:
// | output - expm1(dx) / dx | < 2^-51.
-LIBC_INLINE static double poly_approx_d(double dx) {
+LIBC_INLINE double poly_approx_d(double dx) {
// dx^2
double dx2 = dx * dx;
// c0 = 1 + dx / 2
@@ -87,8 +87,7 @@ LIBC_INLINE static double poly_approx_d(double dx) {
// Return expm1(dx) / dx ~ 1 + dx / 2 + dx^2 / 6 + ... + dx^6 / 5040
// For |dx| < 2^-13 + 2^-30:
// | output - expm1(dx) | < 2^-101
-LIBC_INLINE static constexpr DoubleDouble
-poly_approx_dd(const DoubleDouble &dx) {
+LIBC_INLINE constexpr DoubleDouble poly_approx_dd(const DoubleDouble &dx) {
// Taylor polynomial.
constexpr DoubleDouble COEFFS[] = {
{0, 0x1p0}, // 1
@@ -109,7 +108,7 @@ poly_approx_dd(const DoubleDouble &dx) {
// Return (exp(dx) - 1)/dx ~ 1 + dx / 2 + dx^2 / 6 + ... + dx^6 / 5040
// For |dx| < 2^-13 + 2^-30:
// | output - exp(dx) | < 2^-126.
-[[maybe_unused]] LIBC_INLINE static constexpr Float128
+[[maybe_unused]] LIBC_INLINE constexpr Float128
poly_approx_f128(const Float128 &dx) {
constexpr Float128 COEFFS_128[]{
{Sign::POS, -127, 0x80000000'00000000'00000000'00000000_u128}, // 1.0
@@ -144,8 +143,8 @@ std::ostream &operator<<(std::ostream &OS, const DoubleDouble &r) {
// Compute exp(x) - 1 using 128-bit precision.
// TODO(lntue): investigate triple-double precision implementation for this
// step.
-[[maybe_unused]] LIBC_INLINE static Float128 expm1_f128(double x, double kd,
- int idx1, int idx2) {
+[[maybe_unused]] LIBC_INLINE Float128 expm1_f128(double x, double kd, int idx1,
+ int idx2) {
// Recalculate dx:
double t1 = fputil::multiply_add(kd, MLOG_2_EXP2_M12_HI, x); // exact
@@ -196,9 +195,9 @@ std::ostream &operator<<(std::ostream &OS, const DoubleDouble &r) {
}
// Compute exp(x) - 1 with double-double precision.
-LIBC_INLINE static DoubleDouble exp_double_double(double x, double kd,
- const DoubleDouble &exp_mid,
- const DoubleDouble &hi_part) {
+LIBC_INLINE DoubleDouble exp_double_double(double x, double kd,
+ const DoubleDouble &exp_mid,
+ const DoubleDouble &hi_part) {
// Recalculate dx:
// dx = x - k * 2^-12 * log(2)
double t1 = fputil::multiply_add(kd, MLOG_2_EXP2_M12_HI, x); // exact
@@ -226,7 +225,7 @@ LIBC_INLINE static DoubleDouble exp_double_double(double x, double kd,
// Check for exceptional cases when
// |x| <= 2^-53 or x < log(2^-54) or x >= 0x1.6232bdd7abcd3p+9
-LIBC_INLINE static constexpr double set_exceptional(double x) {
+LIBC_INLINE constexpr double set_exceptional(double x) {
using FPBits = typename fputil::FPBits<double>;
FPBits xbits(x);
@@ -280,7 +279,7 @@ LIBC_INLINE static constexpr double set_exceptional(double x) {
} // namespace expm1_internal
-LIBC_INLINE static constexpr double expm1(double x) {
+LIBC_INLINE constexpr double expm1(double x) {
using namespace expm1_internal;
using FPBits = typename fputil::FPBits<double>;
diff --git a/libc/src/__support/math/expm1f.h b/libc/src/__support/math/expm1f.h
index 43e79ae3112dc..f581635f77c7b 100644
--- a/libc/src/__support/math/expm1f.h
+++ b/libc/src/__support/math/expm1f.h
@@ -27,7 +27,7 @@ namespace LIBC_NAMESPACE_DECL {
namespace math {
-LIBC_INLINE static constexpr float expm1f(float x) {
+LIBC_INLINE constexpr float expm1f(float x) {
using namespace common_constants_internal;
using FPBits = typename fputil::FPBits<float>;
FPBits xbits(x);
diff --git a/libc/src/__support/math/expm1f16.h b/libc/src/__support/math/expm1f16.h
index 79547b62b0892..a14a6f051a834 100644
--- a/libc/src/__support/math/expm1f16.h
+++ b/libc/src/__support/math/expm1f16.h
@@ -29,7 +29,7 @@ namespace LIBC_NAMESPACE_DECL {
namespace math {
-LIBC_INLINE static constexpr float16 expm1f16(float16 x) {
+LIBC_INLINE constexpr float16 expm1f16(float16 x) {
#ifndef LIBC_MATH_HAS_SKIP_ACCURATE_PASS
constexpr fputil::ExceptValues<float16, 1> EXPM1F16_EXCEPTS_LO = {{
// (input, RZ output, RU offset, RD offset, RN offset)
diff --git a/libc/src/__support/math/expxf16_utils.h b/libc/src/__support/math/expxf16_utils.h
index 5d3bd3845a74f..0375eaf179b9f 100644
--- a/libc/src/__support/math/expxf16_utils.h
+++ b/libc/src/__support/math/expxf16_utils.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLVM_LIBC_SRC_MATH_GENERIC_EXPXF16_H
-#define LLVM_LIBC_SRC_MATH_GENERIC_EXPXF16_H
+#ifndef LLVM_LIBC_SRC___SUPPORT_MATH_EXPXF16_UTILS_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_EXPXF16_UTILS_H
#include "hdr/stdint_proxy.h"
#include "src/__support/FPUtil/FPBits.h"
@@ -25,7 +25,7 @@ namespace math {
namespace expxf16_internal {
-LIBC_INLINE static ExpRangeReduction exp2_range_reduction(float16 x) {
+LIBC_INLINE ExpRangeReduction exp2_range_reduction(float16 x) {
// For -25 < x < 16, to compute 2^x, we perform the following range reduction:
// find hi, mid, lo, such that:
// x = hi + mid + lo, in which
@@ -65,17 +65,17 @@ LIBC_INLINE static ExpRangeReduction exp2_range_reduction(float16 x) {
// Generated by Sollya with the following commands:
// > display = hexadecimal;
// > round(log2(exp(1)), SG, RN);
-static constexpr float LOG2F_E = 0x1.715476p+0f;
+LIBC_INLINE_VAR constexpr float LOG2F_E = 0x1.715476p+0f;
// Generated by Sollya with the following commands:
// > display = hexadecimal;
// > round(log(2), SG, RN);
-static constexpr float LOGF_2 = 0x1.62e43p-1f;
+LIBC_INLINE_VAR constexpr float LOGF_2 = 0x1.62e43p-1f;
// Generated by Sollya with the following commands:
// > display = hexadecimal;
// > for i from 0 to 31 do printsingle(round(2^(i * 2^-5), SG, RN));
-static constexpr cpp::array<uint32_t, 32> EXP2_MID_5_BITS = {
+LIBC_INLINE_VAR constexpr cpp::array<uint32_t, 32> EXP2_MID_5_BITS = {
0x3f80'0000U, 0x3f82'cd87U, 0x3f85'aac3U, 0x3f88'980fU, 0x3f8b'95c2U,
0x3f8e'a43aU, 0x3f91'c3d3U, 0x3f94'f4f0U, 0x3f98'37f0U, 0x3f9b'8d3aU,
0x3f9e'f532U, 0x3fa2'7043U, 0x3fa5'fed7U, 0x3fa9'a15bU, 0x3fad'583fU,
@@ -122,7 +122,7 @@ static constexpr cpp::array<uint32_t, 32> EXP2_MID_5_BITS = {
// the polynomials approximating lower parts of e^x and e^(-x) is shared and
// only done once.
template <bool IsSinh>
-LIBC_INLINE static constexpr float16 eval_sinh_or_cosh(float16 x) {
+LIBC_INLINE constexpr float16 eval_sinh_or_cosh(float16 x) {
float xf = x;
float kf = fputil::nearest_integer(xf * (LOG2F_E * 0x1.0p+5f));
int x_hi_mid_p = static_cast<int>(kf);
@@ -179,7 +179,7 @@ LIBC_INLINE static constexpr float16 eval_sinh_or_cosh(float16 x) {
// Generated by Sollya with the following commands:
// > display = hexadecimal;
// > for i from 0 to 31 do print(round(log(1 + i * 2^-5), SG, RN));
-static constexpr cpp::array<float, 32> LOGF_F = {
+LIBC_INLINE_VAR constexpr cpp::array<float, 32> LOGF_F = {
0x0p+0f, 0x1.f829bp-6f, 0x1.f0a30cp-5f, 0x1.6f0d28p-4f,
0x1.e27076p-4f, 0x1.29553p-3f, 0x1.5ff308p-3f, 0x1.9525aap-3f,
0x1.c8ff7cp-3f, 0x1.fb9186p-3f, 0x1.1675cap-2f, 0x1.2e8e2cp-2f,
@@ -193,7 +193,7 @@ static constexpr cpp::array<float, 32> LOGF_F = {
// Generated by Sollya with the following commands:
// > display = hexadecimal;
// > for i from 0 to 31 do print(round(log2(1 + i * 2^-5), SG, RN));
-static constexpr cpp::array<float, 32> LOG2F_F = {
+LIBC_INLINE_VAR constexpr cpp::array<float, 32> LOG2F_F = {
0x0p+0f, 0x1.6bad38p-5f, 0x1.663f7p-4f, 0x1.08c588p-3f,
0x1.5c01a4p-3f, 0x1.acf5e2p-3f, 0x1.fbc16cp-3f, 0x1.24407ap-2f,
0x1.49a784p-2f, 0x1.6e221cp-2f, 0x1.91bba8p-2f, 0x1.b47ecp-2f,
@@ -207,7 +207,7 @@ static constexpr cpp::array<float, 32> LOG2F_F = {
// Generated by Sollya with the following commands:
// > display = hexadecimal;
// > for i from 0 to 31 do print(round(log10(1 + i * 2^-5), SG, RN));
-static constexpr cpp::array<float, 32> LOG10F_F = {
+LIBC_INLINE_VAR constexpr cpp::array<float, 32> LOG10F_F = {
0x0p+0f, 0x1.b5e908p-7f, 0x1.af5f92p-6f, 0x1.3ed11ap-5f,
0x1.a30a9ep-5f, 0x1.02428cp-4f, 0x1.31b306p-4f, 0x1.5fe804p-4f,
0x1.8cf184p-4f, 0x1.b8de4ep-4f, 0x1.e3bc1ap-4f, 0x1.06cbd6p-3f,
@@ -221,7 +221,7 @@ static constexpr cpp::array<float, 32> LOG10F_F = {
// Generated by Sollya with the following commands:
// > display = hexadecimal;
// > for i from 0 to 31 do print(round(1 / (1 + i * 2^-5), SG, RN));
-static constexpr cpp::array<float, 32> ONE_OVER_F_F = {
+LIBC_INLINE_VAR constexpr cpp::array<float, 32> ONE_OVER_F_F = {
0x1p+0f, 0x1.f07c2p-1f, 0x1.e1e1e2p-1f, 0x1.d41d42p-1f,
0x1.c71c72p-1f, 0x1.bacf92p-1f, 0x1.af286cp-1f, 0x1.a41a42p-1f,
0x1.99999ap-1f, 0x1.8f9c18p-1f, 0x1.861862p-1f, 0x1.7d05f4p-1f,
@@ -238,4 +238,4 @@ static constexpr cpp::array<float, 32> ONE_OVER_F_F = {
} // namespace LIBC_NAMESPACE_DECL
-#endif // LLVM_LIBC_SRC_MATH_GENERIC_EXPXF16_H
+#endif // LLVM_LIBC_SRC___SUPPORT_MATH_EXPXF16_UTILS_H
diff --git a/libc/src/__support/math/f16fma.h b/libc/src/__support/math/f16fma.h
index f7bb2fe33e963..2fc8e657b9efe 100644
--- a/libc/src/__support/math/f16fma.h
+++ b/libc/src/__support/math/f16fma.h
@@ -20,7 +20,7 @@ namespace LIBC_NAMESPACE_DECL {
namespace math {
-LIBC_INLINE static float16 f16fma(double x, double y, double z) {
+LIBC_INLINE float16 f16fma(double x, double y, double z) {
return fputil::fma<float16>(x, y, z);
}
diff --git a/libc/src/__support/math/f16fmal.h b/libc/src/__support/math/f16fmal.h
index 6e9c4b9af13f4..72fd6950fab49 100644
--- a/libc/src/__support/math/f16fmal.h
+++ b/libc/src/__support/math/f16fmal.h
@@ -20,8 +20,7 @@ namespace LIBC_NAMESPACE_DECL {
namespace math {
-LIBC_INLINE static float16 f16fmal(long double x, long double y,
- long double z) {
+LIBC_INLINE float16 f16fmal(long double x, long double y, long double z) {
return fputil::fma<float16>(x, y, z);
}
diff --git a/libc/src/__support/math/f16sqrt.h b/libc/src/__support/math/f16sqrt.h
index 806aa9fd97372..656196cdb6281 100644
--- a/libc/src/__support/math/f16sqrt.h
+++ b/libc/src/__support/math/f16sqrt.h
@@ -20,7 +20,7 @@
namespace LIBC_NAMESPACE_DECL {
namespace math {
-LIBC_INLINE static constexpr float16 f16sqrt(double x) {
+LIBC_INLINE constexpr float16 f16sqrt(double x) {
return fputil::sqrt<float16>(x);
}
diff --git a/libc/src/__support/math/f16sqrtl.h b/libc/src/__support/math/f16sqrtl.h
index 86f0e594408e1..f76642fa13fa1 100644
--- a/libc/src/__support/math/f16sqrtl.h
+++ b/libc/src/__support/math/f16sqrtl.h
@@ -21,7 +21,7 @@ namespace LIBC_NAMESPACE_DECL {
namespace math {
-LIBC_INLINE static constexpr float16 f16sqrtl(long double x) {
+LIBC_INLINE constexpr float16 f16sqrtl(long double x) {
return fputil::sqrt<float16>(x);
}
diff --git a/libc/src/__support/math/frexpf.h b/libc/src/__support/math/frexpf.h
index 7834a12793d30..caaaaeaf58306 100644
--- a/libc/src/__support/math/frexpf.h
+++ b/libc/src/__support/math/frexpf.h
@@ -17,7 +17,7 @@ namespace LIBC_NAMESPACE_DECL {
namespace math {
-LIBC_INLINE static constexpr float frexpf(float x, int *exp) {
+LIBC_INLINE constexpr float frexpf(float x, int *exp) {
return fputil::frexp(x, *exp);
}
diff --git a/libc/src/__support/math/frexpf128.h b/libc/src/__support/math/frexpf128.h
index 5218b26dd52c6..176a33f0d2407 100644
--- a/libc/src/__support/math/frexpf128.h
+++ b/libc/src/__support/math/frexpf128.h
@@ -21,7 +21,7 @@ namespace LIBC_NAMESPACE_DECL {
namespace math {
-LIBC_INLINE static constexpr float128 frexpf128(float128 x, int *exp) {
+LIBC_INLINE constexpr float128 frexpf128(float128 x, int *exp) {
return fputil::frexp(x, *exp);
}
diff --git a/libc/src/__support/math/frexpf16.h b/libc/src/__support/math/frexpf16.h
index 530b61aea0aeb..0bfc323326add 100644
--- a/libc/src/__support/math/frexpf16.h
+++ b/libc/src/__support/math/frexpf16.h
@@ -21,7 +21,7 @@ namespace LIBC_NAMESPACE_DECL {
namespace math {
-LIBC_INLINE static constexpr float16 frexpf16(float16 x, int *exp) {
+LIBC_INLINE constexpr float16 frexpf16(float16 x, int *exp) {
return fputil::frexp(x, *exp);
}
diff --git a/libc/src/__support/math/fsqrt.h b/libc/src/__support/math/fsqrt.h
index 8dd6afc7845f0..d35f25b9a8111 100644
--- a/libc/src/__support/math/fsqrt.h
+++ b/libc/src/__support/math/fsqrt.h
@@ -15,9 +15,7 @@ namespace LIBC_NAMESPACE_DECL {
namespace math {
-LIBC_INLINE static constexpr float fsqrt(double x) {
- return fputil::sqrt<float>(x);
-}
+LIBC_INLINE constexpr float fsqrt(double x) { return fputil::sqrt<float>(x); }
} // namespace math
diff --git a/libc/src/__support/math/fsqrtf128.h b/libc/src/__support/math/fsqrtf128.h
index 8ca274eff6888..955e19a818c57 100644
--- a/libc/src/__support/math/fsqrtf128.h
+++ b/libc/src/__support/math/fsqrtf128.h
@@ -21,7 +21,7 @@ namespace LIBC_NAMESPACE_DECL {
namespace math {
-LIBC_INLINE static constexpr float fsqrtf128(float128 x) {
+LIBC_INLINE constexpr float fsqrtf128(float128 x) {
return fputil::sqrt<float>(x);
}
diff --git a/libc/src/__support/math/fsqrtl.h b/libc/src/__support/math/fsqrtl.h
index 3033f0a5242f3..26c3b9e4c14c9 100644
--- a/libc/src/__support/math/fsqrtl.h
+++ b/libc/src/__support/math/fsqrtl.h
@@ -15,7 +15,7 @@ namespace LIBC_NAMESPACE_DECL {
namespace math {
-LIBC_INLINE static constexpr float fsqrtl(long double x) {
+LIBC_INLINE constexpr float fsqrtl(long double x) {
return fputil::sqrt<float>(x);
}
diff --git a/libc/src/__support/math/hypotf.h b/libc/src/__support/math/hypotf.h
index e712a07bda01a..081fc91ce4dfb 100644
--- a/libc/src/__support/math/hypotf.h
+++ b/libc/src/__support/math/hypotf.h
@@ -22,7 +22,7 @@ namespace LIBC_NAMESPACE_DECL {
namespace math {
-LIBC_INLINE static float hypotf(float x, float y) {
+LIBC_INLINE float hypotf(float x, float y) {
using DoubleBits = fputil::FPBits<double>;
using FPBits = fputil::FPBits<float>;
diff --git a/libc/src/__support/math/ilogb.h b/libc/src/__support/math/ilogb.h
index 021531489b43f..1172645f678c5 100644
--- a/libc/src/__support/math/ilogb.h
+++ b/libc/src/__support/math/ilogb.h
@@ -17,9 +17,7 @@ namespace LIBC_NAMESPACE_DECL {
namespace math {
-LIBC_INLINE static constexpr int ilogb(double x) {
- return fputil::intlogb<int>(x);
-}
+LIBC_INLINE constexpr int ilogb(double x) { return fputil::intlogb<int>(x); }
} // namespace math
} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/__support/math/ilogbf128.h b/libc/src/__support/math/ilogbf128.h
index 47c3643c2326e..a2a4a3b194044 100644
--- a/libc/src/__support/math/ilogbf128.h
+++ b/libc/src/__support/math/ilogbf128.h
@@ -21,7 +21,7 @@ namespace LIBC_NAMESPACE_DECL {
namespace math {
-LIBC_INLINE static constexpr int ilogbf128(float128 x) {
+LIBC_INLINE constexpr int ilogbf128(float128 x) {
return fputil::intlogb<int>(x);
}
diff --git a/libc/src/__support/math/ilogbl.h b/libc/src/__support/math/ilogbl.h
index 1d6a8b568fe06..71c5bb5ed4ba7 100644
--- a/libc/src/__support/math/ilogbl.h
+++ b/libc/src/__support/math/ilogbl.h
@@ -17,7 +17,7 @@ namespace LIBC_NAMESPACE_DECL {
namespace math {
-LIBC_INLINE static constexpr int ilogbl(long double x) {
+LIBC_INLINE constexpr int ilogbl(long double x) {
return fputil::intlogb<int>(x);
}
diff --git a/libc/src/__support/math/inv_trigf_utils.h b/libc/src/__support/math/inv_trigf_utils.h
index 4a8fbeca93e49..6eab68d8bbe01 100644
--- a/libc/src/__support/math/inv_trigf_utils.h
+++ b/libc/src/__support/math/inv_trigf_utils.h
@@ -19,8 +19,8 @@ namespace LIBC_NAMESPACE_DECL {
namespace inv_trigf_utils_internal {
// PI and PI / 2
-static constexpr double M_MATH_PI = 0x1.921fb54442d18p+1;
-static constexpr double M_MATH_PI_2 = 0x1.921fb54442d18p+0;
+LIBC_INLINE_VAR constexpr double M_MATH_PI = 0x1.921fb54442d18p+1;
+LIBC_INLINE_VAR constexpr double M_MATH_PI_2 = 0x1.921fb54442d18p+0;
// Polynomial approximation for 0 <= x <= 1:
// atan(x) ~ atan((i/16) + (x - (i/16)) * Q(x - i/16)
@@ -40,7 +40,7 @@ static constexpr double M_MATH_PI_2 = 0x1.921fb54442d18p+0;
// Notice that degree-7 is good enough for atanf, but degree-8 helps reduce the
// error bounds for atan2f's fast pass 16 times, and it does not affect the
// performance of atanf much.
-static constexpr double ATAN_COEFFS[17][9] = {
+LIBC_INLINE_VAR constexpr double ATAN_COEFFS[17][9] = {
{0.0, 1.0, 0x1.3f8d76d26d61bp-47, -0x1.5555555574cd8p-2,
0x1.0dde5d06878eap-29, 0x1.99997738acc77p-3, 0x1.2c43eac9797cap-16,
-0x1.25fb020007dbdp-3, 0x1.c1b6c31d7b0aep-7},
@@ -95,7 +95,7 @@ static constexpr double ATAN_COEFFS[17][9] = {
};
// Look-up table for atan(k/16) with k = 0..16.
-static constexpr double ATAN_K_OVER_16[17] = {
+LIBC_INLINE_VAR constexpr double ATAN_K_OVER_16[17] = {
0.0,
0x1.ff55bb72cfdeap-5,
0x1.fd5ba9aac2f6ep-4,
@@ -117,7 +117,7 @@ static constexpr double ATAN_K_OVER_16[17] = {
// For |x| <= 1/32 and 0 <= i <= 16, return Q(x) such that:
// Q(x) ~ (atan(x + i/16) - atan(i/16)) / x.
-LIBC_INLINE static double atan_eval(double x, unsigned i) {
+LIBC_INLINE double atan_eval(double x, unsigned i) {
double x2 = x * x;
double c0 = fputil::multiply_add(x, ATAN_COEFFS[i][2], ATAN_COEFFS[i][1]);
@@ -138,8 +138,8 @@ LIBC_INLINE static double atan_eval(double x, unsigned i) {
// So we let q = (n - d * k/16) / (d + n * k/16),
// and approximate with Taylor polynomial:
// atan(q) ~ q - q^3/3 + q^5/5 - q^7/7 + q^9/9
-LIBC_INLINE static double atan_eval_no_table(double num, double den,
- double k_over_16) {
+LIBC_INLINE double atan_eval_no_table(double num, double den,
+ double k_over_16) {
double num_r = fputil::multiply_add(den, -k_over_16, num);
double den_r = fputil::multiply_add(num, k_over_16, den);
double q = num_r / den_r;
@@ -161,14 +161,14 @@ LIBC_INLINE static double atan_eval_no_table(double num, double den,
// > Q = fpminimax(asin(x)/x, [|0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20|],
// [|1, D...|], [0, 0.5]);
-static constexpr double ASIN_COEFFS[10] = {
+LIBC_INLINE_VAR constexpr double ASIN_COEFFS[10] = {
0x1.5555555540fa1p-3, 0x1.333333512edc2p-4, 0x1.6db6cc1541b31p-5,
0x1.f1caff324770ep-6, 0x1.6e43899f5f4f4p-6, 0x1.1f847cf652577p-6,
0x1.9b60f47f87146p-7, 0x1.259e2634c494fp-6, -0x1.df946fa875ddp-8,
0x1.02311ecf99c28p-5};
// Evaluate P(x^2) - 1, where P(x^2) ~ asin(x)/x
-LIBC_INLINE static double asin_eval(double xsq) {
+LIBC_INLINE double asin_eval(double xsq) {
double x4 = xsq * xsq;
double r1 = fputil::polyeval(x4, ASIN_COEFFS[0], ASIN_COEFFS[2],
ASIN_COEFFS[4], ASIN_COEFFS[6], ASIN_COEFFS[8]);
diff --git a/libc/src/__support/math/ldexpf.h b/libc/src/__support/math/ldexpf.h
index 9ef5d96d00e06..9d0030e3dd529 100644
--- a/libc/src/__support/math/ldexpf.h
+++ b/libc/src/__support/math/ldexpf.h
@@ -17,7 +17,7 @@ namespace LIBC_NAMESPACE_DECL {
namespace math {
-LIBC_INLINE static constexpr float ldexpf(float x, int exp) {
+LIBC_INLINE constexpr float ldexpf(float x, int exp) {
return fputil::ldexp(x, exp);
}
diff --git a/libc/src/__support/math/ldexpf128.h b/libc/src/__support/math/ldexpf128.h
index 4fba20c3a2d92..571d2f951294d 100644
--- a/libc/src/__support/math/ldexpf128.h
+++ b/libc/src/__support/math/ldexpf128.h
@@ -21,7 +21,7 @@ namespace LIBC_NAMESPACE_DECL {
namespace math {
-LIBC_INLINE static constexpr float128 ldexpf128(float128 x, int exp) {
+LIBC_INLINE constexpr float128 ldexpf128(float128 x, int exp) {
return fputil::ldexp(x, exp);
}
diff --git a/libc/src/__support/math/ldexpf16.h b/libc/src/__support/math/ldexpf16.h
index d978d222142b4..b9cf06d7ec8dd 100644
--- a/libc/src/__support/math/ldexpf16.h
+++ b/libc/src/__support/math/ldexpf16.h
@@ -21,7 +21,7 @@ namespace LIBC_NAMESPACE_DECL {
namespace math {
-LIBC_INLINE static constexpr float16 ldexpf16(float16 x, int exp) {
+LIBC_INLINE constexpr float16 ldexpf16(float16 x, int exp) {
return fputil::ldexp(x, exp);
}
diff --git a/libc/src/__support/math/llogb.h b/libc/src/__support/math/llogb.h
index 0c6acf0db6f4a..f790cfb092087 100644
--- a/libc/src/__support/math/llogb.h
+++ b/libc/src/__support/math/llogb.h
@@ -16,9 +16,7 @@
namespace LIBC_NAMESPACE_DECL {
namespace math {
-LIBC_INLINE static constexpr long llogb(double x) {
- return fputil::intlogb<long>(x);
-}
+LIBC_INLINE constexpr long llogb(double x) { return fputil::intlogb<long>(x); }
} // namespace math
diff --git a/libc/src/__support/math/llogbf.h b/libc/src/__support/math/llogbf.h
index 1dcdcd0f7311f..ed8648242d4eb 100644
--- a/libc/src/__support/math/llogbf.h
+++ b/libc/src/__support/math/llogbf.h
@@ -17,9 +17,7 @@ namespace LIBC_NAMESPACE_DECL {
namespace math {
-LIBC_INLINE static constexpr long llogbf(float x) {
- return fputil::intlogb<long>(x);
-}
+LIBC_INLINE constexpr long llogbf(float x) { return fputil::intlogb<long>(x); }
} // namespace math
diff --git a/libc/src/__support/math/llogbf128.h b/libc/src/__support/math/llogbf128.h
index 5168647f49c02..483c464fd3a63 100644
--- a/libc/src/__support/math/llogbf128.h
+++ b/libc/src/__support/math/llogbf128.h
@@ -21,7 +21,7 @@ namespace LIBC_NAMESPACE_DECL {
namespace math {
-LIBC_INLINE static constexpr long llogbf128(float128 x) {
+LIBC_INLINE constexpr long llogbf128(float128 x) {
return fputil::intlogb<long>(x);
}
diff --git a/libc/src/__support/math/llogbf16.h b/libc/src/__support/math/llogbf16.h
index 55ddd3b9e2569..275a149fdbfee 100644
--- a/libc/src/__support/math/llogbf16.h
+++ b/libc/src/__support/math/llogbf16.h
@@ -21,7 +21,7 @@ namespace LIBC_NAMESPACE_DECL {
namespace math {
-LIBC_INLINE static constexpr long llogbf16(float16 x) {
+LIBC_INLINE constexpr long llogbf16(float16 x) {
return fputil::intlogb<long>(x);
}
diff --git a/libc/src/__support/math/log.h b/libc/src/__support/math/log.h
index 7640e6a5707c1..f7b5767899ccc 100644
--- a/libc/src/__support/math/log.h
+++ b/libc/src/__support/math/log.h
@@ -721,7 +721,7 @@ LIBC_INLINE_VAR constexpr Float128 BIG_COEFFS[3]{
// Reuse the output of the fast pass range reduction.
// -2^-8 <= m_x < 2^-7
#ifndef LIBC_MATH_HAS_SKIP_ACCURATE_PASS
-LIBC_INLINE static double log_accurate(int e_x, int index, double m_x) {
+LIBC_INLINE double log_accurate(int e_x, int index, double m_x) {
Float128 e_x_f128(static_cast<float>(e_x));
Float128 sum = fputil::quick_mul(LOG_2, e_x_f128);
@@ -744,7 +744,7 @@ LIBC_INLINE static double log_accurate(int e_x, int index, double m_x) {
} // namespace log_internal
-LIBC_INLINE static double log(double x) {
+LIBC_INLINE double log(double x) {
using namespace log_internal;
using FPBits_t = typename fputil::FPBits<double>;
diff --git a/libc/src/__support/math/log10.h b/libc/src/__support/math/log10.h
index 8861c8934578d..e4e7313449633 100644
--- a/libc/src/__support/math/log10.h
+++ b/libc/src/__support/math/log10.h
@@ -722,7 +722,7 @@ LIBC_INLINE_VAR constexpr Float128 BIG_COEFFS[4]{
// Reuse the output of the fast pass range reduction.
// -2^-8 <= m_x < 2^-7
-LIBC_INLINE static double log10_accurate(int e_x, int index, double m_x) {
+LIBC_INLINE double log10_accurate(int e_x, int index, double m_x) {
Float128 e_x_f128(static_cast<float>(e_x));
Float128 sum = fputil::quick_mul(LOG10_2, e_x_f128);
@@ -744,7 +744,7 @@ LIBC_INLINE static double log10_accurate(int e_x, int index, double m_x) {
} // namespace log10_internal
-LIBC_INLINE static double log10(double x) {
+LIBC_INLINE double log10(double x) {
using namespace log10_internal;
using namespace common_constants_internal;
using FPBits_t = typename fputil::FPBits<double>;
diff --git a/libc/src/__support/math/log1p.h b/libc/src/__support/math/log1p.h
index 9950161b338cb..b0ab4514e895a 100644
--- a/libc/src/__support/math/log1p.h
+++ b/libc/src/__support/math/log1p.h
@@ -828,8 +828,8 @@ LIBC_INLINE_VAR constexpr Float128 BIG_COEFFS[4]{
{Sign::NEG, -128, 0x80000000'00000000'00000000'00000000_u128},
};
-[[maybe_unused]] LIBC_INLINE static double
-log1p_accurate(int e_x, int index, fputil::DoubleDouble m_x) {
+[[maybe_unused]] LIBC_INLINE double log1p_accurate(int e_x, int index,
+ fputil::DoubleDouble m_x) {
Float128 e_x_f128(static_cast<float>(e_x));
Float128 sum = fputil::quick_mul(LOG_2, e_x_f128);
sum = fputil::quick_add(sum, LOG_R1[index]);
@@ -884,7 +884,7 @@ log1p_accurate(int e_x, int index, fputil::DoubleDouble m_x) {
} // namespace log1p_internal
-LIBC_INLINE static double log1p(double x) {
+LIBC_INLINE double log1p(double x) {
using namespace log1p_internal;
using FPBits_t = typename fputil::FPBits<double>;
diff --git a/libc/src/__support/math/log2.h b/libc/src/__support/math/log2.h
index 79ec907783f69..3033bf332fe04 100644
--- a/libc/src/__support/math/log2.h
+++ b/libc/src/__support/math/log2.h
@@ -841,7 +841,7 @@ LIBC_INLINE_VAR constexpr Float128 BIG_COEFFS[4]{
// Reuse the output of the fast pass range reduction.
// -2^-8 <= m_x < 2^-7
-LIBC_INLINE static double log2_accurate(int e_x, int index, double m_x) {
+LIBC_INLINE double log2_accurate(int e_x, int index, double m_x) {
Float128 sum(static_cast<float>(e_x));
sum = fputil::quick_add(sum, LOG2_TABLE.step_1[index]);
@@ -862,7 +862,7 @@ LIBC_INLINE static double log2_accurate(int e_x, int index, double m_x) {
} // namespace log2_internal
-LIBC_INLINE static double log2(double x) {
+LIBC_INLINE double log2(double x) {
using namespace log2_internal;
using namespace common_constants_internal;
using FPBits_t = typename fputil::FPBits<double>;
diff --git a/libc/src/__support/math/logbf.h b/libc/src/__support/math/logbf.h
index 1b0daf92784ed..2580748e2891b 100644
--- a/libc/src/__support/math/logbf.h
+++ b/libc/src/__support/math/logbf.h
@@ -17,7 +17,7 @@ namespace LIBC_NAMESPACE_DECL {
namespace math {
-LIBC_INLINE static constexpr float logbf(float x) { return fputil::logb(x); }
+LIBC_INLINE constexpr float logbf(float x) { return fputil::logb(x); }
} // namespace math
diff --git a/libc/src/__support/math/logbf128.h b/libc/src/__support/math/logbf128.h
index d18efc5077ade..e7053fe8a4cbd 100644
--- a/libc/src/__support/math/logbf128.h
+++ b/libc/src/__support/math/logbf128.h
@@ -21,9 +21,7 @@ namespace LIBC_NAMESPACE_DECL {
namespace math {
-LIBC_INLINE static constexpr float128 logbf128(float128 x) {
- return fputil::logb(x);
-}
+LIBC_INLINE constexpr float128 logbf128(float128 x) { return fputil::logb(x); }
} // namespace math
diff --git a/libc/src/__support/math/logbf16.h b/libc/src/__support/math/logbf16.h
index 239e57b0a2cd5..2c8fe94615958 100644
--- a/libc/src/__support/math/logbf16.h
+++ b/libc/src/__support/math/logbf16.h
@@ -21,9 +21,7 @@ namespace LIBC_NAMESPACE_DECL {
namespace math {
-LIBC_INLINE static constexpr float16 logbf16(float16 x) {
- return fputil::logb(x);
-}
+LIBC_INLINE constexpr float16 logbf16(float16 x) { return fputil::logb(x); }
} // namespace math
diff --git a/libc/src/__support/math/logf.h b/libc/src/__support/math/logf.h
index e96fe28fc020d..09baa283cb120 100644
--- a/libc/src/__support/math/logf.h
+++ b/libc/src/__support/math/logf.h
@@ -56,7 +56,7 @@ namespace LIBC_NAMESPACE_DECL {
namespace math {
-LIBC_INLINE static float logf(float x) {
+LIBC_INLINE float logf(float x) {
using namespace common_constants_internal;
constexpr double LOG_2 = 0x1.62e42fefa39efp-1;
using FPBits = typename fputil::FPBits<float>;
diff --git a/libc/src/__support/math/logf16.h b/libc/src/__support/math/logf16.h
index c123eb09b9665..77682e6082e0b 100644
--- a/libc/src/__support/math/logf16.h
+++ b/libc/src/__support/math/logf16.h
@@ -78,7 +78,7 @@ LIBC_INLINE_VAR constexpr fputil::ExceptValues<float16, N_LOGF16_EXCEPTS>
} // namespace logf16_internal
-LIBC_INLINE static float16 logf16(float16 x) {
+LIBC_INLINE float16 logf16(float16 x) {
using namespace math::expxf16_internal;
using namespace math::logf16_internal;
using FPBits = fputil::FPBits<float16>;
diff --git a/libc/src/__support/math/range_reduction.h b/libc/src/__support/math/range_reduction.h
index b813b2ed42d06..93ec9846e5f1b 100644
--- a/libc/src/__support/math/range_reduction.h
+++ b/libc/src/__support/math/range_reduction.h
@@ -17,11 +17,13 @@
namespace LIBC_NAMESPACE_DECL {
-namespace generic {
+namespace math {
-static constexpr uint32_t FAST_PASS_BOUND = 0x4a80'0000U; // 2^22
+namespace trigonometric_func_utils_internal {
-static constexpr int N_ENTRIES = 8;
+LIBC_INLINE_VAR constexpr uint32_t FAST_PASS_BOUND = 0x4a80'0000U; // 2^22
+
+LIBC_INLINE_VAR constexpr int N_ENTRIES = 8;
// We choose to split bits of 32/pi into 28-bit precision pieces, so that the
// product of x * THIRTYTWO_OVER_PI_28[i] is exact.
@@ -31,13 +33,13 @@ static constexpr int N_ENTRIES = 8;
// > a3 = D(round(32/pi - a1 - a2, 28, RN)); a3;
// > a4 = D(round(32/pi - a1 - a2 - a3, 28, RN)); a4;
// ...
-static constexpr double THIRTYTWO_OVER_PI_28[N_ENTRIES] = {
+LIBC_INLINE_VAR constexpr double THIRTYTWO_OVER_PI_28[N_ENTRIES] = {
0x1.45f306ep+3, -0x1.b1bbeaep-28, 0x1.3f84ebp-57, -0x1.7056592p-87,
0x1.c0db62ap-116, -0x1.4cd8778p-145, -0x1.bef806cp-174, 0x1.63abdecp-204};
// Exponents of the least significant bits of the corresponding entries in
// THIRTYTWO_OVER_PI_28.
-static constexpr int THIRTYTWO_OVER_PI_28_LSB_EXP[N_ENTRIES] = {
+LIBC_INLINE_VAR constexpr int THIRTYTWO_OVER_PI_28_LSB_EXP[N_ENTRIES] = {
-24, -55, -81, -114, -143, -170, -200, -230};
// Return k and y, where
@@ -83,7 +85,9 @@ LIBC_INLINE int64_t large_range_reduction(double x, int x_exp, double &y) {
return static_cast<int64_t>(k_hi) + static_cast<int64_t>(k_lo);
}
-} // namespace generic
+} // namespace trigonometric_func_utils_internal
+
+} // namespace math
} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/__support/math/range_reduction_double_common.h b/libc/src/__support/math/range_reduction_double_common.h
index 5dda3f9ec43ea..5888ca5f833ef 100644
--- a/libc/src/__support/math/range_reduction_double_common.h
+++ b/libc/src/__support/math/range_reduction_double_common.h
@@ -25,12 +25,12 @@ namespace math {
namespace range_reduction_double_internal {
#ifdef LIBC_TARGET_CPU_HAS_FMA_DOUBLE
-static constexpr unsigned SPLIT = fputil::DefaultSplit<double>::VALUE;
+LIBC_INLINE_VAR constexpr unsigned SPLIT = fputil::DefaultSplit<double>::VALUE;
#else
// When there is no-FMA instructions, in order to have exact product of 2 double
// precision with directional roundings, we need to lower the precision of the
// constants by at least 1 bit, and use a
diff erent splitting constant.
-static constexpr unsigned SPLIT = 28;
+LIBC_INLINE_VAR constexpr unsigned SPLIT = 28;
#endif // LIBC_TARGET_CPU_HAS_FMA_DOUBLE
using LIBC_NAMESPACE::fputil::DoubleDouble;
@@ -44,7 +44,7 @@ using Float128 = LIBC_NAMESPACE::fputil::DyadicFloat<128>;
// Error bound:
// |(x - k * pi/128) - (u_hi + u_lo)| <= max(ulp(ulp(u_hi)), 2^-119)
// <= 2^-111.
-LIBC_INLINE static unsigned range_reduction_small(double x, DoubleDouble &u) {
+LIBC_INLINE unsigned range_reduction_small(double x, DoubleDouble &u) {
// Values of -pi/128 used for inputs with absolute value <= 2^16.
// The first 3 parts are generated with (53 - 21 = 32)-bit precision, so that
// the product k * MPI_OVER_128[i] is exact.
@@ -284,7 +284,7 @@ struct LargeRangeReduction {
};
#ifndef LIBC_MATH_HAS_SKIP_ACCURATE_PASS
-LIBC_INLINE static Float128 range_reduction_small_f128(double x) {
+LIBC_INLINE Float128 range_reduction_small_f128(double x) {
constexpr Float128 PI_OVER_128_F128 = {
Sign::POS, -133, 0xc90f'daa2'2168'c234'c4c6'628b'80dc'1cd1_u128};
constexpr double ONE_TWENTY_EIGHT_OVER_PI_D = 0x1.45f306dc9c883p5;
diff --git a/libc/src/__support/math/range_reduction_double_fma.h b/libc/src/__support/math/range_reduction_double_fma.h
index 7fa3e40522cf6..b03d7f08713a3 100644
--- a/libc/src/__support/math/range_reduction_double_fma.h
+++ b/libc/src/__support/math/range_reduction_double_fma.h
@@ -82,7 +82,7 @@ LIBC_INLINE unsigned LargeRangeReduction::fast(double x, DoubleDouble &u) {
// b = D(sin(k * pi/128) - a);
// print("{", b, ",", a, "},");
// };
-LIBC_INLINE constexpr DoubleDouble SIN_K_PI_OVER_128[] = {
+LIBC_INLINE_VAR constexpr DoubleDouble SIN_K_PI_OVER_128[] = {
{0, 0},
{-0x1.b1d63091a013p-64, 0x1.92155f7a3667ep-6},
{-0x1.912bd0d569a9p-61, 0x1.91f65f10dd814p-5},
diff --git a/libc/src/__support/math/range_reduction_double_nofma.h b/libc/src/__support/math/range_reduction_double_nofma.h
index 3990b9bcbd3bb..d3ad74b6ffb7d 100644
--- a/libc/src/__support/math/range_reduction_double_nofma.h
+++ b/libc/src/__support/math/range_reduction_double_nofma.h
@@ -85,7 +85,7 @@ LIBC_INLINE unsigned LargeRangeReduction::fast(double x, DoubleDouble &u) {
// b = round(sin(k * pi/128) - a, D, RN);
// print("{", b, ",", a, "},");
// };
-LIBC_INLINE constexpr DoubleDouble SIN_K_PI_OVER_128[] = {
+LIBC_INLINE_VAR constexpr DoubleDouble SIN_K_PI_OVER_128[] = {
{0, 0},
{0x1.f938a73db97fbp-58, 0x1.92155f7a3667cp-6},
{-0x1.912bd0d569a9p-61, 0x1.91f65f10dd814p-5},
diff --git a/libc/src/__support/math/range_reduction_fma.h b/libc/src/__support/math/range_reduction_fma.h
index d8676d0ad1c77..fe6d94946af7e 100644
--- a/libc/src/__support/math/range_reduction_fma.h
+++ b/libc/src/__support/math/range_reduction_fma.h
@@ -16,16 +16,18 @@
namespace LIBC_NAMESPACE_DECL {
-namespace fma {
+namespace math {
-static constexpr uint32_t FAST_PASS_BOUND = 0x5600'0000U; // 2^45
+namespace trigonometric_fma_utils_internal {
+
+LIBC_INLINE_VAR constexpr uint32_t FAST_PASS_BOUND = 0x5600'0000U; // 2^45
// Digits of 32/pi, generated by Sollya with:
// > a0 = D(32/pi);
// > a1 = D(32/pi - a0);
// > a2 = D(32/pi - a0 - a1);
// > a3 = D(32/pi - a0 - a1 - a2);
-static constexpr double THIRTYTWO_OVER_PI[5] = {
+LIBC_INLINE_VAR constexpr double THIRTYTWO_OVER_PI[5] = {
0x1.45f306dc9c883p+3, -0x1.6b01ec5417056p-51, -0x1.6447e493ad4cep-105,
0x1.e21c820ff28b2p-159, -0x1.508510ea79237p-214};
@@ -85,7 +87,9 @@ LIBC_INLINE int64_t large_range_reduction(double x, int x_exp, double &y) {
return static_cast<int64_t>(k_lo);
}
-} // namespace fma
+} // namespace trigonometric_fma_utils_internal
+
+} // namespace math
} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/__support/math/rsqrtf.h b/libc/src/__support/math/rsqrtf.h
index 5da1e73109488..1e98a5dbb428f 100644
--- a/libc/src/__support/math/rsqrtf.h
+++ b/libc/src/__support/math/rsqrtf.h
@@ -20,7 +20,7 @@
namespace LIBC_NAMESPACE_DECL {
namespace math {
-LIBC_INLINE static constexpr float rsqrtf(float x) {
+LIBC_INLINE constexpr float rsqrtf(float x) {
using FPBits = fputil::FPBits<float>;
FPBits xbits(x);
diff --git a/libc/src/__support/math/rsqrtf16.h b/libc/src/__support/math/rsqrtf16.h
index 30ab58f8a5798..ab7529682950d 100644
--- a/libc/src/__support/math/rsqrtf16.h
+++ b/libc/src/__support/math/rsqrtf16.h
@@ -24,7 +24,7 @@
namespace LIBC_NAMESPACE_DECL {
namespace math {
-LIBC_INLINE static constexpr float16 rsqrtf16(float16 x) {
+LIBC_INLINE constexpr float16 rsqrtf16(float16 x) {
using FPBits = fputil::FPBits<float16>;
FPBits xbits(x);
diff --git a/libc/src/__support/math/sincos_eval.h b/libc/src/__support/math/sincos_eval.h
index fc741af19551f..3c0bafc5cebf8 100644
--- a/libc/src/__support/math/sincos_eval.h
+++ b/libc/src/__support/math/sincos_eval.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLVM_LIBC_SRC_MATH_GENERIC_SINCOS_EVAL_H
-#define LLVM_LIBC_SRC_MATH_GENERIC_SINCOS_EVAL_H
+#ifndef LLVM_LIBC_SRC___SUPPORT_MATH_SINCOS_EVAL_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_SINCOS_EVAL_H
#include "src/__support/FPUtil/PolyEval.h"
#include "src/__support/FPUtil/double_double.h"
@@ -139,4 +139,4 @@ LIBC_INLINE void sincos_eval(const Float128 &u, Float128 &sin_u,
} // namespace LIBC_NAMESPACE_DECL
-#endif // LLVM_LIBC_SRC_MATH_GENERIC_SINCOSF_EVAL_H
+#endif // LLVM_LIBC_SRC___SUPPORT_MATH_SINCOS_EVAL_H
diff --git a/libc/src/__support/math/sincosf.h b/libc/src/__support/math/sincosf.h
index b6b6ffeb7e6b0..a6b1cd8ae3010 100644
--- a/libc/src/__support/math/sincosf.h
+++ b/libc/src/__support/math/sincosf.h
@@ -60,6 +60,7 @@ LIBC_INLINE_VAR constexpr uint32_t EXCEPT_OUTPUTS_COS[N_EXCEPTS][4] = {
LIBC_INLINE void sincosf(float x, float *sinp, float *cosp) {
using namespace sincosf_internal;
+ using namespace sincosf_utils_internal;
using FPBits = typename fputil::FPBits<float>;
FPBits xbits(x);
diff --git a/libc/src/__support/math/sincosf16_utils.h b/libc/src/__support/math/sincosf16_utils.h
index 74f21fd0a9dc4..cd91eaf711df2 100644
--- a/libc/src/__support/math/sincosf16_utils.h
+++ b/libc/src/__support/math/sincosf16_utils.h
@@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//
-#ifndef LLVM_LIBC_SRC_MATH_GENERIC_SINCOSF16_UTILS_H
-#define LLVM_LIBC_SRC_MATH_GENERIC_SINCOSF16_UTILS_H
+#ifndef LLVM_LIBC_SRC___SUPPORT_MATH_SINCOSF16_UTILS_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_SINCOSF16_UTILS_H
#include "src/__support/FPUtil/PolyEval.h"
#include "src/__support/FPUtil/nearest_integer.h"
@@ -16,13 +16,15 @@
namespace LIBC_NAMESPACE_DECL {
+namespace math {
+
namespace sincosf16_internal {
// Lookup table for sin(k * pi / 32) with k = 0, ..., 63.
// Table is generated with Sollya as follows:
// > display = hexadecimmal;
// > for k from 0 to 63 do { round(sin(k * pi/32), SG, RN); };
-constexpr float SIN_K_PI_OVER_32[64] = {
+LIBC_INLINE_VAR constexpr float SIN_K_PI_OVER_32[64] = {
0x0.0p0, 0x1.917a6cp-4, 0x1.8f8b84p-3, 0x1.294062p-2,
0x1.87de2ap-2, 0x1.e2b5d4p-2, 0x1.1c73b4p-1, 0x1.44cf32p-1,
0x1.6a09e6p-1, 0x1.8bc806p-1, 0x1.a9b662p-1, 0x1.c38b3p-1,
@@ -68,9 +70,9 @@ LIBC_INLINE int32_t range_reduction_sincosf16(float x, float &y) {
return static_cast<int32_t>(kd);
}
-LIBC_INLINE static void sincosf16_poly_eval(int32_t k, float y, float &sin_k,
- float &cos_k, float &sin_y,
- float &cosm1_y) {
+LIBC_INLINE void sincosf16_poly_eval(int32_t k, float y, float &sin_k,
+ float &cos_k, float &sin_y,
+ float &cosm1_y) {
sin_k = SIN_K_PI_OVER_32[k & 63];
cos_k = SIN_K_PI_OVER_32[(k + 16) & 63];
@@ -111,6 +113,8 @@ LIBC_INLINE void sincospif16_eval(float xf, float &sin_k, float &cos_k,
} // namespace sincosf16_internal
+} // namespace math
+
} // namespace LIBC_NAMESPACE_DECL
-#endif // LLVM_LIBC_SRC_MATH_GENERIC_SINCOSF16_UTILS_H
+#endif // LLVM_LIBC_SRC___SUPPORT_MATH_SINCOSF16_UTILS_H
diff --git a/libc/src/__support/math/sincosf_utils.h b/libc/src/__support/math/sincosf_utils.h
index b13a39999866d..8fbc8384f9e32 100644
--- a/libc/src/__support/math/sincosf_utils.h
+++ b/libc/src/__support/math/sincosf_utils.h
@@ -16,21 +16,32 @@
#if defined(LIBC_TARGET_CPU_HAS_FMA_DOUBLE)
#include "range_reduction_fma.h"
-// using namespace LIBC_NAMESPACE::fma;
-using LIBC_NAMESPACE::fma::FAST_PASS_BOUND;
-using LIBC_NAMESPACE::fma::large_range_reduction;
-using LIBC_NAMESPACE::fma::small_range_reduction;
-
#else
#include "range_reduction.h"
-// using namespace LIBC_NAMESPACE::generic;
-using LIBC_NAMESPACE::generic::FAST_PASS_BOUND;
-using LIBC_NAMESPACE::generic::large_range_reduction;
-using LIBC_NAMESPACE::generic::small_range_reduction;
#endif // LIBC_TARGET_CPU_HAS_FMA_DOUBLE
namespace LIBC_NAMESPACE_DECL {
+namespace math {
+
+namespace sincosf_utils_internal {
+
+#if defined(LIBC_TARGET_CPU_HAS_FMA_DOUBLE)
+
+// using namespace LIBC_NAMESPACE::fma;
+using math::trigonometric_fma_utils_internal::FAST_PASS_BOUND;
+using math::trigonometric_fma_utils_internal::large_range_reduction;
+using math::trigonometric_fma_utils_internal::small_range_reduction;
+
+#else
+
+// using namespace LIBC_NAMESPACE::generic;
+using math::trigonometric_func_utils_internal::FAST_PASS_BOUND;
+using math::trigonometric_func_utils_internal::large_range_reduction;
+using math::trigonometric_func_utils_internal::small_range_reduction;
+
+#endif // LIBC_TARGET_CPU_HAS_FMA_DOUBLE
+
// Lookup table for sin(k * pi / 32) with k = 0, ..., 63.
// Table is generated with Sollya as follow:
// > display = hexadecimal;
@@ -120,6 +131,10 @@ LIBC_INLINE void sincospif_eval(double xd, double &sin_k, double &cos_k,
sincosf_poly_eval(k, y, sin_k, cos_k, sin_y, cosm1_y);
}
+} // namespace sincosf_utils_internal
+
+} // namespace math
+
} // namespace LIBC_NAMESPACE_DECL
#endif // LLVM_LIBC_SRC___SUPPORT_MATH_SINCOSF_UTILS_H
diff --git a/libc/src/__support/math/sinf.h b/libc/src/__support/math/sinf.h
index 9290444b43619..c61beed749900 100644
--- a/libc/src/__support/math/sinf.h
+++ b/libc/src/__support/math/sinf.h
@@ -29,7 +29,7 @@ namespace LIBC_NAMESPACE_DECL {
namespace math {
-LIBC_INLINE static float sinf(float x) {
+LIBC_INLINE float sinf(float x) {
return math::sincosf_float_eval::sincosf_eval</*IS_SIN*/ true>(x);
}
@@ -51,7 +51,8 @@ namespace LIBC_NAMESPACE_DECL {
namespace math {
-LIBC_INLINE static float sinf(float x) {
+LIBC_INLINE float sinf(float x) {
+ using namespace sincosf_utils_internal;
using FPBits = typename fputil::FPBits<float>;
FPBits xbits(x);
diff --git a/libc/src/__support/math/sinf16.h b/libc/src/__support/math/sinf16.h
index e18d0cfbd262f..ec27c4ec61c53 100644
--- a/libc/src/__support/math/sinf16.h
+++ b/libc/src/__support/math/sinf16.h
@@ -44,7 +44,7 @@ LIBC_INLINE_VAR constexpr fputil::ExceptValues<float16, N_EXCEPTS>
} // namespace sinf16_internal
-LIBC_INLINE static float16 sinf16(float16 x) {
+LIBC_INLINE float16 sinf16(float16 x) {
using namespace sinf16_internal;
using namespace sincosf16_internal;
using FPBits = fputil::FPBits<float16>;
diff --git a/libc/src/__support/math/sinhf.h b/libc/src/__support/math/sinhf.h
index e8efc29aeac79..6af34412129fc 100644
--- a/libc/src/__support/math/sinhf.h
+++ b/libc/src/__support/math/sinhf.h
@@ -20,7 +20,7 @@ namespace LIBC_NAMESPACE_DECL {
namespace math {
-LIBC_INLINE static constexpr float sinhf(float x) {
+LIBC_INLINE constexpr float sinhf(float x) {
using FPBits = typename fputil::FPBits<float>;
FPBits xbits(x);
uint32_t x_abs = xbits.abs().uintval();
diff --git a/libc/src/__support/math/sinhf16.h b/libc/src/__support/math/sinhf16.h
index df9b82c967ae4..19ff5a3e12423 100644
--- a/libc/src/__support/math/sinhf16.h
+++ b/libc/src/__support/math/sinhf16.h
@@ -28,7 +28,7 @@ namespace LIBC_NAMESPACE_DECL {
namespace math {
-LIBC_INLINE static constexpr float16 sinhf16(float16 x) {
+LIBC_INLINE constexpr float16 sinhf16(float16 x) {
#ifndef LIBC_MATH_HAS_SKIP_ACCURATE_PASS
constexpr fputil::ExceptValues<float16, 17> SINHF16_EXCEPTS_POS = {{
diff --git a/libc/src/__support/math/sinpif.h b/libc/src/__support/math/sinpif.h
index 8f1570399f6c4..926e17ba6203c 100644
--- a/libc/src/__support/math/sinpif.h
+++ b/libc/src/__support/math/sinpif.h
@@ -21,7 +21,8 @@
namespace LIBC_NAMESPACE_DECL {
namespace math {
-LIBC_INLINE static float sinpif(float x) {
+LIBC_INLINE float sinpif(float x) {
+ using namespace sincosf_utils_internal;
using FPBits = typename fputil::FPBits<float>;
FPBits xbits(x);
diff --git a/libc/src/__support/math/sqrt.h b/libc/src/__support/math/sqrt.h
index 3faa62dea8eb1..baef03fca9587 100644
--- a/libc/src/__support/math/sqrt.h
+++ b/libc/src/__support/math/sqrt.h
@@ -15,7 +15,7 @@ namespace LIBC_NAMESPACE_DECL {
namespace math {
-LIBC_INLINE static double sqrt(double x) { return fputil::sqrt<double>(x); }
+LIBC_INLINE double sqrt(double x) { return fputil::sqrt<double>(x); }
} // namespace math
diff --git a/libc/src/__support/math/sqrtf.h b/libc/src/__support/math/sqrtf.h
index 4818dfee50a74..aaa25d91ee820 100644
--- a/libc/src/__support/math/sqrtf.h
+++ b/libc/src/__support/math/sqrtf.h
@@ -15,7 +15,7 @@ namespace LIBC_NAMESPACE_DECL {
namespace math {
-LIBC_INLINE static float sqrtf(float x) { return fputil::sqrt<float>(x); }
+LIBC_INLINE float sqrtf(float x) { return fputil::sqrt<float>(x); }
} // namespace math
diff --git a/libc/src/__support/math/sqrtf16.h b/libc/src/__support/math/sqrtf16.h
index 8c9e1e65177de..a1a11a7574ced 100644
--- a/libc/src/__support/math/sqrtf16.h
+++ b/libc/src/__support/math/sqrtf16.h
@@ -19,7 +19,7 @@
namespace LIBC_NAMESPACE_DECL {
namespace math {
-LIBC_INLINE static constexpr float16 sqrtf16(float16 x) {
+LIBC_INLINE constexpr float16 sqrtf16(float16 x) {
return fputil::sqrt<float16>(x);
}
diff --git a/libc/src/__support/math/tan.h b/libc/src/__support/math/tan.h
index f7566bda360ea..27cd4b7a044ab 100644
--- a/libc/src/__support/math/tan.h
+++ b/libc/src/__support/math/tan.h
@@ -38,8 +38,7 @@ namespace tan_internal {
using DoubleDouble = fputil::DoubleDouble;
using Float128 = typename fputil::DyadicFloat<128>;
-LIBC_INLINE static double tan_eval(const DoubleDouble &u,
- DoubleDouble &result) {
+LIBC_INLINE double tan_eval(const DoubleDouble &u, DoubleDouble &result) {
// Evaluate tan(y) = tan(x - k * (pi/128))
// We use the degree-9 Taylor approximation:
// tan(y) ~ P(y) = y + y^3/3 + 2*y^5/15 + 17*y^7/315 + 62*y^9/2835
@@ -77,7 +76,7 @@ LIBC_INLINE static double tan_eval(const DoubleDouble &u,
#ifndef LIBC_MATH_HAS_SKIP_ACCURATE_PASS
// Accurate evaluation of tan for small u.
-[[maybe_unused]] LIBC_INLINE static Float128 tan_eval(const Float128 &u) {
+[[maybe_unused]] LIBC_INLINE Float128 tan_eval(const Float128 &u) {
Float128 u_sq = fputil::quick_mul(u, u);
// tan(x) ~ x + x^3/3 + x^5 * 2/15 + x^7 * 17/315 + x^9 * 62/2835 +
@@ -124,7 +123,7 @@ LIBC_INLINE static double tan_eval(const DoubleDouble &u,
} // namespace tan_internal
-LIBC_INLINE static double tan(double x) {
+LIBC_INLINE double tan(double x) {
using namespace tan_internal;
using namespace math::range_reduction_double_internal;
using FPBits = typename fputil::FPBits<double>;
diff --git a/libc/src/__support/math/tanf.h b/libc/src/__support/math/tanf.h
index 139de3c593ad4..3a1d8e8bd53b6 100644
--- a/libc/src/__support/math/tanf.h
+++ b/libc/src/__support/math/tanf.h
@@ -49,7 +49,8 @@ LIBC_INLINE_VAR constexpr fputil::ExceptValues<float, N_EXCEPTS> TANF_EXCEPTS{{
} // namespace tanf_internal
-LIBC_INLINE static float tanf(float x) {
+LIBC_INLINE float tanf(float x) {
+ using namespace sincosf_utils_internal;
using namespace tanf_internal;
using FPBits = typename fputil::FPBits<float>;
FPBits xbits(x);
diff --git a/libc/src/math/generic/sinpif16.cpp b/libc/src/math/generic/sinpif16.cpp
index 311e6f989ebf1..94cbd33b76f9e 100644
--- a/libc/src/math/generic/sinpif16.cpp
+++ b/libc/src/math/generic/sinpif16.cpp
@@ -18,7 +18,7 @@
namespace LIBC_NAMESPACE_DECL {
LLVM_LIBC_FUNCTION(float16, sinpif16, (float16 x)) {
- using namespace sincosf16_internal;
+ using namespace math::sincosf16_internal;
using FPBits = typename fputil::FPBits<float16>;
FPBits xbits(x);
diff --git a/libc/src/math/generic/tanf16.cpp b/libc/src/math/generic/tanf16.cpp
index 20323a88f3527..880ba0101a96e 100644
--- a/libc/src/math/generic/tanf16.cpp
+++ b/libc/src/math/generic/tanf16.cpp
@@ -37,7 +37,7 @@ constexpr fputil::ExceptValues<float16, N_EXCEPTS> TANF16_EXCEPTS{{
#endif // !LIBC_MATH_HAS_SKIP_ACCURATE_PASS
LLVM_LIBC_FUNCTION(float16, tanf16, (float16 x)) {
- using namespace sincosf16_internal;
+ using namespace math::sincosf16_internal;
using FPBits = fputil::FPBits<float16>;
FPBits xbits(x);
diff --git a/libc/src/math/generic/tanpif.cpp b/libc/src/math/generic/tanpif.cpp
index b49f3cea4911b..44df22b517a46 100644
--- a/libc/src/math/generic/tanpif.cpp
+++ b/libc/src/math/generic/tanpif.cpp
@@ -31,6 +31,7 @@ constexpr fputil::ExceptValues<float, N_EXCEPTS> TANPIF_EXCEPTS{{
#endif // !LIBC_MATH_HAS_SKIP_ACCURATE_PASS
LLVM_LIBC_FUNCTION(float, tanpif, (float x)) {
+ using namespace math::sincosf_utils_internal;
using FPBits = typename fputil::FPBits<float>;
FPBits xbits(x);
diff --git a/libc/src/math/generic/tanpif16.cpp b/libc/src/math/generic/tanpif16.cpp
index b137b09860f7c..c8dbe9eaf7d6f 100644
--- a/libc/src/math/generic/tanpif16.cpp
+++ b/libc/src/math/generic/tanpif16.cpp
@@ -39,7 +39,7 @@ constexpr fputil::ExceptValues<float16, N_EXCEPTS> TANPIF16_EXCEPTS{{
#endif // !LIBC_MATH_HAS_SKIP_ACCURATE_PASS
LLVM_LIBC_FUNCTION(float16, tanpif16, (float16 x)) {
- using namespace sincosf16_internal;
+ using namespace math::sincosf16_internal;
using FPBits = typename fputil::FPBits<float16>;
FPBits xbits(x);
More information about the libc-commits
mailing list