[libc-commits] [libc] [llvm] [libc][math] Refactor ceil family to header-only (PR #182121)
via libc-commits
libc-commits at lists.llvm.org
Wed Feb 18 12:12:32 PST 2026
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-libc
Author: Mohamed Emad (hulxv)
<details>
<summary>Changes</summary>
Refactors the ceil math family to be header-only.
Closes https://github.com/llvm/llvm-project/issues/182120
Target Functions:
- ceil
- ceilbf16
- ceilf
- ceilf128
- ceilf16
- ceill
---
Patch is 26.31 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/182121.diff
24 Files Affected:
- (modified) libc/shared/math.h (+6)
- (added) libc/shared/math/ceil.h (+22)
- (added) libc/shared/math/ceilbf16.h (+22)
- (added) libc/shared/math/ceilf.h (+22)
- (added) libc/shared/math/ceilf128.h (+28)
- (added) libc/shared/math/ceilf16.h (+28)
- (added) libc/shared/math/ceill.h (+22)
- (modified) libc/src/__support/math/CMakeLists.txt (+52)
- (added) libc/src/__support/math/ceil.h (+30)
- (added) libc/src/__support/math/ceilbf16.h (+25)
- (added) libc/src/__support/math/ceilf.h (+30)
- (added) libc/src/__support/math/ceilf128.h (+30)
- (added) libc/src/__support/math/ceilf16.h (+39)
- (added) libc/src/__support/math/ceill.h (+26)
- (modified) libc/src/math/generic/CMakeLists.txt (+6-22)
- (modified) libc/src/math/generic/ceil.cpp (+2-10)
- (modified) libc/src/math/generic/ceilbf16.cpp (+4-5)
- (modified) libc/src/math/generic/ceilf.cpp (+2-10)
- (modified) libc/src/math/generic/ceilf128.cpp (+4-4)
- (modified) libc/src/math/generic/ceilf16.cpp (+2-13)
- (modified) libc/src/math/generic/ceill.cpp (+2-4)
- (modified) libc/test/shared/CMakeLists.txt (+6)
- (modified) libc/test/shared/shared_math_test.cpp (+12)
- (modified) utils/bazel/llvm-project-overlay/libc/BUILD.bazel (+88-5)
``````````diff
diff --git a/libc/shared/math.h b/libc/shared/math.h
index 8a5aca82c6ec3..ca187b9c3a7df 100644
--- a/libc/shared/math.h
+++ b/libc/shared/math.h
@@ -45,6 +45,12 @@
#include "math/canonicalizel.h"
#include "math/cbrt.h"
#include "math/cbrtf.h"
+#include "math/ceil.h"
+#include "math/ceilbf16.h"
+#include "math/ceilf.h"
+#include "math/ceilf128.h"
+#include "math/ceilf16.h"
+#include "math/ceill.h"
#include "math/cos.h"
#include "math/cosf.h"
#include "math/cosf16.h"
diff --git a/libc/shared/math/ceil.h b/libc/shared/math/ceil.h
new file mode 100644
index 0000000000000..ecbe5699cbc61
--- /dev/null
+++ b/libc/shared/math/ceil.h
@@ -0,0 +1,22 @@
+//===-- Shared ceil function ------------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SHARED_MATH_CEIL_H
+#define LLVM_LIBC_SHARED_MATH_CEIL_H
+
+#include "src/__support/math/ceil.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::ceil;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SHARED_MATH_CEIL_H
diff --git a/libc/shared/math/ceilbf16.h b/libc/shared/math/ceilbf16.h
new file mode 100644
index 0000000000000..a72a77c237324
--- /dev/null
+++ b/libc/shared/math/ceilbf16.h
@@ -0,0 +1,22 @@
+//===-- Shared ceilbf16 function --------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SHARED_MATH_CEILBF16_H
+#define LLVM_LIBC_SHARED_MATH_CEILBF16_H
+
+#include "src/__support/math/ceilbf16.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::ceilbf16;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SHARED_MATH_CEILBF16_H
diff --git a/libc/shared/math/ceilf.h b/libc/shared/math/ceilf.h
new file mode 100644
index 0000000000000..9cae81ee98e1e
--- /dev/null
+++ b/libc/shared/math/ceilf.h
@@ -0,0 +1,22 @@
+//===-- Shared ceilf function -----------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SHARED_MATH_CEILF_H
+#define LLVM_LIBC_SHARED_MATH_CEILF_H
+
+#include "src/__support/math/ceilf.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::ceilf;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SHARED_MATH_CEILF_H
diff --git a/libc/shared/math/ceilf128.h b/libc/shared/math/ceilf128.h
new file mode 100644
index 0000000000000..08500bb46a022
--- /dev/null
+++ b/libc/shared/math/ceilf128.h
@@ -0,0 +1,28 @@
+//===-- Shared ceilf128 function --------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SHARED_MATH_CEILF128_H
+#define LLVM_LIBC_SHARED_MATH_CEILF128_H
+
+#include "include/llvm-libc-types/float128.h"
+
+#ifdef LIBC_TYPES_HAS_FLOAT128
+
+#include "src/__support/math/ceilf128.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::ceilf128;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LIBC_TYPES_HAS_FLOAT128
+
+#endif // LLVM_LIBC_SHARED_MATH_CEILF128_H
diff --git a/libc/shared/math/ceilf16.h b/libc/shared/math/ceilf16.h
new file mode 100644
index 0000000000000..0758fd3d79158
--- /dev/null
+++ b/libc/shared/math/ceilf16.h
@@ -0,0 +1,28 @@
+//===-- Shared ceilf16 function ---------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SHARED_MATH_CEILF16_H
+#define LLVM_LIBC_SHARED_MATH_CEILF16_H
+
+#include "include/llvm-libc-macros/float16-macros.h"
+
+#ifdef LIBC_TYPES_HAS_FLOAT16
+
+#include "src/__support/math/ceilf16.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::ceilf16;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LIBC_TYPES_HAS_FLOAT16
+
+#endif // LLVM_LIBC_SHARED_MATH_CEILF16_H
diff --git a/libc/shared/math/ceill.h b/libc/shared/math/ceill.h
new file mode 100644
index 0000000000000..d3bc61d150c4d
--- /dev/null
+++ b/libc/shared/math/ceill.h
@@ -0,0 +1,22 @@
+//===-- Shared ceill function -----------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SHARED_MATH_CEILL_H
+#define LLVM_LIBC_SHARED_MATH_CEILL_H
+
+#include "src/__support/math/ceill.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::ceill;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SHARED_MATH_CEILL_H
diff --git a/libc/src/__support/math/CMakeLists.txt b/libc/src/__support/math/CMakeLists.txt
index e21fe8ef0ab93..0b5854ab6fe66 100644
--- a/libc/src/__support/math/CMakeLists.txt
+++ b/libc/src/__support/math/CMakeLists.txt
@@ -475,6 +475,58 @@ add_header_library(
libc.src.__support.FPUtil.multiply_add
libc.src.__support.macros.optimization
)
+add_header_library(
+ ceil
+ HDRS
+ ceil.h
+ DEPENDS
+ libc.src.__support.FPUtil.nearest_integer_operations
+ libc.src.__support.macros.config
+)
+add_header_library(
+ ceilbf16
+ HDRS
+ ceilbf16.h
+ DEPENDS
+ libc.src.__support.FPUtil.bfloat16
+ libc.src.__support.FPUtil.nearest_integer_operations
+ libc.src.__support.macros.config
+)
+add_header_library(
+ ceilf
+ HDRS
+ ceilf.h
+ DEPENDS
+ libc.src.__support.FPUtil.nearest_integer_operations
+ libc.src.__support.macros.config
+)
+add_header_library(
+ ceilf128
+ HDRS
+ ceilf128.h
+ DEPENDS
+ libc.include.llvm-libc-types.float128
+ libc.src.__support.FPUtil.nearest_integer_operations
+ libc.src.__support.macros.config
+)
+add_header_library(
+ ceilf16
+ HDRS
+ ceilf16.h
+ DEPENDS
+ libc.include.llvm-libc-macros.float16_macros
+ libc.src.__support.FPUtil.cast
+ libc.src.__support.FPUtil.nearest_integer_operations
+ libc.src.__support.macros.config
+)
+add_header_library(
+ ceill
+ HDRS
+ ceill.h
+ DEPENDS
+ libc.src.__support.FPUtil.nearest_integer_operations
+ libc.src.__support.macros.config
+)
add_header_library(
common_constants
diff --git a/libc/src/__support/math/ceil.h b/libc/src/__support/math/ceil.h
new file mode 100644
index 0000000000000..7c5ca6ed222d8
--- /dev/null
+++ b/libc/src/__support/math/ceil.h
@@ -0,0 +1,30 @@
+//===-- Implementation header for ceil --------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC___SUPPORT_MATH_CEIL_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_CEIL_H
+
+#include "src/__support/FPUtil/NearestIntegerOperations.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+namespace math {
+
+LIBC_INLINE constexpr double ceil(double x) {
+#ifdef __LIBC_USE_BUILTIN_CEIL_FLOOR_RINT_TRUNC
+ return __builtin_ceil(x);
+#else
+ return fputil::ceil(x);
+#endif
+}
+
+} // namespace math
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC___SUPPORT_MATH_CEIL_H
diff --git a/libc/src/__support/math/ceilbf16.h b/libc/src/__support/math/ceilbf16.h
new file mode 100644
index 0000000000000..83d0c9484e21e
--- /dev/null
+++ b/libc/src/__support/math/ceilbf16.h
@@ -0,0 +1,25 @@
+//===-- Implementation header for ceilbf16 ----------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC___SUPPORT_MATH_CEILBF16_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_CEILBF16_H
+
+#include "src/__support/FPUtil/NearestIntegerOperations.h"
+#include "src/__support/FPUtil/bfloat16.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+namespace math {
+
+LIBC_INLINE constexpr bfloat16 ceilbf16(bfloat16 x) { return fputil::ceil(x); }
+
+} // namespace math
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC___SUPPORT_MATH_CEILBF16_H
diff --git a/libc/src/__support/math/ceilf.h b/libc/src/__support/math/ceilf.h
new file mode 100644
index 0000000000000..4ab62725a6789
--- /dev/null
+++ b/libc/src/__support/math/ceilf.h
@@ -0,0 +1,30 @@
+//===-- Implementation header for ceilf -------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC___SUPPORT_MATH_CEILF_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_CEILF_H
+
+#include "src/__support/FPUtil/NearestIntegerOperations.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+namespace math {
+
+LIBC_INLINE constexpr float ceilf(float x) {
+#ifdef __LIBC_USE_BUILTIN_CEIL_FLOOR_RINT_TRUNC
+ return __builtin_ceilf(x);
+#else
+ return fputil::ceil(x);
+#endif
+}
+
+} // namespace math
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC___SUPPORT_MATH_CEILF_H
diff --git a/libc/src/__support/math/ceilf128.h b/libc/src/__support/math/ceilf128.h
new file mode 100644
index 0000000000000..20ca1869d17e7
--- /dev/null
+++ b/libc/src/__support/math/ceilf128.h
@@ -0,0 +1,30 @@
+//===-- Implementation header for ceilf128 ----------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC___SUPPORT_MATH_CEILF128_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_CEILF128_H
+
+#include "include/llvm-libc-types/float128.h"
+
+#ifdef LIBC_TYPES_HAS_FLOAT128
+
+#include "src/__support/FPUtil/NearestIntegerOperations.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+namespace math {
+
+LIBC_INLINE constexpr float128 ceilf128(float128 x) { return fputil::ceil(x); }
+
+} // namespace math
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LIBC_TYPES_HAS_FLOAT128
+
+#endif // LLVM_LIBC_SRC___SUPPORT_MATH_CEILF128_H
diff --git a/libc/src/__support/math/ceilf16.h b/libc/src/__support/math/ceilf16.h
new file mode 100644
index 0000000000000..6644d6a4e21b5
--- /dev/null
+++ b/libc/src/__support/math/ceilf16.h
@@ -0,0 +1,39 @@
+//===-- Implementation header for ceilf16 -----------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC___SUPPORT_MATH_CEILF16_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_CEILF16_H
+
+#include "include/llvm-libc-macros/float16-macros.h"
+
+#ifdef LIBC_TYPES_HAS_FLOAT16
+
+#include "src/__support/FPUtil/NearestIntegerOperations.h"
+#include "src/__support/FPUtil/cast.h"
+#include "src/__support/macros/config.h"
+#include "src/__support/macros/properties/cpu_features.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+namespace math {
+
+LIBC_INLINE constexpr float16 ceilf16(float16 x) {
+#if defined(__LIBC_USE_BUILTIN_CEIL_FLOOR_RINT_TRUNC) && \
+ defined(LIBC_TARGET_CPU_HAS_FAST_FLOAT16_OPS)
+ return fputil::cast<float16>(__builtin_ceilf(x));
+#else
+ return fputil::ceil(x);
+#endif
+}
+
+} // namespace math
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LIBC_TYPES_HAS_FLOAT16
+
+#endif // LLVM_LIBC_SRC___SUPPORT_MATH_CEILF16_H
diff --git a/libc/src/__support/math/ceill.h b/libc/src/__support/math/ceill.h
new file mode 100644
index 0000000000000..e090c0dba39eb
--- /dev/null
+++ b/libc/src/__support/math/ceill.h
@@ -0,0 +1,26 @@
+//===-- Implementation header for ceill -------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC___SUPPORT_MATH_CEILL_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_CEILL_H
+
+#include "src/__support/FPUtil/NearestIntegerOperations.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+namespace math {
+
+LIBC_INLINE constexpr long double ceill(long double x) {
+ return fputil::ceil(x);
+}
+
+} // namespace math
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC___SUPPORT_MATH_CEILL_H
diff --git a/libc/src/math/generic/CMakeLists.txt b/libc/src/math/generic/CMakeLists.txt
index 57a29665318a3..32329680dc58b 100644
--- a/libc/src/math/generic/CMakeLists.txt
+++ b/libc/src/math/generic/CMakeLists.txt
@@ -125,9 +125,7 @@ add_entrypoint_object(
HDRS
../ceil.h
DEPENDS
- libc.src.__support.FPUtil.nearest_integer_operations
- FLAGS
- ROUND_OPT
+ libc.src.__support.math.ceil
)
add_entrypoint_object(
@@ -137,9 +135,7 @@ add_entrypoint_object(
HDRS
../ceilf.h
DEPENDS
- libc.src.__support.FPUtil.nearest_integer_operations
- FLAGS
- ROUND_OPT
+ libc.src.__support.math.ceilf
)
add_entrypoint_object(
@@ -149,7 +145,7 @@ add_entrypoint_object(
HDRS
../ceill.h
DEPENDS
- libc.src.__support.FPUtil.nearest_integer_operations
+ libc.src.__support.math.ceill
)
add_entrypoint_object(
@@ -159,12 +155,7 @@ add_entrypoint_object(
HDRS
../ceilf16.h
DEPENDS
- libc.src.__support.FPUtil.cast
- libc.src.__support.FPUtil.nearest_integer_operations
- libc.src.__support.macros.properties.cpu_features
- libc.src.__support.macros.properties.types
- FLAGS
- ROUND_OPT
+ libc.src.__support.math.ceilf16
)
add_entrypoint_object(
@@ -174,8 +165,7 @@ add_entrypoint_object(
HDRS
../ceilf128.h
DEPENDS
- libc.src.__support.macros.properties.types
- libc.src.__support.FPUtil.nearest_integer_operations
+ libc.src.__support.math.ceilf128
)
add_entrypoint_object(
@@ -185,13 +175,7 @@ add_entrypoint_object(
HDRS
../ceilbf16.h
DEPENDS
- libc.src.__support.common
- libc.src.__support.FPUtil.bfloat16
- libc.src.__support.FPUtil.nearest_integer_operations
- libc.src.__support.macros.config
- libc.src.__support.macros.properties.types
- FLAGS
- ROUND_OPT
+ libc.src.__support.math.ceilbf16
)
add_entrypoint_object(
diff --git a/libc/src/math/generic/ceil.cpp b/libc/src/math/generic/ceil.cpp
index 72c6e990fcc71..bb0cd7b869566 100644
--- a/libc/src/math/generic/ceil.cpp
+++ b/libc/src/math/generic/ceil.cpp
@@ -7,18 +7,10 @@
//===----------------------------------------------------------------------===//
#include "src/math/ceil.h"
-#include "src/__support/FPUtil/NearestIntegerOperations.h"
-#include "src/__support/common.h"
-#include "src/__support/macros/config.h"
+#include "src/__support/math/ceil.h"
namespace LIBC_NAMESPACE_DECL {
-LLVM_LIBC_FUNCTION(double, ceil, (double x)) {
-#ifdef __LIBC_USE_BUILTIN_CEIL_FLOOR_RINT_TRUNC
- return __builtin_ceil(x);
-#else
- return fputil::ceil(x);
-#endif
-}
+LLVM_LIBC_FUNCTION(double, ceil, (double x)) { return math::ceil(x); }
} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/ceilbf16.cpp b/libc/src/math/generic/ceilbf16.cpp
index 441dcf0e93d6f..0abb7b22cbc6b 100644
--- a/libc/src/math/generic/ceilbf16.cpp
+++ b/libc/src/math/generic/ceilbf16.cpp
@@ -7,13 +7,12 @@
//===----------------------------------------------------------------------===//
#include "src/math/ceilbf16.h"
-#include "src/__support/FPUtil/NearestIntegerOperations.h"
-#include "src/__support/FPUtil/bfloat16.h"
-#include "src/__support/common.h"
-#include "src/__support/macros/config.h"
+#include "src/__support/math/ceilbf16.h"
namespace LIBC_NAMESPACE_DECL {
-LLVM_LIBC_FUNCTION(bfloat16, ceilbf16, (bfloat16 x)) { return fputil::ceil(x); }
+LLVM_LIBC_FUNCTION(bfloat16, ceilbf16, (bfloat16 x)) {
+ return math::ceilbf16(x);
+}
} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/ceilf.cpp b/libc/src/math/generic/ceilf.cpp
index dfd0dc62bc51b..f13371354d273 100644
--- a/libc/src/math/generic/ceilf.cpp
+++ b/libc/src/math/generic/ceilf.cpp
@@ -7,18 +7,10 @@
//===----------------------------------------------------------------------===//
#include "src/math/ceilf.h"
-#include "src/__support/FPUtil/NearestIntegerOperations.h"
-#include "src/__support/common.h"
-#include "src/__support/macros/config.h"
+#include "src/__support/math/ceilf.h"
namespace LIBC_NAMESPACE_DECL {
-LLVM_LIBC_FUNCTION(float, ceilf, (float x)) {
-#ifdef __LIBC_USE_BUILTIN_CEIL_FLOOR_RINT_TRUNC
- return __builtin_ceilf(x);
-#else
- return fputil::ceil(x);
-#endif
-}
+LLVM_LIBC_FUNCTION(float, ceilf, (float x)) { return math::ceilf(x); }
} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/ceilf128.cpp b/libc/src/math/generic/ceilf128.cpp
index 5d0cf46933cdf..fd9c206612207 100644
--- a/libc/src/math/generic/ceilf128.cpp
+++ b/libc/src/math/generic/ceilf128.cpp
@@ -7,12 +7,12 @@
//===----------------------------------------------------------------------===//
#include "src/math/ceilf128.h"
-#include "src/__support/FPUtil/NearestIntegerOperations.h"
-#include "src/__support/common.h"
-#include "src/__support/macros/config.h"
+#include "src/__support/math/ceilf128.h"
namespace LIBC_NAMESPACE_DECL {
-LLVM_LIBC_FUNCTION(float128, ceilf128, (float128 x)) { return fputil::ceil(x); }
+LLVM_LIBC_FUNCTION(float128, ceilf128, (float128 x)) {
+ return math::ceilf128(x);
+}
} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/ceilf16.cpp b/libc/src/math/generic/ceilf16.cpp
index 9d89efc5311d1..74fe2e5e0ad52 100644
--- a/libc/src/math/generic/ceilf16.cpp
+++ b/libc/src/math/generic/ceilf16.cpp
@@ -7,21 +7,10 @@
//===----------------------------------------------------------------------===//
#include "src/math/ceilf16.h"
-#include "src/__support/FPUtil/NearestIntegerOperations.h"
-#include "src/__support/FPUtil/cast.h"
-#include "src/__support/common.h"
-#include "src/__support/macros/config.h"
-#include "src/__support/macros/properties/cpu_features.h"
+#include "src/__support/math/ceilf16.h"
namespace LIBC_NAMESPACE_DECL {
-LLVM_LIBC_FUNCTION(float16, ceilf16, (float16 x)) {
-#if defined(__LIBC_USE_BUILTIN_CEIL_FLOOR_RINT_TRUNC) && \
- defined(LIBC_TARGET_CPU_HAS_FAST_FLOAT16_OPS)
- return fputil::cast<float16>(__builtin_ceilf(x));
-#else
- return fputil::ceil(x);
-#endif...
[truncated]
``````````
</details>
https://github.com/llvm/llvm-project/pull/182121
More information about the libc-commits
mailing list