[libc][math] Refactor floor family to header-only#182194
Merged
Conversation
Member
|
@llvm/pr-subscribers-libc Author: Mohamed Emad (hulxv) ChangesRefactors the floor math family to be header-only. Closes #182193 Target Functions:
Patch is 26.73 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/182194.diff 24 Files Affected:
diff --git a/libc/shared/math.h b/libc/shared/math.h
index 8a5aca82c6ec3..07b3b169812df 100644
--- a/libc/shared/math.h
+++ b/libc/shared/math.h
@@ -85,6 +85,12 @@
#include "math/f16sqrtl.h"
#include "math/ffma.h"
#include "math/ffmal.h"
+#include "math/floor.h"
+#include "math/floorbf16.h"
+#include "math/floorf.h"
+#include "math/floorf128.h"
+#include "math/floorf16.h"
+#include "math/floorl.h"
#include "math/frexpf.h"
#include "math/frexpf128.h"
#include "math/frexpf16.h"
diff --git a/libc/shared/math/floor.h b/libc/shared/math/floor.h
new file mode 100644
index 0000000000000..feacbf2a7a038
--- /dev/null
+++ b/libc/shared/math/floor.h
@@ -0,0 +1,22 @@
+//===-- Shared floor 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_FLOOR_H
+#define LLVM_LIBC_SHARED_MATH_FLOOR_H
+
+#include "src/__support/math/floor.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::floor;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SHARED_MATH_FLOOR_H
diff --git a/libc/shared/math/floorbf16.h b/libc/shared/math/floorbf16.h
new file mode 100644
index 0000000000000..6153a9fa3d57f
--- /dev/null
+++ b/libc/shared/math/floorbf16.h
@@ -0,0 +1,22 @@
+//===-- Shared floorbf16 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_FLOORBF16_H
+#define LLVM_LIBC_SHARED_MATH_FLOORBF16_H
+
+#include "src/__support/math/floorbf16.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::floorbf16;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SHARED_MATH_FLOORBF16_H
diff --git a/libc/shared/math/floorf.h b/libc/shared/math/floorf.h
new file mode 100644
index 0000000000000..b6b9f8b21a1ea
--- /dev/null
+++ b/libc/shared/math/floorf.h
@@ -0,0 +1,22 @@
+//===-- Shared floorf 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_FLOORF_H
+#define LLVM_LIBC_SHARED_MATH_FLOORF_H
+
+#include "src/__support/math/floorf.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::floorf;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SHARED_MATH_FLOORF_H
diff --git a/libc/shared/math/floorf128.h b/libc/shared/math/floorf128.h
new file mode 100644
index 0000000000000..bdf6bf6749f72
--- /dev/null
+++ b/libc/shared/math/floorf128.h
@@ -0,0 +1,28 @@
+//===-- Shared floorf128 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_FLOORF128_H
+#define LLVM_LIBC_SHARED_MATH_FLOORF128_H
+
+#include "include/llvm-libc-types/float128.h"
+
+#ifdef LIBC_TYPES_HAS_FLOAT128
+
+#include "src/__support/math/floorf128.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::floorf128;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LIBC_TYPES_HAS_FLOAT128
+
+#endif // LLVM_LIBC_SHARED_MATH_FLOORF128_H
diff --git a/libc/shared/math/floorf16.h b/libc/shared/math/floorf16.h
new file mode 100644
index 0000000000000..fbb4650798a42
--- /dev/null
+++ b/libc/shared/math/floorf16.h
@@ -0,0 +1,28 @@
+//===-- Shared floorf16 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_FLOORF16_H
+#define LLVM_LIBC_SHARED_MATH_FLOORF16_H
+
+#include "include/llvm-libc-macros/float16-macros.h"
+
+#ifdef LIBC_TYPES_HAS_FLOAT16
+
+#include "src/__support/math/floorf16.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::floorf16;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LIBC_TYPES_HAS_FLOAT16
+
+#endif // LLVM_LIBC_SHARED_MATH_FLOORF16_H
diff --git a/libc/shared/math/floorl.h b/libc/shared/math/floorl.h
new file mode 100644
index 0000000000000..f071031a9e22c
--- /dev/null
+++ b/libc/shared/math/floorl.h
@@ -0,0 +1,22 @@
+//===-- Shared floorl 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_FLOORL_H
+#define LLVM_LIBC_SHARED_MATH_FLOORL_H
+
+#include "src/__support/math/floorl.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::floorl;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SHARED_MATH_FLOORL_H
diff --git a/libc/src/__support/math/CMakeLists.txt b/libc/src/__support/math/CMakeLists.txt
index e21fe8ef0ab93..aaa99a34ab2dc 100644
--- a/libc/src/__support/math/CMakeLists.txt
+++ b/libc/src/__support/math/CMakeLists.txt
@@ -800,6 +800,58 @@ add_header_library(
libc.src.__support.FPUtil.fma
libc.src.__support.macros.config
)
+add_header_library(
+ floor
+ HDRS
+ floor.h
+ DEPENDS
+ libc.src.__support.FPUtil.nearest_integer_operations
+ libc.src.__support.macros.config
+)
+add_header_library(
+ floorbf16
+ HDRS
+ floorbf16.h
+ DEPENDS
+ libc.src.__support.FPUtil.bfloat16
+ libc.src.__support.FPUtil.nearest_integer_operations
+ libc.src.__support.macros.config
+)
+add_header_library(
+ floorf
+ HDRS
+ floorf.h
+ DEPENDS
+ libc.src.__support.FPUtil.nearest_integer_operations
+ libc.src.__support.macros.config
+)
+add_header_library(
+ floorf128
+ HDRS
+ floorf128.h
+ DEPENDS
+ libc.include.llvm-libc-types.float128
+ libc.src.__support.FPUtil.nearest_integer_operations
+ libc.src.__support.macros.config
+)
+add_header_library(
+ floorf16
+ HDRS
+ floorf16.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(
+ floorl
+ HDRS
+ floorl.h
+ DEPENDS
+ libc.src.__support.FPUtil.nearest_integer_operations
+ libc.src.__support.macros.config
+)
add_header_library(
frexpf128
diff --git a/libc/src/__support/math/floor.h b/libc/src/__support/math/floor.h
new file mode 100644
index 0000000000000..ec58531cff40e
--- /dev/null
+++ b/libc/src/__support/math/floor.h
@@ -0,0 +1,30 @@
+//===-- Implementation header for floor -------------------------*- 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_FLOOR_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_FLOOR_H
+
+#include "src/__support/FPUtil/NearestIntegerOperations.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+namespace math {
+
+LIBC_INLINE double floor(double x) {
+#ifdef __LIBC_USE_BUILTIN_CEIL_FLOOR_RINT_TRUNC
+ return __builtin_floor(x);
+#else
+ return fputil::floor(x);
+#endif
+}
+
+} // namespace math
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC___SUPPORT_MATH_FLOOR_H
diff --git a/libc/src/__support/math/floorbf16.h b/libc/src/__support/math/floorbf16.h
new file mode 100644
index 0000000000000..41e1cc4830f92
--- /dev/null
+++ b/libc/src/__support/math/floorbf16.h
@@ -0,0 +1,25 @@
+//===-- Implementation header for floorbf16 ---------------------*- 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_FLOORBF16_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_FLOORBF16_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 bfloat16 floorbf16(bfloat16 x) { return fputil::floor(x); }
+
+} // namespace math
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC___SUPPORT_MATH_FLOORBF16_H
diff --git a/libc/src/__support/math/floorf.h b/libc/src/__support/math/floorf.h
new file mode 100644
index 0000000000000..000825a8dfdbd
--- /dev/null
+++ b/libc/src/__support/math/floorf.h
@@ -0,0 +1,30 @@
+//===-- Implementation header for floorf ------------------------*- 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_FLOORF_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_FLOORF_H
+
+#include "src/__support/FPUtil/NearestIntegerOperations.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+namespace math {
+
+LIBC_INLINE float floorf(float x) {
+#ifdef __LIBC_USE_BUILTIN_CEIL_FLOOR_RINT_TRUNC
+ return __builtin_floorf(x);
+#else
+ return fputil::floor(x);
+#endif
+}
+
+} // namespace math
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC___SUPPORT_MATH_FLOORF_H
diff --git a/libc/src/__support/math/floorf128.h b/libc/src/__support/math/floorf128.h
new file mode 100644
index 0000000000000..951970ba6ae75
--- /dev/null
+++ b/libc/src/__support/math/floorf128.h
@@ -0,0 +1,30 @@
+//===-- Implementation header for floorf128 ---------------------*- 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_FLOORF128_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_FLOORF128_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 float128 floorf128(float128 x) { return fputil::floor(x); }
+
+} // namespace math
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LIBC_TYPES_HAS_FLOAT128
+
+#endif // LLVM_LIBC_SRC___SUPPORT_MATH_FLOORF128_H
diff --git a/libc/src/__support/math/floorf16.h b/libc/src/__support/math/floorf16.h
new file mode 100644
index 0000000000000..5ceebb63d2718
--- /dev/null
+++ b/libc/src/__support/math/floorf16.h
@@ -0,0 +1,39 @@
+//===-- Implementation header for floorf16 ----------------------*- 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_FLOORF16_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_FLOORF16_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 float16 floorf16(float16 x) {
+#if defined(__LIBC_USE_BUILTIN_CEIL_FLOOR_RINT_TRUNC) && \
+ defined(LIBC_TARGET_CPU_HAS_FAST_FLOAT16_OPS)
+ return fputil::cast<float16>(__builtin_floorf(x));
+#else
+ return fputil::floor(x);
+#endif
+}
+
+} // namespace math
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LIBC_TYPES_HAS_FLOAT16
+
+#endif // LLVM_LIBC_SRC___SUPPORT_MATH_FLOORF16_H
diff --git a/libc/src/__support/math/floorl.h b/libc/src/__support/math/floorl.h
new file mode 100644
index 0000000000000..6c6cdf3ed3dfc
--- /dev/null
+++ b/libc/src/__support/math/floorl.h
@@ -0,0 +1,24 @@
+//===-- Implementation header for floorl ------------------------*- 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_FLOORL_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_FLOORL_H
+
+#include "src/__support/FPUtil/NearestIntegerOperations.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+namespace math {
+
+LIBC_INLINE long double floorl(long double x) { return fputil::floor(x); }
+
+} // namespace math
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC___SUPPORT_MATH_FLOORL_H
diff --git a/libc/src/math/generic/CMakeLists.txt b/libc/src/math/generic/CMakeLists.txt
index 57a29665318a3..25a1768494b7c 100644
--- a/libc/src/math/generic/CMakeLists.txt
+++ b/libc/src/math/generic/CMakeLists.txt
@@ -671,9 +671,7 @@ add_entrypoint_object(
HDRS
../floor.h
DEPENDS
- libc.src.__support.FPUtil.nearest_integer_operations
- FLAGS
- ROUND_OPT
+ libc.src.__support.math.floor
)
add_entrypoint_object(
@@ -683,9 +681,7 @@ add_entrypoint_object(
HDRS
../floorf.h
DEPENDS
- libc.src.__support.FPUtil.nearest_integer_operations
- FLAGS
- ROUND_OPT
+ libc.src.__support.math.floorf
)
add_entrypoint_object(
@@ -695,7 +691,7 @@ add_entrypoint_object(
HDRS
../floorl.h
DEPENDS
- libc.src.__support.FPUtil.nearest_integer_operations
+ libc.src.__support.math.floorl
)
add_entrypoint_object(
@@ -705,12 +701,7 @@ add_entrypoint_object(
HDRS
../floorf16.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.floorf16
)
add_entrypoint_object(
@@ -720,8 +711,7 @@ add_entrypoint_object(
HDRS
../floorf128.h
DEPENDS
- libc.src.__support.macros.properties.types
- libc.src.__support.FPUtil.nearest_integer_operations
+ libc.src.__support.math.floorf128
)
add_entrypoint_object(
@@ -731,13 +721,7 @@ add_entrypoint_object(
HDRS
../floorbf16.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.floorbf16
)
add_entrypoint_object(
diff --git a/libc/src/math/generic/floor.cpp b/libc/src/math/generic/floor.cpp
index 86aed6c61a7cc..525e0f2a6ae88 100644
--- a/libc/src/math/generic/floor.cpp
+++ b/libc/src/math/generic/floor.cpp
@@ -7,18 +7,10 @@
//===----------------------------------------------------------------------===//
#include "src/math/floor.h"
-#include "src/__support/FPUtil/NearestIntegerOperations.h"
-#include "src/__support/common.h"
-#include "src/__support/macros/config.h"
+#include "src/__support/math/floor.h"
namespace LIBC_NAMESPACE_DECL {
-LLVM_LIBC_FUNCTION(double, floor, (double x)) {
-#ifdef __LIBC_USE_BUILTIN_CEIL_FLOOR_RINT_TRUNC
- return __builtin_floor(x);
-#else
- return fputil::floor(x);
-#endif
-}
+LLVM_LIBC_FUNCTION(double, floor, (double x)) { return math::floor(x); }
} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/floorbf16.cpp b/libc/src/math/generic/floorbf16.cpp
index d157096c3e62f..88fb89d193432 100644
--- a/libc/src/math/generic/floorbf16.cpp
+++ b/libc/src/math/generic/floorbf16.cpp
@@ -7,15 +7,12 @@
//===----------------------------------------------------------------------===//
#include "src/math/floorbf16.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/floorbf16.h"
namespace LIBC_NAMESPACE_DECL {
LLVM_LIBC_FUNCTION(bfloat16, floorbf16, (bfloat16 x)) {
- return fputil::floor(x);
+ return math::floorbf16(x);
}
} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/floorf.cpp b/libc/src/math/generic/floorf.cpp
index 22739eff68ec2..c9f7e780b5eb1 100644
--- a/libc/src/math/generic/floorf.cpp
+++ b/libc/src/math/generic/floorf.cpp
@@ -7,18 +7,10 @@
//===----------------------------------------------------------------------===//
#include "src/math/floorf.h"
-#include "src/__support/FPUtil/NearestIntegerOperations.h"
-#include "src/__support/common.h"
-#include "src/__support/macros/config.h"
+#include "src/__support/math/floorf.h"
namespace LIBC_NAMESPACE_DECL {
-LLVM_LIBC_FUNCTION(float, floorf, (float x)) {
-#ifdef __LIBC_USE_BUILTIN_CEIL_FLOOR_RINT_TRUNC
- return __builtin_floorf(x);
-#else
- return fputil::floor(x);
-#endif
-}
+LLVM_LIBC_FUNCTION(float, floorf, (float x)) { return math::floorf(x); }
} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/floorf128.cpp b/libc/src/math/generic/floorf128.cpp
index f3ad20a1dcba0..4740ec569611c 100644
--- a/libc/src/math/generic/floorf128.cpp
+++ b/libc/src/math/generic/floorf128.cpp
@@ -7,14 +7,12 @@
//===----------------------------------------------------------------------===//
#include "src/math/floorf128.h"
-#include "src/__support/FPUtil/NearestIntegerOperations.h"
-#include "src/__support/common.h"
-#include "src/__support/macros/config.h"
+#include "src/__support/math/floorf128.h"
namespace LIBC_NAMESPACE_DECL {
LLVM_LIBC_FUNCTION(float128, floorf128, (float128 x)) {
- return fputil::floor(x);
+ return math::floorf128(x);
}
} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/floorf16.cpp b/libc/src/math/generic/floorf16.cpp
index 361b22729f642..f79e61278cfca 100644
--- a/libc/src/math/generic/floorf16.cpp
+++ b/libc/src/math/generic/floorf16.cpp
@@ -7,21 +7,10 @@
//===----------------------------------------------------------------------===//
#include "src/math/floorf16.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/floorf16.h"
namespace LIBC_NAMESPACE_DECL {
-LLVM_LIBC_FUNCTION(float16, floorf16, (float16 x)) {
-#if defined(__LIBC_USE_BUILTIN_CEIL_FLOOR_RINT_TRUNC) && \
- defined(LIBC_TARGET_CPU_HAS_FAST_FLOAT16_OPS)
- return fputil::cast<float16>(__builtin_floorf(x));
-#else
- return fputil::floor(x);
-#endif
-}
+LLVM_LIB...
[truncated]
|
058e0d8 to
be87db6
Compare
Refactored functions: - floor - floorbf16 - floorf - floorf128 - floorf16 - floorl
be87db6 to
e9bb55f
Compare
bassiounix
requested changes
Feb 23, 2026
Refactored functions: - floor - floorbf16 - floorf - floorf128 - floorf16 - floorl
5042395 to
8fe259b
Compare
bassiounix
requested changes
Feb 24, 2026
bassiounix
requested changes
Feb 25, 2026
bassiounix
requested changes
Feb 26, 2026
3773c00 to
e9d26a1
Compare
bassiounix
approved these changes
Feb 28, 2026
sahas3
pushed a commit
to sahas3/llvm-project
that referenced
this pull request
Mar 4, 2026
Refactors the floor math family to be header-only. Closes llvm#182193 Target Functions: - floor - floorbf16 - floorf - floorf128 - floorf16 - floorl
sujianIBM
pushed a commit
to sujianIBM/llvm-project
that referenced
this pull request
Mar 5, 2026
Refactors the floor math family to be header-only. Closes llvm#182193 Target Functions: - floor - floorbf16 - floorf - floorf128 - floorf16 - floorl
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refactors the floor math family to be header-only.
Closes #182193
Target Functions: