[libc-commits] [libc] [llvm] [libc][math] Refactor f16fmaf128 to Header Only (PR #177850)

Muhammad Bassiouni via libc-commits libc-commits at lists.llvm.org
Thu Jan 29 22:08:37 PST 2026


https://github.com/bassiounix updated https://github.com/llvm/llvm-project/pull/177850

>From 5e04c47da52bafe4a91020c8fba2f601d0100e48 Mon Sep 17 00:00:00 2001
From: Sukumarsawant <sawantsukumar at gmail.com>
Date: Sun, 25 Jan 2026 02:37:26 +0530
Subject: [PATCH 1/9] new files added

---
 libc/shared/math/f16fmaf128.h        | 30 ++++++++++++++++++++++++
 libc/src/__support/math/f16fmaf128.h | 34 ++++++++++++++++++++++++++++
 2 files changed, 64 insertions(+)
 create mode 100644 libc/shared/math/f16fmaf128.h
 create mode 100644 libc/src/__support/math/f16fmaf128.h

diff --git a/libc/shared/math/f16fmaf128.h b/libc/shared/math/f16fmaf128.h
new file mode 100644
index 0000000000000..f3dc9f07db550
--- /dev/null
+++ b/libc/shared/math/f16fmaf128.h
@@ -0,0 +1,30 @@
+//===-- Shared f16fmaf128 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_F16FMAF128_H
+#define LLVM_LIBC_SHARED_MATH_F16FMAF128_H
+
+#include "include/llvm-libc-macros/float128-macros.h"
+#include "shared/libc_common.h"
+
+#ifdef LIBC_TYPES_HAS_FLOAT128
+
+
+#include "src/__support/math/f16fmaf128.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::f16fmaf128;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LIBC_TYPES_HAS_FLOAT128
+
+#endif // LLVM_LIBC_SHARED_MATH_F16FMAF128_H
diff --git a/libc/src/__support/math/f16fmaf128.h b/libc/src/__support/math/f16fmaf128.h
new file mode 100644
index 0000000000000..a341e87eede48
--- /dev/null
+++ b/libc/src/__support/math/f16fmaf128.h
@@ -0,0 +1,34 @@
+//===-- Implementation header for f16fmaf128 ------------------------*- 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_F16FMAF128_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_F16FMAF128_H
+
+#include "include/llvm-libc-macros/float128-macros.h"
+
+#ifdef LIBC_TYPES_HAS_FLOAT128
+
+#include "src/__support/FPUtil/FMA.h"
+#include "src/__support/common.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+namespace math {
+
+LIBC_INLINE static float16 f16fmaf128(float128 x, float128 y, float128 z) {
+  return fputil::fma<float16>(x, y, z);
+}
+
+} // namespace math
+
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LIBC_TYPES_HAS_FLOAT128
+
+#endif // LLVM_LIBC_SRC___SUPPORT_MATH_F16FMAF128_H

>From 4e0fcc9eebb17dd6630923e9117b0f1d599ac012 Mon Sep 17 00:00:00 2001
From: Sukumarsawant <sawantsukumar at gmail.com>
Date: Sun, 25 Jan 2026 02:37:55 +0530
Subject: [PATCH 2/9] edited files

---
 libc/shared/math.h                                |  4 ++++
 libc/shared/math/f16fmaf128.h                     |  5 ++++-
 libc/src/__support/math/CMakeLists.txt            | 12 ++++++++++++
 libc/src/__support/math/f16fmaf128.h              |  5 +++++
 libc/src/math/generic/CMakeLists.txt              |  3 +--
 libc/src/math/generic/f16fmaf128.cpp              |  6 ++----
 libc/test/shared/CMakeLists.txt                   |  4 ++++
 libc/test/shared/shared_math_test.cpp             |  3 +++
 utils/bazel/llvm-project-overlay/libc/BUILD.bazel | 14 +++++++++++++-
 9 files changed, 48 insertions(+), 8 deletions(-)

diff --git a/libc/shared/math.h b/libc/shared/math.h
index 835165d036912..dc17b466b075a 100644
--- a/libc/shared/math.h
+++ b/libc/shared/math.h
@@ -60,9 +60,13 @@
 #include "math/expm1f.h"
 #include "math/expm1f16.h"
 #include "math/f16fma.h"
+<<<<<<< HEAD
 #include "math/f16fmal.h"
 #include "math/f16sqrt.h"
 #include "math/f16sqrtl.h"
+=======
+#include "math/f16fmaf128.h"
+>>>>>>> a01ef8ee0824 (edited files)
 #include "math/frexpf.h"
 #include "math/frexpf128.h"
 #include "math/frexpf16.h"
