[libc-commits] [libc] fd77b5d - [libc][math] Add emulated f128 support for ddivf128 (#242651)
via libc-commits
libc-commits at lists.llvm.org
Sun Nov 15 05:12:48 PST 2026
Author: Sachin 🗲
Date: 2026-11-15T18:42:43+05:30
New Revision: fd77b5d6db335ceff69606c340e6e4040e6aac9f
URL: https://github.com/llvm/llvm-project/commit/fd77b5d6db335ceff69606c340e6e4040e6aac9f
DIFF: https://github.com/llvm/llvm-project/commit/fd77b5d6db335ceff69606c340e6e4040e6aac9f.diff
LOG: [libc][math] Add emulated f128 support for ddivf128 (#242651)
Implements support for ddivf128 to use the emulated f128 type
part of https://github.com/llvm/llvm-project/issues/234601
Added:
libc/test/src/math/ddivf128_test.cpp
Modified:
libc/config/baremetal/aarch64/entrypoints.txt
libc/config/baremetal/arm/entrypoints.txt
libc/config/baremetal/hexagon/entrypoints.txt
libc/config/baremetal/riscv/entrypoints.txt
libc/config/darwin/aarch64/entrypoints.txt
libc/config/darwin/x86_64/entrypoints.txt
libc/config/freebsd/x86_64/entrypoints.txt
libc/config/gpu/amdgpu/entrypoints.txt
libc/config/gpu/nvptx/entrypoints.txt
libc/config/linux/aarch64/entrypoints.txt
libc/config/linux/arm/entrypoints.txt
libc/config/linux/riscv/entrypoints.txt
libc/config/linux/x86_64/entrypoints.txt
libc/config/windows/entrypoints.txt
libc/shared/math/ddivf128.h
libc/src/__support/math/CMakeLists.txt
libc/src/__support/math/ddivf128.h
libc/src/math/ddivf128.h
libc/src/math/generic/CMakeLists.txt
libc/src/math/generic/ddivf128.cpp
libc/test/shared/shared_math_constexpr_test.cpp
libc/test/shared/shared_math_test.cpp
libc/test/src/math/CMakeLists.txt
libc/test/src/math/smoke/CMakeLists.txt
libc/test/src/math/smoke/ddivf128_test.cpp
libc/test/src/math/smoke/dmulf128_test.cpp
utils/bazel/llvm-project-overlay/libc/src/__support/math/BUILD.bazel
utils/bazel/llvm-project-overlay/libc/src/math/BUILD.bazel
utils/bazel/llvm-project-overlay/libc/test/src/math/BUILD.bazel
utils/bazel/llvm-project-overlay/libc/test/src/math/smoke/BUILD.bazel
Removed:
################################################################################
diff --git a/libc/config/baremetal/aarch64/entrypoints.txt b/libc/config/baremetal/aarch64/entrypoints.txt
index b7563d187ed71..d5ae19be94983 100644
--- a/libc/config/baremetal/aarch64/entrypoints.txt
+++ b/libc/config/baremetal/aarch64/entrypoints.txt
@@ -391,12 +391,13 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.coshf
libc.src.math.cospif
libc.src.math.daddf128
- libc.src.math.dmulf128
+ libc.src.math.daddl
+ libc.src.math.ddivf128
+ libc.src.math.ddivl
libc.src.math.dfmal
+ libc.src.math.dmulf128
libc.src.math.dmull
libc.src.math.dsqrtl
- libc.src.math.daddl
- libc.src.math.ddivl
libc.src.math.dsubf128
libc.src.math.dsubl
libc.src.math.erff
@@ -806,7 +807,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
list(APPEND TARGET_LIBM_ENTRYPOINTS
# math.h C23 _Float128 entrypoints
libc.src.math.canonicalizef80
- libc.src.math.ddivf128
libc.src.math.dfmaf128
libc.src.math.dsqrtf128
libc.src.math.faddf128
diff --git a/libc/config/baremetal/arm/entrypoints.txt b/libc/config/baremetal/arm/entrypoints.txt
index 8733fe6596eef..cf6fcc97c2175 100644
--- a/libc/config/baremetal/arm/entrypoints.txt
+++ b/libc/config/baremetal/arm/entrypoints.txt
@@ -403,12 +403,13 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.coshf
libc.src.math.cospif
libc.src.math.daddf128
- libc.src.math.dmulf128
+ libc.src.math.daddl
+ libc.src.math.ddivf128
+ libc.src.math.ddivl
libc.src.math.dfmal
+ libc.src.math.dmulf128
libc.src.math.dmull
libc.src.math.dsqrtl
- libc.src.math.daddl
- libc.src.math.ddivl
libc.src.math.dsubf128
libc.src.math.dsubl
libc.src.math.erff
@@ -817,7 +818,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
list(APPEND TARGET_LIBM_ENTRYPOINTS
# math.h C23 _Float128 entrypoints
libc.src.math.canonicalizef80
- libc.src.math.ddivf128
libc.src.math.dfmaf128
libc.src.math.dsqrtf128
libc.src.math.faddf128
diff --git a/libc/config/baremetal/hexagon/entrypoints.txt b/libc/config/baremetal/hexagon/entrypoints.txt
index 071976c6df5d9..b8451998151ab 100644
--- a/libc/config/baremetal/hexagon/entrypoints.txt
+++ b/libc/config/baremetal/hexagon/entrypoints.txt
@@ -389,12 +389,13 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.coshf
libc.src.math.cospif
libc.src.math.daddf128
- libc.src.math.dmulf128
+ libc.src.math.daddl
+ libc.src.math.ddivf128
+ libc.src.math.ddivl
libc.src.math.dfmal
+ libc.src.math.dmulf128
libc.src.math.dmull
libc.src.math.dsqrtl
- libc.src.math.daddl
- libc.src.math.ddivl
libc.src.math.dsubf128
libc.src.math.dsubl
libc.src.math.erff
@@ -761,7 +762,6 @@ if(LIBC_TYPES_HAS_FLOAT128)
libc.src.math.canonicalizef80
libc.src.math.ceilf128
libc.src.math.copysignf128
- libc.src.math.ddivf128
libc.src.math.dfmaf128
libc.src.math.dsqrtf128
libc.src.math.fabsf128
diff --git a/libc/config/baremetal/riscv/entrypoints.txt b/libc/config/baremetal/riscv/entrypoints.txt
index 93939035a1181..1c66546a34b24 100644
--- a/libc/config/baremetal/riscv/entrypoints.txt
+++ b/libc/config/baremetal/riscv/entrypoints.txt
@@ -394,12 +394,13 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.coshf
libc.src.math.cospif
libc.src.math.daddf128
- libc.src.math.dmulf128
+ libc.src.math.daddl
+ libc.src.math.ddivf128
+ libc.src.math.ddivl
libc.src.math.dfmal
+ libc.src.math.dmulf128
libc.src.math.dmull
libc.src.math.dsqrtl
- libc.src.math.daddl
- libc.src.math.ddivl
libc.src.math.dsubf128
libc.src.math.dsubl
libc.src.math.erff
@@ -809,7 +810,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
list(APPEND TARGET_LIBM_ENTRYPOINTS
# math.h C23 _Float128 entrypoints
libc.src.math.canonicalizef80
- libc.src.math.ddivf128
libc.src.math.dfmaf128
libc.src.math.dsqrtf128
libc.src.math.faddf128
diff --git a/libc/config/darwin/aarch64/entrypoints.txt b/libc/config/darwin/aarch64/entrypoints.txt
index 47ac8122d0301..b0fa44ccbd6df 100644
--- a/libc/config/darwin/aarch64/entrypoints.txt
+++ b/libc/config/darwin/aarch64/entrypoints.txt
@@ -212,12 +212,13 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.coshf
libc.src.math.cospif
libc.src.math.daddf128
- libc.src.math.dmulf128
+ libc.src.math.daddl
+ libc.src.math.ddivf128
+ libc.src.math.ddivl
libc.src.math.dfmal
+ libc.src.math.dmulf128
libc.src.math.dmull
libc.src.math.dsqrtl
- libc.src.math.daddl
- libc.src.math.ddivl
libc.src.math.dsubf128
libc.src.math.dsubl
libc.src.math.erff
@@ -628,7 +629,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
list(APPEND TARGET_LIBM_ENTRYPOINTS
# math.h C23 _Float128 entrypoints
libc.src.math.canonicalizef80
- libc.src.math.ddivf128
libc.src.math.dfmaf128
libc.src.math.dsqrtf128
libc.src.math.faddf128
diff --git a/libc/config/darwin/x86_64/entrypoints.txt b/libc/config/darwin/x86_64/entrypoints.txt
index 991cde4198f9c..a85ea90f123e7 100644
--- a/libc/config/darwin/x86_64/entrypoints.txt
+++ b/libc/config/darwin/x86_64/entrypoints.txt
@@ -132,10 +132,11 @@ set(TARGET_LIBM_ENTRYPOINTS
#libc.src.math.coshf
#libc.src.math.cosf
#libc.src.math.daddf128
- #libc.src.math.dmulf128
#libc.src.math.daddl
+ #libc.src.math.ddivf128
#libc.src.math.ddivl
#libc.src.math.dfmal
+ #libc.src.math.dmulf128
#libc.src.math.dsqrtl
#libc.src.math.dsubf128
#libc.src.math.dsubl
diff --git a/libc/config/freebsd/x86_64/entrypoints.txt b/libc/config/freebsd/x86_64/entrypoints.txt
index c26c2bed8a183..862a421c473d3 100644
--- a/libc/config/freebsd/x86_64/entrypoints.txt
+++ b/libc/config/freebsd/x86_64/entrypoints.txt
@@ -145,10 +145,11 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.cosh
libc.src.math.coshf
libc.src.math.daddf128
- libc.src.math.dmulf128
libc.src.math.daddl
+ libc.src.math.ddivf128
libc.src.math.ddivl
libc.src.math.dfmal
+ libc.src.math.dmulf128
libc.src.math.dsubf128
libc.src.math.dsubl
libc.src.math.erff
@@ -561,7 +562,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
list(APPEND TARGET_LIBM_ENTRYPOINTS
libc.src.math.atan2l
libc.src.math.canonicalizef80
- libc.src.math.ddivf128
libc.src.math.dfmaf128
libc.src.math.dsqrtf128
libc.src.math.faddf128
diff --git a/libc/config/gpu/amdgpu/entrypoints.txt b/libc/config/gpu/amdgpu/entrypoints.txt
index 31b8d293bab34..d2b1050abf66b 100644
--- a/libc/config/gpu/amdgpu/entrypoints.txt
+++ b/libc/config/gpu/amdgpu/entrypoints.txt
@@ -338,9 +338,10 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.coshf
libc.src.math.cospif
libc.src.math.daddf128
- libc.src.math.dmulf128
+ libc.src.math.ddivf128
libc.src.math.ddivl
libc.src.math.dfmal
+ libc.src.math.dmulf128
libc.src.math.dmull
libc.src.math.dsqrtl
libc.src.math.dsubf128
diff --git a/libc/config/gpu/nvptx/entrypoints.txt b/libc/config/gpu/nvptx/entrypoints.txt
index af321c07e5d2f..8dba78c330a5f 100644
--- a/libc/config/gpu/nvptx/entrypoints.txt
+++ b/libc/config/gpu/nvptx/entrypoints.txt
@@ -334,9 +334,10 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.coshf
libc.src.math.cospif
libc.src.math.daddf128
- libc.src.math.dmulf128
+ libc.src.math.ddivf128
libc.src.math.ddivl
libc.src.math.dfmal
+ libc.src.math.dmulf128
libc.src.math.dmull
libc.src.math.dsqrtl
libc.src.math.dsubf128
diff --git a/libc/config/linux/aarch64/entrypoints.txt b/libc/config/linux/aarch64/entrypoints.txt
index fff845810bda6..4f96b13ba478e 100644
--- a/libc/config/linux/aarch64/entrypoints.txt
+++ b/libc/config/linux/aarch64/entrypoints.txt
@@ -657,10 +657,11 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.coshf
libc.src.math.cospif
libc.src.math.daddf128
- libc.src.math.dmulf128
libc.src.math.daddl
+ libc.src.math.ddivf128
libc.src.math.ddivl
libc.src.math.dfmal
+ libc.src.math.dmulf128
libc.src.math.dmull
libc.src.math.dsqrtl
libc.src.math.dsubf128
@@ -1062,7 +1063,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
list(APPEND TARGET_LIBM_ENTRYPOINTS
# math.h C23 _Float128 entrypoints
libc.src.math.canonicalizef80
- libc.src.math.ddivf128
libc.src.math.dfmaf128
libc.src.math.dsqrtf128
libc.src.math.faddf128
diff --git a/libc/config/linux/arm/entrypoints.txt b/libc/config/linux/arm/entrypoints.txt
index bd5580bfc6f09..956a154cf0d5e 100644
--- a/libc/config/linux/arm/entrypoints.txt
+++ b/libc/config/linux/arm/entrypoints.txt
@@ -437,8 +437,9 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.cosh
libc.src.math.coshf
libc.src.math.daddf128
- libc.src.math.dmulf128
+ libc.src.math.ddivf128
libc.src.math.dfmal
+ libc.src.math.dmulf128
libc.src.math.dsqrtl
libc.src.math.dsubf128
libc.src.math.erff
diff --git a/libc/config/linux/riscv/entrypoints.txt b/libc/config/linux/riscv/entrypoints.txt
index f8adf1d35d500..8d3f601139800 100644
--- a/libc/config/linux/riscv/entrypoints.txt
+++ b/libc/config/linux/riscv/entrypoints.txt
@@ -738,10 +738,11 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.coshf
libc.src.math.cospif
libc.src.math.daddf128
- libc.src.math.dmulf128
libc.src.math.daddl
+ libc.src.math.ddivf128
libc.src.math.ddivl
libc.src.math.dfmal
+ libc.src.math.dmulf128
libc.src.math.dmull
libc.src.math.dsqrtl
libc.src.math.dsubf128
@@ -1164,7 +1165,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
# math.h C23 _Float128 entrypoints
libc.src.math.atan2l
libc.src.math.canonicalizef80
- libc.src.math.ddivf128
libc.src.math.dfmaf128
libc.src.math.dsqrtf128
libc.src.math.faddf128
diff --git a/libc/config/linux/x86_64/entrypoints.txt b/libc/config/linux/x86_64/entrypoints.txt
index 03245100c7995..56c3968cc083c 100644
--- a/libc/config/linux/x86_64/entrypoints.txt
+++ b/libc/config/linux/x86_64/entrypoints.txt
@@ -738,10 +738,11 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.coshf
libc.src.math.cospif
libc.src.math.daddf128
- libc.src.math.dmulf128
libc.src.math.daddl
+ libc.src.math.ddivf128
libc.src.math.ddivl
libc.src.math.dfmal
+ libc.src.math.dmulf128
libc.src.math.dmull
libc.src.math.dsqrtl
libc.src.math.dsubf128
@@ -1164,7 +1165,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
# math.h C23 _Float128 entrypoints
libc.src.math.atan2l
libc.src.math.canonicalizef80
- libc.src.math.ddivf128
libc.src.math.dfmaf128
libc.src.math.dsqrtf128
libc.src.math.faddf128
diff --git a/libc/config/windows/entrypoints.txt b/libc/config/windows/entrypoints.txt
index 059034b4a3e21..7046934c02938 100644
--- a/libc/config/windows/entrypoints.txt
+++ b/libc/config/windows/entrypoints.txt
@@ -177,10 +177,11 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.cosh
libc.src.math.coshf
libc.src.math.daddf128
- libc.src.math.dmulf128
libc.src.math.daddl
+ libc.src.math.ddivf128
libc.src.math.ddivl
libc.src.math.dfmal
+ libc.src.math.dmulf128
libc.src.math.dsubf128
libc.src.math.dsubl
libc.src.math.erff
diff --git a/libc/shared/math/ddivf128.h b/libc/shared/math/ddivf128.h
index 90248f4398aa9..e2bec8e65cc74 100644
--- a/libc/shared/math/ddivf128.h
+++ b/libc/shared/math/ddivf128.h
@@ -1,18 +1,19 @@
-//===-- Shared ddivf128 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
//
//===----------------------------------------------------------------------===//
+///
+/// \file
+/// Shared ddivf128 function.
+///
+//===----------------------------------------------------------------------===//
#ifndef LLVM_LIBC_SHARED_MATH_DDIVF128_H
#define LLVM_LIBC_SHARED_MATH_DDIVF128_H
-#include "include/llvm-libc-types/float128.h"
-
-#ifdef LIBC_TYPES_HAS_NATIVE_FLOAT128
-
#include "shared/libc_common.h"
#include "src/__support/math/ddivf128.h"
@@ -24,6 +25,4 @@ using math::ddivf128;
} // namespace shared
} // namespace LIBC_NAMESPACE_DECL
-#endif // LIBC_TYPES_HAS_NATIVE_FLOAT128
-
#endif // LLVM_LIBC_SHARED_MATH_DDIVF128_H
diff --git a/libc/src/__support/math/CMakeLists.txt b/libc/src/__support/math/CMakeLists.txt
index d6ab84e5ccd4f..4b250d16bed3b 100644
--- a/libc/src/__support/math/CMakeLists.txt
+++ b/libc/src/__support/math/CMakeLists.txt
@@ -3118,7 +3118,7 @@ add_header_library(
HDRS
ddivf128.h
DEPENDS
- libc.include.llvm-libc-types.float128
+ libc.src.__support.FPUtil.float128
libc.src.__support.FPUtil.generic.div
libc.src.__support.macros.config
)
diff --git a/libc/src/__support/math/ddivf128.h b/libc/src/__support/math/ddivf128.h
index 61f9c6d22e324..51c630d5f04ae 100644
--- a/libc/src/__support/math/ddivf128.h
+++ b/libc/src/__support/math/ddivf128.h
@@ -1,31 +1,33 @@
-//===-- Implementation header for ddivf128 ----------------------*- 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
//
//===----------------------------------------------------------------------===//
+///
+/// \file
+/// Implementation of the ddivf128 function.
+///
+//===----------------------------------------------------------------------===//
#ifndef LLVM_LIBC_SRC___SUPPORT_MATH_DDIVF128_H
#define LLVM_LIBC_SRC___SUPPORT_MATH_DDIVF128_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/div.h"
#include "src/__support/macros/config.h"
namespace LIBC_NAMESPACE_DECL {
namespace math {
-LIBC_INLINE constexpr double ddivf128(float128 x, float128 y) {
+using LIBC_NAMESPACE::fputil::Float128;
+
+LIBC_INLINE constexpr double ddivf128(Float128 x, Float128 y) {
return fputil::generic::div<double>(x, y);
}
} // namespace math
} // namespace LIBC_NAMESPACE_DECL
-#endif // LIBC_TYPES_HAS_NATIVE_FLOAT128
-
#endif // LLVM_LIBC_SRC___SUPPORT_MATH_DDIVF128_H
diff --git a/libc/src/math/ddivf128.h b/libc/src/math/ddivf128.h
index f7a5ef07cb5fe..aa1bd81103245 100644
--- a/libc/src/math/ddivf128.h
+++ b/libc/src/math/ddivf128.h
@@ -1,19 +1,29 @@
-//===-- Implementation header for ddivf128 ----------------------*- 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
//
//===----------------------------------------------------------------------===//
+///
+/// \file
+/// Public declaration of the ddivf128 entrypoint.
+///
+//===----------------------------------------------------------------------===//
#ifndef LLVM_LIBC_SRC_MATH_DDIVF128_H
#define LLVM_LIBC_SRC_MATH_DDIVF128_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 ddivf128(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 f4ddc7584380c..0c495701e9788 100644
--- a/libc/src/math/generic/CMakeLists.txt
+++ b/libc/src/math/generic/CMakeLists.txt
@@ -235,6 +235,7 @@ add_entrypoint_object(
HDRS
../ddivf128.h
DEPENDS
+ libc.src.__support.CPP.bit
libc.src.__support.math.ddivf128
)
diff --git a/libc/src/math/generic/ddivf128.cpp b/libc/src/math/generic/ddivf128.cpp
index e7df2fa8be08a..1974cb1e537f2 100644
--- a/libc/src/math/generic/ddivf128.cpp
+++ b/libc/src/math/generic/ddivf128.cpp
@@ -1,18 +1,26 @@
-//===-- Implementation of ddivf128 function--------------------------------===//
+//===----------------------------------------------------------------------===//
//
// 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
+/// Implementation of the ddivf128 function.
+///
+//===----------------------------------------------------------------------===//
#include "src/math/ddivf128.h"
+#include "src/__support/CPP/bit.h"
#include "src/__support/math/ddivf128.h"
namespace LIBC_NAMESPACE_DECL {
+using LIBC_NAMESPACE::fputil::Float128;
+
LLVM_LIBC_FUNCTION(double, ddivf128, (float128 x, float128 y)) {
- return math::ddivf128(x, y);
+ return math::ddivf128(cpp::bit_cast<Float128>(x), cpp::bit_cast<Float128>(y));
}
} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/test/shared/shared_math_constexpr_test.cpp b/libc/test/shared/shared_math_constexpr_test.cpp
index 9052ac636c851..a4188c3f57fb8 100644
--- a/libc/test/shared/shared_math_constexpr_test.cpp
+++ b/libc/test/shared/shared_math_constexpr_test.cpp
@@ -422,6 +422,8 @@ static_assert(0.0 ==
LIBC_NAMESPACE::shared::dsubf128(Float128(0.0), Float128(0.0)));
static_assert(0.0 ==
LIBC_NAMESPACE::shared::dmulf128(Float128(0.0), Float128(0.0)));
+static_assert(0.0 ==
+ LIBC_NAMESPACE::shared::ddivf128(Float128(0.0), Float128(1.0)));
static_assert(Float128(1.0) ==
LIBC_NAMESPACE::shared::fabsf128(Float128(-1.0)));
static_assert(Float80(0.0) ==
@@ -577,8 +579,6 @@ static_assert(1 == [] {
#ifdef LIBC_TYPES_HAS_NATIVE_FLOAT128
-static_assert(0.0 ==
- LIBC_NAMESPACE::shared::ddivf128(float128(0.0), float128(1.0)));
static_assert(0.0f ==
LIBC_NAMESPACE::shared::faddf128(float128(0.0), float128(0.0)));
static_assert(0.0f ==
diff --git a/libc/test/shared/shared_math_test.cpp b/libc/test/shared/shared_math_test.cpp
index 4293c63aecd4e..65a6153766237 100644
--- a/libc/test/shared/shared_math_test.cpp
+++ b/libc/test/shared/shared_math_test.cpp
@@ -612,6 +612,8 @@ TEST(LlvmLibcSharedMathTest, AllEmuFloat128) {
LIBC_NAMESPACE::shared::dsubf128(Float128(0.0), Float128(0.0)));
EXPECT_FP_EQ(0.0,
LIBC_NAMESPACE::shared::dmulf128(Float128(0.0), Float128(0.0)));
+ EXPECT_FP_EQ(0.0,
+ LIBC_NAMESPACE::shared::ddivf128(Float128(0.0), Float128(1.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) {
float128(0.0), float128(0.0)));
EXPECT_FP_EQ(bfloat16(2.0), LIBC_NAMESPACE::shared::bf16divf128(
float128(4.0), float128(2.0)));
- EXPECT_FP_EQ(1.0,
- LIBC_NAMESPACE::shared::ddivf128(float128(1.0), float128(1.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 95202ccfcdcfb..f10f74030f729 100644
--- a/libc/test/src/math/CMakeLists.txt
+++ b/libc/test/src/math/CMakeLists.txt
@@ -3783,6 +3783,21 @@ add_fp_unittest(
libc.src.math.ddivl
)
+add_fp_unittest(
+ ddivf128_test
+ NEED_MPFR_F128
+ SUITE
+ libc-math-tests
+ SRCS
+ ddivf128_test.cpp
+ HDRS
+ DivTest.h
+ DEPENDS
+ libc.src.math.ddivf128
+ libc.src.__support.FPUtil.float128
+ libc.src.__support.FPUtil.fp_bits
+)
+
add_fp_unittest(
dfmal_test
NEED_MPFR
diff --git a/libc/test/src/math/ddivf128_test.cpp b/libc/test/src/math/ddivf128_test.cpp
new file mode 100644
index 0000000000000..177a323f92c7a
--- /dev/null
+++ b/libc/test/src/math/ddivf128_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 ddivf128.
+///
+//===----------------------------------------------------------------------===//
+
+#include "DivTest.h"
+
+#include "src/__support/FPUtil/float128.h"
+#include "src/math/ddivf128.h"
+
+LIST_DIV_TESTS(Ddivf128, double, float128, LIBC_NAMESPACE::ddivf128)
diff --git a/libc/test/src/math/smoke/CMakeLists.txt b/libc/test/src/math/smoke/CMakeLists.txt
index b234ba7a15aa4..bb7bc9b176074 100644
--- a/libc/test/src/math/smoke/CMakeLists.txt
+++ b/libc/test/src/math/smoke/CMakeLists.txt
@@ -6847,6 +6847,7 @@ add_fp_unittest(
DivTest.h
DEPENDS
libc.src.math.ddivf128
+ libc.src.__support.FPUtil.float128
)
add_fp_unittest(
diff --git a/libc/test/src/math/smoke/ddivf128_test.cpp b/libc/test/src/math/smoke/ddivf128_test.cpp
index 28aae17af28c3..42cb94335bdda 100644
--- a/libc/test/src/math/smoke/ddivf128_test.cpp
+++ b/libc/test/src/math/smoke/ddivf128_test.cpp
@@ -1,13 +1,22 @@
-//===-- Unittests for ddivf128 --------------------------------------------===//
+//===----------------------------------------------------------------------===//
//
// 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 ddivf128.
+///
+//===----------------------------------------------------------------------===//
-#include "DivTest.h"
-
+#include "src/__support/FPUtil/float128.h"
#include "src/math/ddivf128.h"
+#include "test/src/math/smoke/DivTest.h"
+
+#ifndef LIBC_TYPES_HAS_NATIVE_FLOAT128
+using float128 = LIBC_NAMESPACE::fputil::Float128;
+#endif // LIBC_TYPES_HAS_NATIVE_FLOAT128
LIST_DIV_TESTS(Ddivf128, double, float128, LIBC_NAMESPACE::ddivf128)
diff --git a/libc/test/src/math/smoke/dmulf128_test.cpp b/libc/test/src/math/smoke/dmulf128_test.cpp
index 317eb666066ea..e6ddc47efdf8f 100644
--- a/libc/test/src/math/smoke/dmulf128_test.cpp
+++ b/libc/test/src/math/smoke/dmulf128_test.cpp
@@ -1,15 +1,19 @@
-//===-- Unittests for dmulf128 --------------------------------------------===//
+//===----------------------------------------------------------------------===//
//
// 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
//
//===----------------------------------------------------------------------===//
-
-#include "MulTest.h"
+///
+/// \file
+/// Unittests for dmulf128.
+///
+//===----------------------------------------------------------------------===//
#include "src/__support/FPUtil/float128.h"
#include "src/math/dmulf128.h"
+#include "test/src/math/smoke/MulTest.h"
#ifndef LIBC_TYPES_HAS_NATIVE_FLOAT128
using float128 = LIBC_NAMESPACE::fputil::Float128;
diff --git a/utils/bazel/llvm-project-overlay/libc/src/__support/math/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/src/__support/math/BUILD.bazel
index cae3c9ca3e9b9..63824814bdba9 100644
--- a/utils/bazel/llvm-project-overlay/libc/src/__support/math/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/libc/src/__support/math/BUILD.bazel
@@ -3354,8 +3354,8 @@ libc_support_library(
name = "ddivf128",
hdrs = ["ddivf128.h"],
deps = [
- "//libc:llvm_libc_types_float128",
"//libc/src/__support/FPUtil:basic_operations",
+ "//libc/src/__support/FPUtil:float128",
"//libc/src/__support/macros:config",
],
)
diff --git a/utils/bazel/llvm-project-overlay/libc/src/math/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/src/math/BUILD.bazel
index 8f93e065e3d45..7f332b0ec64a5 100644
--- a/utils/bazel/llvm-project-overlay/libc/src/math/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/libc/src/math/BUILD.bazel
@@ -782,6 +782,8 @@ libc_math_function(
name = "ddivf128",
additional_deps = [
"//libc/src/__support/math:ddivf128",
+ "//libc/src/__support/CPP:bit",
+ "//libc/src/__support/FPUtil:float128",
],
)
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 8a05c6b84494e..be5e289f5fa97 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
@@ -237,6 +237,14 @@ math_mpfr_test(
hdrs = ["DivTest.h"],
)
+math_mpfr_test(
+ name = "ddivf128",
+ hdrs = ["DivTest.h"],
+ deps = [
+ "//libc/src/__support/FPUtil:float128",
+ ],
+)
+
math_mpfr_test(
name = "dfmal",
hdrs = ["FmaTest.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 0742646e3b712..03aa6b89730ab 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
@@ -397,6 +397,9 @@ math_test(
math_test(
name = "ddivf128",
hdrs = ["DivTest.h"],
+ deps = [
+ "//libc/src/__support/FPUtil:float128",
+ ],
)
math_test(
More information about the libc-commits
mailing list