Skip to content

Commit 4b0635e

Browse files
committed
[libc][math] Refactor exp10 implementation to header-only in src/__support/math folder.
1 parent 2f2b773 commit 4b0635e

File tree

8 files changed

+575
-510
lines changed

8 files changed

+575
-510
lines changed

libc/shared/math.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include "libc_common.h"
1313

1414
#include "math/exp.h"
15+
#include "math/exp10.h"
1516
#include "math/expf.h"
1617
#include "math/expf16.h"
1718
#include "math/frexpf.h"

libc/shared/math/exp10.h

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
//===-- Shared exp10 function -----------------------------------*- C++ -*-===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#ifndef LLVM_LIBC_SHARED_MATH_EXP10_H
10+
#define LLVM_LIBC_SHARED_MATH_EXP10_H
11+
12+
#include "shared/libc_common.h"
13+
#include "src/__support/math/exp10.h"
14+
15+
namespace LIBC_NAMESPACE_DECL {
16+
namespace shared {
17+
18+
using math::exp10;
19+
20+
} // namespace shared
21+
} // namespace LIBC_NAMESPACE_DECL
22+
23+
#endif // LLVM_LIBC_SHARED_MATH_EXP10_H

libc/src/__support/FPUtil/double_double.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,8 @@ LIBC_INLINE DoubleDouble quick_mult(double a, const DoubleDouble &b) {
151151
}
152152

153153
template <size_t SPLIT_B = 27>
154-
LIBC_INLINE DoubleDouble quick_mult(const DoubleDouble &a,
155-
const DoubleDouble &b) {
154+
LIBC_INLINE constexpr DoubleDouble quick_mult(const DoubleDouble &a,
155+
const DoubleDouble &b) {
156156
DoubleDouble r = exact_mult<double, SPLIT_B>(a.hi, b.hi);
157157
double t1 = multiply_add(a.hi, b.lo, r.lo);
158158
double t2 = multiply_add(a.lo, b.hi, t1);

libc/src/__support/math/CMakeLists.txt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,3 +149,24 @@ add_header_library(
149149
libc.src.__support.integer_literals
150150
libc.src.__support.macros.optimization
151151
)
152+
153+
add_header_library(
154+
exp10
155+
HDRS
156+
exp10.h
157+
DEPENDS
158+
.exp_constants
159+
.exp_utils
160+
libc.src.__support.CPP.bit
161+
libc.src.__support.CPP.optional
162+
libc.src.__support.FPUtil.dyadic_float
163+
libc.src.__support.FPUtil.fenv_impl
164+
libc.src.__support.FPUtil.fp_bits
165+
libc.src.__support.FPUtil.multiply_add
166+
libc.src.__support.FPUtil.nearest_integer
167+
libc.src.__support.FPUtil.polyeval
168+
libc.src.__support.FPUtil.rounding_mode
169+
libc.src.__support.FPUtil.triple_double
170+
libc.src.__support.integer_literals
171+
libc.src.__support.macros.optimization
172+
)

0 commit comments

Comments
 (0)