Skip to content

Commit a76dfde

Browse files
authored
[libc][math] Refactor exp implementation to header-only in src/__support/math folder. (#148091)
Part of #147386 in preparation for: https://discourse.llvm.org/t/rfc-make-clang-builtin-math-functions-constexpr-with-llvm-libc-to-support-c-23-constexpr-math-functions/86450
1 parent 9609655 commit a76dfde

File tree

12 files changed

+809
-677
lines changed

12 files changed

+809
-677
lines changed

libc/shared/math.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
#include "libc_common.h"
1313

14+
#include "math/exp.h"
1415
#include "math/expf.h"
1516
#include "math/expf16.h"
1617
#include "math/frexpf.h"

libc/shared/math/exp.h

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
//===-- Shared exp 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_EXP_H
10+
#define LLVM_LIBC_SHARED_MATH_EXP_H
11+
12+
#include "shared/libc_common.h"
13+
#include "src/__support/math/exp.h"
14+
15+
namespace LIBC_NAMESPACE_DECL {
16+
namespace shared {
17+
18+
using math::exp;
19+
20+
} // namespace shared
21+
} // namespace LIBC_NAMESPACE_DECL
22+
23+
#endif // LLVM_LIBC_SHARED_MATH_EXP_H

libc/src/__support/math/CMakeLists.txt

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,3 +110,42 @@ add_header_library(
110110
DEPENDS
111111
libc.src.__support.FPUtil.manipulation_functions
112112
)
113+
114+
add_header_library(
115+
exp_constants
116+
HDRS
117+
exp_constants.h
118+
DEPENDS
119+
libc.src.__support.FPUtil.triple_double
120+
)
121+
122+
add_header_library(
123+
exp_utils
124+
HDRS
125+
exp_utils.h
126+
DEPENDS
127+
libc.src.__support.CPP.optional
128+
libc.src.__support.CPP.bit
129+
libc.src.__support.FPUtil.fp_bits
130+
)
131+
132+
add_header_library(
133+
exp
134+
HDRS
135+
exp.h
136+
DEPENDS
137+
.exp_constants
138+
.exp_utils
139+
libc.src.__support.CPP.bit
140+
libc.src.__support.CPP.optional
141+
libc.src.__support.FPUtil.dyadic_float
142+
libc.src.__support.FPUtil.fenv_impl
143+
libc.src.__support.FPUtil.fp_bits
144+
libc.src.__support.FPUtil.multiply_add
145+
libc.src.__support.FPUtil.nearest_integer
146+
libc.src.__support.FPUtil.polyeval
147+
libc.src.__support.FPUtil.rounding_mode
148+
libc.src.__support.FPUtil.triple_double
149+
libc.src.__support.integer_literals
150+
libc.src.__support.macros.optimization
151+
)

0 commit comments

Comments
 (0)