[libc-commits] [libc] [llvm] [libc] Make ldexpf128/scalbnf128/scalblnf128 use emulated Float128 (PR #220295)
Parth Patel via libc-commits
libc-commits at lists.llvm.org
Tue Sep 1 11:46:46 PDT 2026
https://github.com/rigalis updated https://github.com/llvm/llvm-project/pull/220295
>From 647d492005412d64a34f71452208a76ab9020649 Mon Sep 17 00:00:00 2001
From: rigalis <patelpparth15 at gmail.com>
Date: Tue, 1 Sep 2026 21:12:30 +0530
Subject: [PATCH 1/5] ldexpf128
---
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/freebsd/x86_64/entrypoints.txt | 2 +-
libc/config/linux/aarch64/entrypoints.txt | 2 +-
libc/config/linux/riscv/entrypoints.txt | 2 +-
libc/config/linux/x86_64/entrypoints.txt | 2 +-
libc/shared/math/ldexpf128.h | 6 ------
libc/src/__support/math/CMakeLists.txt | 4 ++--
libc/src/__support/math/ldexpf128.h | 16 +++++-----------
libc/src/math/generic/CMakeLists.txt | 1 +
libc/src/math/generic/ldexpf128.cpp | 6 ++++--
libc/src/math/ldexpf128.h | 5 +++++
libc/test/shared/shared_math_constexpr_test.cpp | 2 ++
libc/test/shared/shared_math_test.cpp | 6 ++----
16 files changed, 29 insertions(+), 33 deletions(-)
diff --git a/libc/config/baremetal/aarch64/entrypoints.txt b/libc/config/baremetal/aarch64/entrypoints.txt
index 9a296693e22eb..b0a28afad3f7c 100644
--- a/libc/config/baremetal/aarch64/entrypoints.txt
+++ b/libc/config/baremetal/aarch64/entrypoints.txt
@@ -412,6 +412,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.ffma
libc.src.math.ffmal
libc.src.math.floor
+ libc.src.math.ldexpf128
libc.src.math.floorf
libc.src.math.floorf128
libc.src.math.floorl
@@ -779,7 +780,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
diff --git a/libc/config/baremetal/arm/entrypoints.txt b/libc/config/baremetal/arm/entrypoints.txt
index 7ac1a9ce0d35f..1a0a155c16e44 100644
--- a/libc/config/baremetal/arm/entrypoints.txt
+++ b/libc/config/baremetal/arm/entrypoints.txt
@@ -424,6 +424,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.ffma
libc.src.math.ffmal
libc.src.math.floor
+ libc.src.math.ldexpf128
libc.src.math.floorf
libc.src.math.floorf128
libc.src.math.floorl
@@ -790,7 +791,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
diff --git a/libc/config/baremetal/riscv/entrypoints.txt b/libc/config/baremetal/riscv/entrypoints.txt
index 9dbaf71d285ee..fb2d27d98695a 100644
--- a/libc/config/baremetal/riscv/entrypoints.txt
+++ b/libc/config/baremetal/riscv/entrypoints.txt
@@ -420,6 +420,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.ffma
libc.src.math.ffmal
libc.src.math.floor
+ libc.src.math.ldexpf128
libc.src.math.floorf
libc.src.math.floorf128
libc.src.math.floorl
@@ -787,7 +788,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
diff --git a/libc/config/darwin/aarch64/entrypoints.txt b/libc/config/darwin/aarch64/entrypoints.txt
index ba397e2958cae..26836cffd8a58 100644
--- a/libc/config/darwin/aarch64/entrypoints.txt
+++ b/libc/config/darwin/aarch64/entrypoints.txt
@@ -231,6 +231,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.ffma
libc.src.math.ffmal
libc.src.math.floor
+ libc.src.math.ldexpf128
libc.src.math.floorf
libc.src.math.floorf128
libc.src.math.floorl
@@ -599,7 +600,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
diff --git a/libc/config/freebsd/x86_64/entrypoints.txt b/libc/config/freebsd/x86_64/entrypoints.txt
index 2bb022667dd09..f9385e9297a93 100644
--- a/libc/config/freebsd/x86_64/entrypoints.txt
+++ b/libc/config/freebsd/x86_64/entrypoints.txt
@@ -166,6 +166,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.ffma
libc.src.math.ffmal
libc.src.math.floor
+ libc.src.math.ldexpf128
libc.src.math.floorf
libc.src.math.floorf128
libc.src.math.floorl
@@ -539,7 +540,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
diff --git a/libc/config/linux/aarch64/entrypoints.txt b/libc/config/linux/aarch64/entrypoints.txt
index 9754db38d1d8a..096fa83f66495 100644
--- a/libc/config/linux/aarch64/entrypoints.txt
+++ b/libc/config/linux/aarch64/entrypoints.txt
@@ -584,6 +584,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.fdimf
libc.src.math.fdiml
libc.src.math.floor
+ libc.src.math.ldexpf128
libc.src.math.floorf
libc.src.math.floorf128
libc.src.math.floorl
@@ -945,7 +946,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
diff --git a/libc/config/linux/riscv/entrypoints.txt b/libc/config/linux/riscv/entrypoints.txt
index dfc70de59ce5d..a6147512bf18a 100644
--- a/libc/config/linux/riscv/entrypoints.txt
+++ b/libc/config/linux/riscv/entrypoints.txt
@@ -653,6 +653,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.ffma
libc.src.math.ffmal
libc.src.math.floor
+ libc.src.math.ldexpf128
libc.src.math.floorf
libc.src.math.floorf128
libc.src.math.floorl
@@ -1031,7 +1032,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
diff --git a/libc/config/linux/x86_64/entrypoints.txt b/libc/config/linux/x86_64/entrypoints.txt
index 42f58dcc3da7e..aa1f687a08282 100644
--- a/libc/config/linux/x86_64/entrypoints.txt
+++ b/libc/config/linux/x86_64/entrypoints.txt
@@ -662,6 +662,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.ffma
libc.src.math.ffmal
libc.src.math.floor
+ libc.src.math.ldexpf128
libc.src.math.floorf
libc.src.math.floorf128
libc.src.math.floorl
@@ -1040,7 +1041,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
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/src/__support/math/CMakeLists.txt b/libc/src/__support/math/CMakeLists.txt
index 272e9425a4e1e..d42d095bb457f 100644
--- a/libc/src/__support/math/CMakeLists.txt
+++ b/libc/src/__support/math/CMakeLists.txt
@@ -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/math/generic/CMakeLists.txt b/libc/src/math/generic/CMakeLists.txt
index 71f610d9f8281..2f78f8cca4074 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
)
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/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/test/shared/shared_math_constexpr_test.cpp b/libc/test/shared/shared_math_constexpr_test.cpp
index c04f1a361395a..fcf5de3b2f1db 100644
--- a/libc/test/shared/shared_math_constexpr_test.cpp
+++ b/libc/test/shared/shared_math_constexpr_test.cpp
@@ -403,6 +403,8 @@ static_assert(Float128(0.0) ==
LIBC_NAMESPACE::shared::roundf128(Float128(0.0)));
static_assert(Float128(0.0) ==
LIBC_NAMESPACE::shared::truncf128(Float128(0.0)));
+static_assert(Float128(0.0) ==
+ LIBC_NAMESPACE::shared::ldexpf128(Float128(0.0), 0));
//===----------------------------------------------------------------------===//
// Native Float128 Tests
diff --git a/libc/test/shared/shared_math_test.cpp b/libc/test/shared/shared_math_test.cpp
index 737efdb09d8c5..74e336070ff82 100644
--- a/libc/test/shared/shared_math_test.cpp
+++ b/libc/test/shared/shared_math_test.cpp
@@ -604,6 +604,8 @@ TEST(LlvmLibcSharedMathTest, AllEmuFloat128) {
EXPECT_FP_EQ(Float128(0.0), LIBC_NAMESPACE::shared::roundf128(Float128(0.0)));
EXPECT_FP_EQ(Float128(1.0), LIBC_NAMESPACE::shared::sqrtf128(Float128(1.0)));
EXPECT_FP_EQ(Float128(0.0), LIBC_NAMESPACE::shared::truncf128(Float128(0.0)));
+ EXPECT_FP_EQ(Float128(0.0),
+ LIBC_NAMESPACE::shared::ldexpf128(Float128(0.0), 0));
}
#ifdef LIBC_TYPES_HAS_NATIVE_FLOAT128
@@ -620,10 +622,6 @@ TEST(LlvmLibcSharedMathTest, AllFloat128) {
EXPECT_EQ(exponent, 5);
EXPECT_EQ(3, LIBC_NAMESPACE::shared::ilogbf128(float128(8.0)));
- ASSERT_FP_EQ(float128(8 << 5),
- LIBC_NAMESPACE::shared::ldexpf128(float128(8), 5));
- ASSERT_FP_EQ(float128(-1 * (8 << 5)),
- LIBC_NAMESPACE::shared::ldexpf128(float128(-8), 5));
EXPECT_FP_EQ(float128(0.0), LIBC_NAMESPACE::shared::logbf128(float128(1.0)));
EXPECT_FP_EQ(0.0, LIBC_NAMESPACE::shared::dfmaf128(
float128(0.0), float128(0.0), float128(0.0)));
>From 9da604a9667bbcfee4c0f8a4e24c540d7bcf7687 Mon Sep 17 00:00:00 2001
From: rigalis <patelpparth15 at gmail.com>
Date: Tue, 1 Sep 2026 21:18:27 +0530
Subject: [PATCH 2/5] scalbnf128
---
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/freebsd/x86_64/entrypoints.txt | 2 +-
libc/config/linux/aarch64/entrypoints.txt | 2 +-
libc/config/linux/riscv/entrypoints.txt | 2 +-
libc/config/linux/x86_64/entrypoints.txt | 2 +-
libc/shared/math/scalbnf128.h | 8 +-------
libc/src/__support/math/CMakeLists.txt | 2 +-
libc/src/__support/math/scalbnf128.h | 11 ++++-------
libc/src/math/generic/CMakeLists.txt | 1 +
libc/src/math/generic/scalbnf128.cpp | 5 ++++-
libc/src/math/scalbnf128.h | 7 ++++++-
libc/test/shared/shared_math_constexpr_test.cpp | 5 +++--
libc/test/shared/shared_math_test.cpp | 5 +++--
16 files changed, 31 insertions(+), 29 deletions(-)
diff --git a/libc/config/baremetal/aarch64/entrypoints.txt b/libc/config/baremetal/aarch64/entrypoints.txt
index b0a28afad3f7c..a0597c1c54f08 100644
--- a/libc/config/baremetal/aarch64/entrypoints.txt
+++ b/libc/config/baremetal/aarch64/entrypoints.txt
@@ -413,6 +413,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.ffmal
libc.src.math.floor
libc.src.math.ldexpf128
+ libc.src.math.scalbnf128
libc.src.math.floorf
libc.src.math.floorf128
libc.src.math.floorl
@@ -790,7 +791,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
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 1a0a155c16e44..2cb544b947611 100644
--- a/libc/config/baremetal/arm/entrypoints.txt
+++ b/libc/config/baremetal/arm/entrypoints.txt
@@ -425,6 +425,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.ffmal
libc.src.math.floor
libc.src.math.ldexpf128
+ libc.src.math.scalbnf128
libc.src.math.floorf
libc.src.math.floorf128
libc.src.math.floorl
@@ -801,7 +802,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
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 fb2d27d98695a..af0a31784985d 100644
--- a/libc/config/baremetal/riscv/entrypoints.txt
+++ b/libc/config/baremetal/riscv/entrypoints.txt
@@ -421,6 +421,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.ffmal
libc.src.math.floor
libc.src.math.ldexpf128
+ libc.src.math.scalbnf128
libc.src.math.floorf
libc.src.math.floorf128
libc.src.math.floorl
@@ -798,7 +799,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
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 26836cffd8a58..d5ade421f2a8d 100644
--- a/libc/config/darwin/aarch64/entrypoints.txt
+++ b/libc/config/darwin/aarch64/entrypoints.txt
@@ -232,6 +232,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.ffmal
libc.src.math.floor
libc.src.math.ldexpf128
+ libc.src.math.scalbnf128
libc.src.math.floorf
libc.src.math.floorf128
libc.src.math.floorl
@@ -610,7 +611,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
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 f9385e9297a93..ca25f637addcb 100644
--- a/libc/config/freebsd/x86_64/entrypoints.txt
+++ b/libc/config/freebsd/x86_64/entrypoints.txt
@@ -167,6 +167,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.ffmal
libc.src.math.floor
libc.src.math.ldexpf128
+ libc.src.math.scalbnf128
libc.src.math.floorf
libc.src.math.floorf128
libc.src.math.floorl
@@ -550,7 +551,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
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 096fa83f66495..510df5f6594e1 100644
--- a/libc/config/linux/aarch64/entrypoints.txt
+++ b/libc/config/linux/aarch64/entrypoints.txt
@@ -585,6 +585,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.fdiml
libc.src.math.floor
libc.src.math.ldexpf128
+ libc.src.math.scalbnf128
libc.src.math.floorf
libc.src.math.floorf128
libc.src.math.floorl
@@ -956,7 +957,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
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 a6147512bf18a..44639fa20d8af 100644
--- a/libc/config/linux/riscv/entrypoints.txt
+++ b/libc/config/linux/riscv/entrypoints.txt
@@ -654,6 +654,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.ffmal
libc.src.math.floor
libc.src.math.ldexpf128
+ libc.src.math.scalbnf128
libc.src.math.floorf
libc.src.math.floorf128
libc.src.math.floorl
@@ -1042,7 +1043,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
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 aa1f687a08282..a6384092649e7 100644
--- a/libc/config/linux/x86_64/entrypoints.txt
+++ b/libc/config/linux/x86_64/entrypoints.txt
@@ -663,6 +663,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.ffmal
libc.src.math.floor
libc.src.math.ldexpf128
+ libc.src.math.scalbnf128
libc.src.math.floorf
libc.src.math.floorf128
libc.src.math.floorl
@@ -1051,7 +1052,6 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
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/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 d42d095bb457f..a07cc81dd1839 100644
--- a/libc/src/__support/math/CMakeLists.txt
+++ b/libc/src/__support/math/CMakeLists.txt
@@ -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
)
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 2f78f8cca4074..79a65e07b8e44 100644
--- a/libc/src/math/generic/CMakeLists.txt
+++ b/libc/src/math/generic/CMakeLists.txt
@@ -4179,6 +4179,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/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/scalbnf128.h b/libc/src/math/scalbnf128.h
index b96d954c69e30..35771da381c58 100644
--- a/libc/src/math/scalbnf128.h
+++ b/libc/src/math/scalbnf128.h
@@ -1,4 +1,4 @@
-//===-- Implementation header for scalbnf128 --------------------*- C++ -*-===//
+//===-- Implementation header for scalbnf128 ---------------------*- 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_SCALBNF128_H
#define LLVM_LIBC_SRC_MATH_SCALBNF128_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 scalbnf128(float128 x, int n);
} // 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 fcf5de3b2f1db..6bfb8f5287081 100644
--- a/libc/test/shared/shared_math_constexpr_test.cpp
+++ b/libc/test/shared/shared_math_constexpr_test.cpp
@@ -405,6 +405,8 @@ static_assert(Float128(0.0) ==
LIBC_NAMESPACE::shared::truncf128(Float128(0.0)));
static_assert(Float128(0.0) ==
LIBC_NAMESPACE::shared::ldexpf128(Float128(0.0), 0));
+static_assert(Float128(0.0) ==
+ LIBC_NAMESPACE::shared::scalbnf128(Float128(0.0), 0));
//===----------------------------------------------------------------------===//
// Native Float128 Tests
@@ -494,8 +496,7 @@ static_assert(float128(0.0) == [] {
}());
static_assert(float128(0.0) ==
LIBC_NAMESPACE::shared::scalblnf128(float128(0.0), 0.0));
-static_assert(float128(0.0) ==
- LIBC_NAMESPACE::shared::scalbnf128(float128(0.0), 0.0));
+
static_assert(0 == [] {
float128 setpayload_x = float128(0.0);
return LIBC_NAMESPACE::shared::setpayloadf128(&setpayload_x, float128(0.0));
diff --git a/libc/test/shared/shared_math_test.cpp b/libc/test/shared/shared_math_test.cpp
index 74e336070ff82..9c868309e302b 100644
--- a/libc/test/shared/shared_math_test.cpp
+++ b/libc/test/shared/shared_math_test.cpp
@@ -606,6 +606,8 @@ TEST(LlvmLibcSharedMathTest, AllEmuFloat128) {
EXPECT_FP_EQ(Float128(0.0), LIBC_NAMESPACE::shared::truncf128(Float128(0.0)));
EXPECT_FP_EQ(Float128(0.0),
LIBC_NAMESPACE::shared::ldexpf128(Float128(0.0), 0));
+ EXPECT_FP_EQ(Float128(0.0),
+ LIBC_NAMESPACE::shared::scalbnf128(Float128(0.0), 0));
}
#ifdef LIBC_TYPES_HAS_NATIVE_FLOAT128
@@ -747,8 +749,7 @@ TEST(LlvmLibcSharedMathTest, AllFloat128) {
EXPECT_EQ(1, remquof128_exp);
EXPECT_FP_EQ(float128(0.0),
LIBC_NAMESPACE::shared::scalblnf128(float128(0.0), 0L));
- EXPECT_FP_EQ(float128(0.0),
- LIBC_NAMESPACE::shared::scalbnf128(float128(0.0), 0));
+
EXPECT_FP_EQ(0x0p+0f,
LIBC_NAMESPACE::shared::fsubf128(float128(0.0), float128(0.0)));
EXPECT_FP_EQ(0x0p+0f,
>From 91393caac97745a1733b45f0f64f9365268d4a71 Mon Sep 17 00:00:00 2001
From: rigalis <patelpparth15 at gmail.com>
Date: Tue, 1 Sep 2026 21:23:39 +0530
Subject: [PATCH 3/5] scalblnf128
---
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/freebsd/x86_64/entrypoints.txt | 2 +-
libc/config/linux/aarch64/entrypoints.txt | 2 +-
libc/config/linux/riscv/entrypoints.txt | 2 +-
libc/config/linux/x86_64/entrypoints.txt | 2 +-
libc/shared/math/scalblnf128.h | 8 +-------
libc/src/__support/math/CMakeLists.txt | 2 +-
libc/src/__support/math/scalblnf128.h | 11 ++++-------
libc/src/math/generic/CMakeLists.txt | 1 +
libc/src/math/generic/scalblnf128.cpp | 5 ++++-
libc/src/math/scalblnf128.h | 7 ++++++-
libc/test/shared/shared_math_constexpr_test.cpp | 5 ++---
libc/test/shared/shared_math_test.cpp | 5 +++--
16 files changed, 30 insertions(+), 30 deletions(-)
diff --git a/libc/config/baremetal/aarch64/entrypoints.txt b/libc/config/baremetal/aarch64/entrypoints.txt
index a0597c1c54f08..fad95af15ae81 100644
--- a/libc/config/baremetal/aarch64/entrypoints.txt
+++ b/libc/config/baremetal/aarch64/entrypoints.txt
@@ -413,6 +413,7 @@ set(TARGET_LIBM_ENTRYPOINTS
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
@@ -790,7 +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.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 2cb544b947611..24a39419fedbb 100644
--- a/libc/config/baremetal/arm/entrypoints.txt
+++ b/libc/config/baremetal/arm/entrypoints.txt
@@ -425,6 +425,7 @@ set(TARGET_LIBM_ENTRYPOINTS
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
@@ -801,7 +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.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 af0a31784985d..4b4690f433ebc 100644
--- a/libc/config/baremetal/riscv/entrypoints.txt
+++ b/libc/config/baremetal/riscv/entrypoints.txt
@@ -421,6 +421,7 @@ set(TARGET_LIBM_ENTRYPOINTS
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
@@ -798,7 +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.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 d5ade421f2a8d..801dda0f51b5f 100644
--- a/libc/config/darwin/aarch64/entrypoints.txt
+++ b/libc/config/darwin/aarch64/entrypoints.txt
@@ -232,6 +232,7 @@ set(TARGET_LIBM_ENTRYPOINTS
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
@@ -610,7 +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.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 ca25f637addcb..f2320521e4ab4 100644
--- a/libc/config/freebsd/x86_64/entrypoints.txt
+++ b/libc/config/freebsd/x86_64/entrypoints.txt
@@ -167,6 +167,7 @@ set(TARGET_LIBM_ENTRYPOINTS
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
@@ -550,7 +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.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 510df5f6594e1..41d48b1bfb02c 100644
--- a/libc/config/linux/aarch64/entrypoints.txt
+++ b/libc/config/linux/aarch64/entrypoints.txt
@@ -585,6 +585,7 @@ set(TARGET_LIBM_ENTRYPOINTS
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
@@ -956,7 +957,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.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 44639fa20d8af..3f95d33333f1f 100644
--- a/libc/config/linux/riscv/entrypoints.txt
+++ b/libc/config/linux/riscv/entrypoints.txt
@@ -654,6 +654,7 @@ set(TARGET_LIBM_ENTRYPOINTS
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
@@ -1042,7 +1043,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.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 a6384092649e7..bb61185d634d6 100644
--- a/libc/config/linux/x86_64/entrypoints.txt
+++ b/libc/config/linux/x86_64/entrypoints.txt
@@ -663,6 +663,7 @@ set(TARGET_LIBM_ENTRYPOINTS
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
@@ -1051,7 +1052,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.setpayloadf128
libc.src.math.setpayloadsigf128
libc.src.math.totalorderf128
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/src/__support/math/CMakeLists.txt b/libc/src/__support/math/CMakeLists.txt
index a07cc81dd1839..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
)
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/math/generic/CMakeLists.txt b/libc/src/math/generic/CMakeLists.txt
index 79a65e07b8e44..274d679bb8593 100644
--- a/libc/src/math/generic/CMakeLists.txt
+++ b/libc/src/math/generic/CMakeLists.txt
@@ -4119,6 +4119,7 @@ add_entrypoint_object(
HDRS
../scalblnf128.h
DEPENDS
+ libc.src.__support.CPP.bit
libc.src.__support.math.scalblnf128
)
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/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_HAS_NATIVE_FLOAT128
+using float128 = LIBC_NAMESPACE::fputil::Float128;
+#endif // LIBC_TYPES_HAS_NATIVE_FLOAT128
+
float128 scalblnf128(float128 x, long n);
} // 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 6bfb8f5287081..39bb4406b14e6 100644
--- a/libc/test/shared/shared_math_constexpr_test.cpp
+++ b/libc/test/shared/shared_math_constexpr_test.cpp
@@ -407,6 +407,8 @@ static_assert(Float128(0.0) ==
LIBC_NAMESPACE::shared::ldexpf128(Float128(0.0), 0));
static_assert(Float128(0.0) ==
LIBC_NAMESPACE::shared::scalbnf128(Float128(0.0), 0));
+static_assert(Float128(0.0) ==
+ LIBC_NAMESPACE::shared::scalblnf128(Float128(0.0), 0L));
//===----------------------------------------------------------------------===//
// Native Float128 Tests
@@ -494,9 +496,6 @@ static_assert(float128(0.0) == [] {
int exp{};
return LIBC_NAMESPACE::shared::remquof128(float128(1.0), float128(1.0), &exp);
}());
-static_assert(float128(0.0) ==
- LIBC_NAMESPACE::shared::scalblnf128(float128(0.0), 0.0));
-
static_assert(0 == [] {
float128 setpayload_x = float128(0.0);
return LIBC_NAMESPACE::shared::setpayloadf128(&setpayload_x, float128(0.0));
diff --git a/libc/test/shared/shared_math_test.cpp b/libc/test/shared/shared_math_test.cpp
index 9c868309e302b..05155bc2dff70 100644
--- a/libc/test/shared/shared_math_test.cpp
+++ b/libc/test/shared/shared_math_test.cpp
@@ -608,6 +608,8 @@ TEST(LlvmLibcSharedMathTest, AllEmuFloat128) {
LIBC_NAMESPACE::shared::ldexpf128(Float128(0.0), 0));
EXPECT_FP_EQ(Float128(0.0),
LIBC_NAMESPACE::shared::scalbnf128(Float128(0.0), 0));
+ EXPECT_FP_EQ(Float128(0.0),
+ LIBC_NAMESPACE::shared::scalblnf128(Float128(0.0), 0L));
}
#ifdef LIBC_TYPES_HAS_NATIVE_FLOAT128
@@ -747,8 +749,7 @@ TEST(LlvmLibcSharedMathTest, AllFloat128) {
LIBC_NAMESPACE::shared::remquof128(float128(1.0), float128(1.0),
&remquof128_exp));
EXPECT_EQ(1, remquof128_exp);
- EXPECT_FP_EQ(float128(0.0),
- LIBC_NAMESPACE::shared::scalblnf128(float128(0.0), 0L));
+
EXPECT_FP_EQ(0x0p+0f,
LIBC_NAMESPACE::shared::fsubf128(float128(0.0), float128(0.0)));
>From 1df385ed53cdcc599c113bae7e709acfa9244fb0 Mon Sep 17 00:00:00 2001
From: rigalis <patelpparth15 at gmail.com>
Date: Tue, 1 Sep 2026 22:50:57 +0530
Subject: [PATCH 4/5] bazel
---
utils/bazel/llvm-project-overlay/libc/BUILD.bazel | 14 +++++++++-----
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
index f6ff9867ff130..24a8f6ce3adfb 100644
--- a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
@@ -7115,10 +7115,10 @@ libc_support_library(
name = "__support_math_scalblnf128",
hdrs = ["src/__support/math/scalblnf128.h"],
deps = [
+ ":__support_fputil_float128",
":__support_fputil_manipulation_functions",
":__support_macros_config",
":hdr_float_macros",
- ":llvm_libc_types_float128",
],
)
@@ -7178,10 +7178,10 @@ libc_support_library(
name = "__support_math_scalbnf128",
hdrs = ["src/__support/math/scalbnf128.h"],
deps = [
+ ":__support_fputil_float128",
":__support_fputil_manipulation_functions",
":__support_macros_config",
":hdr_float_macros",
- ":llvm_libc_types_float128",
],
)
@@ -8674,11 +8674,9 @@ libc_support_library(
name = "__support_math_ldexpf128",
hdrs = ["src/__support/math/ldexpf128.h"],
deps = [
- ":__support_common",
+ ":__support_fputil_float128",
":__support_fputil_manipulation_functions",
":__support_macros_config",
- ":__support_macros_properties_types",
- ":llvm_libc_types_float128",
],
)
@@ -12550,6 +12548,8 @@ libc_math_function(
libc_math_function(
name = "ldexpf128",
additional_deps = [
+ ":__support_cpp_bit",
+ ":__support_fputil_float128",
":__support_math_ldexpf128",
],
)
@@ -13479,6 +13479,8 @@ libc_math_function(
libc_math_function(
name = "scalblnf128",
additional_deps = [
+ ":__support_cpp_bit",
+ ":__support_fputil_float128",
":__support_math_scalblnf128",
],
)
@@ -13521,6 +13523,8 @@ libc_math_function(
libc_math_function(
name = "scalbnf128",
additional_deps = [
+ ":__support_cpp_bit",
+ ":__support_fputil_float128",
":__support_math_scalbnf128",
],
)
>From a0574cb82da50447735f420b320d66752e848a75 Mon Sep 17 00:00:00 2001
From: rigalis <patelpparth15 at gmail.com>
Date: Wed, 2 Sep 2026 00:16:18 +0530
Subject: [PATCH 5/5] nits
---
libc/config/baremetal/aarch64/entrypoints.txt | 6 +++---
libc/config/baremetal/arm/entrypoints.txt | 6 +++---
libc/config/baremetal/riscv/entrypoints.txt | 6 +++---
libc/config/darwin/aarch64/entrypoints.txt | 6 +++---
libc/config/freebsd/x86_64/entrypoints.txt | 6 +++---
libc/config/linux/aarch64/entrypoints.txt | 6 +++---
libc/config/linux/riscv/entrypoints.txt | 6 +++---
libc/config/linux/x86_64/entrypoints.txt | 6 +++---
libc/shared/math/scalblnf128.h | 2 +-
libc/shared/math/scalbnf128.h | 2 +-
libc/src/math/generic/ldexpf128.cpp | 3 ++-
libc/src/math/generic/scalblnf128.cpp | 3 ++-
libc/src/math/generic/scalbnf128.cpp | 3 ++-
libc/test/shared/shared_math_test.cpp | 1 -
14 files changed, 32 insertions(+), 30 deletions(-)
diff --git a/libc/config/baremetal/aarch64/entrypoints.txt b/libc/config/baremetal/aarch64/entrypoints.txt
index fad95af15ae81..b0f0dc7310f32 100644
--- a/libc/config/baremetal/aarch64/entrypoints.txt
+++ b/libc/config/baremetal/aarch64/entrypoints.txt
@@ -412,9 +412,6 @@ 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
@@ -493,6 +490,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.issignalingl
libc.src.math.ldexp
libc.src.math.ldexpf
+ libc.src.math.ldexpf128
libc.src.math.ldexpl
libc.src.math.lgammaf
libc.src.math.llogb
@@ -569,9 +567,11 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.roundl
libc.src.math.scalbln
libc.src.math.scalblnf
+ libc.src.math.scalblnf128
libc.src.math.scalblnl
libc.src.math.scalbn
libc.src.math.scalbnf
+ libc.src.math.scalbnf128
libc.src.math.scalbnl
libc.src.math.setpayload
libc.src.math.setpayloadf
diff --git a/libc/config/baremetal/arm/entrypoints.txt b/libc/config/baremetal/arm/entrypoints.txt
index 24a39419fedbb..710fb0444109a 100644
--- a/libc/config/baremetal/arm/entrypoints.txt
+++ b/libc/config/baremetal/arm/entrypoints.txt
@@ -424,9 +424,6 @@ 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
@@ -505,6 +502,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.issignalingl
libc.src.math.ldexp
libc.src.math.ldexpf
+ libc.src.math.ldexpf128
libc.src.math.ldexpl
libc.src.math.lgammaf
libc.src.math.llogb
@@ -581,9 +579,11 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.roundl
libc.src.math.scalbln
libc.src.math.scalblnf
+ libc.src.math.scalblnf128
libc.src.math.scalblnl
libc.src.math.scalbn
libc.src.math.scalbnf
+ libc.src.math.scalbnf128
libc.src.math.scalbnl
libc.src.math.setpayload
libc.src.math.setpayloadf
diff --git a/libc/config/baremetal/riscv/entrypoints.txt b/libc/config/baremetal/riscv/entrypoints.txt
index 4b4690f433ebc..8f57054e756a5 100644
--- a/libc/config/baremetal/riscv/entrypoints.txt
+++ b/libc/config/baremetal/riscv/entrypoints.txt
@@ -420,9 +420,6 @@ 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
@@ -501,6 +498,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.issignalingl
libc.src.math.ldexp
libc.src.math.ldexpf
+ libc.src.math.ldexpf128
libc.src.math.ldexpl
libc.src.math.lgammaf
libc.src.math.llogb
@@ -577,9 +575,11 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.roundl
libc.src.math.scalbln
libc.src.math.scalblnf
+ libc.src.math.scalblnf128
libc.src.math.scalblnl
libc.src.math.scalbn
libc.src.math.scalbnf
+ libc.src.math.scalbnf128
libc.src.math.scalbnl
libc.src.math.setpayload
libc.src.math.setpayloadf
diff --git a/libc/config/darwin/aarch64/entrypoints.txt b/libc/config/darwin/aarch64/entrypoints.txt
index 801dda0f51b5f..8ec8e20e02863 100644
--- a/libc/config/darwin/aarch64/entrypoints.txt
+++ b/libc/config/darwin/aarch64/entrypoints.txt
@@ -231,9 +231,6 @@ 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
@@ -312,6 +309,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.issignalingl
libc.src.math.ldexp
libc.src.math.ldexpf
+ libc.src.math.ldexpf128
libc.src.math.ldexpl
libc.src.math.lgammaf
libc.src.math.llogb
@@ -388,9 +386,11 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.roundl
libc.src.math.scalbln
libc.src.math.scalblnf
+ libc.src.math.scalblnf128
libc.src.math.scalblnl
libc.src.math.scalbn
libc.src.math.scalbnf
+ libc.src.math.scalbnf128
libc.src.math.scalbnl
libc.src.math.setpayload
libc.src.math.setpayloadf
diff --git a/libc/config/freebsd/x86_64/entrypoints.txt b/libc/config/freebsd/x86_64/entrypoints.txt
index f2320521e4ab4..4dfbe5baf64d0 100644
--- a/libc/config/freebsd/x86_64/entrypoints.txt
+++ b/libc/config/freebsd/x86_64/entrypoints.txt
@@ -166,9 +166,6 @@ 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
@@ -225,6 +222,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.issignalingf128
libc.src.math.ldexp
libc.src.math.ldexpf
+ libc.src.math.ldexpf128
libc.src.math.ldexpl
libc.src.math.lgammaf
libc.src.math.llrint
@@ -289,9 +287,11 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.roundl
libc.src.math.scalbln
libc.src.math.scalblnf
+ libc.src.math.scalblnf128
libc.src.math.scalblnl
libc.src.math.scalbn
libc.src.math.scalbnf
+ libc.src.math.scalbnf128
libc.src.math.scalbnl
libc.src.math.sin
libc.src.math.sincosf
diff --git a/libc/config/linux/aarch64/entrypoints.txt b/libc/config/linux/aarch64/entrypoints.txt
index 41d48b1bfb02c..05ae6c24de7f9 100644
--- a/libc/config/linux/aarch64/entrypoints.txt
+++ b/libc/config/linux/aarch64/entrypoints.txt
@@ -584,9 +584,6 @@ 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
@@ -665,6 +662,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.issignalingl
libc.src.math.ldexp
libc.src.math.ldexpf
+ libc.src.math.ldexpf128
libc.src.math.ldexpl
libc.src.math.lgammaf
libc.src.math.llogb
@@ -741,9 +739,11 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.roundl
libc.src.math.scalbln
libc.src.math.scalblnf
+ libc.src.math.scalblnf128
libc.src.math.scalblnl
libc.src.math.scalbn
libc.src.math.scalbnf
+ libc.src.math.scalbnf128
libc.src.math.scalbnl
libc.src.math.setpayload
libc.src.math.setpayloadf
diff --git a/libc/config/linux/riscv/entrypoints.txt b/libc/config/linux/riscv/entrypoints.txt
index 3f95d33333f1f..c16d6dc0baf84 100644
--- a/libc/config/linux/riscv/entrypoints.txt
+++ b/libc/config/linux/riscv/entrypoints.txt
@@ -653,9 +653,6 @@ 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
@@ -734,6 +731,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.issignalingl
libc.src.math.ldexp
libc.src.math.ldexpf
+ libc.src.math.ldexpf128
libc.src.math.ldexpl
libc.src.math.lgammaf
libc.src.math.llogb
@@ -810,9 +808,11 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.roundl
libc.src.math.scalbln
libc.src.math.scalblnf
+ libc.src.math.scalblnf128
libc.src.math.scalblnl
libc.src.math.scalbn
libc.src.math.scalbnf
+ libc.src.math.scalbnf128
libc.src.math.scalbnl
libc.src.math.setpayload
libc.src.math.setpayloadf
diff --git a/libc/config/linux/x86_64/entrypoints.txt b/libc/config/linux/x86_64/entrypoints.txt
index bb61185d634d6..33d0d14487314 100644
--- a/libc/config/linux/x86_64/entrypoints.txt
+++ b/libc/config/linux/x86_64/entrypoints.txt
@@ -662,9 +662,6 @@ 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
@@ -743,6 +740,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.issignalingl
libc.src.math.ldexp
libc.src.math.ldexpf
+ libc.src.math.ldexpf128
libc.src.math.ldexpl
libc.src.math.lgammaf
libc.src.math.llogb
@@ -819,9 +817,11 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.roundl
libc.src.math.scalbln
libc.src.math.scalblnf
+ libc.src.math.scalblnf128
libc.src.math.scalblnl
libc.src.math.scalbn
libc.src.math.scalbnf
+ libc.src.math.scalbnf128
libc.src.math.scalbnl
libc.src.math.setpayload
libc.src.math.setpayloadf
diff --git a/libc/shared/math/scalblnf128.h b/libc/shared/math/scalblnf128.h
index 3953ea59401eb..1b929558a2651 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.
diff --git a/libc/shared/math/scalbnf128.h b/libc/shared/math/scalbnf128.h
index a870b276a6dac..8c96fab5fa151 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.
diff --git a/libc/src/math/generic/ldexpf128.cpp b/libc/src/math/generic/ldexpf128.cpp
index 13c64041b7eda..0766809da28eb 100644
--- a/libc/src/math/generic/ldexpf128.cpp
+++ b/libc/src/math/generic/ldexpf128.cpp
@@ -15,7 +15,8 @@ namespace LIBC_NAMESPACE_DECL {
using LIBC_NAMESPACE::fputil::Float128;
LLVM_LIBC_FUNCTION(float128, ldexpf128, (float128 x, int exp)) {
- return cpp::bit_cast<float128>(math::ldexpf128(cpp::bit_cast<Float128>(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 31428084a5951..8b76757896700 100644
--- a/libc/src/math/generic/scalblnf128.cpp
+++ b/libc/src/math/generic/scalblnf128.cpp
@@ -15,7 +15,8 @@ namespace LIBC_NAMESPACE_DECL {
using LIBC_NAMESPACE::fputil::Float128;
LLVM_LIBC_FUNCTION(float128, scalblnf128, (float128 x, long n)) {
- return cpp::bit_cast<float128>(math::scalblnf128(cpp::bit_cast<Float128>(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 0923372dc6c53..b2554c9c95011 100644
--- a/libc/src/math/generic/scalbnf128.cpp
+++ b/libc/src/math/generic/scalbnf128.cpp
@@ -15,7 +15,8 @@ namespace LIBC_NAMESPACE_DECL {
using LIBC_NAMESPACE::fputil::Float128;
LLVM_LIBC_FUNCTION(float128, scalbnf128, (float128 x, int n)) {
- return cpp::bit_cast<float128>(math::scalbnf128(cpp::bit_cast<Float128>(x), n));
+ return cpp::bit_cast<float128>(
+ math::scalbnf128(cpp::bit_cast<Float128>(x), n));
}
} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/test/shared/shared_math_test.cpp b/libc/test/shared/shared_math_test.cpp
index 05155bc2dff70..c5251a9603299 100644
--- a/libc/test/shared/shared_math_test.cpp
+++ b/libc/test/shared/shared_math_test.cpp
@@ -750,7 +750,6 @@ TEST(LlvmLibcSharedMathTest, AllFloat128) {
&remquof128_exp));
EXPECT_EQ(1, remquof128_exp);
-
EXPECT_FP_EQ(0x0p+0f,
LIBC_NAMESPACE::shared::fsubf128(float128(0.0), float128(0.0)));
EXPECT_FP_EQ(0x0p+0f,
More information about the libc-commits
mailing list