[libc-commits] [libc] [llvm] [libc] add emulated f128 support for dsubf128 (PR #242204)

Sachin 🗲 via libc-commits libc-commits at lists.llvm.org
Thu Nov 12 23:50:44 PST 2026


https://github.com/s4chinjha created https://github.com/llvm/llvm-project/pull/242204

this pr implements support for dsubf128 to use the emulated f128 type

addresses https://github.com/llvm/llvm-project/issues/234601

>From 32805a0c69c0fcbd63e130ef3b2c1639a2c37665 Mon Sep 17 00:00:00 2001
From: s4chinjha <s4chinjha at gmail.com>
Date: Fri, 13 Nov 2026 12:58:13 +0530
Subject: [PATCH] [libc] add emulated f128 support for dsubf128

---
 libc/config/baremetal/aarch64/entrypoints.txt |  2 +-
 libc/config/baremetal/arm/entrypoints.txt     |  2 +-
 libc/config/baremetal/hexagon/entrypoints.txt |  2 +-
 libc/config/baremetal/riscv/entrypoints.txt   |  2 +-
 libc/config/darwin/aarch64/entrypoints.txt    |  2 +-
 libc/config/darwin/x86_64/entrypoints.txt     |  1 +
 libc/config/freebsd/x86_64/entrypoints.txt    |  2 +-
 libc/config/gpu/amdgpu/entrypoints.txt        |  1 +
 libc/config/gpu/nvptx/entrypoints.txt         |  1 +
 libc/config/linux/aarch64/entrypoints.txt     |  2 +-
 libc/config/linux/arm/entrypoints.txt         |  1 +
 libc/config/linux/riscv/entrypoints.txt       |  2 +-
 libc/config/linux/x86_64/entrypoints.txt      |  2 +-
 libc/config/windows/entrypoints.txt           |  1 +
 libc/shared/math/dsubf128.h                   |  6 ------
 libc/src/__support/math/CMakeLists.txt        |  2 +-
 libc/src/__support/math/dsubf128.h            | 11 ++++-------
 libc/src/math/dsubf128.h                      |  5 +++++
 libc/src/math/generic/CMakeLists.txt          |  1 +
 libc/src/math/generic/dsubf128.cpp            |  5 ++++-
 libc/test/shared/CMakeLists.txt               |  1 +
 .../shared/shared_math_constexpr_test.cpp     |  2 ++
 libc/test/shared/shared_math_test.cpp         |  4 ++--
 libc/test/src/math/CMakeLists.txt             | 15 +++++++++++++++
 libc/test/src/math/dsubf128_test.cpp          | 19 +++++++++++++++++++
 libc/test/src/math/smoke/CMakeLists.txt       |  1 +
 libc/test/src/math/smoke/dsubf128_test.cpp    | 15 ++++++++++++---
 .../llvm-project-overlay/libc/BUILD.bazel     |  4 +++-
 .../libc/test/src/math/BUILD.bazel            |  8 ++++++++
 .../libc/test/src/math/smoke/BUILD.bazel      |  3 +++
 30 files changed, 95 insertions(+), 30 deletions(-)
 create mode 100644 libc/test/src/math/dsubf128_test.cpp

diff --git a/libc/config/baremetal/aarch64/entrypoints.txt b/libc/config/baremetal/aarch64/entrypoints.txt
index 1c2c46869cb3f..0fb0107bca188 100644
--- a/libc/config/baremetal/aarch64/entrypoints.txt
+++ b/libc/config/baremetal/aarch64/entrypoints.txt
@@ -396,6 +396,7 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.dsqrtl
     libc.src.math.daddl
     libc.src.math.ddivl
+    libc.src.math.dsubf128
     libc.src.math.dsubl
     libc.src.math.erff
     libc.src.math.exp
@@ -808,7 +809,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
     libc.src.math.dfmaf128
     libc.src.math.dmulf128
     libc.src.math.dsqrtf128
-    libc.src.math.dsubf128
     libc.src.math.faddf128
     libc.src.math.fdivf128
     libc.src.math.ffmaf128
diff --git a/libc/config/baremetal/arm/entrypoints.txt b/libc/config/baremetal/arm/entrypoints.txt
index 5d8de6562f9e9..89f02bdd938d6 100644
--- a/libc/config/baremetal/arm/entrypoints.txt
+++ b/libc/config/baremetal/arm/entrypoints.txt
@@ -408,6 +408,7 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.dsqrtl
     libc.src.math.daddl
     libc.src.math.ddivl
+    libc.src.math.dsubf128
     libc.src.math.dsubl
     libc.src.math.erff
     libc.src.math.exp
@@ -819,7 +820,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
     libc.src.math.dfmaf128
     libc.src.math.dmulf128
     libc.src.math.dsqrtf128
-    libc.src.math.dsubf128
     libc.src.math.faddf128
     libc.src.math.fdivf128
     libc.src.math.ffmaf128
diff --git a/libc/config/baremetal/hexagon/entrypoints.txt b/libc/config/baremetal/hexagon/entrypoints.txt
index b7d0f2a74d21f..891b563e8c91e 100644
--- a/libc/config/baremetal/hexagon/entrypoints.txt
+++ b/libc/config/baremetal/hexagon/entrypoints.txt
@@ -394,6 +394,7 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.dsqrtl
     libc.src.math.daddl
     libc.src.math.ddivl
+    libc.src.math.dsubf128
     libc.src.math.dsubl
     libc.src.math.erff
     libc.src.math.exp
@@ -763,7 +764,6 @@ if(LIBC_TYPES_HAS_FLOAT128)
     libc.src.math.dfmaf128
     libc.src.math.dmulf128
     libc.src.math.dsqrtf128
-    libc.src.math.dsubf128
     libc.src.math.fabsf128
     libc.src.math.faddf128
     libc.src.math.fdimf128
diff --git a/libc/config/baremetal/riscv/entrypoints.txt b/libc/config/baremetal/riscv/entrypoints.txt
index c21149a19dde8..b0ff79e477d94 100644
--- a/libc/config/baremetal/riscv/entrypoints.txt
+++ b/libc/config/baremetal/riscv/entrypoints.txt
@@ -399,6 +399,7 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.dsqrtl
     libc.src.math.daddl
     libc.src.math.ddivl
+    libc.src.math.dsubf128
     libc.src.math.dsubl
     libc.src.math.erff
     libc.src.math.exp
@@ -811,7 +812,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
     libc.src.math.dfmaf128
     libc.src.math.dmulf128
     libc.src.math.dsqrtf128
-    libc.src.math.dsubf128
     libc.src.math.faddf128
     libc.src.math.fdivf128
     libc.src.math.ffmaf128
diff --git a/libc/config/darwin/aarch64/entrypoints.txt b/libc/config/darwin/aarch64/entrypoints.txt
index b3b033e890793..c987b82e26283 100644
--- a/libc/config/darwin/aarch64/entrypoints.txt
+++ b/libc/config/darwin/aarch64/entrypoints.txt
@@ -217,6 +217,7 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.dsqrtl
     libc.src.math.daddl
     libc.src.math.ddivl
+    libc.src.math.dsubf128
     libc.src.math.dsubl
     libc.src.math.erff
     libc.src.math.exp
@@ -630,7 +631,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
     libc.src.math.dfmaf128
     libc.src.math.dmulf128
     libc.src.math.dsqrtf128
-    libc.src.math.dsubf128
     libc.src.math.faddf128
     libc.src.math.fdivf128
     libc.src.math.ffmaf128
diff --git a/libc/config/darwin/x86_64/entrypoints.txt b/libc/config/darwin/x86_64/entrypoints.txt
index d42cb3bb5bc62..671cdb575d272 100644
--- a/libc/config/darwin/x86_64/entrypoints.txt
+++ b/libc/config/darwin/x86_64/entrypoints.txt
@@ -136,6 +136,7 @@ set(TARGET_LIBM_ENTRYPOINTS
     #libc.src.math.ddivl
     #libc.src.math.dfmal
     #libc.src.math.dsqrtl
+    #libc.src.math.dsubf128
     #libc.src.math.dsubl
     #libc.src.math.expf
     #libc.src.math.exp2f
diff --git a/libc/config/freebsd/x86_64/entrypoints.txt b/libc/config/freebsd/x86_64/entrypoints.txt
index 85a18879b86fb..212978537bdc1 100644
--- a/libc/config/freebsd/x86_64/entrypoints.txt
+++ b/libc/config/freebsd/x86_64/entrypoints.txt
@@ -148,6 +148,7 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.daddl
     libc.src.math.ddivl
     libc.src.math.dfmal
+    libc.src.math.dsubf128
     libc.src.math.dsubl
     libc.src.math.erff
     libc.src.math.exp
@@ -563,7 +564,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
     libc.src.math.dfmaf128
     libc.src.math.dmulf128
     libc.src.math.dsqrtf128
-    libc.src.math.dsubf128
     libc.src.math.faddf128
     libc.src.math.fdivf128
     libc.src.math.ffmaf128
diff --git a/libc/config/gpu/amdgpu/entrypoints.txt b/libc/config/gpu/amdgpu/entrypoints.txt
index 13792b307c5e7..3a9a5bfb8d27d 100644
--- a/libc/config/gpu/amdgpu/entrypoints.txt
+++ b/libc/config/gpu/amdgpu/entrypoints.txt
@@ -342,6 +342,7 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.dfmal
     libc.src.math.dmull
     libc.src.math.dsqrtl
+    libc.src.math.dsubf128
     libc.src.math.erff
     libc.src.math.exp
     libc.src.math.exp10
diff --git a/libc/config/gpu/nvptx/entrypoints.txt b/libc/config/gpu/nvptx/entrypoints.txt
index 493eb07c8f526..e5400773ee22f 100644
--- a/libc/config/gpu/nvptx/entrypoints.txt
+++ b/libc/config/gpu/nvptx/entrypoints.txt
@@ -338,6 +338,7 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.dfmal
     libc.src.math.dmull
     libc.src.math.dsqrtl
+    libc.src.math.dsubf128
     libc.src.math.erff
     libc.src.math.exp
     libc.src.math.exp10
diff --git a/libc/config/linux/aarch64/entrypoints.txt b/libc/config/linux/aarch64/entrypoints.txt
index aed6852ff9b06..aa5341345bc1c 100644
--- a/libc/config/linux/aarch64/entrypoints.txt
+++ b/libc/config/linux/aarch64/entrypoints.txt
@@ -656,6 +656,7 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.dfmal
     libc.src.math.dmull
     libc.src.math.dsqrtl
+    libc.src.math.dsubf128
     libc.src.math.dsubl
     libc.src.math.erff
     libc.src.math.exp
@@ -1058,7 +1059,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
     libc.src.math.dfmaf128
     libc.src.math.dmulf128
     libc.src.math.dsqrtf128
-    libc.src.math.dsubf128
     libc.src.math.faddf128
     libc.src.math.fdivf128
     libc.src.math.ffmaf128
diff --git a/libc/config/linux/arm/entrypoints.txt b/libc/config/linux/arm/entrypoints.txt
index 77edf1dc5d071..2927e66c631d0 100644
--- a/libc/config/linux/arm/entrypoints.txt
+++ b/libc/config/linux/arm/entrypoints.txt
@@ -439,6 +439,7 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.daddf128
     libc.src.math.dfmal
     libc.src.math.dsqrtl
+    libc.src.math.dsubf128
     libc.src.math.erff
     libc.src.math.exp
     libc.src.math.exp10
diff --git a/libc/config/linux/riscv/entrypoints.txt b/libc/config/linux/riscv/entrypoints.txt
index dda4f01e36978..9d9f96b6a406d 100644
--- a/libc/config/linux/riscv/entrypoints.txt
+++ b/libc/config/linux/riscv/entrypoints.txt
@@ -737,6 +737,7 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.dfmal
     libc.src.math.dmull
     libc.src.math.dsqrtl
+    libc.src.math.dsubf128
     libc.src.math.dsubl
     libc.src.math.erff
     libc.src.math.exp
@@ -1160,7 +1161,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
     libc.src.math.dfmaf128
     libc.src.math.dmulf128
     libc.src.math.dsqrtf128
-    libc.src.math.dsubf128
     libc.src.math.faddf128
     libc.src.math.fdivf128
     libc.src.math.ffmaf128
diff --git a/libc/config/linux/x86_64/entrypoints.txt b/libc/config/linux/x86_64/entrypoints.txt
index eb5dcd44c8fb7..f5fc83abce784 100644
--- a/libc/config/linux/x86_64/entrypoints.txt
+++ b/libc/config/linux/x86_64/entrypoints.txt
@@ -737,6 +737,7 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.dfmal
     libc.src.math.dmull
     libc.src.math.dsqrtl
+    libc.src.math.dsubf128
     libc.src.math.dsubl
     libc.src.math.erff
     libc.src.math.exp
@@ -1160,7 +1161,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
     libc.src.math.dfmaf128
     libc.src.math.dmulf128
     libc.src.math.dsqrtf128
-    libc.src.math.dsubf128
     libc.src.math.faddf128
     libc.src.math.fdivf128
     libc.src.math.ffmaf128
diff --git a/libc/config/windows/entrypoints.txt b/libc/config/windows/entrypoints.txt
index 6cb1e28e72280..8c0df83a70772 100644
--- a/libc/config/windows/entrypoints.txt
+++ b/libc/config/windows/entrypoints.txt
@@ -180,6 +180,7 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.daddl
     libc.src.math.ddivl
     libc.src.math.dfmal
+    libc.src.math.dsubf128
     libc.src.math.dsubl
     libc.src.math.erff
     libc.src.math.exp
diff --git a/libc/shared/math/dsubf128.h b/libc/shared/math/dsubf128.h
index cc3df7bae8d59..7688514a92a5b 100644
--- a/libc/shared/math/dsubf128.h
+++ b/libc/shared/math/dsubf128.h
@@ -9,10 +9,6 @@
 #ifndef LLVM_LIBC_SHARED_MATH_DSUBF128_H
 #define LLVM_LIBC_SHARED_MATH_DSUBF128_H
 
-#include "include/llvm-libc-types/float128.h"
-
-#ifdef LIBC_TYPES_HAS_NATIVE_FLOAT128
-
 #include "shared/libc_common.h"
 #include "src/__support/math/dsubf128.h"
 
@@ -24,6 +20,4 @@ using math::dsubf128;
 } // namespace shared
 } // namespace LIBC_NAMESPACE_DECL
 
