[libc-commits] [libc] [llvm] [libc][math] Refactor canonicalize family to header-only (PR #181467)

via libc-commits libc-commits at lists.llvm.org
Sat Feb 14 00:37:57 PST 2026


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-libc

Author: Anonmiraj (AnonMiraj)

<details>
<summary>Changes</summary>

closes: #<!-- -->181466

---

Patch is 27.89 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/181467.diff


24 Files Affected:

- (modified) libc/shared/math.h (+6) 
- (added) libc/shared/math/canonicalize.h (+23) 
- (added) libc/shared/math/canonicalizebf16.h (+23) 
- (added) libc/shared/math/canonicalizef.h (+23) 
- (added) libc/shared/math/canonicalizef128.h (+29) 
- (added) libc/shared/math/canonicalizef16.h (+29) 
- (added) libc/shared/math/canonicalizel.h (+23) 
- (modified) libc/src/__support/math/CMakeLists.txt (+54) 
- (added) libc/src/__support/math/canonicalize.h (+27) 
- (added) libc/src/__support/math/canonicalizebf16.h (+28) 
- (added) libc/src/__support/math/canonicalizef.h (+27) 
- (added) libc/src/__support/math/canonicalizef128.h (+33) 
- (added) libc/src/__support/math/canonicalizef16.h (+33) 
- (added) libc/src/__support/math/canonicalizel.h (+27) 
- (modified) libc/src/math/generic/CMakeLists.txt (+6-12) 
- (modified) libc/src/math/generic/canonicalize.cpp (+2-4) 
- (modified) libc/src/math/generic/canonicalizebf16.cpp (+2-5) 
- (modified) libc/src/math/generic/canonicalizef.cpp (+2-4) 
- (modified) libc/src/math/generic/canonicalizef128.cpp (+2-4) 
- (modified) libc/src/math/generic/canonicalizef16.cpp (+2-4) 
- (modified) libc/src/math/generic/canonicalizel.cpp (+2-4) 
- (modified) libc/test/shared/CMakeLists.txt (+6) 
- (modified) libc/test/shared/shared_math_test.cpp (+39) 
- (modified) utils/bazel/llvm-project-overlay/libc/BUILD.bazel (+84-5) 


``````````diff
diff --git a/libc/shared/math.h b/libc/shared/math.h
index 06cf83d0f3334..fbde5c055fc80 100644
--- a/libc/shared/math.h
+++ b/libc/shared/math.h
@@ -31,6 +31,12 @@
 #include "math/atanhf.h"
 #include "math/atanhf16.h"
 #include "math/bf16addf128.h"
+#include "math/canonicalize.h"
+#include "math/canonicalizebf16.h"
+#include "math/canonicalizef.h"
+#include "math/canonicalizef128.h"
+#include "math/canonicalizef16.h"
+#include "math/canonicalizel.h"
 #include "math/cbrt.h"
 #include "math/cbrtf.h"
 #include "math/cos.h"
diff --git a/libc/shared/math/canonicalize.h b/libc/shared/math/canonicalize.h
new file mode 100644
index 0000000000000..5e21641de2f40
--- /dev/null
+++ b/libc/shared/math/canonicalize.h
@@ -0,0 +1,23 @@
+//===-- Shared canonicalize 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_CANONICALIZE_H
+#define LLVM_LIBC_SHARED_MATH_CANONICALIZE_H
+
+#include "shared/libc_common.h"
+#include "src/__support/math/canonicalize.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::canonicalize;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SHARED_MATH_CANONICALIZE_H
diff --git a/libc/shared/math/canonicalizebf16.h b/libc/shared/math/canonicalizebf16.h
new file mode 100644
index 0000000000000..1b92e00076362
--- /dev/null
+++ b/libc/shared/math/canonicalizebf16.h
@@ -0,0 +1,23 @@
+//===-- Shared canonicalizebf16 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_CANONICALIZEBF16_H
+#define LLVM_LIBC_SHARED_MATH_CANONICALIZEBF16_H
+
+#include "shared/libc_common.h"
+#include "src/__support/math/canonicalizebf16.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::canonicalizebf16;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SHARED_MATH_CANONICALIZEBF16_H
diff --git a/libc/shared/math/canonicalizef.h b/libc/shared/math/canonicalizef.h
new file mode 100644
index 0000000000000..8097cdf0987fd
--- /dev/null
+++ b/libc/shared/math/canonicalizef.h
@@ -0,0 +1,23 @@
+//===-- Shared canonicalizef 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_CANONICALIZEF_H
+#define LLVM_LIBC_SHARED_MATH_CANONICALIZEF_H
+
+#include "shared/libc_common.h"
+#include "src/__support/math/canonicalizef.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::canonicalizef;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SHARED_MATH_CANONICALIZEF_H
diff --git a/libc/shared/math/canonicalizef128.h b/libc/shared/math/canonicalizef128.h
new file mode 100644
index 0000000000000..dfc5f89afee50
--- /dev/null
+++ b/libc/shared/math/canonicalizef128.h
@@ -0,0 +1,29 @@
+//===-- Shared canonicalizef128 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_CANONICALIZEF128_H
+#define LLVM_LIBC_SHARED_MATH_CANONICALIZEF128_H
+
+#include "include/llvm-libc-types/float128.h"
+
+#ifdef LIBC_TYPES_HAS_FLOAT128
+
+#include "shared/libc_common.h"
+#include "src/__support/math/canonicalizef128.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::canonicalizef128;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LIBC_TYPES_HAS_FLOAT128
+
+#endif // LLVM_LIBC_SHARED_MATH_CANONICALIZEF128_H
diff --git a/libc/shared/math/canonicalizef16.h b/libc/shared/math/canonicalizef16.h
new file mode 100644
index 0000000000000..1925d052ac0fd
--- /dev/null
+++ b/libc/shared/math/canonicalizef16.h
@@ -0,0 +1,29 @@
+//===-- Shared canonicalizef16 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_CANONICALIZEF16_H
+#define LLVM_LIBC_SHARED_MATH_CANONICALIZEF16_H
+
+#include "include/llvm-libc-macros/float16-macros.h"
+
+#ifdef LIBC_TYPES_HAS_FLOAT16
+
+#include "shared/libc_common.h"
+#include "src/__support/math/canonicalizef16.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::canonicalizef16;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LIBC_TYPES_HAS_FLOAT16
+
+#endif // LLVM_LIBC_SHARED_MATH_CANONICALIZEF16_H
diff --git a/libc/shared/math/canonicalizel.h b/libc/shared/math/canonicalizel.h
new file mode 100644
index 0000000000000..66e2ed9053dc2
--- /dev/null
+++ b/libc/shared/math/canonicalizel.h
@@ -0,0 +1,23 @@
+//===-- Shared canonicalizel 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_CANONICALIZEL_H
+#define LLVM_LIBC_SHARED_MATH_CANONICALIZEL_H
+
+#include "shared/libc_common.h"
+#include "src/__support/math/canonicalizel.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::canonicalizel;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SHARED_MATH_CANONICALIZEL_H
diff --git a/libc/src/__support/math/CMakeLists.txt b/libc/src/__support/math/CMakeLists.txt
index fe20faee176fb..4494902d86ee3 100644
--- a/libc/src/__support/math/CMakeLists.txt
+++ b/libc/src/__support/math/CMakeLists.txt
@@ -341,6 +341,60 @@ add_header_library(
     libc.src.__support.FPUtil.generic.add_sub
     libc.src.__support.macros.config
 )
+add_header_library(
+  canonicalize
+  HDRS
+    canonicalize.h
+  DEPENDS
+    libc.src.__support.FPUtil.basic_operations
+)
+
+add_header_library(
+  canonicalizebf16
+  HDRS
+    canonicalizebf16.h
+  DEPENDS
+    libc.src.__support.FPUtil.basic_operations
+    libc.src.__support.FPUtil.bfloat16
+    libc.src.__support.common
+    libc.src.__support.macros.config
+    libc.src.__support.macros.properties.types
+)
+
+add_header_library(
+  canonicalizef
+  HDRS
+    canonicalizef.h
+  DEPENDS
+    libc.src.__support.FPUtil.basic_operations
+)
+
+add_header_library(
+  canonicalizef128
+  HDRS
+    canonicalizef128.h
+  DEPENDS
+    libc.src.__support.FPUtil.basic_operations
+    libc.src.__support.macros.properties.types
+)
+
+add_header_library(
+  canonicalizef16
+  HDRS
+    canonicalizef16.h
+  DEPENDS
+    libc.src.__support.FPUtil.basic_operations
+    libc.src.__support.macros.properties.types
+)
+
+add_header_library(
+  canonicalizel
+  HDRS
+    canonicalizel.h
+  DEPENDS
+    libc.src.__support.FPUtil.basic_operations
+)
+
 
 add_header_library(
   cbrt
diff --git a/libc/src/__support/math/canonicalize.h b/libc/src/__support/math/canonicalize.h
new file mode 100644
index 0000000000000..eb208b2de744e
--- /dev/null
+++ b/libc/src/__support/math/canonicalize.h
@@ -0,0 +1,27 @@
+//===-- Implementation header for canonicalize ------------------*- 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_CANONICALIZE_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_CANONICALIZE_H
+
+#include "src/__support/FPUtil/BasicOperations.h"
+#include "src/__support/common.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+namespace math {
+
+LIBC_INLINE int canonicalize(double *cx, const double *x) {
+  return fputil::canonicalize(*cx, *x);
+}
+
+} // namespace math
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC___SUPPORT_MATH_CANONICALIZE_H
diff --git a/libc/src/__support/math/canonicalizebf16.h b/libc/src/__support/math/canonicalizebf16.h
new file mode 100644
index 0000000000000..9a2fe3b6561cf
--- /dev/null
+++ b/libc/src/__support/math/canonicalizebf16.h
@@ -0,0 +1,28 @@
+//===-- Implementation header for canonicalizebf16 --------------*- 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_CANONICALIZEBF16_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_CANONICALIZEBF16_H
+
+#include "src/__support/FPUtil/BasicOperations.h"
+#include "src/__support/FPUtil/bfloat16.h"
+#include "src/__support/common.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+namespace math {
+
+LIBC_INLINE int canonicalizebf16(bfloat16 *cx, const bfloat16 *x) {
+  return fputil::canonicalize(*cx, *x);
+}
+
+} // namespace math
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC___SUPPORT_MATH_CANONICALIZEBF16_H
diff --git a/libc/src/__support/math/canonicalizef.h b/libc/src/__support/math/canonicalizef.h
new file mode 100644
index 0000000000000..39e20b9253e53
--- /dev/null
+++ b/libc/src/__support/math/canonicalizef.h
@@ -0,0 +1,27 @@
+//===-- Implementation header for canonicalizef -----------------*- 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_CANONICALIZEF_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_CANONICALIZEF_H
+
+#include "src/__support/FPUtil/BasicOperations.h"
+#include "src/__support/common.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+namespace math {
+
+LIBC_INLINE int canonicalizef(float *cx, const float *x) {
+  return fputil::canonicalize(*cx, *x);
+}
+
+} // namespace math
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC___SUPPORT_MATH_CANONICALIZEF_H
diff --git a/libc/src/__support/math/canonicalizef128.h b/libc/src/__support/math/canonicalizef128.h
new file mode 100644
index 0000000000000..de357c75c655f
--- /dev/null
+++ b/libc/src/__support/math/canonicalizef128.h
@@ -0,0 +1,33 @@
+//===-- Implementation header for canonicalizef128 --------------*- 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_CANONICALIZEF128_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_CANONICALIZEF128_H
+
+#include "include/llvm-libc-types/float128.h"
+
+#ifdef LIBC_TYPES_HAS_FLOAT128
+
+#include "src/__support/FPUtil/BasicOperations.h"
+#include "src/__support/common.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+namespace math {
+
+LIBC_INLINE int canonicalizef128(float128 *cx, const float128 *x) {
+  return fputil::canonicalize(*cx, *x);
+}
+
+} // namespace math
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LIBC_TYPES_HAS_FLOAT128
+
+#endif // LLVM_LIBC_SRC___SUPPORT_MATH_CANONICALIZEF128_H
diff --git a/libc/src/__support/math/canonicalizef16.h b/libc/src/__support/math/canonicalizef16.h
new file mode 100644
index 0000000000000..6feea9aa271d1
--- /dev/null
+++ b/libc/src/__support/math/canonicalizef16.h
@@ -0,0 +1,33 @@
+//===-- Implementation header for canonicalizef16 ---------------*- 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_CANONICALIZEF16_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_CANONICALIZEF16_H
+
+#include "include/llvm-libc-macros/float16-macros.h"
+
+#ifdef LIBC_TYPES_HAS_FLOAT16
+
+#include "src/__support/FPUtil/BasicOperations.h"
+#include "src/__support/common.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+namespace math {
+
+LIBC_INLINE int canonicalizef16(float16 *cx, const float16 *x) {
+  return fputil::canonicalize(*cx, *x);
+}
+
+} // namespace math
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LIBC_TYPES_HAS_FLOAT16
+
+#endif // LLVM_LIBC_SRC___SUPPORT_MATH_CANONICALIZEF16_H
diff --git a/libc/src/__support/math/canonicalizel.h b/libc/src/__support/math/canonicalizel.h
new file mode 100644
index 0000000000000..63b4af24718ad
--- /dev/null
+++ b/libc/src/__support/math/canonicalizel.h
@@ -0,0 +1,27 @@
+//===-- Implementation header for canonicalizel -----------------*- 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_CANONICALIZEL_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_CANONICALIZEL_H
+
+#include "src/__support/FPUtil/BasicOperations.h"
+#include "src/__support/common.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+namespace math {
+
+LIBC_INLINE int canonicalizel(long double *cx, const long double *x) {
+  return fputil::canonicalize(*cx, *x);
+}
+
+} // namespace math
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC___SUPPORT_MATH_CANONICALIZEL_H
diff --git a/libc/src/math/generic/CMakeLists.txt b/libc/src/math/generic/CMakeLists.txt
index b0a2e5a2a381f..6cec4c4518234 100644
--- a/libc/src/math/generic/CMakeLists.txt
+++ b/libc/src/math/generic/CMakeLists.txt
@@ -7,7 +7,7 @@ add_entrypoint_object(
   HDRS
     ../canonicalize.h
   DEPENDS
-    libc.src.__support.FPUtil.basic_operations
+    libc.src.__support.math.canonicalize
 )
 
 add_entrypoint_object(
@@ -17,7 +17,7 @@ add_entrypoint_object(
   HDRS
     ../canonicalizef.h
   DEPENDS
-    libc.src.__support.FPUtil.basic_operations
+    libc.src.__support.math.canonicalizef
 )
 
 add_entrypoint_object(
@@ -27,8 +27,7 @@ add_entrypoint_object(
   HDRS
     ../canonicalizef16.h
   DEPENDS
-    libc.src.__support.macros.properties.types
-    libc.src.__support.FPUtil.basic_operations
+    libc.src.__support.math.canonicalizef16
 )
 
 add_entrypoint_object(
@@ -38,8 +37,7 @@ add_entrypoint_object(
   HDRS
     ../canonicalizef128.h
   DEPENDS
-    libc.src.__support.macros.properties.types
-    libc.src.__support.FPUtil.basic_operations
+    libc.src.__support.math.canonicalizef128
 )
 
 add_entrypoint_object(
@@ -49,7 +47,7 @@ add_entrypoint_object(
   HDRS
     ../canonicalizel.h
   DEPENDS
-    libc.src.__support.FPUtil.basic_operations
+    libc.src.__support.math.canonicalizel
 )
 
 add_entrypoint_object(
@@ -59,11 +57,7 @@ add_entrypoint_object(
   HDRS
     ../canonicalizebf16.h
   DEPENDS
-    libc.src.__support.common
-    libc.src.__support.macros.config
-    libc.src.__support.macros.properties.types
-    libc.src.__support.FPUtil.basic_operations
-    libc.src.__support.FPUtil.bfloat16
+    libc.src.__support.math.canonicalizebf16
 )
 
 add_entrypoint_object(
diff --git a/libc/src/math/generic/canonicalize.cpp b/libc/src/math/generic/canonicalize.cpp
index d93501d597376..0d2aaf7cc799d 100644
--- a/libc/src/math/generic/canonicalize.cpp
+++ b/libc/src/math/generic/canonicalize.cpp
@@ -7,14 +7,12 @@
 //===----------------------------------------------------------------------===//
 
 #include "src/math/canonicalize.h"
-#include "src/__support/FPUtil/BasicOperations.h"
-#include "src/__support/common.h"
-#include "src/__support/macros/config.h"
+#include "src/__support/math/canonicalize.h"
 
 namespace LIBC_NAMESPACE_DECL {
 
 LLVM_LIBC_FUNCTION(int, canonicalize, (double *cx, const double *x)) {
-  return fputil::canonicalize(*cx, *x);
+  return math::canonicalize(cx, x);
 }
 
 } // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/canonicalizebf16.cpp b/libc/src/math/generic/canonicalizebf16.cpp
index 9cc379060c3de..bad7cef480c38 100644
--- a/libc/src/math/generic/canonicalizebf16.cpp
+++ b/libc/src/math/generic/canonicalizebf16.cpp
@@ -7,15 +7,12 @@
 //===----------------------------------------------------------------------===//
 
 #include "src/math/canonicalizebf16.h"
-#include "src/__support/FPUtil/BasicOperations.h"
-#include "src/__support/FPUtil/bfloat16.h"
-#include "src/__support/common.h"
-#include "src/__support/macros/config.h"
+#include "src/__support/math/canonicalizebf16.h"
 
 namespace LIBC_NAMESPACE_DECL {
 
 LLVM_LIBC_FUNCTION(int, canonicalizebf16, (bfloat16 * cx, const bfloat16 *x)) {
-  return fputil::canonicalize(*cx, *x);
+  return math::canonicalizebf16(cx, x);
 }
 
 } // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/canonicalizef.cpp b/libc/src/math/generic/canonicalizef.cpp
index 437cf8768458a..77ffba9789c22 100644
--- a/libc/src/math/generic/canonicalizef.cpp
+++ b/libc/src/math/generic/canonicalizef.cpp
@@ -7,14 +7,12 @@
 //===----------------------------------------------------------------------===//
 
 #include "src/math/canonicalizef.h"
-#include "src/__support/FPUtil/BasicOperations.h"
-#include "src/__support/common.h"
-#include "src/__support/macros/config.h"
+#include "src/__support/math/canonicalizef.h"
 
 namespace LIBC_NAMESPACE_DECL {
 
 LLVM_LIBC_FUNCTION(int, canonicalizef, (float *cx, const float *x)) {
-  return fputil::canonicalize(*cx, *x);
+  return math::canonicalizef(cx, x);
 }
 
 } // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/canonicalizef128.cpp b/libc/src/math/generic/canonicalizef128.cpp
index 477d9c740a746..48bce08a555cf 100644
--- a/libc/src/math/generic/canonicalizef128.cpp
+++ b/libc/src/math/generic/canonicalizef128.cpp
@@ -7,14 +7,12 @@
 //===----------------------------------------------------------------------===//
 
 #include "src/math/canonicalizef128.h"
-#include "src/__support/FPUtil/BasicOperations.h"
-#include "src/__support/common.h"
-#include "src/__support/macros/config.h"
+#include "src/__support/math/canonicalizef128.h"
 
 namespace LIBC_NAMESPACE_DECL {
 
 LLVM_LIBC_FUNCTION(int, canonicalizef128, (float128 * cx, const float128 *x)) {
-  return fputil::canonicalize(*cx, *x);
+  return math::canonicalizef128(cx, x);
 }
 
 } // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/canonicalizef16.cpp b/libc/src/math/generic/canonicalizef16.cpp
index ff32c918793ff..f02e57b0a1070 100644
--- a/libc/src/math/generic/canonicalizef16.cpp
+++ b/libc/src/math/generic/canonicalizef16.cpp
@@ -7,14 +7,12 @@
 //===----------------------------------------------------------------------===//
 
 #include "src/math/canonicalizef16.h"
-#include "src/__support/FPUtil/BasicOperations.h"
-#include "src/__support/common.h"
-#include "s...
[truncated]

``````````

</details>


https://github.com/llvm/llvm-project/pull/181467


More information about the libc-commits mailing list