[libc-commits] [libc] [libc] Modify `fromfpf128`, `fromfpxf128`, `ufromfpf128` and `ufromfpxf128` to use emulated Float128 type (PR #216578)
via libc-commits
libc-commits at lists.llvm.org
Sun Aug 16 09:57:59 PDT 2026
https://github.com/Sukumarsawant created https://github.com/llvm/llvm-project/pull/216578
None
>From 23a54e6eedeb061dd96828f1f79d34bbe60d2724 Mon Sep 17 00:00:00 2001
From: Sukumarsawant <sawantsukumar at gmail.com>
Date: Sun, 16 Aug 2026 22:19:23 +0530
Subject: [PATCH 1/4] fromfpf128
---
libc/config/baremetal/aarch64/entrypoints.txt | 2 +-
libc/config/baremetal/arm/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/fromfpf128.h | 6 ------
libc/src/__support/math/CMakeLists.txt | 2 +-
libc/src/__support/math/fromfpf128.h | 11 ++++-------
libc/src/math/fromfpf128.h | 5 +++++
libc/src/math/generic/CMakeLists.txt | 1 +
libc/src/math/generic/fromfpf128.cpp | 6 +++++-
libc/test/shared/shared_math_constexpr_test.cpp | 6 +++---
libc/test/shared/shared_math_test.cpp | 4 ++--
libc/test/src/math/smoke/CMakeLists.txt | 1 +
libc/test/src/math/smoke/fromfpf128_test.cpp | 5 +++++
23 files changed, 40 insertions(+), 28 deletions(-)
diff --git a/libc/config/baremetal/aarch64/entrypoints.txt b/libc/config/baremetal/aarch64/entrypoints.txt
index 81958d224f70d..86ed1a1b828a3 100644
--- a/libc/config/baremetal/aarch64/entrypoints.txt
+++ b/libc/config/baremetal/aarch64/entrypoints.txt
@@ -456,6 +456,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.frexpl
libc.src.math.fromfp
libc.src.math.fromfpf
+ libc.src.math.fromfpf128
libc.src.math.fromfpl
libc.src.math.fromfpx
libc.src.math.fromfpxf
@@ -759,7 +760,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
libc.src.math.fmodf128
libc.src.math.fmulf128
libc.src.math.frexpf128
- libc.src.math.fromfpf128
libc.src.math.fromfpxf128
libc.src.math.fsqrtf128
libc.src.math.fsubf128
diff --git a/libc/config/baremetal/arm/entrypoints.txt b/libc/config/baremetal/arm/entrypoints.txt
index ee3ec63132cc2..447b2cf7c3296 100644
--- a/libc/config/baremetal/arm/entrypoints.txt
+++ b/libc/config/baremetal/arm/entrypoints.txt
@@ -468,6 +468,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.frexpl
libc.src.math.fromfp
libc.src.math.fromfpf
+ libc.src.math.fromfpf128
libc.src.math.fromfpl
libc.src.math.fromfpx
libc.src.math.fromfpxf
@@ -770,7 +771,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
libc.src.math.fmodf128
libc.src.math.fmulf128
libc.src.math.frexpf128
- libc.src.math.fromfpf128
libc.src.math.fromfpxf128
libc.src.math.fsqrtf128
libc.src.math.fsubf128
diff --git a/libc/config/baremetal/riscv/entrypoints.txt b/libc/config/baremetal/riscv/entrypoints.txt
index c9f7c042bf4a8..af51eca350543 100644
--- a/libc/config/baremetal/riscv/entrypoints.txt
+++ b/libc/config/baremetal/riscv/entrypoints.txt
@@ -464,6 +464,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.frexpl
libc.src.math.fromfp
libc.src.math.fromfpf
+ libc.src.math.fromfpf128
libc.src.math.fromfpl
libc.src.math.fromfpx
libc.src.math.fromfpxf
@@ -767,7 +768,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
# libc.src.math.fmodf128
libc.src.math.fmulf128
libc.src.math.frexpf128
- libc.src.math.fromfpf128
libc.src.math.fromfpxf128
libc.src.math.fsqrtf128
libc.src.math.fsubf128
diff --git a/libc/config/darwin/aarch64/entrypoints.txt b/libc/config/darwin/aarch64/entrypoints.txt
index 0ca00419a916c..7d9c826c7ac41 100644
--- a/libc/config/darwin/aarch64/entrypoints.txt
+++ b/libc/config/darwin/aarch64/entrypoints.txt
@@ -275,6 +275,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.frexpl
libc.src.math.fromfp
libc.src.math.fromfpf
+ libc.src.math.fromfpf128
libc.src.math.fromfpl
libc.src.math.fromfpx
libc.src.math.fromfpxf
@@ -579,7 +580,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
libc.src.math.fmodf128
libc.src.math.fmulf128
libc.src.math.frexpf128
- libc.src.math.fromfpf128
libc.src.math.fromfpxf128
libc.src.math.fsqrtf128
libc.src.math.fsubf128
diff --git a/libc/config/darwin/x86_64/entrypoints.txt b/libc/config/darwin/x86_64/entrypoints.txt
index 136d5a458d484..bc6fc2934e899 100644
--- a/libc/config/darwin/x86_64/entrypoints.txt
+++ b/libc/config/darwin/x86_64/entrypoints.txt
@@ -162,6 +162,7 @@ set(TARGET_LIBM_ENTRYPOINTS
#libc.src.math.frexp
#libc.src.math.frexpf
#libc.src.math.frexpl
+ #libc.src.math.fromfpf128
#libc.src.math.fsub
#libc.src.math.fsubl
#libc.src.math.hypot
diff --git a/libc/config/freebsd/x86_64/entrypoints.txt b/libc/config/freebsd/x86_64/entrypoints.txt
index 2223504718444..581893f3d243b 100644
--- a/libc/config/freebsd/x86_64/entrypoints.txt
+++ b/libc/config/freebsd/x86_64/entrypoints.txt
@@ -206,6 +206,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.frexp
libc.src.math.frexpf
libc.src.math.frexpl
+ libc.src.math.fromfpf128
libc.src.math.fsub
libc.src.math.fsubl
libc.src.math.hypot
@@ -518,7 +519,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
libc.src.math.fmodf128
libc.src.math.fmulf128
libc.src.math.frexpf128
- libc.src.math.fromfpf128
libc.src.math.fromfpxf128
libc.src.math.fsqrtf128
libc.src.math.fsubf128
diff --git a/libc/config/gpu/amdgpu/entrypoints.txt b/libc/config/gpu/amdgpu/entrypoints.txt
index 12783aa4e5316..6a0cd7edd0c9e 100644
--- a/libc/config/gpu/amdgpu/entrypoints.txt
+++ b/libc/config/gpu/amdgpu/entrypoints.txt
@@ -403,6 +403,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.frexpl
libc.src.math.fromfp
libc.src.math.fromfpf
+ libc.src.math.fromfpf128
libc.src.math.fromfpl
libc.src.math.fromfpx
libc.src.math.fromfpxf
diff --git a/libc/config/gpu/nvptx/entrypoints.txt b/libc/config/gpu/nvptx/entrypoints.txt
index 5820448e06663..e503169c2c962 100644
--- a/libc/config/gpu/nvptx/entrypoints.txt
+++ b/libc/config/gpu/nvptx/entrypoints.txt
@@ -400,6 +400,7 @@ set(TARGET_LIBM_ENTRYPOINTS
# FIXME: Broken.
# libc.src.math.fromfp
# libc.src.math.fromfpf
+ #libc.src.math.fromfpf128
# libc.src.math.fromfpl
# libc.src.math.fromfpx
# libc.src.math.fromfpxf
diff --git a/libc/config/linux/aarch64/entrypoints.txt b/libc/config/linux/aarch64/entrypoints.txt
index 071a7830b43d3..de76781bc38fb 100644
--- a/libc/config/linux/aarch64/entrypoints.txt
+++ b/libc/config/linux/aarch64/entrypoints.txt
@@ -609,6 +609,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.frexpl
libc.src.math.fromfp
libc.src.math.fromfpf
+ libc.src.math.fromfpf128
libc.src.math.fromfpl
libc.src.math.fromfpx
libc.src.math.fromfpxf
@@ -906,7 +907,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
libc.src.math.fmodf128
libc.src.math.fmulf128
libc.src.math.frexpf128
- libc.src.math.fromfpf128
libc.src.math.fromfpxf128
libc.src.math.fsqrtf128
libc.src.math.fsubf128
diff --git a/libc/config/linux/arm/entrypoints.txt b/libc/config/linux/arm/entrypoints.txt
index 1adbb04bb4cbe..b0ef5cf18bd83 100644
--- a/libc/config/linux/arm/entrypoints.txt
+++ b/libc/config/linux/arm/entrypoints.txt
@@ -441,6 +441,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.frexpl
libc.src.math.fromfp
libc.src.math.fromfpf
+ libc.src.math.fromfpf128
libc.src.math.fromfpl
libc.src.math.fromfpx
libc.src.math.fromfpxf
diff --git a/libc/config/linux/riscv/entrypoints.txt b/libc/config/linux/riscv/entrypoints.txt
index 66dd9dd790737..d51ca90a397b9 100644
--- a/libc/config/linux/riscv/entrypoints.txt
+++ b/libc/config/linux/riscv/entrypoints.txt
@@ -682,6 +682,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.frexpl
libc.src.math.fromfp
libc.src.math.fromfpf
+ libc.src.math.fromfpf128
libc.src.math.fromfpl
libc.src.math.fromfpx
libc.src.math.fromfpxf
@@ -996,7 +997,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
libc.src.math.fmodf128
libc.src.math.fmulf128
libc.src.math.frexpf128
- libc.src.math.fromfpf128
libc.src.math.fromfpxf128
libc.src.math.fsqrtf128
libc.src.math.fsubf128
diff --git a/libc/config/linux/x86_64/entrypoints.txt b/libc/config/linux/x86_64/entrypoints.txt
index 6045886c2f11c..62924a51bb577 100644
--- a/libc/config/linux/x86_64/entrypoints.txt
+++ b/libc/config/linux/x86_64/entrypoints.txt
@@ -687,6 +687,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.frexpl
libc.src.math.fromfp
libc.src.math.fromfpf
+ libc.src.math.fromfpf128
libc.src.math.fromfpl
libc.src.math.fromfpx
libc.src.math.fromfpxf
@@ -1001,7 +1002,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
libc.src.math.fmodf128
libc.src.math.fmulf128
libc.src.math.frexpf128
- libc.src.math.fromfpf128
libc.src.math.fromfpxf128
libc.src.math.fsqrtf128
libc.src.math.fsubf128
diff --git a/libc/config/windows/entrypoints.txt b/libc/config/windows/entrypoints.txt
index 142b83e71efe6..43c29d8c06edc 100644
--- a/libc/config/windows/entrypoints.txt
+++ b/libc/config/windows/entrypoints.txt
@@ -239,6 +239,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.frexp
libc.src.math.frexpf
libc.src.math.frexpl
+ libc.src.math.fromfpf128
libc.src.math.fsub
libc.src.math.fsubl
libc.src.math.hypot
diff --git a/libc/shared/math/fromfpf128.h b/libc/shared/math/fromfpf128.h
index a0e5085de11aa..ff777ccd90f89 100644
--- a/libc/shared/math/fromfpf128.h
+++ b/libc/shared/math/fromfpf128.h
@@ -9,10 +9,6 @@
#ifndef LLVM_LIBC_SHARED_MATH_FROMFPF128_H
#define LLVM_LIBC_SHARED_MATH_FROMFPF128_H
-#include "include/llvm-libc-types/float128.h"
-
-#ifdef LIBC_TYPES_HAS_NATIVE_FLOAT128
-
#include "shared/libc_common.h"
#include "src/__support/math/fromfpf128.h"
@@ -24,6 +20,4 @@ using math::fromfpf128;
} // namespace shared
} // namespace LIBC_NAMESPACE_DECL
-#endif // LIBC_TYPES_HAS_NATIVE_FLOAT128
-
#endif // LLVM_LIBC_SHARED_MATH_FROMFPF128_H
diff --git a/libc/src/__support/math/CMakeLists.txt b/libc/src/__support/math/CMakeLists.txt
index db514db61a9df..2809bca283ac1 100644
--- a/libc/src/__support/math/CMakeLists.txt
+++ b/libc/src/__support/math/CMakeLists.txt
@@ -1540,7 +1540,7 @@ add_header_library(
HDRS
fromfpf128.h
DEPENDS
- libc.include.llvm-libc-types.float128
+ libc.src.__support.FPUtil.float128
libc.src.__support.FPUtil.nearest_integer_operations
libc.src.__support.macros.config
)
diff --git a/libc/src/__support/math/fromfpf128.h b/libc/src/__support/math/fromfpf128.h
index 3415ce8e51f98..cbafd3c6b322f 100644
--- a/libc/src/__support/math/fromfpf128.h
+++ b/libc/src/__support/math/fromfpf128.h
@@ -9,17 +9,16 @@
#ifndef LLVM_LIBC_SRC___SUPPORT_MATH_FROMFPF128_H
#define LLVM_LIBC_SRC___SUPPORT_MATH_FROMFPF128_H
-#include "include/llvm-libc-types/float128.h"
-
-#ifdef LIBC_TYPES_HAS_NATIVE_FLOAT128
-
#include "src/__support/FPUtil/NearestIntegerOperations.h"
+#include "src/__support/FPUtil/float128.h"
#include "src/__support/macros/config.h"
namespace LIBC_NAMESPACE_DECL {
namespace math {
-LIBC_INLINE constexpr float128 fromfpf128(float128 x, int rnd,
+using LIBC_NAMESPACE::fputil::Float128;
+
+LIBC_INLINE constexpr Float128 fromfpf128(Float128 x, int rnd,
unsigned int width) {
return fputil::fromfp</*IsSigned=*/true>(x, rnd, width);
}
@@ -27,6 +26,4 @@ LIBC_INLINE constexpr float128 fromfpf128(float128 x, int rnd,
} // namespace math
} // namespace LIBC_NAMESPACE_DECL
-#endif // LIBC_TYPES_HAS_NATIVE_FLOAT128
-
#endif // LLVM_LIBC_SRC___SUPPORT_MATH_FROMFPF128_H
diff --git a/libc/src/math/fromfpf128.h b/libc/src/math/fromfpf128.h
index 1600b81351ee6..05fe5f5f9066d 100644
--- a/libc/src/math/fromfpf128.h
+++ b/libc/src/math/fromfpf128.h
@@ -9,11 +9,16 @@
#ifndef LLVM_LIBC_SRC_MATH_FROMFPF128_H
#define LLVM_LIBC_SRC_MATH_FROMFPF128_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
+
float128 fromfpf128(float128 x, int rnd, unsigned int width);
} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/CMakeLists.txt b/libc/src/math/generic/CMakeLists.txt
index 80c2053066f16..b6d50a5a5f601 100644
--- a/libc/src/math/generic/CMakeLists.txt
+++ b/libc/src/math/generic/CMakeLists.txt
@@ -3492,6 +3492,7 @@ add_entrypoint_object(
HDRS
../fromfpf128.h
DEPENDS
+ libc.src.__support.CPP.bit
libc.src.__support.math.fromfpf128
)
diff --git a/libc/src/math/generic/fromfpf128.cpp b/libc/src/math/generic/fromfpf128.cpp
index d8b9ece78a698..5957aea6c6192 100644
--- a/libc/src/math/generic/fromfpf128.cpp
+++ b/libc/src/math/generic/fromfpf128.cpp
@@ -7,13 +7,17 @@
//===----------------------------------------------------------------------===//
#include "src/math/fromfpf128.h"
+#include "src/__support/CPP/bit.h"
#include "src/__support/math/fromfpf128.h"
namespace LIBC_NAMESPACE_DECL {
+using LIBC_NAMESPACE::fputil::Float128;
+
LLVM_LIBC_FUNCTION(float128, fromfpf128,
(float128 x, int rnd, unsigned int width)) {
- return math::fromfpf128(x, rnd, width);
+ return cpp::bit_cast<float128>(
+ math::fromfpf128(cpp::bit_cast<Float128>(x), rnd, width));
}
} // 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 6f9df85f3bb1c..4fb3a3ced7b94 100644
--- a/libc/test/shared/shared_math_constexpr_test.cpp
+++ b/libc/test/shared/shared_math_constexpr_test.cpp
@@ -382,6 +382,9 @@ static_assert(0 == LIBC_NAMESPACE::shared::isnanl(0.0L));
static_assert(Float128(0.0) == LIBC_NAMESPACE::shared::ceilf128(Float128(0.0)));
+static_assert(Float128(0.0) ==
+ LIBC_NAMESPACE::shared::fromfpf128(Float128(0.0), 0, 32));
+
//===----------------------------------------------------------------------===//
// Native Float128 Tests
//===----------------------------------------------------------------------===//
@@ -428,9 +431,6 @@ static_assert(float128(0.0) ==
static_assert(float128(0.0) ==
LIBC_NAMESPACE::shared::fminimum_numf128(float128(0.0),
float128(0.0)));
-
-static_assert(float128(0.0) ==
- LIBC_NAMESPACE::shared::fromfpf128(float128(0.0), 0, 32));
static_assert(float128(0.0) ==
LIBC_NAMESPACE::shared::fromfpxf128(float128(0.0), 0, 32));
static_assert(float128(-1.0) == [] {
diff --git a/libc/test/shared/shared_math_test.cpp b/libc/test/shared/shared_math_test.cpp
index 8850deda1c805..21532ee6f95ba 100644
--- a/libc/test/shared/shared_math_test.cpp
+++ b/libc/test/shared/shared_math_test.cpp
@@ -582,6 +582,8 @@ TEST(LlvmLibcSharedMathTest, AllLongDouble) {
// Emulated float128 tests
TEST(LlvmLibcSharedMathTest, AllEmuFloat128) {
EXPECT_FP_EQ(Float128(0.0), LIBC_NAMESPACE::shared::ceilf128(Float128(0.0)));
+ EXPECT_FP_EQ(Float128(0.0),
+ LIBC_NAMESPACE::shared::fromfpf128(Float128(0.0), 0, 32));
}
#ifdef LIBC_TYPES_HAS_NATIVE_FLOAT128
@@ -697,8 +699,6 @@ TEST(LlvmLibcSharedMathTest, AllFloat128) {
float128(0.0), float128(0.0)));
EXPECT_FP_EQ(float128(0.0), LIBC_NAMESPACE::shared::fminimum_numf128(
float128(0.0), float128(0.0)));
- EXPECT_FP_EQ(float128(0.0),
- LIBC_NAMESPACE::shared::fromfpf128(float128(0.0), 0, 32));
EXPECT_FP_EQ(float128(0.0),
LIBC_NAMESPACE::shared::fromfpxf128(float128(0.0), 0, 32));
EXPECT_FP_EQ(float128(0.0),
diff --git a/libc/test/src/math/smoke/CMakeLists.txt b/libc/test/src/math/smoke/CMakeLists.txt
index 91d76f2c7973c..93e5948b6a55a 100644
--- a/libc/test/src/math/smoke/CMakeLists.txt
+++ b/libc/test/src/math/smoke/CMakeLists.txt
@@ -1781,6 +1781,7 @@ add_fp_unittest(
HDRS
FromfpTest.h
DEPENDS
+ libc.src.__support.FPUtil.float128
libc.src.math.fromfpf128
)
diff --git a/libc/test/src/math/smoke/fromfpf128_test.cpp b/libc/test/src/math/smoke/fromfpf128_test.cpp
index 288aadb359bfe..a2c09874aa97a 100644
--- a/libc/test/src/math/smoke/fromfpf128_test.cpp
+++ b/libc/test/src/math/smoke/fromfpf128_test.cpp
@@ -7,7 +7,12 @@
//===----------------------------------------------------------------------===//
#include "FromfpTest.h"
+#include "src/__support/FPUtil/float128.h"
#include "src/math/fromfpf128.h"
+#ifndef LIBC_TYPES_HAS_NATIVE_FLOAT128
+using float128 = LIBC_NAMESPACE::fputil::Float128;
+#endif // LIBC_TYPES_HAS_NATIVE_FLOAT128
+
LIST_FROMFP_TESTS(float128, LIBC_NAMESPACE::fromfpf128)
>From 6653c04f76bbd4afcb3c691b342154c158f7bbfc Mon Sep 17 00:00:00 2001
From: Sukumarsawant <sawantsukumar at gmail.com>
Date: Sun, 16 Aug 2026 22:20:09 +0530
Subject: [PATCH 2/4] fromfpxf128
---
libc/config/baremetal/aarch64/entrypoints.txt | 2 +-
libc/config/baremetal/arm/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/fromfpxf128.h | 6 ------
libc/src/__support/math/CMakeLists.txt | 2 +-
libc/src/__support/math/fromfpxf128.h | 11 ++++-------
libc/src/math/fromfpxf128.h | 5 +++++
libc/src/math/generic/CMakeLists.txt | 1 +
libc/src/math/generic/fromfpxf128.cpp | 6 +++++-
libc/test/shared/shared_math_constexpr_test.cpp | 4 ++--
libc/test/shared/shared_math_test.cpp | 4 ++--
libc/test/src/math/smoke/CMakeLists.txt | 1 +
libc/test/src/math/smoke/fromfpxf128_test.cpp | 5 +++++
23 files changed, 39 insertions(+), 27 deletions(-)
diff --git a/libc/config/baremetal/aarch64/entrypoints.txt b/libc/config/baremetal/aarch64/entrypoints.txt
index 86ed1a1b828a3..120ebd5e2ffc3 100644
--- a/libc/config/baremetal/aarch64/entrypoints.txt
+++ b/libc/config/baremetal/aarch64/entrypoints.txt
@@ -460,6 +460,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.fromfpl
libc.src.math.fromfpx
libc.src.math.fromfpxf
+ libc.src.math.fromfpxf128
libc.src.math.fromfpxl
libc.src.math.fsqrt
libc.src.math.fsqrtl
@@ -760,7 +761,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
libc.src.math.fmodf128
libc.src.math.fmulf128
libc.src.math.frexpf128
- libc.src.math.fromfpxf128
libc.src.math.fsqrtf128
libc.src.math.fsubf128
libc.src.math.getpayloadf128
diff --git a/libc/config/baremetal/arm/entrypoints.txt b/libc/config/baremetal/arm/entrypoints.txt
index 447b2cf7c3296..4be544e8f81d1 100644
--- a/libc/config/baremetal/arm/entrypoints.txt
+++ b/libc/config/baremetal/arm/entrypoints.txt
@@ -472,6 +472,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.fromfpl
libc.src.math.fromfpx
libc.src.math.fromfpxf
+ libc.src.math.fromfpxf128
libc.src.math.fromfpxl
libc.src.math.fsqrt
libc.src.math.fsqrtl
@@ -771,7 +772,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
libc.src.math.fmodf128
libc.src.math.fmulf128
libc.src.math.frexpf128
- libc.src.math.fromfpxf128
libc.src.math.fsqrtf128
libc.src.math.fsubf128
libc.src.math.getpayloadf128
diff --git a/libc/config/baremetal/riscv/entrypoints.txt b/libc/config/baremetal/riscv/entrypoints.txt
index af51eca350543..a1d09b36b086c 100644
--- a/libc/config/baremetal/riscv/entrypoints.txt
+++ b/libc/config/baremetal/riscv/entrypoints.txt
@@ -468,6 +468,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.fromfpl
libc.src.math.fromfpx
libc.src.math.fromfpxf
+ libc.src.math.fromfpxf128
libc.src.math.fromfpxl
libc.src.math.fsqrt
libc.src.math.fsqrtl
@@ -768,7 +769,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
# libc.src.math.fmodf128
libc.src.math.fmulf128
libc.src.math.frexpf128
- libc.src.math.fromfpxf128
libc.src.math.fsqrtf128
libc.src.math.fsubf128
libc.src.math.getpayloadf128
diff --git a/libc/config/darwin/aarch64/entrypoints.txt b/libc/config/darwin/aarch64/entrypoints.txt
index 7d9c826c7ac41..c75dd6a89b02d 100644
--- a/libc/config/darwin/aarch64/entrypoints.txt
+++ b/libc/config/darwin/aarch64/entrypoints.txt
@@ -279,6 +279,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.fromfpl
libc.src.math.fromfpx
libc.src.math.fromfpxf
+ libc.src.math.fromfpxf128
libc.src.math.fromfpxl
libc.src.math.fsqrt
libc.src.math.fsqrtl
@@ -580,7 +581,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
libc.src.math.fmodf128
libc.src.math.fmulf128
libc.src.math.frexpf128
- libc.src.math.fromfpxf128
libc.src.math.fsqrtf128
libc.src.math.fsubf128
libc.src.math.getpayloadf128
diff --git a/libc/config/darwin/x86_64/entrypoints.txt b/libc/config/darwin/x86_64/entrypoints.txt
index bc6fc2934e899..2752fbb112e6f 100644
--- a/libc/config/darwin/x86_64/entrypoints.txt
+++ b/libc/config/darwin/x86_64/entrypoints.txt
@@ -163,6 +163,7 @@ set(TARGET_LIBM_ENTRYPOINTS
#libc.src.math.frexpf
#libc.src.math.frexpl
#libc.src.math.fromfpf128
+ #libc.src.math.fromfpxf128
#libc.src.math.fsub
#libc.src.math.fsubl
#libc.src.math.hypot
diff --git a/libc/config/freebsd/x86_64/entrypoints.txt b/libc/config/freebsd/x86_64/entrypoints.txt
index 581893f3d243b..3d15628a6efc9 100644
--- a/libc/config/freebsd/x86_64/entrypoints.txt
+++ b/libc/config/freebsd/x86_64/entrypoints.txt
@@ -207,6 +207,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.frexpf
libc.src.math.frexpl
libc.src.math.fromfpf128
+ libc.src.math.fromfpxf128
libc.src.math.fsub
libc.src.math.fsubl
libc.src.math.hypot
@@ -519,7 +520,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
libc.src.math.fmodf128
libc.src.math.fmulf128
libc.src.math.frexpf128
- libc.src.math.fromfpxf128
libc.src.math.fsqrtf128
libc.src.math.fsubf128
libc.src.math.getpayloadf128
diff --git a/libc/config/gpu/amdgpu/entrypoints.txt b/libc/config/gpu/amdgpu/entrypoints.txt
index 6a0cd7edd0c9e..09f24c82eb96b 100644
--- a/libc/config/gpu/amdgpu/entrypoints.txt
+++ b/libc/config/gpu/amdgpu/entrypoints.txt
@@ -407,6 +407,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.fromfpl
libc.src.math.fromfpx
libc.src.math.fromfpxf
+ libc.src.math.fromfpxf128
libc.src.math.fromfpxl
libc.src.math.fsqrt
libc.src.math.fsqrtl
diff --git a/libc/config/gpu/nvptx/entrypoints.txt b/libc/config/gpu/nvptx/entrypoints.txt
index e503169c2c962..a18c5197d7c27 100644
--- a/libc/config/gpu/nvptx/entrypoints.txt
+++ b/libc/config/gpu/nvptx/entrypoints.txt
@@ -404,6 +404,7 @@ set(TARGET_LIBM_ENTRYPOINTS
# libc.src.math.fromfpl
# libc.src.math.fromfpx
# libc.src.math.fromfpxf
+ #libc.src.math.fromfpxf128
# libc.src.math.fromfpxl
libc.src.math.fsqrt
libc.src.math.fsqrtl
diff --git a/libc/config/linux/aarch64/entrypoints.txt b/libc/config/linux/aarch64/entrypoints.txt
index de76781bc38fb..cff6536d3d58c 100644
--- a/libc/config/linux/aarch64/entrypoints.txt
+++ b/libc/config/linux/aarch64/entrypoints.txt
@@ -613,6 +613,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.fromfpl
libc.src.math.fromfpx
libc.src.math.fromfpxf
+ libc.src.math.fromfpxf128
libc.src.math.fromfpxl
libc.src.math.fsqrt
libc.src.math.fsqrtl
@@ -907,7 +908,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
libc.src.math.fmodf128
libc.src.math.fmulf128
libc.src.math.frexpf128
- libc.src.math.fromfpxf128
libc.src.math.fsqrtf128
libc.src.math.fsubf128
libc.src.math.getpayloadf128
diff --git a/libc/config/linux/arm/entrypoints.txt b/libc/config/linux/arm/entrypoints.txt
index b0ef5cf18bd83..1ef4f073beba9 100644
--- a/libc/config/linux/arm/entrypoints.txt
+++ b/libc/config/linux/arm/entrypoints.txt
@@ -445,6 +445,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.fromfpl
libc.src.math.fromfpx
libc.src.math.fromfpxf
+ libc.src.math.fromfpxf128
libc.src.math.fromfpxl
libc.src.math.fsub
libc.src.math.fsubl
diff --git a/libc/config/linux/riscv/entrypoints.txt b/libc/config/linux/riscv/entrypoints.txt
index d51ca90a397b9..b2dcc0b20de77 100644
--- a/libc/config/linux/riscv/entrypoints.txt
+++ b/libc/config/linux/riscv/entrypoints.txt
@@ -686,6 +686,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.fromfpl
libc.src.math.fromfpx
libc.src.math.fromfpxf
+ libc.src.math.fromfpxf128
libc.src.math.fromfpxl
libc.src.math.fsqrt
libc.src.math.fsqrtl
@@ -997,7 +998,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
libc.src.math.fmodf128
libc.src.math.fmulf128
libc.src.math.frexpf128
- libc.src.math.fromfpxf128
libc.src.math.fsqrtf128
libc.src.math.fsubf128
libc.src.math.getpayloadf128
diff --git a/libc/config/linux/x86_64/entrypoints.txt b/libc/config/linux/x86_64/entrypoints.txt
index 62924a51bb577..d785bb8961510 100644
--- a/libc/config/linux/x86_64/entrypoints.txt
+++ b/libc/config/linux/x86_64/entrypoints.txt
@@ -691,6 +691,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.fromfpl
libc.src.math.fromfpx
libc.src.math.fromfpxf
+ libc.src.math.fromfpxf128
libc.src.math.fromfpxl
libc.src.math.fsqrt
libc.src.math.fsqrtl
@@ -1002,7 +1003,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
libc.src.math.fmodf128
libc.src.math.fmulf128
libc.src.math.frexpf128
- libc.src.math.fromfpxf128
libc.src.math.fsqrtf128
libc.src.math.fsubf128
libc.src.math.getpayloadf128
diff --git a/libc/config/windows/entrypoints.txt b/libc/config/windows/entrypoints.txt
index 43c29d8c06edc..d86a6c1dc298a 100644
--- a/libc/config/windows/entrypoints.txt
+++ b/libc/config/windows/entrypoints.txt
@@ -240,6 +240,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.frexpf
libc.src.math.frexpl
libc.src.math.fromfpf128
+ libc.src.math.fromfpxf128
libc.src.math.fsub
libc.src.math.fsubl
libc.src.math.hypot
diff --git a/libc/shared/math/fromfpxf128.h b/libc/shared/math/fromfpxf128.h
index 1f1aba101d1bf..6c6ef6f13e49b 100644
--- a/libc/shared/math/fromfpxf128.h
+++ b/libc/shared/math/fromfpxf128.h
@@ -9,10 +9,6 @@
#ifndef LLVM_LIBC_SHARED_MATH_FROMFPXF128_H
#define LLVM_LIBC_SHARED_MATH_FROMFPXF128_H
-#include "include/llvm-libc-types/float128.h"
-
-#ifdef LIBC_TYPES_HAS_NATIVE_FLOAT128
-
#include "shared/libc_common.h"
#include "src/__support/math/fromfpxf128.h"
@@ -24,6 +20,4 @@ using math::fromfpxf128;
} // namespace shared
} // namespace LIBC_NAMESPACE_DECL
-#endif // LIBC_TYPES_HAS_NATIVE_FLOAT128
-
#endif // LLVM_LIBC_SHARED_MATH_FROMFPXF128_H
diff --git a/libc/src/__support/math/CMakeLists.txt b/libc/src/__support/math/CMakeLists.txt
index 2809bca283ac1..219e89fd9d88a 100644
--- a/libc/src/__support/math/CMakeLists.txt
+++ b/libc/src/__support/math/CMakeLists.txt
@@ -1597,7 +1597,7 @@ add_header_library(
HDRS
fromfpxf128.h
DEPENDS
- libc.include.llvm-libc-types.float128
+ libc.src.__support.FPUtil.float128
libc.src.__support.FPUtil.nearest_integer_operations
libc.src.__support.macros.config
)
diff --git a/libc/src/__support/math/fromfpxf128.h b/libc/src/__support/math/fromfpxf128.h
index 4fa2599fad34b..149fac0f36ea7 100644
--- a/libc/src/__support/math/fromfpxf128.h
+++ b/libc/src/__support/math/fromfpxf128.h
@@ -9,17 +9,16 @@
#ifndef LLVM_LIBC_SRC___SUPPORT_MATH_FROMFPXF128_H
#define LLVM_LIBC_SRC___SUPPORT_MATH_FROMFPXF128_H
-#include "include/llvm-libc-types/float128.h"
-
-#ifdef LIBC_TYPES_HAS_NATIVE_FLOAT128
-
#include "src/__support/FPUtil/NearestIntegerOperations.h"
+#include "src/__support/FPUtil/float128.h"
#include "src/__support/macros/config.h"
namespace LIBC_NAMESPACE_DECL {
namespace math {
-LIBC_INLINE constexpr float128 fromfpxf128(float128 x, int rnd,
+using LIBC_NAMESPACE::fputil::Float128;
+
+LIBC_INLINE constexpr Float128 fromfpxf128(Float128 x, int rnd,
unsigned int width) {
return fputil::fromfpx</*IsSigned=*/true>(x, rnd, width);
}
@@ -27,6 +26,4 @@ LIBC_INLINE constexpr float128 fromfpxf128(float128 x, int rnd,
} // namespace math
} // namespace LIBC_NAMESPACE_DECL
-#endif // LIBC_TYPES_HAS_NATIVE_FLOAT128
-
#endif // LLVM_LIBC_SRC___SUPPORT_MATH_FROMFPXF128_H
diff --git a/libc/src/math/fromfpxf128.h b/libc/src/math/fromfpxf128.h
index 32a772973cb05..ce77d46d807ec 100644
--- a/libc/src/math/fromfpxf128.h
+++ b/libc/src/math/fromfpxf128.h
@@ -9,11 +9,16 @@
#ifndef LLVM_LIBC_SRC_MATH_FROMFPXF128_H
#define LLVM_LIBC_SRC_MATH_FROMFPXF128_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
+
float128 fromfpxf128(float128 x, int rnd, unsigned int width);
} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/CMakeLists.txt b/libc/src/math/generic/CMakeLists.txt
index b6d50a5a5f601..8d9909970cf46 100644
--- a/libc/src/math/generic/CMakeLists.txt
+++ b/libc/src/math/generic/CMakeLists.txt
@@ -3553,6 +3553,7 @@ add_entrypoint_object(
HDRS
../fromfpxf128.h
DEPENDS
+ libc.src.__support.CPP.bit
libc.src.__support.math.fromfpxf128
)
diff --git a/libc/src/math/generic/fromfpxf128.cpp b/libc/src/math/generic/fromfpxf128.cpp
index 472b7516fe1bc..30a1d4a137f93 100644
--- a/libc/src/math/generic/fromfpxf128.cpp
+++ b/libc/src/math/generic/fromfpxf128.cpp
@@ -7,13 +7,17 @@
//===----------------------------------------------------------------------===//
#include "src/math/fromfpxf128.h"
+#include "src/__support/CPP/bit.h"
#include "src/__support/math/fromfpxf128.h"
namespace LIBC_NAMESPACE_DECL {
+using LIBC_NAMESPACE::fputil::Float128;
+
LLVM_LIBC_FUNCTION(float128, fromfpxf128,
(float128 x, int rnd, unsigned int width)) {
- return math::fromfpxf128(x, rnd, width);
+ return cpp::bit_cast<float128>(
+ math::fromfpxf128(cpp::bit_cast<Float128>(x), rnd, width));
}
} // 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 4fb3a3ced7b94..2591e2a67ba06 100644
--- a/libc/test/shared/shared_math_constexpr_test.cpp
+++ b/libc/test/shared/shared_math_constexpr_test.cpp
@@ -381,6 +381,8 @@ static_assert(0 == LIBC_NAMESPACE::shared::isnanl(0.0L));
//===----------------------------------------------------------------------===//
static_assert(Float128(0.0) == LIBC_NAMESPACE::shared::ceilf128(Float128(0.0)));
+static_assert(Float128(0.0) ==
+ LIBC_NAMESPACE::shared::fromfpxf128(Float128(0.0), 0, 32));
static_assert(Float128(0.0) ==
LIBC_NAMESPACE::shared::fromfpf128(Float128(0.0), 0, 32));
@@ -431,8 +433,6 @@ static_assert(float128(0.0) ==
static_assert(float128(0.0) ==
LIBC_NAMESPACE::shared::fminimum_numf128(float128(0.0),
float128(0.0)));
-static_assert(float128(0.0) ==
- LIBC_NAMESPACE::shared::fromfpxf128(float128(0.0), 0, 32));
static_assert(float128(-1.0) == [] {
float128 getpayload_x = float128(0.0);
return LIBC_NAMESPACE::shared::getpayloadf128(&getpayload_x);
diff --git a/libc/test/shared/shared_math_test.cpp b/libc/test/shared/shared_math_test.cpp
index 21532ee6f95ba..e2c29d38b1b61 100644
--- a/libc/test/shared/shared_math_test.cpp
+++ b/libc/test/shared/shared_math_test.cpp
@@ -582,6 +582,8 @@ TEST(LlvmLibcSharedMathTest, AllLongDouble) {
// Emulated float128 tests
TEST(LlvmLibcSharedMathTest, AllEmuFloat128) {
EXPECT_FP_EQ(Float128(0.0), LIBC_NAMESPACE::shared::ceilf128(Float128(0.0)));
+ EXPECT_FP_EQ(Float128(0.0),
+ LIBC_NAMESPACE::shared::fromfpxf128(Float128(0.0), 0, 32));
EXPECT_FP_EQ(Float128(0.0),
LIBC_NAMESPACE::shared::fromfpf128(Float128(0.0), 0, 32));
}
@@ -699,8 +701,6 @@ TEST(LlvmLibcSharedMathTest, AllFloat128) {
float128(0.0), float128(0.0)));
EXPECT_FP_EQ(float128(0.0), LIBC_NAMESPACE::shared::fminimum_numf128(
float128(0.0), float128(0.0)));
- EXPECT_FP_EQ(float128(0.0),
- LIBC_NAMESPACE::shared::fromfpxf128(float128(0.0), 0, 32));
EXPECT_FP_EQ(float128(0.0),
LIBC_NAMESPACE::shared::ufromfpf128(float128(0.0), 0, 32));
EXPECT_FP_EQ(float128(0.0),
diff --git a/libc/test/src/math/smoke/CMakeLists.txt b/libc/test/src/math/smoke/CMakeLists.txt
index 93e5948b6a55a..ea50b28c083ce 100644
--- a/libc/test/src/math/smoke/CMakeLists.txt
+++ b/libc/test/src/math/smoke/CMakeLists.txt
@@ -1855,6 +1855,7 @@ add_fp_unittest(
HDRS
FromfpxTest.h
DEPENDS
+ libc.src.__support.FPUtil.float128
libc.src.math.fromfpxf128
)
diff --git a/libc/test/src/math/smoke/fromfpxf128_test.cpp b/libc/test/src/math/smoke/fromfpxf128_test.cpp
index 2839bed30cb7c..dad9b582f417d 100644
--- a/libc/test/src/math/smoke/fromfpxf128_test.cpp
+++ b/libc/test/src/math/smoke/fromfpxf128_test.cpp
@@ -7,7 +7,12 @@
//===----------------------------------------------------------------------===//
#include "FromfpxTest.h"
+#include "src/__support/FPUtil/float128.h"
#include "src/math/fromfpxf128.h"
+#ifndef LIBC_TYPES_HAS_NATIVE_FLOAT128
+using float128 = LIBC_NAMESPACE::fputil::Float128;
+#endif // LIBC_TYPES_HAS_NATIVE_FLOAT128
+
LIST_FROMFPX_TESTS(float128, LIBC_NAMESPACE::fromfpxf128)
>From addec09371ac8a6abe9d3889ed87701ad240ca0e Mon Sep 17 00:00:00 2001
From: Sukumarsawant <sawantsukumar at gmail.com>
Date: Sun, 16 Aug 2026 22:20:46 +0530
Subject: [PATCH 3/4] ufromfpf128
---
libc/config/baremetal/aarch64/entrypoints.txt | 2 +-
libc/config/baremetal/arm/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/ufromfpf128.h | 6 ------
libc/src/__support/math/CMakeLists.txt | 2 +-
libc/src/__support/math/ufromfpf128.h | 11 ++++-------
libc/src/math/generic/CMakeLists.txt | 1 +
libc/src/math/generic/ufromfpf128.cpp | 6 +++++-
libc/src/math/ufromfpf128.h | 5 +++++
libc/test/shared/shared_math_constexpr_test.cpp | 4 ++--
libc/test/shared/shared_math_test.cpp | 4 ++--
libc/test/src/math/smoke/CMakeLists.txt | 1 +
libc/test/src/math/smoke/ufromfpf128_test.cpp | 5 +++++
23 files changed, 39 insertions(+), 27 deletions(-)
diff --git a/libc/config/baremetal/aarch64/entrypoints.txt b/libc/config/baremetal/aarch64/entrypoints.txt
index 120ebd5e2ffc3..7cd495d475fc7 100644
--- a/libc/config/baremetal/aarch64/entrypoints.txt
+++ b/libc/config/baremetal/aarch64/entrypoints.txt
@@ -585,6 +585,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.truncl
libc.src.math.ufromfp
libc.src.math.ufromfpf
+ libc.src.math.ufromfpf128
libc.src.math.ufromfpl
libc.src.math.ufromfpx
libc.src.math.ufromfpxf
@@ -794,7 +795,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
libc.src.math.totalorderf128
libc.src.math.totalordermagf128
libc.src.math.truncf128
- libc.src.math.ufromfpf128
libc.src.math.ufromfpxf128
)
endif()
diff --git a/libc/config/baremetal/arm/entrypoints.txt b/libc/config/baremetal/arm/entrypoints.txt
index 4be544e8f81d1..94a2408f5a396 100644
--- a/libc/config/baremetal/arm/entrypoints.txt
+++ b/libc/config/baremetal/arm/entrypoints.txt
@@ -597,6 +597,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.truncl
libc.src.math.ufromfp
libc.src.math.ufromfpf
+ libc.src.math.ufromfpf128
libc.src.math.ufromfpl
libc.src.math.ufromfpx
libc.src.math.ufromfpxf
@@ -805,7 +806,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
libc.src.math.totalorderf128
libc.src.math.totalordermagf128
libc.src.math.truncf128
- libc.src.math.ufromfpf128
libc.src.math.ufromfpxf128
)
endif()
diff --git a/libc/config/baremetal/riscv/entrypoints.txt b/libc/config/baremetal/riscv/entrypoints.txt
index a1d09b36b086c..aad0e5d8dc0a3 100644
--- a/libc/config/baremetal/riscv/entrypoints.txt
+++ b/libc/config/baremetal/riscv/entrypoints.txt
@@ -593,6 +593,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.truncl
libc.src.math.ufromfp
libc.src.math.ufromfpf
+ libc.src.math.ufromfpf128
libc.src.math.ufromfpl
libc.src.math.ufromfpx
libc.src.math.ufromfpxf
@@ -802,7 +803,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
libc.src.math.totalorderf128
libc.src.math.totalordermagf128
libc.src.math.truncf128
- libc.src.math.ufromfpf128
libc.src.math.ufromfpxf128
)
endif()
diff --git a/libc/config/darwin/aarch64/entrypoints.txt b/libc/config/darwin/aarch64/entrypoints.txt
index c75dd6a89b02d..a2a4daf772d8c 100644
--- a/libc/config/darwin/aarch64/entrypoints.txt
+++ b/libc/config/darwin/aarch64/entrypoints.txt
@@ -405,6 +405,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.truncl
libc.src.math.ufromfp
libc.src.math.ufromfpf
+ libc.src.math.ufromfpf128
libc.src.math.ufromfpl
libc.src.math.ufromfpx
libc.src.math.ufromfpxf
@@ -614,7 +615,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
libc.src.math.totalorderf128
libc.src.math.totalordermagf128
libc.src.math.truncf128
- libc.src.math.ufromfpf128
libc.src.math.ufromfpxf128
)
endif()
diff --git a/libc/config/darwin/x86_64/entrypoints.txt b/libc/config/darwin/x86_64/entrypoints.txt
index 2752fbb112e6f..76ca2c803623d 100644
--- a/libc/config/darwin/x86_64/entrypoints.txt
+++ b/libc/config/darwin/x86_64/entrypoints.txt
@@ -234,6 +234,7 @@ set(TARGET_LIBM_ENTRYPOINTS
#libc.src.math.trunc
#libc.src.math.truncf
#libc.src.math.truncl
+ #libc.src.math.ufromfpf128
)
list(APPEND TARGET_LIBM_ENTRYPOINTS
diff --git a/libc/config/freebsd/x86_64/entrypoints.txt b/libc/config/freebsd/x86_64/entrypoints.txt
index 3d15628a6efc9..9cef3ff79b6c9 100644
--- a/libc/config/freebsd/x86_64/entrypoints.txt
+++ b/libc/config/freebsd/x86_64/entrypoints.txt
@@ -290,6 +290,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.trunc
libc.src.math.truncf
libc.src.math.truncl
+ libc.src.math.ufromfpf128
)
list(APPEND TARGET_LIBM_ENTRYPOINTS
@@ -552,7 +553,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
libc.src.math.totalorderf128
libc.src.math.totalordermagf128
libc.src.math.truncf128
- libc.src.math.ufromfpf128
libc.src.math.ufromfpxf128
)
endif()
diff --git a/libc/config/gpu/amdgpu/entrypoints.txt b/libc/config/gpu/amdgpu/entrypoints.txt
index 09f24c82eb96b..77d2f66118eeb 100644
--- a/libc/config/gpu/amdgpu/entrypoints.txt
+++ b/libc/config/gpu/amdgpu/entrypoints.txt
@@ -531,6 +531,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.truncl
libc.src.math.ufromfp
libc.src.math.ufromfpf
+ libc.src.math.ufromfpf128
libc.src.math.ufromfpl
libc.src.math.ufromfpx
libc.src.math.ufromfpxf
diff --git a/libc/config/gpu/nvptx/entrypoints.txt b/libc/config/gpu/nvptx/entrypoints.txt
index a18c5197d7c27..cb3d7fd03f2d0 100644
--- a/libc/config/gpu/nvptx/entrypoints.txt
+++ b/libc/config/gpu/nvptx/entrypoints.txt
@@ -529,6 +529,7 @@ set(TARGET_LIBM_ENTRYPOINTS
# FIXME: Broken.
# libc.src.math.ufromfp
# libc.src.math.ufromfpf
+ #libc.src.math.ufromfpf128
# libc.src.math.ufromfpl
# libc.src.math.ufromfpx
# libc.src.math.ufromfpxf
diff --git a/libc/config/linux/aarch64/entrypoints.txt b/libc/config/linux/aarch64/entrypoints.txt
index cff6536d3d58c..eda89d0b08df2 100644
--- a/libc/config/linux/aarch64/entrypoints.txt
+++ b/libc/config/linux/aarch64/entrypoints.txt
@@ -739,6 +739,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.truncl
libc.src.math.ufromfp
libc.src.math.ufromfpf
+ libc.src.math.ufromfpf128
libc.src.math.ufromfpl
libc.src.math.ufromfpx
libc.src.math.ufromfpxf
@@ -941,7 +942,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
libc.src.math.totalorderf128
libc.src.math.totalordermagf128
libc.src.math.truncf128
- libc.src.math.ufromfpf128
libc.src.math.ufromfpxf128
)
endif()
diff --git a/libc/config/linux/arm/entrypoints.txt b/libc/config/linux/arm/entrypoints.txt
index 1ef4f073beba9..c9f8ce717ea27 100644
--- a/libc/config/linux/arm/entrypoints.txt
+++ b/libc/config/linux/arm/entrypoints.txt
@@ -556,6 +556,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.truncl
libc.src.math.ufromfp
libc.src.math.ufromfpf
+ libc.src.math.ufromfpf128
libc.src.math.ufromfpl
libc.src.math.ufromfpx
libc.src.math.ufromfpxf
diff --git a/libc/config/linux/riscv/entrypoints.txt b/libc/config/linux/riscv/entrypoints.txt
index b2dcc0b20de77..17a0da4c36f15 100644
--- a/libc/config/linux/riscv/entrypoints.txt
+++ b/libc/config/linux/riscv/entrypoints.txt
@@ -812,6 +812,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.truncl
libc.src.math.ufromfp
libc.src.math.ufromfpf
+ libc.src.math.ufromfpf128
libc.src.math.ufromfpl
libc.src.math.ufromfpx
libc.src.math.ufromfpxf
@@ -1031,7 +1032,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
libc.src.math.totalorderf128
libc.src.math.totalordermagf128
libc.src.math.truncf128
- libc.src.math.ufromfpf128
libc.src.math.ufromfpxf128
)
endif()
diff --git a/libc/config/linux/x86_64/entrypoints.txt b/libc/config/linux/x86_64/entrypoints.txt
index d785bb8961510..ed1f225a3ebcc 100644
--- a/libc/config/linux/x86_64/entrypoints.txt
+++ b/libc/config/linux/x86_64/entrypoints.txt
@@ -817,6 +817,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.truncl
libc.src.math.ufromfp
libc.src.math.ufromfpf
+ libc.src.math.ufromfpf128
libc.src.math.ufromfpl
libc.src.math.ufromfpx
libc.src.math.ufromfpxf
@@ -1036,7 +1037,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
libc.src.math.totalorderf128
libc.src.math.totalordermagf128
libc.src.math.truncf128
- libc.src.math.ufromfpf128
libc.src.math.ufromfpxf128
)
endif()
diff --git a/libc/config/windows/entrypoints.txt b/libc/config/windows/entrypoints.txt
index d86a6c1dc298a..98e41c63b119d 100644
--- a/libc/config/windows/entrypoints.txt
+++ b/libc/config/windows/entrypoints.txt
@@ -324,6 +324,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.trunc
libc.src.math.truncf
libc.src.math.truncl
+ libc.src.math.ufromfpf128
)
list(APPEND TARGET_LIBM_ENTRYPOINTS
diff --git a/libc/shared/math/ufromfpf128.h b/libc/shared/math/ufromfpf128.h
index 91195943c1e2e..25cf54d18dd41 100644
--- a/libc/shared/math/ufromfpf128.h
+++ b/libc/shared/math/ufromfpf128.h
@@ -9,10 +9,6 @@
#ifndef LLVM_LIBC_SHARED_MATH_UFROMFPF128_H
#define LLVM_LIBC_SHARED_MATH_UFROMFPF128_H
-#include "include/llvm-libc-types/float128.h"
-
-#ifdef LIBC_TYPES_HAS_NATIVE_FLOAT128
-
#include "shared/libc_common.h"
#include "src/__support/math/ufromfpf128.h"
@@ -24,6 +20,4 @@ using math::ufromfpf128;
} // namespace shared
} // namespace LIBC_NAMESPACE_DECL
-#endif // LIBC_TYPES_HAS_NATIVE_FLOAT128
-
#endif // LLVM_LIBC_SHARED_MATH_UFROMFPF128_H
diff --git a/libc/src/__support/math/CMakeLists.txt b/libc/src/__support/math/CMakeLists.txt
index 219e89fd9d88a..c4d3ffe2e3ece 100644
--- a/libc/src/__support/math/CMakeLists.txt
+++ b/libc/src/__support/math/CMakeLists.txt
@@ -5763,7 +5763,7 @@ add_header_library(
HDRS
ufromfpf128.h
DEPENDS
- libc.include.llvm-libc-types.float128
+ libc.src.__support.FPUtil.float128
libc.src.__support.FPUtil.nearest_integer_operations
libc.src.__support.macros.config
)
diff --git a/libc/src/__support/math/ufromfpf128.h b/libc/src/__support/math/ufromfpf128.h
index b7a3376924c70..7645f70b79d07 100644
--- a/libc/src/__support/math/ufromfpf128.h
+++ b/libc/src/__support/math/ufromfpf128.h
@@ -9,17 +9,16 @@
#ifndef LLVM_LIBC_SRC___SUPPORT_MATH_UFROMFPF128_H
#define LLVM_LIBC_SRC___SUPPORT_MATH_UFROMFPF128_H
-#include "include/llvm-libc-types/float128.h"
-
-#ifdef LIBC_TYPES_HAS_NATIVE_FLOAT128
-
#include "src/__support/FPUtil/NearestIntegerOperations.h"
+#include "src/__support/FPUtil/float128.h"
#include "src/__support/macros/config.h"
namespace LIBC_NAMESPACE_DECL {
namespace math {
-LIBC_INLINE constexpr float128 ufromfpf128(float128 x, int rnd,
+using LIBC_NAMESPACE::fputil::Float128;
+
+LIBC_INLINE constexpr Float128 ufromfpf128(Float128 x, int rnd,
unsigned int width) {
return fputil::fromfp</*IsSigned=*/false>(x, rnd, width);
}
@@ -27,6 +26,4 @@ LIBC_INLINE constexpr float128 ufromfpf128(float128 x, int rnd,
} // namespace math
} // namespace LIBC_NAMESPACE_DECL
-#endif // LIBC_TYPES_HAS_NATIVE_FLOAT128
-
#endif // LLVM_LIBC_SRC___SUPPORT_MATH_UFROMFPF128_H
diff --git a/libc/src/math/generic/CMakeLists.txt b/libc/src/math/generic/CMakeLists.txt
index 8d9909970cf46..4d6d818974589 100644
--- a/libc/src/math/generic/CMakeLists.txt
+++ b/libc/src/math/generic/CMakeLists.txt
@@ -3614,6 +3614,7 @@ add_entrypoint_object(
HDRS
../ufromfpf128.h
DEPENDS
+ libc.src.__support.CPP.bit
libc.src.__support.math.ufromfpf128
)
diff --git a/libc/src/math/generic/ufromfpf128.cpp b/libc/src/math/generic/ufromfpf128.cpp
index 02c5518a2fdaf..b9ca050392c91 100644
--- a/libc/src/math/generic/ufromfpf128.cpp
+++ b/libc/src/math/generic/ufromfpf128.cpp
@@ -7,13 +7,17 @@
//===----------------------------------------------------------------------===//
#include "src/math/ufromfpf128.h"
+#include "src/__support/CPP/bit.h"
#include "src/__support/math/ufromfpf128.h"
namespace LIBC_NAMESPACE_DECL {
+using LIBC_NAMESPACE::fputil::Float128;
+
LLVM_LIBC_FUNCTION(float128, ufromfpf128,
(float128 x, int rnd, unsigned int width)) {
- return math::ufromfpf128(x, rnd, width);
+ return cpp::bit_cast<float128>(
+ math::ufromfpf128(cpp::bit_cast<Float128>(x), rnd, width));
}
} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/ufromfpf128.h b/libc/src/math/ufromfpf128.h
index b38ef691fa165..b5dcf348b8fae 100644
--- a/libc/src/math/ufromfpf128.h
+++ b/libc/src/math/ufromfpf128.h
@@ -9,11 +9,16 @@
#ifndef LLVM_LIBC_SRC_MATH_UFROMFPF128_H
#define LLVM_LIBC_SRC_MATH_UFROMFPF128_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
+
float128 ufromfpf128(float128 x, int rnd, unsigned int width);
} // 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 2591e2a67ba06..9c635086121e8 100644
--- a/libc/test/shared/shared_math_constexpr_test.cpp
+++ b/libc/test/shared/shared_math_constexpr_test.cpp
@@ -381,6 +381,8 @@ static_assert(0 == LIBC_NAMESPACE::shared::isnanl(0.0L));
//===----------------------------------------------------------------------===//
static_assert(Float128(0.0) == LIBC_NAMESPACE::shared::ceilf128(Float128(0.0)));
+static_assert(Float128(0.0) ==
+ LIBC_NAMESPACE::shared::ufromfpf128(Float128(0.0), 0, 32));
static_assert(Float128(0.0) ==
LIBC_NAMESPACE::shared::fromfpxf128(Float128(0.0), 0, 32));
@@ -437,8 +439,6 @@ static_assert(float128(-1.0) == [] {
float128 getpayload_x = float128(0.0);
return LIBC_NAMESPACE::shared::getpayloadf128(&getpayload_x);
}());
-static_assert(float128(0.0) ==
- LIBC_NAMESPACE::shared::ufromfpf128(float128(0.0), 0, 32));
static_assert(float128(0.0) ==
LIBC_NAMESPACE::shared::ufromfpxf128(float128(0.0), 0, 32));
static_assert(float128(0.0) ==
diff --git a/libc/test/shared/shared_math_test.cpp b/libc/test/shared/shared_math_test.cpp
index e2c29d38b1b61..c63abc56a06ee 100644
--- a/libc/test/shared/shared_math_test.cpp
+++ b/libc/test/shared/shared_math_test.cpp
@@ -582,6 +582,8 @@ TEST(LlvmLibcSharedMathTest, AllLongDouble) {
// Emulated float128 tests
TEST(LlvmLibcSharedMathTest, AllEmuFloat128) {
EXPECT_FP_EQ(Float128(0.0), LIBC_NAMESPACE::shared::ceilf128(Float128(0.0)));
+ EXPECT_FP_EQ(Float128(0.0),
+ LIBC_NAMESPACE::shared::ufromfpf128(Float128(0.0), 0, 32));
EXPECT_FP_EQ(Float128(0.0),
LIBC_NAMESPACE::shared::fromfpxf128(Float128(0.0), 0, 32));
EXPECT_FP_EQ(Float128(0.0),
@@ -701,8 +703,6 @@ TEST(LlvmLibcSharedMathTest, AllFloat128) {
float128(0.0), float128(0.0)));
EXPECT_FP_EQ(float128(0.0), LIBC_NAMESPACE::shared::fminimum_numf128(
float128(0.0), float128(0.0)));
- EXPECT_FP_EQ(float128(0.0),
- LIBC_NAMESPACE::shared::ufromfpf128(float128(0.0), 0, 32));
EXPECT_FP_EQ(float128(0.0),
LIBC_NAMESPACE::shared::ufromfpxf128(float128(0.0), 0, 32));
EXPECT_FP_EQ(float128(0.0), LIBC_NAMESPACE::shared::fmaximum_magf128(
diff --git a/libc/test/src/math/smoke/CMakeLists.txt b/libc/test/src/math/smoke/CMakeLists.txt
index ea50b28c083ce..5ef2ed67c5d90 100644
--- a/libc/test/src/math/smoke/CMakeLists.txt
+++ b/libc/test/src/math/smoke/CMakeLists.txt
@@ -1930,6 +1930,7 @@ add_fp_unittest(
HDRS
UfromfpTest.h
DEPENDS
+ libc.src.__support.FPUtil.float128
libc.src.math.ufromfpf128
)
diff --git a/libc/test/src/math/smoke/ufromfpf128_test.cpp b/libc/test/src/math/smoke/ufromfpf128_test.cpp
index 9ba3034f6e61f..40d3159020bdb 100644
--- a/libc/test/src/math/smoke/ufromfpf128_test.cpp
+++ b/libc/test/src/math/smoke/ufromfpf128_test.cpp
@@ -7,7 +7,12 @@
//===----------------------------------------------------------------------===//
#include "UfromfpTest.h"
+#include "src/__support/FPUtil/float128.h"
#include "src/math/ufromfpf128.h"
+#ifndef LIBC_TYPES_HAS_NATIVE_FLOAT128
+using float128 = LIBC_NAMESPACE::fputil::Float128;
+#endif // LIBC_TYPES_HAS_NATIVE_FLOAT128
+
LIST_UFROMFP_TESTS(float128, LIBC_NAMESPACE::ufromfpf128)
>From cf6b4a528f04a7af438a2a0a1fc1f93b4d85a3e8 Mon Sep 17 00:00:00 2001
From: Sukumarsawant <sawantsukumar at gmail.com>
Date: Sun, 16 Aug 2026 22:21:21 +0530
Subject: [PATCH 4/4] ufromfpxf128
---
libc/config/baremetal/aarch64/entrypoints.txt | 2 +-
libc/config/baremetal/arm/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/ufromfpxf128.h | 6 ------
libc/src/__support/math/CMakeLists.txt | 2 +-
libc/src/__support/math/ufromfpxf128.h | 11 ++++-------
libc/src/math/generic/CMakeLists.txt | 1 +
libc/src/math/generic/ufromfpxf128.cpp | 6 +++++-
libc/src/math/ufromfpxf128.h | 5 +++++
libc/test/shared/shared_math_constexpr_test.cpp | 4 ++--
libc/test/shared/shared_math_test.cpp | 4 ++--
libc/test/src/math/smoke/CMakeLists.txt | 1 +
libc/test/src/math/smoke/ufromfpxf128_test.cpp | 5 +++++
23 files changed, 39 insertions(+), 27 deletions(-)
diff --git a/libc/config/baremetal/aarch64/entrypoints.txt b/libc/config/baremetal/aarch64/entrypoints.txt
index 7cd495d475fc7..7dbb77a5e2ab5 100644
--- a/libc/config/baremetal/aarch64/entrypoints.txt
+++ b/libc/config/baremetal/aarch64/entrypoints.txt
@@ -589,6 +589,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.ufromfpl
libc.src.math.ufromfpx
libc.src.math.ufromfpxf
+ libc.src.math.ufromfpxf128
libc.src.math.ufromfpxl
)
@@ -795,7 +796,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
libc.src.math.totalorderf128
libc.src.math.totalordermagf128
libc.src.math.truncf128
- libc.src.math.ufromfpxf128
)
endif()
diff --git a/libc/config/baremetal/arm/entrypoints.txt b/libc/config/baremetal/arm/entrypoints.txt
index 94a2408f5a396..6165549db93d8 100644
--- a/libc/config/baremetal/arm/entrypoints.txt
+++ b/libc/config/baremetal/arm/entrypoints.txt
@@ -601,6 +601,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.ufromfpl
libc.src.math.ufromfpx
libc.src.math.ufromfpxf
+ libc.src.math.ufromfpxf128
libc.src.math.ufromfpxl
)
@@ -806,7 +807,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
libc.src.math.totalorderf128
libc.src.math.totalordermagf128
libc.src.math.truncf128
- libc.src.math.ufromfpxf128
)
endif()
diff --git a/libc/config/baremetal/riscv/entrypoints.txt b/libc/config/baremetal/riscv/entrypoints.txt
index aad0e5d8dc0a3..2a4c62a34a022 100644
--- a/libc/config/baremetal/riscv/entrypoints.txt
+++ b/libc/config/baremetal/riscv/entrypoints.txt
@@ -597,6 +597,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.ufromfpl
libc.src.math.ufromfpx
libc.src.math.ufromfpxf
+ libc.src.math.ufromfpxf128
libc.src.math.ufromfpxl
)
@@ -803,7 +804,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
libc.src.math.totalorderf128
libc.src.math.totalordermagf128
libc.src.math.truncf128
- libc.src.math.ufromfpxf128
)
endif()
diff --git a/libc/config/darwin/aarch64/entrypoints.txt b/libc/config/darwin/aarch64/entrypoints.txt
index a2a4daf772d8c..de22d6dc77454 100644
--- a/libc/config/darwin/aarch64/entrypoints.txt
+++ b/libc/config/darwin/aarch64/entrypoints.txt
@@ -409,6 +409,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.ufromfpl
libc.src.math.ufromfpx
libc.src.math.ufromfpxf
+ libc.src.math.ufromfpxf128
libc.src.math.ufromfpxl
)
@@ -615,7 +616,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
libc.src.math.totalorderf128
libc.src.math.totalordermagf128
libc.src.math.truncf128
- libc.src.math.ufromfpxf128
)
endif()
diff --git a/libc/config/darwin/x86_64/entrypoints.txt b/libc/config/darwin/x86_64/entrypoints.txt
index 76ca2c803623d..44b923cd94b95 100644
--- a/libc/config/darwin/x86_64/entrypoints.txt
+++ b/libc/config/darwin/x86_64/entrypoints.txt
@@ -235,6 +235,7 @@ set(TARGET_LIBM_ENTRYPOINTS
#libc.src.math.truncf
#libc.src.math.truncl
#libc.src.math.ufromfpf128
+ #libc.src.math.ufromfpxf128
)
list(APPEND TARGET_LIBM_ENTRYPOINTS
diff --git a/libc/config/freebsd/x86_64/entrypoints.txt b/libc/config/freebsd/x86_64/entrypoints.txt
index 9cef3ff79b6c9..c4daffa37617c 100644
--- a/libc/config/freebsd/x86_64/entrypoints.txt
+++ b/libc/config/freebsd/x86_64/entrypoints.txt
@@ -291,6 +291,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.truncf
libc.src.math.truncl
libc.src.math.ufromfpf128
+ libc.src.math.ufromfpxf128
)
list(APPEND TARGET_LIBM_ENTRYPOINTS
@@ -553,7 +554,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
libc.src.math.totalorderf128
libc.src.math.totalordermagf128
libc.src.math.truncf128
- libc.src.math.ufromfpxf128
)
endif()
diff --git a/libc/config/gpu/amdgpu/entrypoints.txt b/libc/config/gpu/amdgpu/entrypoints.txt
index 77d2f66118eeb..7a322e764e6a0 100644
--- a/libc/config/gpu/amdgpu/entrypoints.txt
+++ b/libc/config/gpu/amdgpu/entrypoints.txt
@@ -535,6 +535,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.ufromfpl
libc.src.math.ufromfpx
libc.src.math.ufromfpxf
+ libc.src.math.ufromfpxf128
libc.src.math.ufromfpxl
)
diff --git a/libc/config/gpu/nvptx/entrypoints.txt b/libc/config/gpu/nvptx/entrypoints.txt
index cb3d7fd03f2d0..504c0752356d1 100644
--- a/libc/config/gpu/nvptx/entrypoints.txt
+++ b/libc/config/gpu/nvptx/entrypoints.txt
@@ -533,6 +533,7 @@ set(TARGET_LIBM_ENTRYPOINTS
# libc.src.math.ufromfpl
# libc.src.math.ufromfpx
# libc.src.math.ufromfpxf
+ #libc.src.math.ufromfpxf128
# libc.src.math.ufromfpxl
)
diff --git a/libc/config/linux/aarch64/entrypoints.txt b/libc/config/linux/aarch64/entrypoints.txt
index eda89d0b08df2..3a3665036e290 100644
--- a/libc/config/linux/aarch64/entrypoints.txt
+++ b/libc/config/linux/aarch64/entrypoints.txt
@@ -743,6 +743,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.ufromfpl
libc.src.math.ufromfpx
libc.src.math.ufromfpxf
+ libc.src.math.ufromfpxf128
libc.src.math.ufromfpxl
)
@@ -942,7 +943,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
libc.src.math.totalorderf128
libc.src.math.totalordermagf128
libc.src.math.truncf128
- libc.src.math.ufromfpxf128
)
endif()
diff --git a/libc/config/linux/arm/entrypoints.txt b/libc/config/linux/arm/entrypoints.txt
index c9f8ce717ea27..2dd3dd00f8174 100644
--- a/libc/config/linux/arm/entrypoints.txt
+++ b/libc/config/linux/arm/entrypoints.txt
@@ -560,6 +560,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.ufromfpl
libc.src.math.ufromfpx
libc.src.math.ufromfpxf
+ libc.src.math.ufromfpxf128
libc.src.math.ufromfpxl
)
diff --git a/libc/config/linux/riscv/entrypoints.txt b/libc/config/linux/riscv/entrypoints.txt
index 17a0da4c36f15..f87bb6575d1f6 100644
--- a/libc/config/linux/riscv/entrypoints.txt
+++ b/libc/config/linux/riscv/entrypoints.txt
@@ -816,6 +816,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.ufromfpl
libc.src.math.ufromfpx
libc.src.math.ufromfpxf
+ libc.src.math.ufromfpxf128
libc.src.math.ufromfpxl
)
@@ -1032,7 +1033,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
libc.src.math.totalorderf128
libc.src.math.totalordermagf128
libc.src.math.truncf128
- libc.src.math.ufromfpxf128
)
endif()
diff --git a/libc/config/linux/x86_64/entrypoints.txt b/libc/config/linux/x86_64/entrypoints.txt
index ed1f225a3ebcc..4daee6da955bb 100644
--- a/libc/config/linux/x86_64/entrypoints.txt
+++ b/libc/config/linux/x86_64/entrypoints.txt
@@ -821,6 +821,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.ufromfpl
libc.src.math.ufromfpx
libc.src.math.ufromfpxf
+ libc.src.math.ufromfpxf128
libc.src.math.ufromfpxl
)
@@ -1037,7 +1038,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
libc.src.math.totalorderf128
libc.src.math.totalordermagf128
libc.src.math.truncf128
- libc.src.math.ufromfpxf128
)
endif()
diff --git a/libc/config/windows/entrypoints.txt b/libc/config/windows/entrypoints.txt
index 98e41c63b119d..9765d1c00f21d 100644
--- a/libc/config/windows/entrypoints.txt
+++ b/libc/config/windows/entrypoints.txt
@@ -325,6 +325,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.truncf
libc.src.math.truncl
libc.src.math.ufromfpf128
+ libc.src.math.ufromfpxf128
)
list(APPEND TARGET_LIBM_ENTRYPOINTS
diff --git a/libc/shared/math/ufromfpxf128.h b/libc/shared/math/ufromfpxf128.h
index 4be803c60877a..08dcb96ba0445 100644
--- a/libc/shared/math/ufromfpxf128.h
+++ b/libc/shared/math/ufromfpxf128.h
@@ -9,10 +9,6 @@
#ifndef LLVM_LIBC_SHARED_MATH_UFROMFPXF128_H
#define LLVM_LIBC_SHARED_MATH_UFROMFPXF128_H
-#include "include/llvm-libc-types/float128.h"
-
-#ifdef LIBC_TYPES_HAS_NATIVE_FLOAT128
-
#include "shared/libc_common.h"
#include "src/__support/math/ufromfpxf128.h"
@@ -24,6 +20,4 @@ using math::ufromfpxf128;
} // namespace shared
} // namespace LIBC_NAMESPACE_DECL
-#endif // LIBC_TYPES_HAS_NATIVE_FLOAT128
-
#endif // LLVM_LIBC_SHARED_MATH_UFROMFPXF128_H
diff --git a/libc/src/__support/math/CMakeLists.txt b/libc/src/__support/math/CMakeLists.txt
index c4d3ffe2e3ece..7b9f333032998 100644
--- a/libc/src/__support/math/CMakeLists.txt
+++ b/libc/src/__support/math/CMakeLists.txt
@@ -5820,7 +5820,7 @@ add_header_library(
HDRS
ufromfpxf128.h
DEPENDS
- libc.include.llvm-libc-types.float128
+ libc.src.__support.FPUtil.float128
libc.src.__support.FPUtil.nearest_integer_operations
libc.src.__support.macros.config
)
diff --git a/libc/src/__support/math/ufromfpxf128.h b/libc/src/__support/math/ufromfpxf128.h
index 3543b62da849d..0053639cdc29f 100644
--- a/libc/src/__support/math/ufromfpxf128.h
+++ b/libc/src/__support/math/ufromfpxf128.h
@@ -9,17 +9,16 @@
#ifndef LLVM_LIBC_SRC___SUPPORT_MATH_UFROMFPXF128_H
#define LLVM_LIBC_SRC___SUPPORT_MATH_UFROMFPXF128_H
-#include "include/llvm-libc-types/float128.h"
-
-#ifdef LIBC_TYPES_HAS_NATIVE_FLOAT128
-
#include "src/__support/FPUtil/NearestIntegerOperations.h"
+#include "src/__support/FPUtil/float128.h"
#include "src/__support/macros/config.h"
namespace LIBC_NAMESPACE_DECL {
namespace math {
-LIBC_INLINE constexpr float128 ufromfpxf128(float128 x, int rnd,
+using LIBC_NAMESPACE::fputil::Float128;
+
+LIBC_INLINE constexpr Float128 ufromfpxf128(Float128 x, int rnd,
unsigned int width) {
return fputil::fromfpx</*IsSigned=*/false>(x, rnd, width);
}
@@ -27,6 +26,4 @@ LIBC_INLINE constexpr float128 ufromfpxf128(float128 x, int rnd,
} // namespace math
} // namespace LIBC_NAMESPACE_DECL
-#endif // LIBC_TYPES_HAS_NATIVE_FLOAT128
-
#endif // LLVM_LIBC_SRC___SUPPORT_MATH_UFROMFPXF128_H
diff --git a/libc/src/math/generic/CMakeLists.txt b/libc/src/math/generic/CMakeLists.txt
index 4d6d818974589..da44d9ab71b26 100644
--- a/libc/src/math/generic/CMakeLists.txt
+++ b/libc/src/math/generic/CMakeLists.txt
@@ -3675,6 +3675,7 @@ add_entrypoint_object(
HDRS
../ufromfpxf128.h
DEPENDS
+ libc.src.__support.CPP.bit
libc.src.__support.math.ufromfpxf128
)
diff --git a/libc/src/math/generic/ufromfpxf128.cpp b/libc/src/math/generic/ufromfpxf128.cpp
index b2d948e63184b..9495af9055a59 100644
--- a/libc/src/math/generic/ufromfpxf128.cpp
+++ b/libc/src/math/generic/ufromfpxf128.cpp
@@ -7,13 +7,17 @@
//===----------------------------------------------------------------------===//
#include "src/math/ufromfpxf128.h"
+#include "src/__support/CPP/bit.h"
#include "src/__support/math/ufromfpxf128.h"
namespace LIBC_NAMESPACE_DECL {
+using LIBC_NAMESPACE::fputil::Float128;
+
LLVM_LIBC_FUNCTION(float128, ufromfpxf128,
(float128 x, int rnd, unsigned int width)) {
- return math::ufromfpxf128(x, rnd, width);
+ return cpp::bit_cast<float128>(
+ math::ufromfpxf128(cpp::bit_cast<Float128>(x), rnd, width));
}
} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/ufromfpxf128.h b/libc/src/math/ufromfpxf128.h
index 5008b7ae9b460..fcdfc99fd29bb 100644
--- a/libc/src/math/ufromfpxf128.h
+++ b/libc/src/math/ufromfpxf128.h
@@ -9,11 +9,16 @@
#ifndef LLVM_LIBC_SRC_MATH_UFROMFPXF128_H
#define LLVM_LIBC_SRC_MATH_UFROMFPXF128_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
+
float128 ufromfpxf128(float128 x, int rnd, unsigned int width);
} // 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 9c635086121e8..e7912ecea0867 100644
--- a/libc/test/shared/shared_math_constexpr_test.cpp
+++ b/libc/test/shared/shared_math_constexpr_test.cpp
@@ -381,6 +381,8 @@ static_assert(0 == LIBC_NAMESPACE::shared::isnanl(0.0L));
//===----------------------------------------------------------------------===//
static_assert(Float128(0.0) == LIBC_NAMESPACE::shared::ceilf128(Float128(0.0)));
+static_assert(Float128(0.0) ==
+ LIBC_NAMESPACE::shared::ufromfpxf128(Float128(0.0), 0, 32));
static_assert(Float128(0.0) ==
LIBC_NAMESPACE::shared::ufromfpf128(Float128(0.0), 0, 32));
static_assert(Float128(0.0) ==
@@ -439,8 +441,6 @@ static_assert(float128(-1.0) == [] {
float128 getpayload_x = float128(0.0);
return LIBC_NAMESPACE::shared::getpayloadf128(&getpayload_x);
}());
-static_assert(float128(0.0) ==
- LIBC_NAMESPACE::shared::ufromfpxf128(float128(0.0), 0, 32));
static_assert(float128(0.0) ==
LIBC_NAMESPACE::shared::fmaximum_magf128(float128(0.0),
float128(0.0)));
diff --git a/libc/test/shared/shared_math_test.cpp b/libc/test/shared/shared_math_test.cpp
index c63abc56a06ee..e69ad02d86300 100644
--- a/libc/test/shared/shared_math_test.cpp
+++ b/libc/test/shared/shared_math_test.cpp
@@ -582,6 +582,8 @@ TEST(LlvmLibcSharedMathTest, AllLongDouble) {
// Emulated float128 tests
TEST(LlvmLibcSharedMathTest, AllEmuFloat128) {
EXPECT_FP_EQ(Float128(0.0), LIBC_NAMESPACE::shared::ceilf128(Float128(0.0)));
+ EXPECT_FP_EQ(Float128(0.0),
+ LIBC_NAMESPACE::shared::ufromfpxf128(Float128(0.0), 0, 32));
EXPECT_FP_EQ(Float128(0.0),
LIBC_NAMESPACE::shared::ufromfpf128(Float128(0.0), 0, 32));
EXPECT_FP_EQ(Float128(0.0),
@@ -703,8 +705,6 @@ TEST(LlvmLibcSharedMathTest, AllFloat128) {
float128(0.0), float128(0.0)));
EXPECT_FP_EQ(float128(0.0), LIBC_NAMESPACE::shared::fminimum_numf128(
float128(0.0), float128(0.0)));
- EXPECT_FP_EQ(float128(0.0),
- LIBC_NAMESPACE::shared::ufromfpxf128(float128(0.0), 0, 32));
EXPECT_FP_EQ(float128(0.0), LIBC_NAMESPACE::shared::fmaximum_magf128(
float128(0.0), float128(0.0)));
EXPECT_FP_EQ(float128(0.0), LIBC_NAMESPACE::shared::fminimum_magf128(
diff --git a/libc/test/src/math/smoke/CMakeLists.txt b/libc/test/src/math/smoke/CMakeLists.txt
index 5ef2ed67c5d90..5af75407ec006 100644
--- a/libc/test/src/math/smoke/CMakeLists.txt
+++ b/libc/test/src/math/smoke/CMakeLists.txt
@@ -2004,6 +2004,7 @@ add_fp_unittest(
HDRS
UfromfpxTest.h
DEPENDS
+ libc.src.__support.FPUtil.float128
libc.src.math.ufromfpxf128
)
diff --git a/libc/test/src/math/smoke/ufromfpxf128_test.cpp b/libc/test/src/math/smoke/ufromfpxf128_test.cpp
index 6defaf7fee3dd..ce64e13ad3c04 100644
--- a/libc/test/src/math/smoke/ufromfpxf128_test.cpp
+++ b/libc/test/src/math/smoke/ufromfpxf128_test.cpp
@@ -7,7 +7,12 @@
//===----------------------------------------------------------------------===//
#include "UfromfpxTest.h"
+#include "src/__support/FPUtil/float128.h"
#include "src/math/ufromfpxf128.h"
+#ifndef LIBC_TYPES_HAS_NATIVE_FLOAT128
+using float128 = LIBC_NAMESPACE::fputil::Float128;
+#endif // LIBC_TYPES_HAS_NATIVE_FLOAT128
+
LIST_UFROMFPX_TESTS(float128, LIBC_NAMESPACE::ufromfpxf128)
More information about the libc-commits
mailing list