-#endif // LIBC_TYPES_HAS_NATIVE_FLOAT128
-
 #endif // LLVM_LIBC_SHARED_MATH_DSUBF128_H
diff --git a/libc/src/__support/math/CMakeLists.txt b/libc/src/__support/math/CMakeLists.txt
index c78bab1e45b8a..9e9d149e350d9 100644
--- a/libc/src/__support/math/CMakeLists.txt
+++ b/libc/src/__support/math/CMakeLists.txt
@@ -3164,7 +3164,7 @@ add_header_library(
   HDRS
     dsubf128.h
   DEPENDS
-    libc.include.llvm-libc-types.float128
+    libc.src.__support.FPUtil.float128
     libc.src.__support.FPUtil.generic.add_sub
     libc.src.__support.macros.config
 )
diff --git a/libc/src/__support/math/dsubf128.h b/libc/src/__support/math/dsubf128.h
index 4aee93a1114b6..b4d25efa047a9 100644
--- a/libc/src/__support/math/dsubf128.h
+++ b/libc/src/__support/math/dsubf128.h
@@ -9,23 +9,20 @@
 #ifndef LLVM_LIBC_SRC___SUPPORT_MATH_DSUBF128_H
 #define LLVM_LIBC_SRC___SUPPORT_MATH_DSUBF128_H
 
