Skip to content

Commit 003f6ad

Browse files
authored
[libc][math] Refactor cbrt implementation to header-only in src/__support/math folder. (#151837)
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 a048aeb commit 003f6ad

File tree

9 files changed

+406
-338
lines changed

9 files changed

+406
-338
lines changed

libc/shared/math.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include "math/atanf16.h"
3131
#include "math/atanhf.h"
3232
#include "math/atanhf16.h"
33+
#include "math/cbrt.h"
3334
#include "math/erff.h"
3435
#include "math/exp.h"
3536
#include "math/exp10.h"

libc/shared/math/cbrt.h

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

libc/src/__support/math/CMakeLists.txt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,21 @@ add_header_library(
331331
libc.src.__support.macros.optimization
332332
)
333333

334+
add_header_library(
335+
cbrt
336+
HDRS
337+
cbrt.h
338+
DEPENDS
339+
libc.src.__support.FPUtil.double_double
340+
libc.src.__support.FPUtil.dyadic_float
341+
libc.src.__support.FPUtil.fenv_impl
342+
libc.src.__support.FPUtil.fp_bits
343+
libc.src.__support.FPUtil.multiply_add
344+
libc.src.__support.FPUtil.polyeval
345+
libc.src.__support.macros.optimization
346+
libc.src.__support.integer_literals
347+
)
348+
334349
add_header_library(
335350
erff
336351
HDRS

0 commit comments

Comments
 (0)