Skip to content

Commit 2fd1d64

Browse files
committed
make explogxf header-only
1 parent b12ff3f commit 2fd1d64

File tree

5 files changed

+1
-122
lines changed

5 files changed

+1
-122
lines changed

libc/src/math/generic/CMakeLists.txt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3766,12 +3766,10 @@ add_entrypoint_object(
37663766
)
37673767

37683768
#TODO: Add errno include to the hyperbolic functions.
3769-
add_object_library(
3769+
add_header_library(
37703770
explogxf
37713771
HDRS
37723772
explogxf.h
3773-
SRCS
3774-
explogxf.cpp
37753773
DEPENDS
37763774
.common_constants
37773775
libc.src.__support.math.exp_utils

libc/src/math/generic/explogxf.cpp

Lines changed: 0 additions & 75 deletions
This file was deleted.

libc/src/math/generic/explogxf.h

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,6 @@ namespace LIBC_NAMESPACE_DECL {
2121
constexpr int LOG_P1_BITS = 6;
2222
constexpr int LOG_P1_SIZE = 1 << LOG_P1_BITS;
2323

24-
// N[Table[Log[2, 1 + x], {x, 0/64, 63/64, 1/64}], 40]
25-
extern const double LOG_P1_LOG2[LOG_P1_SIZE];
26-
27-
// N[Table[1/(1 + x), {x, 0/64, 63/64, 1/64}], 40]
28-
extern const double LOG_P1_1_OVER[LOG_P1_SIZE];
29-
30-
// Taylor series expansion for Log[2, 1 + x] splitted to EVEN AND ODD numbers
31-
// K_LOG2_ODD starts from x^3
32-
extern const double K_LOG2_ODD[4];
33-
extern const double K_LOG2_EVEN[4];
34-
3524
// The function correctly calculates sinh(x) and cosh(x) by calculating exp(x)
3625
// and exp(-x) simultaneously.
3726
// To compute e^x, we perform the following range
@@ -131,33 +120,6 @@ template <bool is_sinh> LIBC_INLINE double exp_pm_eval(float x) {
131120
return r;
132121
}
133122

134-
// x should be positive, normal finite value
135-
LIBC_INLINE static double log2_eval(double x) {
136-
using FPB = fputil::FPBits<double>;
137-
FPB bs(x);
138-
139-
double result = 0;
140-
result += bs.get_exponent();
141-
142-
int p1 = (bs.get_mantissa() >> (FPB::FRACTION_LEN - LOG_P1_BITS)) &
143-
(LOG_P1_SIZE - 1);
144-
145-
bs.set_uintval(bs.uintval() & (FPB::FRACTION_MASK >> LOG_P1_BITS));
146-
bs.set_biased_exponent(FPB::EXP_BIAS);
147-
double dx = (bs.get_val() - 1.0) * LOG_P1_1_OVER[p1];
148-
149-
// Taylor series for log(2,1+x)
150-
double c1 = fputil::multiply_add(dx, K_LOG2_ODD[0], K_LOG2_EVEN[0]);
151-
double c2 = fputil::multiply_add(dx, K_LOG2_ODD[1], K_LOG2_EVEN[1]);
152-
double c3 = fputil::multiply_add(dx, K_LOG2_ODD[2], K_LOG2_EVEN[2]);
153-
double c4 = fputil::multiply_add(dx, K_LOG2_ODD[3], K_LOG2_EVEN[3]);
154-
155-
// c0 = dx * (1.0 / ln(2)) + LOG_P1_LOG2[p1]
156-
double c0 = fputil::multiply_add(dx, 0x1.71547652b82fep+0, LOG_P1_LOG2[p1]);
157-
result += LIBC_NAMESPACE::fputil::polyeval(dx * dx, c0, c1, c2, c3, c4);
158-
return result;
159-
}
160-
161123
// x should be positive, normal finite value
162124
// TODO: Simplify range reduction and polynomial degree for float16.
163125
// See issue #137190.

libc/test/src/math/explogxf_test.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,6 @@ TEST_F(LlvmLibcExplogfTest, ExpInFloatRange) {
4343
def_prec);
4444
}
4545

46-
TEST_F(LlvmLibcExplogfTest, Log2InFloatRange) {
47-
CHECK_DATA(0.0f, inf, mpfr::Operation::Log2, LIBC_NAMESPACE::log2_eval,
48-
f_normal, def_count, def_prec);
49-
}
50-
5146
TEST_F(LlvmLibcExplogfTest, LogInFloatRange) {
5247
CHECK_DATA(0.0f, inf, mpfr::Operation::Log, LIBC_NAMESPACE::log_eval,
5348
f_normal, def_count, def_prec);

utils/bazel/llvm-project-overlay/libc/BUILD.bazel

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1996,7 +1996,6 @@ libc_support_library(
19961996

19971997
libc_support_library(
19981998
name = "explogxf",
1999-
srcs = ["src/math/generic/explogxf.cpp"],
20001999
hdrs = ["src/math/generic/explogxf.h"],
20012000
deps = [
20022001
":__support_fputil_fenv_impl",

0 commit comments

Comments
 (0)