-#include "include/llvm-libc-types/float128.h"
-
-#ifdef LIBC_TYPES_HAS_NATIVE_FLOAT128
-
+#include "src/__support/FPUtil/float128.h"
 #include "src/__support/FPUtil/generic/add_sub.h"
 #include "src/__support/macros/config.h"
 
 namespace LIBC_NAMESPACE_DECL {
 namespace math {
 
-LIBC_INLINE double dsubf128(float128 x, float128 y) {
+using LIBC_NAMESPACE::fputil::Float128;
+
+LIBC_INLINE constexpr double dsubf128(Float128 x, Float128 y) {
   return fputil::generic::sub<double>(x, y);
 }
 
 } // namespace math
 } // namespace LIBC_NAMESPACE_DECL
 
-#endif // LIBC_TYPES_HAS_NATIVE_FLOAT128
-
 #endif // LLVM_LIBC_SRC___SUPPORT_MATH_DSUBF128_H
diff --git a/libc/src/math/dsubf128.h b/libc/src/math/dsubf128.h
index 8ac58a916f0de..07c3ed0ba5cec 100644
--- a/libc/src/math/dsubf128.h
+++ b/libc/src/math/dsubf128.h
@@ -9,11 +9,16 @@
 #ifndef LLVM_LIBC_SRC_MATH_DSUBF128_H
 #define LLVM_LIBC_SRC_MATH_DSUBF128_H
 
+#include "src/__support/FPUtil/float128.h"
 #include "src/__support/macros/config.h"
 #include "src/__support/macros/properties/types.h"
 
 namespace LIBC_NAMESPACE_DECL {
 
+#ifndef LIBC_TYPES_HAS_NATIVE_FLOAT128
+using float128 = LIBC_NAMESPACE::fputil::Float128;
+#endif // LIBC_TYPES_HAS_NATIVE_FLOAT128
+
 double dsubf128(float128 x, float128 y);
 
 } // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/CMakeLists.txt b/libc/src/math/generic/CMakeLists.txt
index 0b3881dd00fa2..d1cfee7bb4a1e 100644
--- a/libc/src/math/generic/CMakeLists.txt
+++ b/libc/src/math/generic/CMakeLists.txt
@@ -285,6 +285,7 @@ add_entrypoint_object(
   HDRS
     ../dsubf128.h
   DEPENDS
+    libc.src.__support.CPP.bit
     libc.src.__support.math.dsubf128
 )
 
diff --git a/libc/src/math/generic/dsubf128.cpp b/libc/src/math/generic/dsubf128.cpp
index 81510246b8b34..a14e4bad38d9f 100644
--- a/libc/src/math/generic/dsubf128.cpp
+++ b/libc/src/math/generic/dsubf128.cpp
@@ -7,12 +7,15 @@
 //===----------------------------------------------------------------------===//
 
 #include "src/math/dsubf128.h"
+#include "src/__support/CPP/bit.h"
 #include "src/__support/math/dsubf128.h"
 
 namespace LIBC_NAMESPACE_DECL {
 
+using LIBC_NAMESPACE::fputil::Float128;
+
 LLVM_LIBC_FUNCTION(double, dsubf128, (float128 x, float128 y)) {
-  return math::dsubf128(x, y);
+  return math::dsubf128(cpp::bit_cast<Float128>(x), cpp::bit_cast<Float128>(y));
 }
 
 } // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/test/shared/CMakeLists.txt b/libc/test/shared/CMakeLists.txt
index 7d368e7752361..d530538e2c9e9 100644
--- a/libc/test/shared/CMakeLists.txt
+++ b/libc/test/shared/CMakeLists.txt
@@ -605,6 +605,7 @@ else()
       libc.src.__support.math.dmulf128
       libc.src.__support.math.dmull
       libc.src.__support.math.dsqrtf128
+      libc.src.__support.math.dsubf128
       libc.src.__support.math.f16add
       libc.src.__support.math.f16addf
       libc.src.__support.math.f16addf128
diff --git a/libc/test/shared/shared_math_constexpr_test.cpp b/libc/test/shared/shared_math_constexpr_test.cpp
index 57776b640b1c3..28d16a053d39e 100644
--- a/libc/test/shared/shared_math_constexpr_test.cpp
+++ b/libc/test/shared/shared_math_constexpr_test.cpp
@@ -418,6 +418,8 @@ static_assert(Float128(0.0) ==
                                                    Float128(0.0)));
 static_assert(0.0 ==
               LIBC_NAMESPACE::shared::daddf128(Float128(0.0), Float128(0.0)));