diff --git a/libc/shared/math/f16fmaf128.h b/libc/shared/math/f16fmaf128.h
index f3dc9f07db550..ac0a473da0beb 100644
--- a/libc/shared/math/f16fmaf128.h
+++ b/libc/shared/math/f16fmaf128.h
@@ -1,3 +1,4 @@
+
 //===-- Shared f16fmaf128 function -------------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
@@ -10,13 +11,15 @@
 #define LLVM_LIBC_SHARED_MATH_F16FMAF128_H
 
 #include "include/llvm-libc-macros/float128-macros.h"
+#include "include/llvm-libc-macros/float16-macros.h"
 #include "shared/libc_common.h"
 
 #ifdef LIBC_TYPES_HAS_FLOAT128
 
-
 #include "src/__support/math/f16fmaf128.h"
 
+
+
 namespace LIBC_NAMESPACE_DECL {
 namespace shared {
 
diff --git a/libc/src/__support/math/CMakeLists.txt b/libc/src/__support/math/CMakeLists.txt
index 869318a20db90..35a54815b3f03 100644
--- a/libc/src/__support/math/CMakeLists.txt
+++ b/libc/src/__support/math/CMakeLists.txt
@@ -675,6 +675,17 @@ add_header_library(
     libc.include.llvm-libc-macros.float16_macros
 )
 
+add_header_library(
+  f16fmaf128
+  HDRS
+    f16fmaf128.h
+  DEPENDS
+    libc.src.__support.FPUtil.fma
+    libc.src.__support.common
+    libc.src.__support.macros.config
+    libc.include.llvm-libc-macros.float128_macros
+)
+
 add_header_library(
   f16fmal
   HDRS
@@ -683,6 +694,7 @@ add_header_library(
     libc.src.__support.macros.config
     libc.src.__support.FPUtil.fma
     libc.include.llvm-libc-macros.float16_macros
+
 )
 
 add_header_library(
diff --git a/libc/src/__support/math/f16fmaf128.h b/libc/src/__support/math/f16fmaf128.h
index a341e87eede48..473a50a5fa87e 100644
--- a/libc/src/__support/math/f16fmaf128.h
+++ b/libc/src/__support/math/f16fmaf128.h
@@ -10,8 +10,12 @@
 #define LLVM_LIBC_SRC___SUPPORT_MATH_F16FMAF128_H
 
 #include "include/llvm-libc-macros/float128-macros.h"
+#include "include/llvm-libc-macros/float16-macros.h"
+#include "include/llvm-libc-types/float128.h"
+#include "include/llvm-libc-types/float16.h"
 
 #ifdef LIBC_TYPES_HAS_FLOAT128
+#ifdef LIBC_TYPES_HAS_FLOAT16
 
 #include "src/__support/FPUtil/FMA.h"
 #include "src/__support/common.h"
@@ -29,6 +33,7 @@ LIBC_INLINE static float16 f16fmaf128(float128 x, float128 y, float128 z) {
 
 } // namespace LIBC_NAMESPACE_DECL
 
+#endif // LIBC_TYPES_HAS_FLOAT16
 #endif // LIBC_TYPES_HAS_FLOAT128
 
 #endif // LLVM_LIBC_SRC___SUPPORT_MATH_F16FMAF128_H
diff --git a/libc/src/math/generic/CMakeLists.txt b/libc/src/math/generic/CMakeLists.txt
index b68ca541286fd..24447356d78bd 100644
--- a/libc/src/math/generic/CMakeLists.txt
+++ b/libc/src/math/generic/CMakeLists.txt
@@ -5060,8 +5060,7 @@ add_entrypoint_object(
   HDRS
     ../f16fmaf128.h
   DEPENDS
-    libc.src.__support.macros.properties.types
-    libc.src.__support.FPUtil.fma
+    libc.src.__support.math.f16fmaf128.h
 )
 
 add_entrypoint_object(
diff --git a/libc/src/math/generic/f16fmaf128.cpp b/libc/src/math/generic/f16fmaf128.cpp
index 5c4823c47e79f..f8bcdc3028972 100644
--- a/libc/src/math/generic/f16fmaf128.cpp
+++ b/libc/src/math/generic/f16fmaf128.cpp
@@ -7,14 +7,12 @@
 //===----------------------------------------------------------------------===//
 
 #include "src/math/f16fmaf128.h"
-#include "src/__support/FPUtil/FMA.h"
-#include "src/__support/common.h"
-#include "src/__support/macros/config.h"
+#include "src/__support/math/f16fmaf128.h"
 
 namespace LIBC_NAMESPACE_DECL {
 
 LLVM_LIBC_FUNCTION(float16, f16fmaf128, (float128 x, float128 y, float128 z)) {
-  return fputil::fma<float16>(x, y, z);
+  return math::f16fmaf128(x, y, z);
 }
 
 } // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/test/shared/CMakeLists.txt b/libc/test/shared/CMakeLists.txt
index 173b4ba57020e..96a00f169d1a6 100644
--- a/libc/test/shared/CMakeLists.txt
+++ b/libc/test/shared/CMakeLists.txt
@@ -56,9 +56,13 @@ add_fp_unittest(
     libc.src.__support.math.expf
     libc.src.__support.math.expf16
     libc.src.__support.math.f16fma
+<<<<<<< HEAD
     libc.src.__support.math.f16fmal
     libc.src.__support.math.f16sqrt
     libc.src.__support.math.f16sqrtl
+=======
+    libc.src.__support.math.f16fmaf128
+>>>>>>> a01ef8ee0824 (edited files)
     libc.src.__support.math.frexpf
     libc.src.__support.math.frexpf128
     libc.src.__support.math.frexpf16
diff --git a/libc/test/shared/shared_math_test.cpp b/libc/test/shared/shared_math_test.cpp
index 4b6fe3fb9fe98..16a6d083210d1 100644
--- a/libc/test/shared/shared_math_test.cpp
+++ b/libc/test/shared/shared_math_test.cpp
@@ -37,6 +37,9 @@ TEST(LlvmLibcSharedMathTest, AllFloat16) {
   EXPECT_FP_EQ(0x0p+0f16, LIBC_NAMESPACE::shared::sinhf16(0.0f16));
 
   EXPECT_FP_EQ(float16(10.0), LIBC_NAMESPACE::shared::f16fma(2.0, 3.0, 4.0));
+#if defined(LIBC_TYPES_HAS_FLOAT128)
+  EXPECT_FP_EQ(float16(10.0), LIBC_NAMESPACE::shared::f16fmaf128(float128(2.0), float128(3.0), float128(4.0)));
+#endif
 
   EXPECT_FP_EQ(0x0p+0f16, LIBC_NAMESPACE::shared::f16sqrt(0.0));
 
diff --git a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
index 70237b51e83b8..1309b916d7def 100644
--- a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
@@ -2908,6 +2908,18 @@ libc_support_library(
     ],
 )
 
+libc_support_library(
+    name = "__support_math_f16fmaf128",
+    hdrs = ["src/__support/math/f16fmaf128.h"],
+    deps = [
+        ":__support_fputil_fma",
+        ":__support_macros_config",
+        ":__support_common",
+        ":llvm_libc_macros_float128_macros",
+        ":llvm_libc_macros_float16_macros",
+    ],
+)
+
 libc_support_library(
     name = "__support_math_f16fmal",
     hdrs = ["src/__support/math/f16fmal.h"],
@@ -4437,7 +4449,7 @@ libc_math_function(
 libc_math_function(
     name = "f16fmaf128",
     additional_deps = [
-        ":__support_fputil_fma",
+        ":__support_math_f16fmaf128",   
     ],
 )
 

>From 2665ffe73f92132729a6882847a5a8bbeea2f707 Mon Sep 17 00:00:00 2001
From: Sukumarsawant <sawantsukumar at gmail.com>
Date: Sun, 25 Jan 2026 11:00:23 +0530
Subject: [PATCH 3/9] fixed .h error

---
 libc/src/math/generic/CMakeLists.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libc/src/math/generic/CMakeLists.txt b/libc/src/math/generic/CMakeLists.txt
index 24447356d78bd..805575e6fa602 100644
--- a/libc/src/math/generic/CMakeLists.txt
+++ b/libc/src/math/generic/CMakeLists.txt
@@ -5060,7 +5060,7 @@ add_entrypoint_object(
   HDRS
     ../f16fmaf128.h
   DEPENDS
-    libc.src.__support.math.f16fmaf128.h
+    libc.src.__support.math.f16fmaf128
 )
 
 add_entrypoint_object(

>From 6e888e3c2e77eea5be47a282b79e0fe169d99134 Mon Sep 17 00:00:00 2001
From: Sukumarsawant <sawantsukumar at gmail.com>
Date: Wed, 28 Jan 2026 12:40:46 +0530
Subject: [PATCH 4/9] resolved format issues and added float16 macro

---
 libc/shared/math.h                                |  5 +----
 libc/shared/math/f16fmaf128.h                     |  3 ---
 libc/src/__support/math/CMakeLists.txt            |  2 +-
 libc/src/__support/math/f16fmaf128.h              |  5 ++---
 libc/test/shared/CMakeLists.txt                   |  5 +----
 libc/test/shared/shared_math_test.cpp             | 11 +++++++----
 utils/bazel/llvm-project-overlay/libc/BUILD.bazel |  2 +-
 7 files changed, 13 insertions(+), 20 deletions(-)

diff --git a/libc/shared/math.h b/libc/shared/math.h
index dc17b466b075a..652581bc05d21 100644
--- a/libc/shared/math.h
+++ b/libc/shared/math.h
@@ -60,13 +60,10 @@
 #include "math/expm1f.h"
 #include "math/expm1f16.h"
 #include "math/f16fma.h"
-<<<<<<< HEAD
+#include "math/f16fmaf28.h"
 #include "math/f16fmal.h"
 #include "math/f16sqrt.h"
 #include "math/f16sqrtl.h"
-=======
-#include "math/f16fmaf128.h"
->>>>>>> a01ef8ee0824 (edited files)
 #include "math/frexpf.h"
 #include "math/frexpf128.h"
 #include "math/frexpf16.h"
diff --git a/libc/shared/math/f16fmaf128.h b/libc/shared/math/f16fmaf128.h
index ac0a473da0beb..a5b637551c62f 100644
--- a/libc/shared/math/f16fmaf128.h
+++ b/libc/shared/math/f16fmaf128.h
@@ -1,4 +1,3 @@
-
 //===-- Shared f16fmaf128 function -------------------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
@@ -18,8 +17,6 @@
 
 #include "src/__support/math/f16fmaf128.h"
 
-
-
 namespace LIBC_NAMESPACE_DECL {
 namespace shared {
 
diff --git a/libc/src/__support/math/CMakeLists.txt b/libc/src/__support/math/CMakeLists.txt
index 35a54815b3f03..5e49b7ee16699 100644
--- a/libc/src/__support/math/CMakeLists.txt
+++ b/libc/src/__support/math/CMakeLists.txt
@@ -684,6 +684,7 @@ add_header_library(
     libc.src.__support.common
     libc.src.__support.macros.config
     libc.include.llvm-libc-macros.float128_macros
+    libc.include.llvm-libc-macros.float16_macros
 )
 
 add_header_library(
@@ -694,7 +695,6 @@ add_header_library(
     libc.src.__support.macros.config
     libc.src.__support.FPUtil.fma
     libc.include.llvm-libc-macros.float16_macros
-
 )
 
 add_header_library(
diff --git a/libc/src/__support/math/f16fmaf128.h b/libc/src/__support/math/f16fmaf128.h
index 473a50a5fa87e..6af4778615ff5 100644
--- a/libc/src/__support/math/f16fmaf128.h
+++ b/libc/src/__support/math/f16fmaf128.h
@@ -1,4 +1,4 @@
-//===-- Implementation header for f16fmaf128 ------------------------*- C++ -*-===//
+//===-- Implementation header for f16fmaf128 --------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -11,8 +11,7 @@
 
 #include "include/llvm-libc-macros/float128-macros.h"
 #include "include/llvm-libc-macros/float16-macros.h"
-#include "include/llvm-libc-types/float128.h"
-#include "include/llvm-libc-types/float16.h"
+
 
 #ifdef LIBC_TYPES_HAS_FLOAT128
 #ifdef LIBC_TYPES_HAS_FLOAT16
diff --git a/libc/test/shared/CMakeLists.txt b/libc/test/shared/CMakeLists.txt
index 96a00f169d1a6..8ca4ac798c7d8 100644
--- a/libc/test/shared/CMakeLists.txt
+++ b/libc/test/shared/CMakeLists.txt
@@ -56,13 +56,10 @@ add_fp_unittest(
     libc.src.__support.math.expf
     libc.src.__support.math.expf16
     libc.src.__support.math.f16fma
-<<<<<<< HEAD
+    libc.src.__support.math.f16fmaf128
     libc.src.__support.math.f16fmal
     libc.src.__support.math.f16sqrt
     libc.src.__support.math.f16sqrtl
-=======
-    libc.src.__support.math.f16fmaf128
->>>>>>> a01ef8ee0824 (edited files)
     libc.src.__support.math.frexpf
     libc.src.__support.math.frexpf128
     libc.src.__support.math.frexpf16
diff --git a/libc/test/shared/shared_math_test.cpp b/libc/test/shared/shared_math_test.cpp
index 16a6d083210d1..b285c3867430e 100644
--- a/libc/test/shared/shared_math_test.cpp
+++ b/libc/test/shared/shared_math_test.cpp
@@ -36,10 +36,13 @@ TEST(LlvmLibcSharedMathTest, AllFloat16) {
   EXPECT_FP_EQ(0x0p+0f16, LIBC_NAMESPACE::shared::logf16(1.0f16));
   EXPECT_FP_EQ(0x0p+0f16, LIBC_NAMESPACE::shared::sinhf16(0.0f16));
 
-  EXPECT_FP_EQ(float16(10.0), LIBC_NAMESPACE::shared::f16fma(2.0, 3.0, 4.0));
-#if defined(LIBC_TYPES_HAS_FLOAT128)
-  EXPECT_FP_EQ(float16(10.0), LIBC_NAMESPACE::shared::f16fmaf128(float128(2.0), float128(3.0), float128(4.0)));
-#endif
+EXPECT_FP_EQ(float16(10.0), LIBC_NAMESPACE::shared::f16fma(2.0, 3.0, 4.0));
+
+#ifdef LIBC_TYPES_HAS_FLOAT128
+
+  EXPECT_FP_EQ(10.0f16, LIBC_NAMESPACE::shared::f16fmaf128(float128(2.0), float128(3.0), float128(4.0)));
+
+#endif 
 
   EXPECT_FP_EQ(0x0p+0f16, LIBC_NAMESPACE::shared::f16sqrt(0.0));
 
diff --git a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
index 1309b916d7def..a1702b345d415 100644
--- a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
@@ -4449,7 +4449,7 @@ libc_math_function(
 libc_math_function(
     name = "f16fmaf128",
     additional_deps = [
-        ":__support_math_f16fmaf128",   
+        ":__support_math_f16fmaf128",
     ],
 )
 

>From bb6bd9c184d72f8a886239d0137fe12fa6fb1266 Mon Sep 17 00:00:00 2001
From: Sukumarsawant <sawantsukumar at gmail.com>
Date: Thu, 29 Jan 2026 22:00:59 +0530
Subject: [PATCH 5/9] change-2 before rebase

---
 libc/shared/math/f16fmaf128.h         | 60 ++++++++++-----------
 libc/src/__support/math/f16fmaf128.h  | 75 +++++++++++++--------------
 libc/test/shared/shared_math_test.cpp |  6 +--
 3 files changed, 69 insertions(+), 72 deletions(-)

diff --git a/libc/shared/math/f16fmaf128.h b/libc/shared/math/f16fmaf128.h
index a5b637551c62f..2b5eb91724304 100644
--- a/libc/shared/math/f16fmaf128.h
+++ b/libc/shared/math/f16fmaf128.h
@@ -1,30 +1,30 @@
-//===-- Shared f16fmaf128 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_F16FMAF128_H
-#define LLVM_LIBC_SHARED_MATH_F16FMAF128_H
-
-#include "include/llvm-libc-macros/float128-macros.h"
-#include "include/llvm-libc-macros/float16-macros.h"
-#include "shared/libc_common.h"
-
-#ifdef LIBC_TYPES_HAS_FLOAT128
-
-#include "src/__support/math/f16fmaf128.h"
-
-namespace LIBC_NAMESPACE_DECL {
-namespace shared {
-
-using math::f16fmaf128;
-
-} // namespace shared
-} // namespace LIBC_NAMESPACE_DECL
-
-#endif // LIBC_TYPES_HAS_FLOAT128
-
-#endif // LLVM_LIBC_SHARED_MATH_F16FMAF128_H
+//===-- Shared f16fmaf128 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_F16FMAF128_H
+#define LLVM_LIBC_SHARED_MATH_F16FMAF128_H
+
+#include "include/llvm-libc-macros/float128-macros.h"
+#include "include/llvm-libc-macros/float16-macros.h"
+#include "shared/libc_common.h"
+
+#ifdef LIBC_TYPES_HAS_FLOAT128
+
+#include "src/__support/math/f16fmaf128.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::f16fmaf128;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LIBC_TYPES_HAS_FLOAT128
+
+#endif // LLVM_LIBC_SHARED_MATH_F16FMAF128_H
diff --git a/libc/src/__support/math/f16fmaf128.h b/libc/src/__support/math/f16fmaf128.h
index 6af4778615ff5..2d120068e5502 100644
--- a/libc/src/__support/math/f16fmaf128.h
+++ b/libc/src/__support/math/f16fmaf128.h
@@ -1,38 +1,37 @@
-//===-- Implementation header for f16fmaf128 --------------------*- 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_F16FMAF128_H
-#define LLVM_LIBC_SRC___SUPPORT_MATH_F16FMAF128_H
-
-#include "include/llvm-libc-macros/float128-macros.h"
-#include "include/llvm-libc-macros/float16-macros.h"
-
-
-#ifdef LIBC_TYPES_HAS_FLOAT128
-#ifdef LIBC_TYPES_HAS_FLOAT16
-
-#include "src/__support/FPUtil/FMA.h"
-#include "src/__support/common.h"
-#include "src/__support/macros/config.h"
-
-namespace LIBC_NAMESPACE_DECL {
-
-namespace math {
-
-LIBC_INLINE static float16 f16fmaf128(float128 x, float128 y, float128 z) {
-  return fputil::fma<float16>(x, y, z);
-}
-
-} // namespace math
-
-} // namespace LIBC_NAMESPACE_DECL
-
-#endif // LIBC_TYPES_HAS_FLOAT16
-#endif // LIBC_TYPES_HAS_FLOAT128
-
-#endif // LLVM_LIBC_SRC___SUPPORT_MATH_F16FMAF128_H
+//===-- Implementation header for f16fmaf128 --------------------*- 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_F16FMAF128_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_F16FMAF128_H
+
+#include "include/llvm-libc-macros/float128-macros.h"
+#include "include/llvm-libc-macros/float16-macros.h"
+
+#ifdef LIBC_TYPES_HAS_FLOAT128
+#ifdef LIBC_TYPES_HAS_FLOAT16
+
+#include "src/__support/FPUtil/FMA.h"
+#include "src/__support/common.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+namespace math {
+
+LIBC_INLINE static float16 f16fmaf128(float128 x, float128 y, float128 z) {
+  return fputil::fma<float16>(x, y, z);
+}
+
+} // namespace math
+
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LIBC_TYPES_HAS_FLOAT16
+#endif // LIBC_TYPES_HAS_FLOAT128
+
+#endif // LLVM_LIBC_SRC___SUPPORT_MATH_F16FMAF128_H
diff --git a/libc/test/shared/shared_math_test.cpp b/libc/test/shared/shared_math_test.cpp
index b285c3867430e..0a0857641fba2 100644
--- a/libc/test/shared/shared_math_test.cpp
+++ b/libc/test/shared/shared_math_test.cpp
@@ -19,7 +19,6 @@ TEST(LlvmLibcSharedMathTest, AllFloat16) {
   EXPECT_FP_EQ(0x0p+0f16, LIBC_NAMESPACE::shared::acospif16(1.0f16));
   EXPECT_FP_EQ(0x1p+0f16, LIBC_NAMESPACE::shared::rsqrtf16(1.0f16));
   EXPECT_FP_EQ(0x1p+0f16, LIBC_NAMESPACE::shared::sqrtf16(1.0f16));
-
   EXPECT_FP_EQ(0x0p+0f16, LIBC_NAMESPACE::shared::asinf16(0.0f16));
   EXPECT_FP_EQ(0x0p+0f16, LIBC_NAMESPACE::shared::asinhf16(0.0f16));
   EXPECT_FP_EQ(0x0p+0f16, LIBC_NAMESPACE::shared::atanf16(0.0f16));
@@ -36,13 +35,13 @@ TEST(LlvmLibcSharedMathTest, AllFloat16) {
   EXPECT_FP_EQ(0x0p+0f16, LIBC_NAMESPACE::shared::logf16(1.0f16));
   EXPECT_FP_EQ(0x0p+0f16, LIBC_NAMESPACE::shared::sinhf16(0.0f16));
 
-EXPECT_FP_EQ(float16(10.0), LIBC_NAMESPACE::shared::f16fma(2.0, 3.0, 4.0));
+  EXPECT_FP_EQ(float16(10.0), LIBC_NAMESPACE::shared::f16fma(2.0, 3.0, 4.0));
 
 #ifdef LIBC_TYPES_HAS_FLOAT128
 
   EXPECT_FP_EQ(10.0f16, LIBC_NAMESPACE::shared::f16fmaf128(float128(2.0), float128(3.0), float128(4.0)));
 
-#endif 
+#endif
 
   EXPECT_FP_EQ(0x0p+0f16, LIBC_NAMESPACE::shared::f16sqrt(0.0));
 
@@ -60,7 +59,6 @@ EXPECT_FP_EQ(float16(10.0), LIBC_NAMESPACE::shared::f16fma(2.0, 3.0, 4.0));
   EXPECT_EQ(0, LIBC_NAMESPACE::shared::ilogbf16(1.0f16));
   EXPECT_FP_EQ(0x0p+0f16, LIBC_NAMESPACE::shared::logbf16(1.0f16));
   EXPECT_EQ(0L, LIBC_NAMESPACE::shared::llogbf16(1.0f16));
-
   EXPECT_FP_EQ(0x1.921fb6p+0f16, LIBC_NAMESPACE::shared::acosf16(0.0f16));
   EXPECT_FP_EQ(0x1p+0f16, LIBC_NAMESPACE::shared::f16sqrtl(1.0L));
   EXPECT_FP_EQ(0.0f16, LIBC_NAMESPACE::shared::sinf16(0.0f16));

>From 41148ed7f2013f298aeb1a6f5ea19dc7c5d990ad Mon Sep 17 00:00:00 2001
From: Sukumarsawant <sawantsukumar at gmail.com>
Date: Thu, 29 Jan 2026 22:08:59 +0530
Subject: [PATCH 6/9] math.h spell err

---
 libc/shared/math.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libc/shared/math.h b/libc/shared/math.h
index 652581bc05d21..23e2a7367fa4b 100644
--- a/libc/shared/math.h
+++ b/libc/shared/math.h
@@ -60,7 +60,7 @@
 #include "math/expm1f.h"
 #include "math/expm1f16.h"
 #include "math/f16fma.h"
-#include "math/f16fmaf28.h"
+#include "math/f16fmaf128.h"
 #include "math/f16fmal.h"
 #include "math/f16sqrt.h"
 #include "math/f16sqrtl.h"

>From 9889354c2c90ae5ae28130d23711bb02299e0a8a Mon Sep 17 00:00:00 2001
From: Sukumarsawant <sawantsukumar at gmail.com>
Date: Thu, 29 Jan 2026 23:37:34 +0530
Subject: [PATCH 7/9] replace float128-macros with float128

---
 libc/shared/math/f16fmaf128.h                     | 2 +-
 libc/src/__support/math/CMakeLists.txt            | 2 +-
 libc/src/__support/math/f16fmaf128.h              | 2 +-
 utils/bazel/llvm-project-overlay/libc/BUILD.bazel | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/libc/shared/math/f16fmaf128.h b/libc/shared/math/f16fmaf128.h
index 2b5eb91724304..eaf2b20562251 100644
--- a/libc/shared/math/f16fmaf128.h
+++ b/libc/shared/math/f16fmaf128.h
@@ -9,7 +9,7 @@
 #ifndef LLVM_LIBC_SHARED_MATH_F16FMAF128_H
 #define LLVM_LIBC_SHARED_MATH_F16FMAF128_H
 
-#include "include/llvm-libc-macros/float128-macros.h"
+#include "include/llvm-libc-types/float128.h"
 #include "include/llvm-libc-macros/float16-macros.h"
 #include "shared/libc_common.h"
 
diff --git a/libc/src/__support/math/CMakeLists.txt b/libc/src/__support/math/CMakeLists.txt
index 5e49b7ee16699..c3b935a693b0b 100644
--- a/libc/src/__support/math/CMakeLists.txt
+++ b/libc/src/__support/math/CMakeLists.txt
@@ -683,7 +683,7 @@ add_header_library(
     libc.src.__support.FPUtil.fma
     libc.src.__support.common
     libc.src.__support.macros.config
-    libc.include.llvm-libc-macros.float128_macros
+    libc.include.llvm-libc-types.float128
     libc.include.llvm-libc-macros.float16_macros
 )
 
diff --git a/libc/src/__support/math/f16fmaf128.h b/libc/src/__support/math/f16fmaf128.h
index 2d120068e5502..0c4206385cf29 100644
--- a/libc/src/__support/math/f16fmaf128.h
+++ b/libc/src/__support/math/f16fmaf128.h
@@ -9,7 +9,7 @@
 #ifndef LLVM_LIBC_SRC___SUPPORT_MATH_F16FMAF128_H
 #define LLVM_LIBC_SRC___SUPPORT_MATH_F16FMAF128_H
 
-#include "include/llvm-libc-macros/float128-macros.h"
+#include "include/llvm-libc-types/float128.h"
 #include "include/llvm-libc-macros/float16-macros.h"
 
 #ifdef LIBC_TYPES_HAS_FLOAT128
diff --git a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
index a1702b345d415..95d2fd490dfed 100644
--- a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
@@ -2915,7 +2915,7 @@ libc_support_library(
         ":__support_fputil_fma",
         ":__support_macros_config",
         ":__support_common",
-        ":llvm_libc_macros_float128_macros",
+        ":llvm_libc_types_float128",
         ":llvm_libc_macros_float16_macros",
     ],
 )

>From 30692826d5e1db3c61c1629c07f83df87d1c42d0 Mon Sep 17 00:00:00 2001
From: Sukumarsawant <sawantsukumar at gmail.com>
Date: Fri, 30 Jan 2026 11:08:41 +0530
Subject: [PATCH 8/9] formatting

---
 libc/shared/math/f16fmaf128.h        | 12 ++++++------
 libc/src/__support/math/f16fmaf128.h | 10 +++++-----
 2 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/libc/shared/math/f16fmaf128.h b/libc/shared/math/f16fmaf128.h
index eaf2b20562251..69a4b6b37553f 100644
--- a/libc/shared/math/f16fmaf128.h
+++ b/libc/shared/math/f16fmaf128.h
@@ -7,12 +7,12 @@
 //===----------------------------------------------------------------------===//
 
 #ifndef LLVM_LIBC_SHARED_MATH_F16FMAF128_H
-#define LLVM_LIBC_SHARED_MATH_F16FMAF128_H
-
-#include "include/llvm-libc-types/float128.h"
-#include "include/llvm-libc-macros/float16-macros.h"
-#include "shared/libc_common.h"
-
+#define LLVM_LIBC_SHARED_MATH_F16FMAF128_H
+
+#include "include/llvm-libc-macros/float16-macros.h"
+#include "include/llvm-libc-types/float128.h"
+#include "shared/libc_common.h"
+
 #ifdef LIBC_TYPES_HAS_FLOAT128
 
 #include "src/__support/math/f16fmaf128.h"
diff --git a/libc/src/__support/math/f16fmaf128.h b/libc/src/__support/math/f16fmaf128.h
index 0c4206385cf29..d68f97516a2cd 100644
--- a/libc/src/__support/math/f16fmaf128.h
+++ b/libc/src/__support/math/f16fmaf128.h
@@ -7,11 +7,11 @@
 //===----------------------------------------------------------------------===//
 
 #ifndef LLVM_LIBC_SRC___SUPPORT_MATH_F16FMAF128_H
-#define LLVM_LIBC_SRC___SUPPORT_MATH_F16FMAF128_H
-
-#include "include/llvm-libc-types/float128.h"
-#include "include/llvm-libc-macros/float16-macros.h"
-
+#define LLVM_LIBC_SRC___SUPPORT_MATH_F16FMAF128_H
+
+#include "include/llvm-libc-macros/float16-macros.h"
+#include "include/llvm-libc-types/float128.h"
+
 #ifdef LIBC_TYPES_HAS_FLOAT128
 #ifdef LIBC_TYPES_HAS_FLOAT16
 

>From 18e13a5dad815bbfe7ed1a533120bd728ac99530 Mon Sep 17 00:00:00 2001
From: bassiounix <muhammad.m.bassiouni at gmail.com>
Date: Fri, 30 Jan 2026 08:03:11 +0200
Subject: [PATCH 9/9] fix: format

---
 libc/shared/math/f16fmaf128.h                     | 2 +-
 libc/src/__support/math/f16fmaf128.h              | 2 +-
 utils/bazel/llvm-project-overlay/libc/BUILD.bazel | 4 ++--
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/libc/shared/math/f16fmaf128.h b/libc/shared/math/f16fmaf128.h
index 69a4b6b37553f..118f0c0e24952 100644
--- a/libc/shared/math/f16fmaf128.h
+++ b/libc/shared/math/f16fmaf128.h
@@ -6,7 +6,7 @@
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef LLVM_LIBC_SHARED_MATH_F16FMAF128_H
+#ifndef LLVM_LIBC_SHARED_MATH_F16FMAF128_H
 #define LLVM_LIBC_SHARED_MATH_F16FMAF128_H
 
 #include "include/llvm-libc-macros/float16-macros.h"
diff --git a/libc/src/__support/math/f16fmaf128.h b/libc/src/__support/math/f16fmaf128.h
index d68f97516a2cd..d2cf940a9a95d 100644
--- a/libc/src/__support/math/f16fmaf128.h
+++ b/libc/src/__support/math/f16fmaf128.h
@@ -6,7 +6,7 @@
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef LLVM_LIBC_SRC___SUPPORT_MATH_F16FMAF128_H
+#ifndef LLVM_LIBC_SRC___SUPPORT_MATH_F16FMAF128_H
 #define LLVM_LIBC_SRC___SUPPORT_MATH_F16FMAF128_H
 
 #include "include/llvm-libc-macros/float16-macros.h"
diff --git a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
index 95d2fd490dfed..49be3212d5749 100644
--- a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
@@ -2912,11 +2912,11 @@ libc_support_library(
     name = "__support_math_f16fmaf128",
     hdrs = ["src/__support/math/f16fmaf128.h"],
     deps = [
+        ":__support_common",
         ":__support_fputil_fma",
         ":__support_macros_config",
-        ":__support_common",
-        ":llvm_libc_types_float128",
         ":llvm_libc_macros_float16_macros",
+        ":llvm_libc_types_float128",
     ],
 )
 



More information about the libc-commits mailing list