[libc-commits] [libc] [libc] Make ldexpf128/scalbnf128/scalblnf128 use emulated Float128 (PR #220295)
via libc-commits
libc-commits at lists.llvm.org
Tue Sep 1 09:56:10 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-libc
Author: Parth Patel (rigalis)
<details>
<summary>Changes</summary>
This makes the three exponent scaling functions ldexpf128, scalbnf128 and scalblnf128 work with the emulated Float128 type, so they can be used on platforms without native __float128.
Fixes #<!-- -->219759 (part of #<!-- -->216576).
---
Patch is 24.57 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/220295.diff
24 Files Affected:
- (modified) libc/config/baremetal/aarch64/entrypoints.txt (+3-3)
- (modified) libc/config/baremetal/arm/entrypoints.txt (+3-3)
- (modified) libc/config/baremetal/riscv/entrypoints.txt (+3-3)
- (modified) libc/config/darwin/aarch64/entrypoints.txt (+3-3)
- (modified) libc/config/freebsd/x86_64/entrypoints.txt (+3-3)
- (modified) libc/config/linux/aarch64/entrypoints.txt (+3-3)
- (modified) libc/config/linux/riscv/entrypoints.txt (+3-3)
- (modified) libc/config/linux/x86_64/entrypoints.txt (+3-3)
- (modified) libc/shared/math/ldexpf128.h (-6)
- (modified) libc/shared/math/scalblnf128.h (+1-7)
- (modified) libc/shared/math/scalbnf128.h (+1-7)
- (modified) libc/src/__support/math/CMakeLists.txt (+4-4)
- (modified) libc/src/__support/math/ldexpf128.h (+5-11)
- (modified) libc/src/__support/math/scalblnf128.h (+4-7)
- (modified) libc/src/__support/math/scalbnf128.h (+4-7)
- (modified) libc/src/math/generic/CMakeLists.txt (+3)
- (modified) libc/src/math/generic/ldexpf128.cpp (+4-2)
- (modified) libc/src/math/generic/scalblnf128.cpp (+4-1)
- (modified) libc/src/math/generic/scalbnf128.cpp (+4-1)
- (modified) libc/src/math/ldexpf128.h (+5)
- (modified) libc/src/math/scalblnf128.h (+6-1)
- (modified) libc/src/math/scalbnf128.h (+6-1)
- (modified) libc/test/shared/shared_math_constexpr_test.cpp (+6-4)
- (modified) libc/test/shared/shared_math_test.cpp (+8-8)
``````````diff
diff --git a/libc/config/baremetal/aarch64/entrypoints.txt b/libc/config/baremetal/aarch64/entrypoints.txt
index 9a296693e22eb..fad95af15ae81 100644
--- a/libc/config/baremetal/aarch64/entrypoints.txt
+++ b/libc/config/baremetal/aarch64/entrypoints.txt
@@ -412,6 +412,9 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.ffma
libc.src.math.ffmal
libc.src.math.floor
+ libc.src.math.ldexpf128
+ libc.src.math.scalblnf128
+ libc.src.math.scalbnf128
libc.src.math.floorf
libc.src.math.floorf128
libc.src.math.floorl
@@ -779,7 +782,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
libc.src.math.fsubf128
libc.src.math.getpayloadf128
libc.src.math.ilogbf128
- libc.src.math.ldexpf128
libc.src.math.llogbf128
libc.src.math.logbf128
libc.src.math.modff128
@@ -789,8 +791,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
libc.src.math.nextupf128
libc.src.math.remainderf128
libc.src.math.remquof128
- libc.src.math.scalblnf128
- libc.src.math.scalbnf128
libc.src.math.setpayloadf128
libc.src.math.setpayloadsigf128
libc.src.math.totalorderf128
diff --git a/libc/config/baremetal/arm/entrypoints.txt b/libc/config/baremetal/arm/entrypoints.txt
index 7ac1a9ce0d35f..24a39419fedbb 100644
--- a/libc/config/baremetal/arm/entrypoints.txt
+++ b/libc/config/baremetal/arm/entrypoints.txt
@@ -424,6 +424,9 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.ffma
libc.src.math.ffmal
libc.src.math.floor
+ libc.src.math.ldexpf128
+ libc.src.math.scalblnf128
+ libc.src.math.scalbnf128
libc.src.math.floorf
libc.src.math.floorf128
libc.src.math.floorl
@@ -790,7 +793,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
libc.src.math.fsubf128
libc.src.math.getpayloadf128
libc.src.math.ilogbf128
- libc.src.math.ldexpf128
libc.src.math.llogbf128
libc.src.math.logbf128
libc.src.math.modff128
@@ -800,8 +802,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
libc.src.math.nextupf128
libc.src.math.remainderf128
libc.src.math.remquof128
- libc.src.math.scalblnf128
- libc.src.math.scalbnf128
libc.src.math.setpayloadf128
libc.src.math.setpayloadsigf128
libc.src.math.totalorderf128
diff --git a/libc/config/baremetal/riscv/entrypoints.txt b/libc/config/baremetal/riscv/entrypoints.txt
index 9dbaf71d285ee..4b4690f433ebc 100644
--- a/libc/config/baremetal/riscv/entrypoints.txt
+++ b/libc/config/baremetal/riscv/entrypoints.txt
@@ -420,6 +420,9 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.ffma
libc.src.math.ffmal
libc.src.math.floor
+ libc.src.math.ldexpf128
+ libc.src.math.scalblnf128
+ libc.src.math.scalbnf128
libc.src.math.floorf
libc.src.math.floorf128
libc.src.math.floorl
@@ -787,7 +790,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
libc.src.math.fsubf128
libc.src.math.getpayloadf128
libc.src.math.ilogbf128
- libc.src.math.ldexpf128
libc.src.math.llogbf128
libc.src.math.logbf128
libc.src.math.modff128
@@ -797,8 +799,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
libc.src.math.nextupf128
libc.src.math.remainderf128
libc.src.math.remquof128
- libc.src.math.scalblnf128
- libc.src.math.scalbnf128
libc.src.math.setpayloadf128
libc.src.math.setpayloadsigf128
libc.src.math.totalorderf128
diff --git a/libc/config/darwin/aarch64/entrypoints.txt b/libc/config/darwin/aarch64/entrypoints.txt
index ba397e2958cae..801dda0f51b5f 100644
--- a/libc/config/darwin/aarch64/entrypoints.txt
+++ b/libc/config/darwin/aarch64/entrypoints.txt
@@ -231,6 +231,9 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.ffma
libc.src.math.ffmal
libc.src.math.floor
+ libc.src.math.ldexpf128
+ libc.src.math.scalblnf128
+ libc.src.math.scalbnf128
libc.src.math.floorf
libc.src.math.floorf128
libc.src.math.floorl
@@ -599,7 +602,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
libc.src.math.fsubf128
libc.src.math.getpayloadf128
libc.src.math.ilogbf128
- libc.src.math.ldexpf128
libc.src.math.llogbf128
libc.src.math.logbf128
libc.src.math.modff128
@@ -609,8 +611,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
libc.src.math.nextupf128
libc.src.math.remainderf128
libc.src.math.remquof128
- libc.src.math.scalblnf128
- libc.src.math.scalbnf128
libc.src.math.setpayloadf128
libc.src.math.setpayloadsigf128
libc.src.math.totalorderf128
diff --git a/libc/config/freebsd/x86_64/entrypoints.txt b/libc/config/freebsd/x86_64/entrypoints.txt
index 2bb022667dd09..f2320521e4ab4 100644
--- a/libc/config/freebsd/x86_64/entrypoints.txt
+++ b/libc/config/freebsd/x86_64/entrypoints.txt
@@ -166,6 +166,9 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.ffma
libc.src.math.ffmal
libc.src.math.floor
+ libc.src.math.ldexpf128
+ libc.src.math.scalblnf128
+ libc.src.math.scalbnf128
libc.src.math.floorf
libc.src.math.floorf128
libc.src.math.floorl
@@ -539,7 +542,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
libc.src.math.fsubf128
libc.src.math.getpayloadf128
libc.src.math.ilogbf128
- libc.src.math.ldexpf128
libc.src.math.llogbf128
libc.src.math.logbf128
libc.src.math.modff128
@@ -549,8 +551,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
libc.src.math.nextupf128
libc.src.math.remainderf128
libc.src.math.remquof128
- libc.src.math.scalblnf128
- libc.src.math.scalbnf128
libc.src.math.setpayloadf128
libc.src.math.setpayloadsigf128
libc.src.math.totalorderf128
diff --git a/libc/config/linux/aarch64/entrypoints.txt b/libc/config/linux/aarch64/entrypoints.txt
index 869a8c35b91f7..a4673b2033136 100644
--- a/libc/config/linux/aarch64/entrypoints.txt
+++ b/libc/config/linux/aarch64/entrypoints.txt
@@ -579,6 +579,9 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.fdimf
libc.src.math.fdiml
libc.src.math.floor
+ libc.src.math.ldexpf128
+ libc.src.math.scalblnf128
+ libc.src.math.scalbnf128
libc.src.math.floorf
libc.src.math.floorf128
libc.src.math.floorl
@@ -940,7 +943,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
libc.src.math.fsubf128
libc.src.math.getpayloadf128
libc.src.math.ilogbf128
- libc.src.math.ldexpf128
libc.src.math.llogbf128
libc.src.math.logbf128
libc.src.math.modff128
@@ -950,8 +952,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
libc.src.math.nextupf128
libc.src.math.remainderf128
libc.src.math.remquof128
- libc.src.math.scalblnf128
- libc.src.math.scalbnf128
libc.src.math.setpayloadf128
libc.src.math.setpayloadsigf128
libc.src.math.totalorderf128
diff --git a/libc/config/linux/riscv/entrypoints.txt b/libc/config/linux/riscv/entrypoints.txt
index e7846fbf40d91..e1f84d0ec7482 100644
--- a/libc/config/linux/riscv/entrypoints.txt
+++ b/libc/config/linux/riscv/entrypoints.txt
@@ -648,6 +648,9 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.ffma
libc.src.math.ffmal
libc.src.math.floor
+ libc.src.math.ldexpf128
+ libc.src.math.scalblnf128
+ libc.src.math.scalbnf128
libc.src.math.floorf
libc.src.math.floorf128
libc.src.math.floorl
@@ -1026,7 +1029,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
libc.src.math.fsubf128
libc.src.math.getpayloadf128
libc.src.math.ilogbf128
- libc.src.math.ldexpf128
libc.src.math.llogbf128
libc.src.math.logbf128
libc.src.math.modff128
@@ -1036,8 +1038,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
libc.src.math.nextupf128
libc.src.math.remainderf128
libc.src.math.remquof128
- libc.src.math.scalblnf128
- libc.src.math.scalbnf128
libc.src.math.setpayloadf128
libc.src.math.setpayloadsigf128
libc.src.math.totalorderf128
diff --git a/libc/config/linux/x86_64/entrypoints.txt b/libc/config/linux/x86_64/entrypoints.txt
index d087d955bca16..c162a7abdc609 100644
--- a/libc/config/linux/x86_64/entrypoints.txt
+++ b/libc/config/linux/x86_64/entrypoints.txt
@@ -657,6 +657,9 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.ffma
libc.src.math.ffmal
libc.src.math.floor
+ libc.src.math.ldexpf128
+ libc.src.math.scalblnf128
+ libc.src.math.scalbnf128
libc.src.math.floorf
libc.src.math.floorf128
libc.src.math.floorl
@@ -1035,7 +1038,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
libc.src.math.fsubf128
libc.src.math.getpayloadf128
libc.src.math.ilogbf128
- libc.src.math.ldexpf128
libc.src.math.llogbf128
libc.src.math.logbf128
libc.src.math.modff128
@@ -1045,8 +1047,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
libc.src.math.nextupf128
libc.src.math.remainderf128
libc.src.math.remquof128
- libc.src.math.scalblnf128
- libc.src.math.scalbnf128
libc.src.math.setpayloadf128
libc.src.math.setpayloadsigf128
libc.src.math.totalorderf128
diff --git a/libc/shared/math/ldexpf128.h b/libc/shared/math/ldexpf128.h
index d221d71665516..91bd7bf3c321f 100644
--- a/libc/shared/math/ldexpf128.h
+++ b/libc/shared/math/ldexpf128.h
@@ -9,10 +9,6 @@
#ifndef LLVM_LIBC_SHARED_MATH_LDEXPF128_H
#define LLVM_LIBC_SHARED_MATH_LDEXPF128_H
-#include "include/llvm-libc-types/float128.h"
-
-#ifdef LIBC_TYPES_HAS_NATIVE_FLOAT128
-
#include "shared/libc_common.h"
#include "src/__support/math/ldexpf128.h"
@@ -24,6 +20,4 @@ using math::ldexpf128;
} // namespace shared
} // namespace LIBC_NAMESPACE_DECL
-#endif // LIBC_TYPES_HAS_NATIVE_FLOAT128
-
#endif // LLVM_LIBC_SHARED_MATH_LDEXPF128_H
diff --git a/libc/shared/math/scalblnf128.h b/libc/shared/math/scalblnf128.h
index dfb15bed117cf..3953ea59401eb 100644
--- a/libc/shared/math/scalblnf128.h
+++ b/libc/shared/math/scalblnf128.h
@@ -1,4 +1,4 @@
-//===-- Shared scalblnf128 function -----------------------------*- C++ -*-===//
+//===-- Shared scalblnf128 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.
@@ -9,10 +9,6 @@
#ifndef LLVM_LIBC_SHARED_MATH_SCALBLNF128_H
#define LLVM_LIBC_SHARED_MATH_SCALBLNF128_H
-#include "include/llvm-libc-types/float128.h"
-
-#ifdef LIBC_TYPES_HAS_NATIVE_FLOAT128
-
#include "shared/libc_common.h"
#include "src/__support/math/scalblnf128.h"
@@ -24,6 +20,4 @@ using math::scalblnf128;
} // namespace shared
} // namespace LIBC_NAMESPACE_DECL
-#endif // LIBC_TYPES_HAS_NATIVE_FLOAT128
-
#endif // LLVM_LIBC_SHARED_MATH_SCALBLNF128_H
diff --git a/libc/shared/math/scalbnf128.h b/libc/shared/math/scalbnf128.h
index 74c8defc0e6d3..a870b276a6dac 100644
--- a/libc/shared/math/scalbnf128.h
+++ b/libc/shared/math/scalbnf128.h
@@ -1,4 +1,4 @@
-//===-- Shared scalbnf128 function ------------------------------*- C++ -*-===//
+//===-- Shared scalbnf128 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.
@@ -9,10 +9,6 @@
#ifndef LLVM_LIBC_SHARED_MATH_SCALBNF128_H
#define LLVM_LIBC_SHARED_MATH_SCALBNF128_H
-#include "include/llvm-libc-types/float128.h"
-
-#ifdef LIBC_TYPES_HAS_NATIVE_FLOAT128
-
#include "shared/libc_common.h"
#include "src/__support/math/scalbnf128.h"
@@ -24,6 +20,4 @@ using math::scalbnf128;
} // namespace shared
} // namespace LIBC_NAMESPACE_DECL
-#endif // LIBC_TYPES_HAS_NATIVE_FLOAT128
-
#endif // LLVM_LIBC_SHARED_MATH_SCALBNF128_H
diff --git a/libc/src/__support/math/CMakeLists.txt b/libc/src/__support/math/CMakeLists.txt
index 272e9425a4e1e..809d90fe3df69 100644
--- a/libc/src/__support/math/CMakeLists.txt
+++ b/libc/src/__support/math/CMakeLists.txt
@@ -2621,7 +2621,7 @@ add_header_library(
scalblnf128.h
DEPENDS
libc.hdr.float_macros
- libc.include.llvm-libc-types.float128
+ libc.src.__support.FPUtil.float128
libc.src.__support.FPUtil.manipulation_functions
libc.src.__support.macros.config
)
@@ -2684,7 +2684,7 @@ add_header_library(
scalbnf128.h
DEPENDS
libc.hdr.float_macros
- libc.include.llvm-libc-types.float128
+ libc.src.__support.FPUtil.float128
libc.src.__support.FPUtil.manipulation_functions
libc.src.__support.macros.config
)
@@ -4039,9 +4039,9 @@ add_header_library(
HDRS
ldexpf128.h
DEPENDS
- libc.src.__support.macros.properties.types
+ libc.src.__support.FPUtil.float128
libc.src.__support.FPUtil.manipulation_functions
- libc.include.llvm-libc-types.float128
+ libc.src.__support.macros.config
)
add_header_library(
diff --git a/libc/src/__support/math/ldexpf128.h b/libc/src/__support/math/ldexpf128.h
index 74e4c354ff8fe..e543d2870f2f7 100644
--- a/libc/src/__support/math/ldexpf128.h
+++ b/libc/src/__support/math/ldexpf128.h
@@ -1,4 +1,4 @@
-//===-- Implementation header for ldexpf ------------------------*- C++ -*-===//
+//===-- Implementation header for ldexpf128 ---------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -9,26 +9,20 @@
#ifndef LLVM_LIBC_SRC___SUPPORT_MATH_LDEXPF128_H
#define LLVM_LIBC_SRC___SUPPORT_MATH_LDEXPF128_H
-#include "include/llvm-libc-types/float128.h"
-
-#ifdef LIBC_TYPES_HAS_NATIVE_FLOAT128
-
#include "src/__support/FPUtil/ManipulationFunctions.h"
-#include "src/__support/common.h"
+#include "src/__support/FPUtil/float128.h"
#include "src/__support/macros/config.h"
namespace LIBC_NAMESPACE_DECL {
-
namespace math {
-LIBC_INLINE constexpr float128 ldexpf128(float128 x, int exp) {
+using LIBC_NAMESPACE::fputil::Float128;
+
+LIBC_INLINE constexpr Float128 ldexpf128(Float128 x, int exp) {
return fputil::ldexp(x, exp);
}
} // namespace math
-
} // namespace LIBC_NAMESPACE_DECL
-#endif // LIBC_TYPES_HAS_NATIVE_FLOAT128
-
#endif // LLVM_LIBC_SRC___SUPPORT_MATH_LDEXPF128_H
diff --git a/libc/src/__support/math/scalblnf128.h b/libc/src/__support/math/scalblnf128.h
index 6bd6dd92b7eb1..d0947e1e168b1 100644
--- a/libc/src/__support/math/scalblnf128.h
+++ b/libc/src/__support/math/scalblnf128.h
@@ -9,12 +9,9 @@
#ifndef LLVM_LIBC_SRC___SUPPORT_MATH_SCALBLNF128_H
#define LLVM_LIBC_SRC___SUPPORT_MATH_SCALBLNF128_H
-#include "include/llvm-libc-types/float128.h"
-
-#ifdef LIBC_TYPES_HAS_NATIVE_FLOAT128
-
#include "hdr/float_macros.h"
#include "src/__support/FPUtil/ManipulationFunctions.h"
+#include "src/__support/FPUtil/float128.h"
#include "src/__support/macros/config.h"
#if FLT_RADIX != 2
@@ -24,13 +21,13 @@
namespace LIBC_NAMESPACE_DECL {
namespace math {
-LIBC_INLINE constexpr float128 scalblnf128(float128 x, long n) {
+using LIBC_NAMESPACE::fputil::Float128;
+
+LIBC_INLINE constexpr Float128 scalblnf128(Float128 x, long n) {
return fputil::ldexp(x, n);
}
} // namespace math
} // namespace LIBC_NAMESPACE_DECL
-#endif // LIBC_TYPES_HAS_NATIVE_FLOAT128
-
#endif // LLVM_LIBC_SRC___SUPPORT_MATH_SCALBLNF128_H
diff --git a/libc/src/__support/math/scalbnf128.h b/libc/src/__support/math/scalbnf128.h
index bb9b3ecfa4024..98aadb1f6165b 100644
--- a/libc/src/__support/math/scalbnf128.h
+++ b/libc/src/__support/math/scalbnf128.h
@@ -9,12 +9,9 @@
#ifndef LLVM_LIBC_SRC___SUPPORT_MATH_SCALBNF128_H
#define LLVM_LIBC_SRC___SUPPORT_MATH_SCALBNF128_H
-#include "include/llvm-libc-types/float128.h"
-
-#ifdef LIBC_TYPES_HAS_NATIVE_FLOAT128
-
#include "hdr/float_macros.h"
#include "src/__support/FPUtil/ManipulationFunctions.h"
+#include "src/__support/FPUtil/float128.h"
#include "src/__support/macros/config.h"
#if FLT_RADIX != 2
@@ -24,13 +21,13 @@
namespace LIBC_NAMESPACE_DECL {
namespace math {
-LIBC_INLINE constexpr float128 scalbnf128(float128 x, int n) {
+using LIBC_NAMESPACE::fputil::Float128;
+
+LIBC_INLINE constexpr Float128 scalbnf128(Float128 x, int n) {
return fputil::ldexp(x, n);
}
} // namespace math
} // namespace LIBC_NAMESPACE_DECL
-#endif // LIBC_TYPES_HAS_NATIVE_FLOAT128
-
#endif // LLVM_LIBC_SRC___SUPPORT_MATH_SCALBNF128_H
diff --git a/libc/src/math/generic/CMakeLists.txt b/libc/src/math/generic/CMakeLists.txt
index 71f610d9f8281..274d679bb8593 100644
--- a/libc/src/math/generic/CMakeLists.txt
+++ b/libc/src/math/generic/CMakeLists.txt
@@ -1733,6 +1733,7 @@ add_entrypoint_object(
HDRS
../ldexpf128.h
DEPENDS
+ libc.src.__support.CPP.bit
libc.src.__support.math.ldexpf128
)
@@ -4118,6 +4119,7 @@ add_entrypoint_object(
HDRS
../scalblnf128.h
DEPENDS
+ libc.src.__support.CPP.bit
libc.src.__support.math.scalblnf128
)
@@ -4178,6 +4180,7 @@ add_entrypoint_object(
HDRS
../scalbnf128.h
DEPENDS
+ libc.src.__support.CPP.bit
libc.src.__support.math.scalbnf128
)
diff --git a/libc/src/math/generic/ldexpf128.cpp b/libc/src/math/generic/ldexpf128.cpp
index 40afa5b285bcd..13c64041b7eda 100644
--- a/libc/src/math/generic/ldexpf128.cpp
+++ b/libc/src/math/generic/ldexpf128.cpp
@@ -7,13 +7,15 @@
//===----------------------------------------------------------------------===//
#include "src/math/ldexpf128.h"
-
+#include "src/__support/CPP/bit.h"
#include "src/__support/math/ldexpf128.h"
namespace LIBC_NAMESPACE_DECL {
+using LIBC_NAMESPACE::fputil::Float128;
+
LLVM_LIBC_FUNCTION(float128, ldexpf128, (float128 x, int exp)) {
- return math::ldexpf128(x, exp);
+ return cpp::bit_cast<float128>(math::ldexpf128(cpp::bit_cast<Float128>(x), exp));
}
} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/scalblnf128.cpp b/libc/src/math/generic/scalblnf128.cpp
index 151b75a913dac..31428084a5951 100644
--- a/libc/src/math/generic/scalblnf128.cpp
+++ b/libc/src/math/generic/scalblnf128.cpp
@@ -7,12 +7,15 @@
//===----------------------------------------------------------------------===//
#include "src/math/scalblnf128.h"
+#include "src/__support/CPP/bit.h"
#include "src/__support/math/scalblnf128.h"
namespace LIBC_NAMESPACE_DECL {
+using LIBC_NAMESPACE::fputil::Float128;
+
LLVM_LIBC_FUNCTION(float128, scalblnf128, (float128 x, long n)) {
- return math::scalblnf128(x, n);
+ return cpp::bit_cast<float128>(math::scalblnf128(cpp::bit_cast<Float128>(x), n));
}
} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/scalbnf128.cpp b/libc/src/math/generic/scalbnf128.cpp
index f2655a3782f33..0923372dc6c53 100644
--- a/libc/src/math/generic/scalbnf128.cpp
+++ b/libc/src/math/generic/scalbnf128.cpp
@@ -7,12 +7,15 @@
//===----------------------------------------------------------------------===//
#include "src/math/scalbnf128.h"
+#include "src/__support/CPP/bit.h"
#include "src/__support/math/scalbnf128.h"
namespace LIBC_NAMESPACE_DECL {
+using LIBC_NAMESPACE::fputil::Float128;
+
LLVM_LIBC_FUNCTION(float128, scalbnf128, (float128 x, int n)) {
- return math::scalbnf128(x, n);
+ return cpp::bit_cast<float128>(math::scalbnf128(cpp::bit_cast<Float128>(x), n));
}
} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/ldexpf128.h b/libc/src/math/ldexpf128.h
index 74c3ef612166e..64e1e07ed80b3 100644
--- a/libc/src/math/ldexpf128.h
+++ b/libc/src/math/ldexpf128.h
@@ -9,11 +9,16 @@
#ifndef LLVM_LIBC_SRC_MATH_LDEXPF128_H
#define LLVM_LIBC_SRC_MATH_LDEXPF128_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 ldexpf128(float128 x, int exp);
} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/scalblnf128.h b/libc/src/math/scalblnf128.h
index b9b7a862f66f6..35ba8ae5f0095 100644
--- a/libc/src/math/scalblnf128.h
+++ b/libc/src/math/scalblnf128.h
@@ -1,4 +1,4 @@
-//===-- Implementation header for scalblnf128 -------------------*- C++ -*-===//
+//===-- Implementation header for scalblnf128 ---------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
@@ -9,11 +9,16 @@
#ifndef LLVM_LIBC_SRC_MATH_SCALBLNF128_H
#define LLVM_LIBC_SRC_MATH_SCALBLNF128_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...
[truncated]
``````````
</details>
https://github.com/llvm/llvm-project/pull/220295
More information about the libc-commits
mailing list