+static_assert(0.0 ==
+              LIBC_NAMESPACE::shared::dsubf128(Float128(0.0), Float128(0.0)));
 static_assert(Float128(1.0) ==
               LIBC_NAMESPACE::shared::fabsf128(Float128(-1.0)));
 static_assert(Float80(0.0) ==
diff --git a/libc/test/shared/shared_math_test.cpp b/libc/test/shared/shared_math_test.cpp
index f88d37bb9f6d3..515abe4480732 100644
--- a/libc/test/shared/shared_math_test.cpp
+++ b/libc/test/shared/shared_math_test.cpp
@@ -608,6 +608,8 @@ TEST(LlvmLibcSharedMathTest, AllEmuFloat128) {
                                   Float128(0.0), Float128(0.0)));
   EXPECT_FP_EQ(0.0,
                LIBC_NAMESPACE::shared::daddf128(Float128(0.0), Float128(0.0)));
+  EXPECT_FP_EQ(0.0,
+               LIBC_NAMESPACE::shared::dsubf128(Float128(0.0), Float128(0.0)));
   EXPECT_FP_EQ(Float128(0.0), LIBC_NAMESPACE::shared::fabsf128(Float128(0.0)));
   EXPECT_FP_EQ(Float128(0.0),
                LIBC_NAMESPACE::shared::fdimf128(Float128(0.0), Float128(0.0)));
