Skip to content

Commit 2865f1b

Browse files
authored
[libc][math] add smoke tests to shared/math.h (llvm#149741)
Adding smoke tests for shared math header. part of llvm#147386
1 parent f7347e9 commit 2865f1b

File tree

12 files changed

+112
-6
lines changed

12 files changed

+112
-6
lines changed

libc/shared/math/exp10f16.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010
#define LLVM_LIBC_SHARED_MATH_EXP10F_H
1111

1212
#include "include/llvm-libc-macros/float16-macros.h"
13+
#include "shared/libc_common.h"
1314

1415
#ifdef LIBC_TYPES_HAS_FLOAT16
1516

16-
#include "shared/libc_common.h"
1717
#include "src/__support/math/exp10f16.h"
1818

1919
namespace LIBC_NAMESPACE_DECL {

libc/src/__support/math/acos.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ namespace LIBC_NAMESPACE_DECL {
2424

2525
namespace math {
2626

27-
using DoubleDouble = fputil::DoubleDouble;
28-
using Float128 = fputil::DyadicFloat<128>;
29-
3027
static constexpr double acos(double x) {
28+
using DoubleDouble = fputil::DoubleDouble;
29+
using Float128 = fputil::DyadicFloat<128>;
30+
using namespace asin_internal;
3131
using FPBits = fputil::FPBits<double>;
3232

3333
FPBits xbits(x);

libc/src/__support/math/acosf.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@ namespace LIBC_NAMESPACE_DECL {
2222

2323
namespace math {
2424

25+
namespace acosf_internal {
26+
2527
#ifndef LIBC_MATH_HAS_SKIP_ACCURATE_PASS
28+
2629
static constexpr size_t N_EXCEPTS = 4;
2730

2831
// Exceptional values when |x| <= 0.5
@@ -37,9 +40,14 @@ static constexpr fputil::ExceptValues<float, N_EXCEPTS> ACOSF_EXCEPTS = {{
3740
// x = -0x1.04c444p-12, acosf(x) = 0x1.923p0 (RZ)
3841
{0xb9826222, 0x3fc91800, 1, 0, 1},
3942
}};
43+
4044
#endif // !LIBC_MATH_HAS_SKIP_ACCURATE_PASS
4145

46+
} // namespace acosf_internal
47+
4248
static constexpr float acosf(float x) {
49+
using namespace acosf_internal;
50+
using namespace inv_trigf_utils_internal;
4351
using FPBits = typename fputil::FPBits<float>;
4452

4553
FPBits xbits(x);

libc/src/__support/math/asin_utils.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
namespace LIBC_NAMESPACE_DECL {
2121

22-
namespace {
22+
namespace asin_internal {
2323

2424
using DoubleDouble = fputil::DoubleDouble;
2525
using Float128 = fputil::DyadicFloat<128>;
@@ -567,7 +567,7 @@ LIBC_INLINE static constexpr Float128 asin_eval(const Float128 &u,
567567

568568
#endif // LIBC_MATH_HAS_SKIP_ACCURATE_PASS
569569

570-
} // anonymous namespace
570+
} // namespace asin_internal
571571

572572
} // namespace LIBC_NAMESPACE_DECL
573573

libc/src/__support/math/inv_trigf_utils.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
namespace LIBC_NAMESPACE_DECL {
1818

19+
namespace inv_trigf_utils_internal {
20+
1921
// PI and PI / 2
2022
static constexpr double M_MATH_PI = 0x1.921fb54442d18p+1;
2123
static constexpr double M_MATH_PI_2 = 0x1.921fb54442d18p+0;
@@ -175,6 +177,8 @@ LIBC_INLINE static double asin_eval(double xsq) {
175177
return fputil::multiply_add(xsq, r2, r1);
176178
}
177179

180+
} // namespace inv_trigf_utils_internal
181+
178182
} // namespace LIBC_NAMESPACE_DECL
179183

180184
#endif // LLVM_LIBC_SRC___SUPPORT_MATH_INV_TRIGF_UTILS_H

libc/src/math/generic/asin.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ using DoubleDouble = fputil::DoubleDouble;
2525
using Float128 = fputil::DyadicFloat<128>;
2626

2727
LLVM_LIBC_FUNCTION(double, asin, (double x)) {
28+
using namespace asin_internal;
2829
using FPBits = fputil::FPBits<double>;
2930

3031
FPBits xbits(x);

libc/src/math/generic/asinf.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ static constexpr fputil::ExceptValues<float, N_EXCEPTS> ASINF_EXCEPTS_HI = {{
4444
#endif // !LIBC_MATH_HAS_SKIP_ACCURATE_PASS
4545

4646
LLVM_LIBC_FUNCTION(float, asinf, (float x)) {
47+
using namespace inv_trigf_utils_internal;
4748
using FPBits = typename fputil::FPBits<float>;
4849

4950
FPBits xbits(x);

libc/src/math/generic/atan2f.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,7 @@ float atan2f_double_double(double num_d, double den_d, double q_d, int idx,
236236
// which is about rounding errors of double-double (2^-104).
237237

238238
LLVM_LIBC_FUNCTION(float, atan2f, (float y, float x)) {
239+
using namespace inv_trigf_utils_internal;
239240
using FPBits = typename fputil::FPBits<float>;
240241
constexpr double IS_NEG[2] = {1.0, -1.0};
241242
constexpr double PI = 0x1.921fb54442d18p1;

libc/src/math/generic/atanf.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
namespace LIBC_NAMESPACE_DECL {
2121

2222
LLVM_LIBC_FUNCTION(float, atanf, (float x)) {
23+
using namespace inv_trigf_utils_internal;
2324
using FPBits = typename fputil::FPBits<float>;
2425

2526
constexpr double FINAL_SIGN[2] = {1.0, -1.0};

libc/test/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ endif()
2020

2121
add_subdirectory(src)
2222
add_subdirectory(utils)
23+
add_subdirectory(shared)
2324

2425
if(NOT LLVM_LIBC_FULL_BUILD)
2526
return()

0 commit comments

Comments
 (0)