@@ -766,8 +768,6 @@ TEST(LlvmLibcSharedMathTest, AllFloat128) {
                LIBC_NAMESPACE::shared::ddivf128(float128(1.0), float128(1.0)));
   EXPECT_FP_EQ(0.0,
                LIBC_NAMESPACE::shared::dmulf128(float128(0.0), float128(0.0)));
-  EXPECT_FP_EQ(0.0,
-               LIBC_NAMESPACE::shared::dsubf128(float128(0.0), float128(0.0)));
   EXPECT_FP_EQ(float128(0.0),
                LIBC_NAMESPACE::shared::faddf128(float128(0.0), float128(0.0)));
   EXPECT_FP_EQ(1.0f,
diff --git a/libc/test/src/math/CMakeLists.txt b/libc/test/src/math/CMakeLists.txt
index ba1259488384d..715fe0b54ab46 100644
--- a/libc/test/src/math/CMakeLists.txt
+++ b/libc/test/src/math/CMakeLists.txt
@@ -3749,6 +3749,21 @@ add_fp_unittest(
     libc.src.stdlib.srand
 )
 
+add_fp_unittest(
+  dsubf128_test
+  NEED_MPFR_F128
+  SUITE
+    libc-math-tests
+  SRCS
+    dsubf128_test.cpp
+  HDRS
+    SubTest.h
+  DEPENDS
+    libc.src.math.dsubf128
+    libc.src.__support.FPUtil.float128
+    libc.src.__support.FPUtil.fp_bits
+)
+
 add_fp_unittest(
   dsubl_test
   NEED_MPFR
diff --git a/libc/test/src/math/dsubf128_test.cpp b/libc/test/src/math/dsubf128_test.cpp
new file mode 100644
index 0000000000000..1bf39f8dac0a9
--- /dev/null
+++ b/libc/test/src/math/dsubf128_test.cpp
@@ -0,0 +1,19 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+///
+/// \file
+/// Unittests for dsubf128.
+///
+//===----------------------------------------------------------------------===//
+
+#include "SubTest.h"
+
+#include "src/__support/FPUtil/float128.h"
+#include "src/math/dsubf128.h"
+
+LIST_SUB_TESTS(Dsubf128, double, float128, LIBC_NAMESPACE::dsubf128)
diff --git a/libc/test/src/math/smoke/CMakeLists.txt b/libc/test/src/math/smoke/CMakeLists.txt
index bc0d6c99b8744..42ed6f96255ca 100644
--- a/libc/test/src/math/smoke/CMakeLists.txt
+++ b/libc/test/src/math/smoke/CMakeLists.txt
@@ -771,6 +771,7 @@ add_fp_unittest(
     libc.hdr.errno_macros
     libc.hdr.fenv_macros
     libc.src.math.dsubf128
+    libc.src.__support.FPUtil.float128
     libc.src.__support.macros.properties.os
 )
 
diff --git a/libc/test/src/math/smoke/dsubf128_test.cpp b/libc/test/src/math/smoke/dsubf128_test.cpp
index 9b35c02548b6e..2afca9224a121 100644
--- a/libc/test/src/math/smoke/dsubf128_test.cpp
+++ b/libc/test/src/math/smoke/dsubf128_test.cpp
@@ -1,13 +1,22 @@
-//===-- Unittests for dsubf128 --------------------------------------------===//
+//===----------------------------------------------------------------------===//
 //
 // 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
 //
 //===----------------------------------------------------------------------===//
+///
+/// \file
+/// Unittests for dsubf128.
+///
+//===----------------------------------------------------------------------===//
 
-#include "SubTest.h"
-
+#include "src/__support/FPUtil/float128.h"
 #include "src/math/dsubf128.h"
+#include "test/src/math/smoke/SubTest.h"
+
+#ifndef LIBC_TYPES_HAS_NATIVE_FLOAT128
+using float128 = LIBC_NAMESPACE::fputil::Float128;
+#endif // LIBC_TYPES_HAS_NATIVE_FLOAT128
 
 LIST_SUB_TESTS(Dsubf128, double, float128, LIBC_NAMESPACE::dsubf128)
diff --git a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
index cb9e218e22e80..e13902c391fc6 100644
--- a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
@@ -9862,8 +9862,8 @@ libc_support_library(
     hdrs = ["src/__support/math/dsubf128.h"],
     deps = [
         ":__support_fputil_basic_operations",
+        ":__support_fputil_float128",
         ":__support_macros_config",
-        ":llvm_libc_types_float128",
     ],
 )
 
@@ -14440,6 +14440,8 @@ libc_math_function(
 libc_math_function(
     name = "dsubf128",
     additional_deps = [
+        ":__support_cpp_bit",
+        ":__support_fputil_float128",
         ":__support_math_dsubf128",
     ],
 )
diff --git a/utils/bazel/llvm-project-overlay/libc/test/src/math/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/test/src/math/BUILD.bazel
index eb2281762a707..2dcf0c340a6a9 100644
--- a/utils/bazel/llvm-project-overlay/libc/test/src/math/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/libc/test/src/math/BUILD.bazel
@@ -253,6 +253,14 @@ math_mpfr_test(
     hdrs = ["SqrtTest.h"],
 )
 
+math_mpfr_test(
+    name = "dsubf128",
+    hdrs = ["SubTest.h"],
+    deps = [
+        "//libc:__support_fputil_float128",
+    ],
+)
+
 math_mpfr_test(
     name = "dsubl",
     hdrs = ["SubTest.h"],
diff --git a/utils/bazel/llvm-project-overlay/libc/test/src/math/smoke/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/test/src/math/smoke/BUILD.bazel
index 2add50bddd902..fd899d7bad6b3 100644
--- a/utils/bazel/llvm-project-overlay/libc/test/src/math/smoke/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/libc/test/src/math/smoke/BUILD.bazel
@@ -566,6 +566,9 @@ math_test(
 math_test(
     name = "dsubf128",
     hdrs = ["SubTest.h"],
+    deps = [
+        "//libc:__support_fputil_float128",
+    ],
 )
 
 math_test(



More information about the libc-commits mailing list