[libc-commits] [libc] [llvm] [libc] Modify Exponent decomposition functions to work with emulated Float128 (PR #221540)

via libc-commits libc-commits at lists.llvm.org
Tue Sep 8 00:16:22 PDT 2026


https://github.com/Hari-Shankar-Karthik updated https://github.com/llvm/llvm-project/pull/221540

>From 0c3d115c2fdd801854b43b36bab98bbc6ff9abfa Mon Sep 17 00:00:00 2001
From: Hari Shankar Karthik <harishankarkarthik.93 at gmail.com>
Date: Sun, 6 Sep 2026 05:37:51 +0000
Subject: [PATCH 01/10] Migrated frexpf128

---
 libc/config/darwin/x86_64/entrypoints.txt             |  1 +
 libc/config/gpu/amdgpu/entrypoints.txt                |  1 +
 libc/config/gpu/nvptx/entrypoints.txt                 |  1 +
 libc/config/linux/arm/entrypoints.txt                 |  1 +
 libc/config/windows/entrypoints.txt                   |  1 +
 libc/shared/math/frexpf128.h                          |  6 ------
 libc/src/__support/math/CMakeLists.txt                |  1 +
 libc/src/__support/math/frexpf128.h                   | 11 ++++-------
 libc/src/math/frexpf128.h                             |  5 +++++
 libc/src/math/generic/CMakeLists.txt                  |  1 +
 libc/src/math/generic/frexpf128.cpp                   |  7 +++++--
 libc/test/shared/shared_math_constexpr_test.cpp       |  4 ++++
 libc/test/shared/shared_math_test.cpp                 |  8 ++++----
 libc/test/src/math/smoke/CMakeLists.txt               |  1 +
 libc/test/src/math/smoke/frexpf128_test.cpp           |  5 +++++
 utils/bazel/llvm-project-overlay/libc/BUILD.bazel     |  4 +++-
 .../libc/test/src/math/smoke/BUILD.bazel              |  3 +++
 17 files changed, 41 insertions(+), 20 deletions(-)

diff --git a/libc/config/darwin/x86_64/entrypoints.txt b/libc/config/darwin/x86_64/entrypoints.txt
index 716ab572f8d3c..b58eaae7f1ef8 100644
--- a/libc/config/darwin/x86_64/entrypoints.txt
+++ b/libc/config/darwin/x86_64/entrypoints.txt
@@ -176,6 +176,7 @@ set(TARGET_LIBM_ENTRYPOINTS
     #libc.src.math.fmodf
     #libc.src.math.frexp
     #libc.src.math.frexpf
+    #libc.src.math.frexpf128
     #libc.src.math.frexpl
     #libc.src.math.fsub
     #libc.src.math.fsubl
diff --git a/libc/config/gpu/amdgpu/entrypoints.txt b/libc/config/gpu/amdgpu/entrypoints.txt
index 5c5e5891da822..5bc0523fee7ba 100644
--- a/libc/config/gpu/amdgpu/entrypoints.txt
+++ b/libc/config/gpu/amdgpu/entrypoints.txt
@@ -415,6 +415,7 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.fmull
     libc.src.math.frexp
     libc.src.math.frexpf
+    libc.src.math.frexpf128
     libc.src.math.frexpl
     libc.src.math.fromfp
     libc.src.math.fromfpf
diff --git a/libc/config/gpu/nvptx/entrypoints.txt b/libc/config/gpu/nvptx/entrypoints.txt
index afae725484a89..39ab3be9a3232 100644
--- a/libc/config/gpu/nvptx/entrypoints.txt
+++ b/libc/config/gpu/nvptx/entrypoints.txt
@@ -411,6 +411,7 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.fmull
     libc.src.math.frexp
     libc.src.math.frexpf
+    libc.src.math.frexpf128
     libc.src.math.frexpl
     # FIXME: Broken.
     # libc.src.math.fromfp
diff --git a/libc/config/linux/arm/entrypoints.txt b/libc/config/linux/arm/entrypoints.txt
index a3f387edc349b..8d9de7e1da75a 100644
--- a/libc/config/linux/arm/entrypoints.txt
+++ b/libc/config/linux/arm/entrypoints.txt
@@ -475,6 +475,7 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.fmul
     libc.src.math.frexp
     libc.src.math.frexpf
+    libc.src.math.frexpf128
     libc.src.math.frexpl
     libc.src.math.fromfp
     libc.src.math.fromfpf
diff --git a/libc/config/windows/entrypoints.txt b/libc/config/windows/entrypoints.txt
index 3a48b49e169b3..d934e6742f3b6 100644
--- a/libc/config/windows/entrypoints.txt
+++ b/libc/config/windows/entrypoints.txt
@@ -253,6 +253,7 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.fmodl
     libc.src.math.frexp
     libc.src.math.frexpf
+    libc.src.math.frexpf128
     libc.src.math.frexpl
     libc.src.math.fsub
     libc.src.math.fsubl
diff --git a/libc/shared/math/frexpf128.h b/libc/shared/math/frexpf128.h
index 13b48635a77ba..4815fa33a874b 100644
--- a/libc/shared/math/frexpf128.h
+++ b/libc/shared/math/frexpf128.h
@@ -9,10 +9,6 @@
 #ifndef LLVM_LIBC_SHARED_MATH_FREXPF128_H
 #define LLVM_LIBC_SHARED_MATH_FREXPF128_H
 
-#include "include/llvm-libc-types/float128.h"
-
-#ifdef LIBC_TYPES_HAS_NATIVE_FLOAT128
-
 #include "shared/libc_common.h"
 #include "src/__support/math/frexpf128.h"
 
@@ -24,6 +20,4 @@ using math::frexpf128;
 } // namespace shared
 } // namespace LIBC_NAMESPACE_DECL
 
-#endif // LIBC_TYPES_HAS_NATIVE_FLOAT128
-
 #endif // LLVM_LIBC_SHARED_MATH_FREXPF128_H
diff --git a/libc/src/__support/math/CMakeLists.txt b/libc/src/__support/math/CMakeLists.txt
index cf9bc11fce824..cbf87e1f608ba 100644
--- a/libc/src/__support/math/CMakeLists.txt
+++ b/libc/src/__support/math/CMakeLists.txt
@@ -3789,6 +3789,7 @@ add_header_library(
     frexpf128.h
   DEPENDS
     libc.src.__support.macros.properties.types
+    libc.src.__support.FPUtil.float128
     libc.src.__support.FPUtil.manipulation_functions
 )
 
diff --git a/libc/src/__support/math/frexpf128.h b/libc/src/__support/math/frexpf128.h
index a16e401889cb3..923eadf999ff6 100644
--- a/libc/src/__support/math/frexpf128.h
+++ b/libc/src/__support/math/frexpf128.h
@@ -9,10 +9,7 @@
 #ifndef LLVM_LIBC_SRC___SUPPORT_MATH_FREXPF128_H
 #define LLVM_LIBC_SRC___SUPPORT_MATH_FREXPF128_H
 
-#include "include/llvm-libc-types/float128.h"
-
-#ifdef LIBC_TYPES_HAS_NATIVE_FLOAT128
-
+#include "src/__support/FPUtil/float128.h"
 #include "src/__support/FPUtil/ManipulationFunctions.h"
 #include "src/__support/common.h"
 #include "src/__support/macros/config.h"
@@ -21,7 +18,9 @@ namespace LIBC_NAMESPACE_DECL {
 
 namespace math {
 
-LIBC_INLINE constexpr float128 frexpf128(float128 x, int *exp) {
+using LIBC_NAMESPACE::fputil::Float128;
+
+LIBC_INLINE constexpr Float128 frexpf128(Float128 x, int *exp) {
   return fputil::frexp(x, *exp);
 }
 
@@ -29,6 +28,4 @@ LIBC_INLINE constexpr float128 frexpf128(float128 x, int *exp) {
 
 } // namespace LIBC_NAMESPACE_DECL
 
-#endif // LIBC_TYPES_HAS_NATIVE_FLOAT128
-
 #endif // LLVM_LIBC_SRC___SUPPORT_MATH_FREXPF128_H
diff --git a/libc/src/math/frexpf128.h b/libc/src/math/frexpf128.h
index e143e6f17ffb3..9ea3efa8481e0 100644
--- a/libc/src/math/frexpf128.h
+++ b/libc/src/math/frexpf128.h
@@ -9,11 +9,16 @@
 #ifndef LLVM_LIBC_SRC_MATH_FREXPF128_H
 #define LLVM_LIBC_SRC_MATH_FREXPF128_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
+
 float128 frexpf128(float128 x, int *exp);
 
 } // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/CMakeLists.txt b/libc/src/math/generic/CMakeLists.txt
index 28b8e954530dd..b40b5cd0f48a9 100644
--- a/libc/src/math/generic/CMakeLists.txt
+++ b/libc/src/math/generic/CMakeLists.txt
@@ -1527,6 +1527,7 @@ add_entrypoint_object(
   HDRS
     ../frexpf128.h
   DEPENDS
+    libc.src.__support.CPP.bit
     libc.src.__support.math.frexpf128
 )
 
diff --git a/libc/src/math/generic/frexpf128.cpp b/libc/src/math/generic/frexpf128.cpp
index 55f7afcf4aea5..e95e31391386a 100644
--- a/libc/src/math/generic/frexpf128.cpp
+++ b/libc/src/math/generic/frexpf128.cpp
@@ -7,13 +7,16 @@
 //===----------------------------------------------------------------------===//
 
 #include "src/math/frexpf128.h"
-
+#include "src/__support/CPP/bit.h"
 #include "src/__support/math/frexpf128.h"
 
 namespace LIBC_NAMESPACE_DECL {
 
+using LIBC_NAMESPACE::fputil::Float128;
+
 LLVM_LIBC_FUNCTION(float128, frexpf128, (float128 x, int *exp)) {
-  return math::frexpf128(x, exp);
+  return cpp::bit_cast<float128>(
+    math::frexpf128(cpp::bit_cast<Float128>(x), 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 862c056411f5c..47d89a6298645 100644
--- a/libc/test/shared/shared_math_constexpr_test.cpp
+++ b/libc/test/shared/shared_math_constexpr_test.cpp
@@ -419,6 +419,10 @@ 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) == [] {
+  int exp{};
+  return LIBC_NAMESPACE::shared::frexpf128(Float128(0.0), &exp);
+}());
 static_assert(1 == LIBC_NAMESPACE::shared::iscanonicalf128(Float128(0.0)));
 static_assert(0 == LIBC_NAMESPACE::shared::isnanf128(Float128(0.0)));
 static_assert(0.0 == LIBC_NAMESPACE::shared::issignalingf128(Float128(0.0)));
diff --git a/libc/test/shared/shared_math_test.cpp b/libc/test/shared/shared_math_test.cpp
index 7b785331f36c6..4d95d827d6b95 100644
--- a/libc/test/shared/shared_math_test.cpp
+++ b/libc/test/shared/shared_math_test.cpp
@@ -610,6 +610,10 @@ TEST(LlvmLibcSharedMathTest, AllEmuFloat128) {
                                   Float128(0.0), Float128(0.0)));
   EXPECT_FP_EQ(Float128(0.0), LIBC_NAMESPACE::shared::fminimum_numf128(
                                   Float128(0.0), Float128(0.0)));
+  int frexpf128_exp = 0;
+  EXPECT_FP_EQ(Float128(0.0), LIBC_NAMESPACE::shared::frexpf128(
+                                  Float128(0.0), &frexpf128_exp));
+  EXPECT_EQ(0, frexpf128_exp);
   EXPECT_EQ(1, LIBC_NAMESPACE::shared::iscanonicalf128(Float128(0.0)));
   EXPECT_EQ(0, LIBC_NAMESPACE::shared::isnanf128(Float128(0.0)));
   EXPECT_EQ(0, LIBC_NAMESPACE::shared::issignalingf128(Float128(0.0)));
@@ -631,14 +635,10 @@ TEST(LlvmLibcSharedMathTest, AllEmuFloat128) {
 
 TEST(LlvmLibcSharedMathTest, AllFloat128) {
   using FPBits = LIBC_NAMESPACE::fputil::FPBits<float128>;
-  int exponent;
 
   EXPECT_FP_EQ(0.0f, LIBC_NAMESPACE::shared::ffmaf128(
                          float128(0.0), float128(0.0), float128(0.0)));
   EXPECT_FP_EQ(1.0f, LIBC_NAMESPACE::shared::fsqrtf128(float128(1.0f)));
-  EXPECT_FP_EQ_ALL_ROUNDING(float128(0.75), LIBC_NAMESPACE::shared::frexpf128(
-                                                float128(24), &exponent));
-  EXPECT_EQ(exponent, 5);
 
   EXPECT_EQ(3, LIBC_NAMESPACE::shared::ilogbf128(float128(8.0)));
   ASSERT_FP_EQ(float128(8 << 5),
diff --git a/libc/test/src/math/smoke/CMakeLists.txt b/libc/test/src/math/smoke/CMakeLists.txt
index a61b854a85fb2..e262ab4dd6661 100644
--- a/libc/test/src/math/smoke/CMakeLists.txt
+++ b/libc/test/src/math/smoke/CMakeLists.txt
@@ -1746,6 +1746,7 @@ add_fp_unittest(
     FrexpTest.h
   DEPENDS
     libc.src.math.frexpf128
+    libc.src.__support.FPUtil.float128
 )
 
 add_fp_unittest(
diff --git a/libc/test/src/math/smoke/frexpf128_test.cpp b/libc/test/src/math/smoke/frexpf128_test.cpp
index a0df32f5fbdd9..4dd21fc127016 100644
--- a/libc/test/src/math/smoke/frexpf128_test.cpp
+++ b/libc/test/src/math/smoke/frexpf128_test.cpp
@@ -8,6 +8,11 @@
 
 #include "FrexpTest.h"
 
+#include "src/__support/FPUtil/float128.h"
 #include "src/math/frexpf128.h"
 
+#ifndef LIBC_TYPES_HAS_NATIVE_FLOAT128
+using float128 = LIBC_NAMESPACE::fputil::Float128;
+#endif // LIBC_TYPES_HAS_NATIVE_FLOAT128
+
 LIST_FREXP_TESTS(float128, LIBC_NAMESPACE::frexpf128);
diff --git a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
index fc1164d88d111..60074d28c12b2 100644
--- a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
@@ -8299,8 +8299,8 @@ libc_support_library(
     deps = [
         ":__support_common",
         ":__support_fputil_manipulation_functions",
+        ":__support_fputil_float128",
         ":__support_macros_config",
-        ":llvm_libc_types_float128",
     ],
 )
 
@@ -12355,6 +12355,8 @@ libc_math_function(
 libc_math_function(
     name = "frexpf128",
     additional_deps = [
+        ":__support_cpp_bit",
+        ":__support_fputil_float128",
         ":__support_math_frexpf128",
     ],
 )
diff --git a/utils/bazel/llvm-project-overlay/libc/test/src/math/smoke/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/test/src/math/smoke/BUILD.bazel
index 1ea19f953e0ad..da03a2830fba3 100644
--- a/utils/bazel/llvm-project-overlay/libc/test/src/math/smoke/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/libc/test/src/math/smoke/BUILD.bazel
@@ -879,6 +879,9 @@ math_test(
 math_test(
     name = "frexpf128",
     hdrs = ["FrexpTest.h"],
+    deps = [
+        "//libc:__support_fputil_float128",
+    ],
 )
 
 math_test(

>From c42669d60b5535256622492992df89c53aeff41e Mon Sep 17 00:00:00 2001
From: Hari Shankar Karthik <harishankarkarthik.93 at gmail.com>
Date: Sun, 6 Sep 2026 06:23:43 +0000
Subject: [PATCH 02/10] Migrated logbf128

---
 libc/shared/math/logbf128.h                         |  6 ------
 libc/src/__support/math/CMakeLists.txt              |  1 +
 libc/src/__support/math/logbf128.h                  | 13 ++++++-------
 libc/src/math/generic/CMakeLists.txt                |  1 +
 libc/src/math/generic/logbf128.cpp                  |  6 +++++-
 libc/src/math/logbf128.h                            |  5 +++++
 libc/test/shared/shared_math_constexpr_test.cpp     |  1 +
 libc/test/shared/shared_math_test.cpp               |  2 +-
 libc/test/src/math/smoke/CMakeLists.txt             |  1 +
 libc/test/src/math/smoke/logbf128_test.cpp          |  5 +++++
 utils/bazel/llvm-project-overlay/libc/BUILD.bazel   |  4 +++-
 .../libc/test/src/math/smoke/BUILD.bazel            |  3 +++
 12 files changed, 32 insertions(+), 16 deletions(-)

diff --git a/libc/shared/math/logbf128.h b/libc/shared/math/logbf128.h
index 95c37fe88b8cd..7549b41c1f821 100644
--- a/libc/shared/math/logbf128.h
+++ b/libc/shared/math/logbf128.h
@@ -9,10 +9,6 @@
 #ifndef LLVM_LIBC_SHARED_MATH_LOGBF128_H
 #define LLVM_LIBC_SHARED_MATH_LOGBF128_H
 
-#include "include/llvm-libc-types/float128.h"
-
-#ifdef LIBC_TYPES_HAS_NATIVE_FLOAT128
-
 #include "shared/libc_common.h"
 #include "src/__support/math/logbf128.h"
 
@@ -24,6 +20,4 @@ using math::logbf128;
 } // namespace shared
 } // namespace LIBC_NAMESPACE_DECL
 
-#endif // LIBC_TYPES_HAS_NATIVE_FLOAT128
-
 #endif // LLVM_LIBC_SHARED_MATH_LOGBF128_H
diff --git a/libc/src/__support/math/CMakeLists.txt b/libc/src/__support/math/CMakeLists.txt
index cbf87e1f608ba..ba98aad11648f 100644
--- a/libc/src/__support/math/CMakeLists.txt
+++ b/libc/src/__support/math/CMakeLists.txt
@@ -5182,6 +5182,7 @@ add_header_library(
   HDRS
     logbf128.h
   DEPENDS
+    libc.src.__support.FPUtil.float128
     libc.src.__support.FPUtil.manipulation_functions
     libc.src.__support.macros.properties.types
 )
diff --git a/libc/src/__support/math/logbf128.h b/libc/src/__support/math/logbf128.h
index f4671c0a94427..eeedfc1f27b92 100644
--- a/libc/src/__support/math/logbf128.h
+++ b/libc/src/__support/math/logbf128.h
@@ -9,10 +9,7 @@
 #ifndef LLVM_LIBC_SRC___SUPPORT_MATH_LOGBF128_H
 #define LLVM_LIBC_SRC___SUPPORT_MATH_LOGBF128_H
 
-#include "include/llvm-libc-types/float128.h"
-
-#ifdef LIBC_TYPES_HAS_NATIVE_FLOAT128
-
+#include "src/__support/FPUtil/float128.h"
 #include "src/__support/FPUtil/ManipulationFunctions.h"
 #include "src/__support/common.h"
 #include "src/__support/macros/config.h"
@@ -21,12 +18,14 @@ namespace LIBC_NAMESPACE_DECL {
 
 namespace math {
 
-LIBC_INLINE constexpr float128 logbf128(float128 x) { return fputil::logb(x); }
+using LIBC_NAMESPACE::fputil::Float128;
+
+LIBC_INLINE constexpr Float128 logbf128(Float128 x) { 
+    return fputil::logb(x); 
+}
 
 } // namespace math
 
 } // namespace LIBC_NAMESPACE_DECL
 
-#endif // LIBC_TYPES_HAS_NATIVE_FLOAT128
-
 #endif // LLVM_LIBC_SRC___SUPPORT_MATH_LOGBF128_H
diff --git a/libc/src/math/generic/CMakeLists.txt b/libc/src/math/generic/CMakeLists.txt
index b40b5cd0f48a9..9cc2cc1606e1a 100644
--- a/libc/src/math/generic/CMakeLists.txt
+++ b/libc/src/math/generic/CMakeLists.txt
@@ -1943,6 +1943,7 @@ add_entrypoint_object(
   HDRS
     ../logbf128.h
   DEPENDS
+    libc.src.__support.CPP.bit
     libc.src.__support.math.logbf128
     libc.src.errno.errno
 )
diff --git a/libc/src/math/generic/logbf128.cpp b/libc/src/math/generic/logbf128.cpp
index e70a04c6aa100..9423001474436 100644
--- a/libc/src/math/generic/logbf128.cpp
+++ b/libc/src/math/generic/logbf128.cpp
@@ -7,12 +7,16 @@
 //===----------------------------------------------------------------------===//
 
 #include "src/math/logbf128.h"
+#include "src/__support/CPP/bit.h"
 #include "src/__support/math/logbf128.h"
 
 namespace LIBC_NAMESPACE_DECL {
 
+using LIBC_NAMESPACE::fputil::Float128;
+
 LLVM_LIBC_FUNCTION(float128, logbf128, (float128 x)) {
-  return math::logbf128(x);
+  return cpp::bit_cast<Float128>(
+      math::logbf128(cpp::bit_cast<Float128>(x)));
 }
 
 } // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/logbf128.h b/libc/src/math/logbf128.h
index 9ce23978707be..366989810b8a2 100644
--- a/libc/src/math/logbf128.h
+++ b/libc/src/math/logbf128.h
@@ -9,11 +9,16 @@
 #ifndef LLVM_LIBC_SRC_MATH_LOGBF128_H
 #define LLVM_LIBC_SRC_MATH_LOGBF128_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 logbf128(float128 x);
 
 } // 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 47d89a6298645..8adedad39e33c 100644
--- a/libc/test/shared/shared_math_constexpr_test.cpp
+++ b/libc/test/shared/shared_math_constexpr_test.cpp
@@ -428,6 +428,7 @@ static_assert(0 == LIBC_NAMESPACE::shared::isnanf128(Float128(0.0)));
 static_assert(0.0 == LIBC_NAMESPACE::shared::issignalingf128(Float128(0.0)));
 static_assert(0LL == LIBC_NAMESPACE::shared::llrintf128(Float128(0.0)));
 static_assert(0LL == LIBC_NAMESPACE::shared::llroundf128(Float128(0.0)));
+static_assert(Float128(0.0) == LIBC_NAMESPACE::shared::logbf128(Float128(1.0)));
 static_assert(0L == LIBC_NAMESPACE::shared::lrintf128(Float128(0.0)));
 static_assert(0L == LIBC_NAMESPACE::shared::lroundf128(Float128(0.0)));
 static_assert(Float128(0.0) ==
diff --git a/libc/test/shared/shared_math_test.cpp b/libc/test/shared/shared_math_test.cpp
index 4d95d827d6b95..a0ab61a23e310 100644
--- a/libc/test/shared/shared_math_test.cpp
+++ b/libc/test/shared/shared_math_test.cpp
@@ -619,6 +619,7 @@ TEST(LlvmLibcSharedMathTest, AllEmuFloat128) {
   EXPECT_EQ(0, LIBC_NAMESPACE::shared::issignalingf128(Float128(0.0)));
   EXPECT_EQ(0LL, LIBC_NAMESPACE::shared::llrintf128(Float128(0.0)));
   EXPECT_EQ(0LL, LIBC_NAMESPACE::shared::llroundf128(Float128(0.0)));
+  EXPECT_FP_EQ(Float128(0.0), LIBC_NAMESPACE::shared::logbf128(Float128(1.0)));
   EXPECT_EQ(0L, LIBC_NAMESPACE::shared::lrintf128(Float128(0.0)));
   EXPECT_EQ(0L, LIBC_NAMESPACE::shared::lroundf128(Float128(0.0)));
   EXPECT_FP_EQ(Float128(0.0),
@@ -645,7 +646,6 @@ TEST(LlvmLibcSharedMathTest, AllFloat128) {
                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)));
   EXPECT_FP_EQ(0.0, LIBC_NAMESPACE::shared::dsqrtf128(float128(0.0)));
diff --git a/libc/test/src/math/smoke/CMakeLists.txt b/libc/test/src/math/smoke/CMakeLists.txt
index e262ab4dd6661..1337a34f6cc3b 100644
--- a/libc/test/src/math/smoke/CMakeLists.txt
+++ b/libc/test/src/math/smoke/CMakeLists.txt
@@ -2487,6 +2487,7 @@ add_fp_unittest(
   DEPENDS
     libc.src.math.logbf128
     libc.src.__support.CPP.algorithm
+    libc.src.__support.FPUtil.float128
     libc.src.__support.FPUtil.manipulation_functions
 )
 
diff --git a/libc/test/src/math/smoke/logbf128_test.cpp b/libc/test/src/math/smoke/logbf128_test.cpp
index 49485f8ee7144..0ccab2b5ef733 100644
--- a/libc/test/src/math/smoke/logbf128_test.cpp
+++ b/libc/test/src/math/smoke/logbf128_test.cpp
@@ -8,6 +8,11 @@
 
 #include "LogbTest.h"
 
+#include "src/__support/FPUtil/float128.h"
 #include "src/math/logbf128.h"
 
+#ifndef LIBC_TYPES_HAS_NATIVE_FLOAT128
+using float128 = LIBC_NAMESPACE::fputil::Float128;
+#endif // LIBC_TYPES_HAS_NATIVE_FLOAT128
+
 LIST_LOGB_TESTS(float128, LIBC_NAMESPACE::logbf128)
diff --git a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
index 60074d28c12b2..5f6097ddf2200 100644
--- a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
@@ -9087,9 +9087,9 @@ libc_support_library(
     hdrs = ["src/__support/math/logbf128.h"],
     deps = [
         ":__support_common",
+        ":__support_fputil_float128",
         ":__support_fputil_manipulation_functions",
         ":__support_macros_config",
-        ":llvm_libc_types_float128",
     ],
 )
 
@@ -12858,6 +12858,8 @@ libc_math_function(
 libc_math_function(
     name = "logbf128",
     additional_deps = [
+        ":__support_cpp_bit",
+        ":__support_fputil_float128",
         ":__support_math_logbf128",
     ],
 )
diff --git a/utils/bazel/llvm-project-overlay/libc/test/src/math/smoke/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/test/src/math/smoke/BUILD.bazel
index da03a2830fba3..baa41fce4f4c1 100644
--- a/utils/bazel/llvm-project-overlay/libc/test/src/math/smoke/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/libc/test/src/math/smoke/BUILD.bazel
@@ -1177,6 +1177,9 @@ math_test(
 math_test(
     name = "logbf128",
     hdrs = ["LogbTest.h"],
+    deps = [
+        "//libc:__support_fputil_float128",
+    ],
 )
 
 math_test(

>From 72cc7a2810a683d8d78d46203cf8b87ef1c28aea Mon Sep 17 00:00:00 2001
From: Hari Shankar Karthik <harishankarkarthik.93 at gmail.com>
Date: Sun, 6 Sep 2026 06:54:54 +0000
Subject: [PATCH 03/10] Migrated ilogbf128 and llogbf128

---
 libc/shared/math/ilogbf128.h                          |  6 ------
 libc/shared/math/llogbf128.h                          |  6 ------
 libc/src/__support/math/CMakeLists.txt                |  4 ++--
 libc/src/__support/math/ilogbf128.h                   | 11 ++++-------
 libc/src/__support/math/llogbf128.h                   | 11 ++++-------
 libc/src/math/generic/CMakeLists.txt                  |  2 ++
 libc/src/math/generic/ilogbf128.cpp                   |  8 +++++++-
 libc/src/math/generic/llogbf128.cpp                   |  8 +++++++-
 libc/src/math/ilogbf128.h                             |  5 +++++
 libc/src/math/llogbf128.h                             |  5 +++++
 libc/test/shared/shared_math_constexpr_test.cpp       |  2 ++
 libc/test/shared/shared_math_test.cpp                 |  5 ++---
 libc/test/src/math/smoke/CMakeLists.txt               |  2 ++
 libc/test/src/math/smoke/ilogbf128_test.cpp           |  5 +++++
 libc/test/src/math/smoke/llogbf128_test.cpp           |  5 +++++
 utils/bazel/llvm-project-overlay/libc/BUILD.bazel     |  8 ++++++--
 .../libc/test/src/math/smoke/BUILD.bazel              |  6 ++++++
 17 files changed, 64 insertions(+), 35 deletions(-)

diff --git a/libc/shared/math/ilogbf128.h b/libc/shared/math/ilogbf128.h
index 072cd1bbb7711..e6a9d32f2464b 100644
--- a/libc/shared/math/ilogbf128.h
+++ b/libc/shared/math/ilogbf128.h
@@ -9,10 +9,6 @@
 #ifndef LLVM_LIBC_SHARED_MATH_ILOGBF128_H
 #define LLVM_LIBC_SHARED_MATH_ILOGBF128_H
 
-#include "include/llvm-libc-types/float128.h"
-
-#ifdef LIBC_TYPES_HAS_NATIVE_FLOAT128
-
 #include "shared/libc_common.h"
 #include "src/__support/math/ilogbf128.h"
 
@@ -24,6 +20,4 @@ using math::ilogbf128;
 } // namespace shared
 } // namespace LIBC_NAMESPACE_DECL
 
-#endif // LIBC_TYPES_HAS_NATIVE_FLOAT128
-
 #endif // LLVM_LIBC_SHARED_MATH_ILOGBF128_H
diff --git a/libc/shared/math/llogbf128.h b/libc/shared/math/llogbf128.h
index f6f945c372f1e..4bf4b29081987 100644
--- a/libc/shared/math/llogbf128.h
+++ b/libc/shared/math/llogbf128.h
@@ -9,10 +9,6 @@
 #ifndef LLVM_LIBC_SHARED_MATH_LLOGBF128_H
 #define LLVM_LIBC_SHARED_MATH_LLOGBF128_H
 
-#include "include/llvm-libc-types/float128.h"
-
-#ifdef LIBC_TYPES_HAS_NATIVE_FLOAT128
-
 #include "shared/libc_common.h"
 #include "src/__support/math/llogbf128.h"
 
@@ -24,6 +20,4 @@ using math::llogbf128;
 } // namespace shared
 } // namespace LIBC_NAMESPACE_DECL
 
-#endif // LIBC_TYPES_HAS_NATIVE_FLOAT128
-
 #endif // LLVM_LIBC_SHARED_MATH_LLOGBF128_H
diff --git a/libc/src/__support/math/CMakeLists.txt b/libc/src/__support/math/CMakeLists.txt
index ba98aad11648f..5ec717eff01ed 100644
--- a/libc/src/__support/math/CMakeLists.txt
+++ b/libc/src/__support/math/CMakeLists.txt
@@ -3975,8 +3975,8 @@ add_header_library(
     ilogbf128.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
 )
 
 add_header_library(
@@ -4054,8 +4054,8 @@ add_header_library(
     llogbf128.h
   DEPENDS
     libc.src.__support.macros.config
+    libc.src.__support.FPUtil.float128
     libc.src.__support.FPUtil.manipulation_functions
-    libc.include.llvm-libc-types.float128
 )
 
 add_header_library(
diff --git a/libc/src/__support/math/ilogbf128.h b/libc/src/__support/math/ilogbf128.h
index 9ea71fc47c7b5..69978373c9fea 100644
--- a/libc/src/__support/math/ilogbf128.h
+++ b/libc/src/__support/math/ilogbf128.h
@@ -9,10 +9,7 @@
 #ifndef LLVM_LIBC_SRC___SUPPORT_MATH_ILOGBF128_H
 #define LLVM_LIBC_SRC___SUPPORT_MATH_ILOGBF128_H
 
-#include "include/llvm-libc-types/float128.h"
-
-#ifdef LIBC_TYPES_HAS_NATIVE_FLOAT128
-
+#include "src/__support/FPUtil/float128.h"
 #include "src/__support/FPUtil/ManipulationFunctions.h"
 #include "src/__support/common.h"
 #include "src/__support/macros/config.h"
@@ -21,7 +18,9 @@ namespace LIBC_NAMESPACE_DECL {
 
 namespace math {
 
-LIBC_INLINE constexpr int ilogbf128(float128 x) {
+using LIBC_NAMESPACE::fputil::Float128;
+
+LIBC_INLINE constexpr int ilogbf128(Float128 x) {
   return fputil::intlogb<int>(x);
 }
 
@@ -29,6 +28,4 @@ LIBC_INLINE constexpr int ilogbf128(float128 x) {
 
 } // namespace LIBC_NAMESPACE_DECL
 
-#endif // LIBC_TYPES_HAS_NATIVE_FLOAT128
-
 #endif // LLVM_LIBC_SRC___SUPPORT_MATH_ILOGBF128_H
diff --git a/libc/src/__support/math/llogbf128.h b/libc/src/__support/math/llogbf128.h
index da925e81d1aa5..c0bf7541744cb 100644
--- a/libc/src/__support/math/llogbf128.h
+++ b/libc/src/__support/math/llogbf128.h
@@ -9,10 +9,7 @@
 #ifndef LLVM_LIBC_SRC___SUPPORT_MATH_LLOGBF128_H
 #define LLVM_LIBC_SRC___SUPPORT_MATH_LLOGBF128_H
 
-#include "include/llvm-libc-types/float128.h"
-
-#ifdef LIBC_TYPES_HAS_NATIVE_FLOAT128
-
+#include "src/__support/FPUtil/float128.h"
 #include "src/__support/FPUtil/ManipulationFunctions.h"
 #include "src/__support/common.h"
 #include "src/__support/macros/config.h"
@@ -21,7 +18,9 @@ namespace LIBC_NAMESPACE_DECL {
 
 namespace math {
 
-LIBC_INLINE constexpr long llogbf128(float128 x) {
+using LIBC_NAMESPACE::fputil::Float128;
+
+LIBC_INLINE constexpr long llogbf128(Float128 x) {
   return fputil::intlogb<long>(x);
 }
 
@@ -29,6 +28,4 @@ LIBC_INLINE constexpr long llogbf128(float128 x) {
 
 } // namespace LIBC_NAMESPACE_DECL
 
-#endif // LIBC_TYPES_HAS_NATIVE_FLOAT128
-
 #endif // LLVM_LIBC_SRC___SUPPORT_MATH_LLOGBF128_H
diff --git a/libc/src/math/generic/CMakeLists.txt b/libc/src/math/generic/CMakeLists.txt
index 9cc2cc1606e1a..5e9d7386d5dc4 100644
--- a/libc/src/math/generic/CMakeLists.txt
+++ b/libc/src/math/generic/CMakeLists.txt
@@ -1589,6 +1589,7 @@ add_entrypoint_object(
   HDRS
     ../ilogbf128.h
   DEPENDS
+    libc.src.__support.CPP.bit
     libc.src.__support.math.ilogbf128
 )
 
@@ -1676,6 +1677,7 @@ add_entrypoint_object(
   HDRS
     ../llogbf128.h
   DEPENDS
+    libc.src.__support.CPP.bit
     libc.src.__support.math.llogbf128
 )
 
diff --git a/libc/src/math/generic/ilogbf128.cpp b/libc/src/math/generic/ilogbf128.cpp
index 2cb6032dfdbb8..ea59ae3ef6df5 100644
--- a/libc/src/math/generic/ilogbf128.cpp
+++ b/libc/src/math/generic/ilogbf128.cpp
@@ -7,10 +7,16 @@
 //===----------------------------------------------------------------------===//
 
 #include "src/math/ilogbf128.h"
+#include "src/__support/CPP/bit.h"
 #include "src/__support/math/ilogbf128.h"
 
 namespace LIBC_NAMESPACE_DECL {
 
-LLVM_LIBC_FUNCTION(int, ilogbf128, (float128 x)) { return math::ilogbf128(x); }
+using LIBC_NAMESPACE::fputil::Float128;
+
+LLVM_LIBC_FUNCTION(int, ilogbf128, (float128 x)) {
+    return math::ilogbf128(
+        cpp::bit_cast<Float128>(x));
+}
 
 } // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/llogbf128.cpp b/libc/src/math/generic/llogbf128.cpp
index 6f8f9c4c853b8..ddd1eaee5a6b4 100644
--- a/libc/src/math/generic/llogbf128.cpp
+++ b/libc/src/math/generic/llogbf128.cpp
@@ -7,10 +7,16 @@
 //===----------------------------------------------------------------------===//
 
 #include "src/math/llogbf128.h"
+#include "src/__support/CPP/bit.h"
 #include "src/__support/math/llogbf128.h"
 
 namespace LIBC_NAMESPACE_DECL {
 
-LLVM_LIBC_FUNCTION(long, llogbf128, (float128 x)) { return math::llogbf128(x); }
+using LIBC_NAMESPACE::fputil::Float128;
+
+LLVM_LIBC_FUNCTION(long, llogbf128, (float128 x)) {
+    return math::llogbf128(
+        cpp::bit_cast<Float128>(x));
+}
 
 } // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/ilogbf128.h b/libc/src/math/ilogbf128.h
index 9ea5e89fdf993..f102dbe097d33 100644
--- a/libc/src/math/ilogbf128.h
+++ b/libc/src/math/ilogbf128.h
@@ -9,11 +9,16 @@
 #ifndef LLVM_LIBC_SRC_MATH_ILOGBF128_H
 #define LLVM_LIBC_SRC_MATH_ILOGBF128_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
+
 int ilogbf128(float128 x);
 
 } // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/llogbf128.h b/libc/src/math/llogbf128.h
index 1ad4932020257..06553f9d12f3b 100644
--- a/libc/src/math/llogbf128.h
+++ b/libc/src/math/llogbf128.h
@@ -9,11 +9,16 @@
 #ifndef LLVM_LIBC_SRC_MATH_LLOGBF128_H
 #define LLVM_LIBC_SRC_MATH_LLOGBF128_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
+
 long llogbf128(float128 x);
 
 } // 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 8adedad39e33c..c41086dcd684b 100644
--- a/libc/test/shared/shared_math_constexpr_test.cpp
+++ b/libc/test/shared/shared_math_constexpr_test.cpp
@@ -423,9 +423,11 @@ static_assert(Float128(0.0) == [] {
   int exp{};
   return LIBC_NAMESPACE::shared::frexpf128(Float128(0.0), &exp);
 }());
+static_assert(0 == LIBC_NAMESPACE::shared::ilogbf128(Float128(1.0)));
 static_assert(1 == LIBC_NAMESPACE::shared::iscanonicalf128(Float128(0.0)));
 static_assert(0 == LIBC_NAMESPACE::shared::isnanf128(Float128(0.0)));
 static_assert(0.0 == LIBC_NAMESPACE::shared::issignalingf128(Float128(0.0)));
+static_assert(0LL == LIBC_NAMESPACE::shared::llogbf128(Float128(1.0)));
 static_assert(0LL == LIBC_NAMESPACE::shared::llrintf128(Float128(0.0)));
 static_assert(0LL == LIBC_NAMESPACE::shared::llroundf128(Float128(0.0)));
 static_assert(Float128(0.0) == LIBC_NAMESPACE::shared::logbf128(Float128(1.0)));
diff --git a/libc/test/shared/shared_math_test.cpp b/libc/test/shared/shared_math_test.cpp
index a0ab61a23e310..68526db367621 100644
--- a/libc/test/shared/shared_math_test.cpp
+++ b/libc/test/shared/shared_math_test.cpp
@@ -614,9 +614,11 @@ TEST(LlvmLibcSharedMathTest, AllEmuFloat128) {
   EXPECT_FP_EQ(Float128(0.0), LIBC_NAMESPACE::shared::frexpf128(
                                   Float128(0.0), &frexpf128_exp));
   EXPECT_EQ(0, frexpf128_exp);
+  EXPECT_EQ(0, LIBC_NAMESPACE::shared::ilogbf128(Float128(1.0)));
   EXPECT_EQ(1, LIBC_NAMESPACE::shared::iscanonicalf128(Float128(0.0)));
   EXPECT_EQ(0, LIBC_NAMESPACE::shared::isnanf128(Float128(0.0)));
   EXPECT_EQ(0, LIBC_NAMESPACE::shared::issignalingf128(Float128(0.0)));
+  EXPECT_EQ(0LL, LIBC_NAMESPACE::shared::llogbf128(Float128(1.0)));
   EXPECT_EQ(0LL, LIBC_NAMESPACE::shared::llrintf128(Float128(0.0)));
   EXPECT_EQ(0LL, LIBC_NAMESPACE::shared::llroundf128(Float128(0.0)));
   EXPECT_FP_EQ(Float128(0.0), LIBC_NAMESPACE::shared::logbf128(Float128(1.0)));
@@ -641,7 +643,6 @@ TEST(LlvmLibcSharedMathTest, AllFloat128) {
                          float128(0.0), float128(0.0), float128(0.0)));
   EXPECT_FP_EQ(1.0f, LIBC_NAMESPACE::shared::fsqrtf128(float128(1.0f)));
 
-  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)),
@@ -650,8 +651,6 @@ TEST(LlvmLibcSharedMathTest, AllFloat128) {
                         float128(0.0), float128(0.0), float128(0.0)));
   EXPECT_FP_EQ(0.0, LIBC_NAMESPACE::shared::dsqrtf128(float128(0.0)));
 
-  EXPECT_EQ(0L, LIBC_NAMESPACE::shared::llogbf128(float128(1.0)));
-
   EXPECT_FP_EQ(bfloat16(5.0), LIBC_NAMESPACE::shared::bf16addf128(
                                   float128(2.0), float128(3.0)));
 
diff --git a/libc/test/src/math/smoke/CMakeLists.txt b/libc/test/src/math/smoke/CMakeLists.txt
index 1337a34f6cc3b..9720223e50ba4 100644
--- a/libc/test/src/math/smoke/CMakeLists.txt
+++ b/libc/test/src/math/smoke/CMakeLists.txt
@@ -2126,6 +2126,7 @@ add_fp_unittest(
   DEPENDS
     libc.src.math.ilogbf128
     libc.src.__support.CPP.algorithm
+    libc.src.__support.FPUtil.float128
     libc.src.__support.FPUtil.fp_bits
     libc.src.__support.FPUtil.manipulation_functions
 )
@@ -2303,6 +2304,7 @@ add_fp_unittest(
   DEPENDS
     libc.src.math.llogbf128
     libc.src.__support.CPP.algorithm
+    libc.src.__support.FPUtil.float128
     libc.src.__support.FPUtil.fp_bits
     libc.src.__support.FPUtil.manipulation_functions
 )
diff --git a/libc/test/src/math/smoke/ilogbf128_test.cpp b/libc/test/src/math/smoke/ilogbf128_test.cpp
index 21ed0dd112b91..4a3a2b5269beb 100644
--- a/libc/test/src/math/smoke/ilogbf128_test.cpp
+++ b/libc/test/src/math/smoke/ilogbf128_test.cpp
@@ -8,6 +8,11 @@
 
 #include "ILogbTest.h"
 
+#include "src/__support/FPUtil/float128.h"
 #include "src/math/ilogbf128.h"
 
+#ifndef LIBC_TYPES_HAS_NATIVE_FLOAT128
+using float128 = LIBC_NAMESPACE::fputil::Float128;
+#endif // LIBC_TYPES_HAS_NATIVE_FLOAT128
+
 LIST_INTLOGB_TESTS(int, float128, LIBC_NAMESPACE::ilogbf128);
diff --git a/libc/test/src/math/smoke/llogbf128_test.cpp b/libc/test/src/math/smoke/llogbf128_test.cpp
index a1d2021d2a378..35b6d5f33b0c5 100644
--- a/libc/test/src/math/smoke/llogbf128_test.cpp
+++ b/libc/test/src/math/smoke/llogbf128_test.cpp
@@ -8,6 +8,11 @@
 
 #include "ILogbTest.h"
 
+#include "src/__support/FPUtil/float128.h"
 #include "src/math/llogbf128.h"
 
+#ifndef LIBC_TYPES_HAS_NATIVE_FLOAT128
+using float128 = LIBC_NAMESPACE::fputil::Float128;
+#endif // LIBC_TYPES_HAS_NATIVE_FLOAT128
+
 LIST_INTLOGB_TESTS(long, float128, LIBC_NAMESPACE::llogbf128);
diff --git a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
index 5f6097ddf2200..6718e752b5941 100644
--- a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
@@ -8309,10 +8309,10 @@ libc_support_library(
     hdrs = ["src/__support/math/ilogbf128.h"],
     deps = [
         ":__support_common",
+        ":__support_fputil_float128",
         ":__support_fputil_manipulation_functions",
         ":__support_macros_config",
         ":__support_macros_properties_types",
-        ":llvm_libc_types_float128",
     ],
 )
 
@@ -8711,9 +8711,9 @@ libc_support_library(
     hdrs = ["src/__support/math/llogbf128.h"],
     deps = [
         ":__support_common",
+        ":__support_fputil_float128",
         ":__support_fputil_manipulation_functions",
         ":__support_macros_config",
-        ":llvm_libc_types_float128",
     ],
 )
 
@@ -12559,6 +12559,8 @@ libc_math_function(
 libc_math_function(
     name = "ilogbf128",
     additional_deps = [
+        ":__support_cpp_bit",
+        ":__support_fputil_float128",
         ":__support_math_ilogbf128",
     ],
 )
@@ -12651,6 +12653,8 @@ libc_math_function(
 libc_math_function(
     name = "llogbf128",
     additional_deps = [
+        ":__support_cpp_bit",
+        ":__support_fputil_float128",
         ":__support_math_llogbf128",
     ],
 )
diff --git a/utils/bazel/llvm-project-overlay/libc/test/src/math/smoke/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/test/src/math/smoke/BUILD.bazel
index baa41fce4f4c1..486c70763dd6d 100644
--- a/utils/bazel/llvm-project-overlay/libc/test/src/math/smoke/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/libc/test/src/math/smoke/BUILD.bazel
@@ -1012,6 +1012,9 @@ math_test(
 math_test(
     name = "ilogbf128",
     hdrs = ["ILogbTest.h"],
+    deps = [
+        "//libc:__support_fputil_float128",
+    ],
 )
 
 math_test(
@@ -1057,6 +1060,9 @@ math_test(
 math_test(
     name = "llogbf128",
     hdrs = ["ILogbTest.h"],
+    deps = [
+        "//libc:__support_fputil_float128",
+    ],
 )
 
 math_test(

>From ede446b3c7d3c33a082815376edec988b4c8139b Mon Sep 17 00:00:00 2001
From: Hari Shankar Karthik <harishankarkarthik.93 at gmail.com>
Date: Sun, 6 Sep 2026 07:22:13 +0000
Subject: [PATCH 04/10] Updated entrypoints.txt to have all f128 functions in
 alphabetical order

---
 libc/config/baremetal/aarch64/entrypoints.txt | 8 ++++----
 libc/config/baremetal/arm/entrypoints.txt     | 8 ++++----
 libc/config/baremetal/riscv/entrypoints.txt   | 8 ++++----
 libc/config/darwin/aarch64/entrypoints.txt    | 8 ++++----
 libc/config/darwin/x86_64/entrypoints.txt     | 2 ++
 libc/config/freebsd/x86_64/entrypoints.txt    | 8 ++++----
 libc/config/gpu/amdgpu/entrypoints.txt        | 3 +++
 libc/config/gpu/nvptx/entrypoints.txt         | 3 +++
 libc/config/linux/aarch64/entrypoints.txt     | 8 ++++----
 libc/config/linux/arm/entrypoints.txt         | 3 +++
 libc/config/linux/riscv/entrypoints.txt       | 8 ++++----
 libc/config/linux/x86_64/entrypoints.txt      | 8 ++++----
 libc/config/windows/entrypoints.txt           | 2 ++
 13 files changed, 45 insertions(+), 32 deletions(-)

diff --git a/libc/config/baremetal/aarch64/entrypoints.txt b/libc/config/baremetal/aarch64/entrypoints.txt
index 757e4729699d1..7a5566ffd0947 100644
--- a/libc/config/baremetal/aarch64/entrypoints.txt
+++ b/libc/config/baremetal/aarch64/entrypoints.txt
@@ -468,6 +468,7 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.fmull
     libc.src.math.frexp
     libc.src.math.frexpf
+    libc.src.math.frexpf128
     libc.src.math.frexpl
     libc.src.math.fromfp
     libc.src.math.fromfpf
@@ -486,6 +487,7 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.hypotf
     libc.src.math.ilogb
     libc.src.math.ilogbf
+    libc.src.math.ilogbf128
     libc.src.math.ilogbl
     libc.src.math.iscanonical
     libc.src.math.iscanonicalf
@@ -505,6 +507,7 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.lgammaf
     libc.src.math.llogb
     libc.src.math.llogbf
+    libc.src.math.llogbf128
     libc.src.math.llogbl
     libc.src.math.llrint
     libc.src.math.llrintf
@@ -523,6 +526,7 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.log2f
     libc.src.math.logb
     libc.src.math.logbf
+    libc.src.math.logbf128
     libc.src.math.logbl
     libc.src.math.logf
     libc.src.math.lrint
@@ -772,16 +776,12 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
     libc.src.math.ffmaf128
     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
     libc.src.math.getpayloadf128
-    libc.src.math.ilogbf128
     libc.src.math.ldexpf128
-    libc.src.math.llogbf128
-    libc.src.math.logbf128
     libc.src.math.modff128
     libc.src.math.nanf128
     libc.src.math.nextafterf128
diff --git a/libc/config/baremetal/arm/entrypoints.txt b/libc/config/baremetal/arm/entrypoints.txt
index 13d4f777650f7..939f9b33ffc1e 100644
--- a/libc/config/baremetal/arm/entrypoints.txt
+++ b/libc/config/baremetal/arm/entrypoints.txt
@@ -480,6 +480,7 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.fmull
     libc.src.math.frexp
     libc.src.math.frexpf
+    libc.src.math.frexpf128
     libc.src.math.frexpl
     libc.src.math.fromfp
     libc.src.math.fromfpf
@@ -498,6 +499,7 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.hypotf
     libc.src.math.ilogb
     libc.src.math.ilogbf
+    libc.src.math.ilogbf128
     libc.src.math.ilogbl
     libc.src.math.iscanonical
     libc.src.math.iscanonicalf
@@ -517,6 +519,7 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.lgammaf
     libc.src.math.llogb
     libc.src.math.llogbf
+    libc.src.math.llogbf128
     libc.src.math.llogbl
     libc.src.math.llrint
     libc.src.math.llrintf
@@ -535,6 +538,7 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.log2f
     libc.src.math.logb
     libc.src.math.logbf
+    libc.src.math.logbf128
     libc.src.math.logbl
     libc.src.math.logf
     libc.src.math.lrint
@@ -783,16 +787,12 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
     libc.src.math.ffmaf128
     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
     libc.src.math.getpayloadf128
-    libc.src.math.ilogbf128
     libc.src.math.ldexpf128
-    libc.src.math.llogbf128
-    libc.src.math.logbf128
     libc.src.math.modff128
     libc.src.math.nanf128
     libc.src.math.nextafterf128
diff --git a/libc/config/baremetal/riscv/entrypoints.txt b/libc/config/baremetal/riscv/entrypoints.txt
index 88613b39086a5..1ce6aaaedd109 100644
--- a/libc/config/baremetal/riscv/entrypoints.txt
+++ b/libc/config/baremetal/riscv/entrypoints.txt
@@ -476,6 +476,7 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.fmull
     libc.src.math.frexp
     libc.src.math.frexpf
+    libc.src.math.frexpf128
     libc.src.math.frexpl
     libc.src.math.fromfp
     libc.src.math.fromfpf
@@ -494,6 +495,7 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.hypotf
     libc.src.math.ilogb
     libc.src.math.ilogbf
+    libc.src.math.ilogbf128
     libc.src.math.ilogbl
     libc.src.math.iscanonical
     libc.src.math.iscanonicalf
@@ -513,6 +515,7 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.lgammaf
     libc.src.math.llogb
     libc.src.math.llogbf
+    libc.src.math.llogbf128
     libc.src.math.llogbl
     libc.src.math.llrint
     libc.src.math.llrintf
@@ -531,6 +534,7 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.log2f
     libc.src.math.logb
     libc.src.math.logbf
+    libc.src.math.logbf128
     libc.src.math.logbl
     libc.src.math.logf
     libc.src.math.lrint
@@ -780,16 +784,12 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
     libc.src.math.ffmaf128
     # 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
     libc.src.math.getpayloadf128
-    libc.src.math.ilogbf128
     libc.src.math.ldexpf128
-    libc.src.math.llogbf128
-    libc.src.math.logbf128
     libc.src.math.modff128
     libc.src.math.nanf128
     libc.src.math.nextafterf128
diff --git a/libc/config/darwin/aarch64/entrypoints.txt b/libc/config/darwin/aarch64/entrypoints.txt
index c6c8357207959..b67b846084a92 100644
--- a/libc/config/darwin/aarch64/entrypoints.txt
+++ b/libc/config/darwin/aarch64/entrypoints.txt
@@ -287,6 +287,7 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.fmull
     libc.src.math.frexp
     libc.src.math.frexpf
+    libc.src.math.frexpf128
     libc.src.math.frexpl
     libc.src.math.fromfp
     libc.src.math.fromfpf
@@ -305,6 +306,7 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.hypotf
     libc.src.math.ilogb
     libc.src.math.ilogbf
+    libc.src.math.ilogbf128
     libc.src.math.ilogbl
     libc.src.math.iscanonical
     libc.src.math.iscanonicalf
@@ -324,6 +326,7 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.lgammaf
     libc.src.math.llogb
     libc.src.math.llogbf
+    libc.src.math.llogbf128
     libc.src.math.llogbl
     libc.src.math.llrint
     libc.src.math.llrintf
@@ -342,6 +345,7 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.log2f
     libc.src.math.logb
     libc.src.math.logbf
+    libc.src.math.logbf128
     libc.src.math.logbl
     libc.src.math.logf
     libc.src.math.lrint
@@ -592,16 +596,12 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
     libc.src.math.ffmaf128
     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
     libc.src.math.getpayloadf128
-    libc.src.math.ilogbf128
     libc.src.math.ldexpf128
-    libc.src.math.llogbf128
-    libc.src.math.logbf128
     libc.src.math.modff128
     libc.src.math.nanf128
     libc.src.math.nextafterf128
diff --git a/libc/config/darwin/x86_64/entrypoints.txt b/libc/config/darwin/x86_64/entrypoints.txt
index b58eaae7f1ef8..802c3c7cfd6ba 100644
--- a/libc/config/darwin/x86_64/entrypoints.txt
+++ b/libc/config/darwin/x86_64/entrypoints.txt
@@ -184,6 +184,7 @@ set(TARGET_LIBM_ENTRYPOINTS
     #libc.src.math.hypotf
     #libc.src.math.ilogb
     #libc.src.math.ilogbf
+    #libc.src.math.ilogbf128b
     #libc.src.math.ilogbl
     #libc.src.math.iscanonicalf128
     #libc.src.math.isnanf128
@@ -213,6 +214,7 @@ set(TARGET_LIBM_ENTRYPOINTS
     #libc.src.math.logf
     #libc.src.math.logb
     #libc.src.math.logbf
+    #libc.src.math.logbf128
     #libc.src.math.logbl
     #libc.src.math.modf
     #libc.src.math.modff
diff --git a/libc/config/freebsd/x86_64/entrypoints.txt b/libc/config/freebsd/x86_64/entrypoints.txt
index 8f6c178301c2f..5b315f0432a5b 100644
--- a/libc/config/freebsd/x86_64/entrypoints.txt
+++ b/libc/config/freebsd/x86_64/entrypoints.txt
@@ -220,6 +220,7 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.fmodl
     libc.src.math.frexp
     libc.src.math.frexpf
+    libc.src.math.frexpf128
     libc.src.math.frexpl
     libc.src.math.fsub
     libc.src.math.fsubl
@@ -227,6 +228,7 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.hypotf
     libc.src.math.ilogb
     libc.src.math.ilogbf
+    libc.src.math.ilogbf128
     libc.src.math.ilogbl
     libc.src.math.iscanonicalf128
     libc.src.math.isnanf128
@@ -253,6 +255,7 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.logf
     libc.src.math.logb
     libc.src.math.logbf
+    libc.src.math.logbf128
     libc.src.math.logbl
     libc.src.math.lrint
     libc.src.math.lrintf
@@ -359,6 +362,7 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
     libc.src.math.issignalingl
     libc.src.math.llogb
     libc.src.math.llogbf
+    libc.src.math.llogbf128
     libc.src.math.llogbl
     libc.src.math.nextdown
     libc.src.math.nextdownf
@@ -532,16 +536,12 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
     libc.src.math.ffmaf128
     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
     libc.src.math.getpayloadf128
-    libc.src.math.ilogbf128
     libc.src.math.ldexpf128
-    libc.src.math.llogbf128
-    libc.src.math.logbf128
     libc.src.math.modff128
     libc.src.math.nanf128
     libc.src.math.nextafterf128
diff --git a/libc/config/gpu/amdgpu/entrypoints.txt b/libc/config/gpu/amdgpu/entrypoints.txt
index 5bc0523fee7ba..37c4dc76a708f 100644
--- a/libc/config/gpu/amdgpu/entrypoints.txt
+++ b/libc/config/gpu/amdgpu/entrypoints.txt
@@ -434,6 +434,7 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.hypotf
     libc.src.math.ilogb
     libc.src.math.ilogbf
+    libc.src.math.ilogbf128
     libc.src.math.ilogbl
     libc.src.math.iscanonicalf128
     libc.src.math.isnan
@@ -449,6 +450,7 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.lgammaf
     libc.src.math.llogb
     libc.src.math.llogbf
+    libc.src.math.llogbf128
     libc.src.math.llogbl
     libc.src.math.llrint
     libc.src.math.llrintf
@@ -467,6 +469,7 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.log2f
     libc.src.math.logb
     libc.src.math.logbf
+    libc.src.math.logbf128
     libc.src.math.logbl
     libc.src.math.logf
     libc.src.math.lrint
diff --git a/libc/config/gpu/nvptx/entrypoints.txt b/libc/config/gpu/nvptx/entrypoints.txt
index 39ab3be9a3232..1b509e8e7de64 100644
--- a/libc/config/gpu/nvptx/entrypoints.txt
+++ b/libc/config/gpu/nvptx/entrypoints.txt
@@ -431,6 +431,7 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.hypotf
     libc.src.math.ilogb
     libc.src.math.ilogbf
+    libc.src.math.ilogbf128
     libc.src.math.ilogbl
     libc.src.math.iscanonicalf128
     libc.src.math.isnan
@@ -446,6 +447,7 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.lgammaf
     libc.src.math.llogb
     libc.src.math.llogbf
+    libc.src.math.llogbf128
     libc.src.math.llogbl
     libc.src.math.llrint
     libc.src.math.llrintf
@@ -464,6 +466,7 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.log2f
     libc.src.math.logb
     libc.src.math.logbf
+    libc.src.math.logbf128
     libc.src.math.logbl
     libc.src.math.logf
     libc.src.math.lrint
diff --git a/libc/config/linux/aarch64/entrypoints.txt b/libc/config/linux/aarch64/entrypoints.txt
index 03053ac04f743..78391d2796f3a 100644
--- a/libc/config/linux/aarch64/entrypoints.txt
+++ b/libc/config/linux/aarch64/entrypoints.txt
@@ -653,6 +653,7 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.fmull
     libc.src.math.frexp
     libc.src.math.frexpf
+    libc.src.math.frexpf128
     libc.src.math.frexpl
     libc.src.math.fromfp
     libc.src.math.fromfpf
@@ -671,6 +672,7 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.hypotf
     libc.src.math.ilogb
     libc.src.math.ilogbf
+    libc.src.math.ilogbf128
     libc.src.math.ilogbl
     libc.src.math.iscanonical
     libc.src.math.iscanonicalf
@@ -690,6 +692,7 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.lgammaf
     libc.src.math.llogb
     libc.src.math.llogbf
+    libc.src.math.llogbf128
     libc.src.math.llogbl
     libc.src.math.llrint
     libc.src.math.llrintf
@@ -708,6 +711,7 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.log2f
     libc.src.math.logb
     libc.src.math.logbf
+    libc.src.math.logbf128
     libc.src.math.logbl
     libc.src.math.logf
     libc.src.math.lrint
@@ -951,16 +955,12 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
     libc.src.math.ffmaf128
     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
     libc.src.math.getpayloadf128
-    libc.src.math.ilogbf128
     libc.src.math.ldexpf128
-    libc.src.math.llogbf128
-    libc.src.math.logbf128
     libc.src.math.modff128
     libc.src.math.nanf128
     libc.src.math.nextafterf128
diff --git a/libc/config/linux/arm/entrypoints.txt b/libc/config/linux/arm/entrypoints.txt
index 8d9de7e1da75a..7634d90c57078 100644
--- a/libc/config/linux/arm/entrypoints.txt
+++ b/libc/config/linux/arm/entrypoints.txt
@@ -492,6 +492,7 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.hypotf
     libc.src.math.ilogb
     libc.src.math.ilogbf
+    libc.src.math.ilogbf128
     libc.src.math.ilogbl
     libc.src.math.iscanonicalf128
     libc.src.math.isnanf128
@@ -502,6 +503,7 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.lgammaf
     libc.src.math.llogb
     libc.src.math.llogbf
+    libc.src.math.llogbf128
     libc.src.math.llogbl
     libc.src.math.llrint
     libc.src.math.llrintf
@@ -520,6 +522,7 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.log2f
     libc.src.math.logb
     libc.src.math.logbf
+    libc.src.math.logbf128
     libc.src.math.logbl
     libc.src.math.logf
     libc.src.math.lrint
diff --git a/libc/config/linux/riscv/entrypoints.txt b/libc/config/linux/riscv/entrypoints.txt
index 5db369a9d871d..ace7445434a12 100644
--- a/libc/config/linux/riscv/entrypoints.txt
+++ b/libc/config/linux/riscv/entrypoints.txt
@@ -722,6 +722,7 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.fmull
     libc.src.math.frexp
     libc.src.math.frexpf
+    libc.src.math.frexpf128
     libc.src.math.frexpl
     libc.src.math.fromfp
     libc.src.math.fromfpf
@@ -740,6 +741,7 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.hypotf
     libc.src.math.ilogb
     libc.src.math.ilogbf
+    libc.src.math.ilogbf128
     libc.src.math.ilogbl
     libc.src.math.iscanonical
     libc.src.math.iscanonicalf
@@ -759,6 +761,7 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.lgammaf
     libc.src.math.llogb
     libc.src.math.llogbf
+    libc.src.math.llogbf128
     libc.src.math.llogbl
     libc.src.math.llrint
     libc.src.math.llrintf
@@ -777,6 +780,7 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.log2f
     libc.src.math.logb
     libc.src.math.logbf
+    libc.src.math.logbf128
     libc.src.math.logbl
     libc.src.math.logf
     libc.src.math.lrint
@@ -1037,16 +1041,12 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
     libc.src.math.ffmaf128
     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
     libc.src.math.getpayloadf128
-    libc.src.math.ilogbf128
     libc.src.math.ldexpf128
-    libc.src.math.llogbf128
-    libc.src.math.logbf128
     libc.src.math.modff128
     libc.src.math.nanf128
     libc.src.math.nextafterf128
diff --git a/libc/config/linux/x86_64/entrypoints.txt b/libc/config/linux/x86_64/entrypoints.txt
index 3cbbb7b3e9f79..3d51046f61d46 100644
--- a/libc/config/linux/x86_64/entrypoints.txt
+++ b/libc/config/linux/x86_64/entrypoints.txt
@@ -731,6 +731,7 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.fmull
     libc.src.math.frexp
     libc.src.math.frexpf
+    libc.src.math.frexpf128
     libc.src.math.frexpl
     libc.src.math.fromfp
     libc.src.math.fromfpf
@@ -749,6 +750,7 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.hypotf
     libc.src.math.ilogb
     libc.src.math.ilogbf
+    libc.src.math.ilogbf128
     libc.src.math.ilogbl
     libc.src.math.iscanonical
     libc.src.math.iscanonicalf
@@ -768,6 +770,7 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.lgammaf
     libc.src.math.llogb
     libc.src.math.llogbf
+    libc.src.math.llogbf128
     libc.src.math.llogbl
     libc.src.math.llrint
     libc.src.math.llrintf
@@ -786,6 +789,7 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.log2f
     libc.src.math.logb
     libc.src.math.logbf
+    libc.src.math.logbf128
     libc.src.math.logbl
     libc.src.math.logf
     libc.src.math.lrint
@@ -1046,16 +1050,12 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
     libc.src.math.ffmaf128
     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
     libc.src.math.getpayloadf128
-    libc.src.math.ilogbf128
     libc.src.math.ldexpf128
-    libc.src.math.llogbf128
-    libc.src.math.logbf128
     libc.src.math.modff128
     libc.src.math.nanf128
     libc.src.math.nextafterf128
diff --git a/libc/config/windows/entrypoints.txt b/libc/config/windows/entrypoints.txt
index d934e6742f3b6..1e94a13c3035c 100644
--- a/libc/config/windows/entrypoints.txt
+++ b/libc/config/windows/entrypoints.txt
@@ -261,6 +261,7 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.hypotf
     libc.src.math.ilogb
     libc.src.math.ilogbf
+    libc.src.math.ilogbf128
     libc.src.math.ilogbl
     libc.src.math.iscanonicalf128
     libc.src.math.isnanf128
@@ -287,6 +288,7 @@ set(TARGET_LIBM_ENTRYPOINTS
     libc.src.math.logf
     libc.src.math.logb
     libc.src.math.logbf
+    libc.src.math.logbf128
     libc.src.math.logbl
     libc.src.math.lrint
     libc.src.math.lrintf

>From 7edfda3373767c62292204ce9d248693adf49c0d Mon Sep 17 00:00:00 2001
From: Hari Shankar Karthik <harishankarkarthik.93 at gmail.com>
Date: Sun, 6 Sep 2026 07:28:30 +0000
Subject: [PATCH 05/10] Type error: 0L and not 0LL

---
 libc/test/shared/shared_math_constexpr_test.cpp | 2 +-
 libc/test/shared/shared_math_test.cpp           | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/libc/test/shared/shared_math_constexpr_test.cpp b/libc/test/shared/shared_math_constexpr_test.cpp
index c41086dcd684b..ca63359fe732b 100644
--- a/libc/test/shared/shared_math_constexpr_test.cpp
+++ b/libc/test/shared/shared_math_constexpr_test.cpp
@@ -427,7 +427,7 @@ static_assert(0 == LIBC_NAMESPACE::shared::ilogbf128(Float128(1.0)));
 static_assert(1 == LIBC_NAMESPACE::shared::iscanonicalf128(Float128(0.0)));
 static_assert(0 == LIBC_NAMESPACE::shared::isnanf128(Float128(0.0)));
 static_assert(0.0 == LIBC_NAMESPACE::shared::issignalingf128(Float128(0.0)));
-static_assert(0LL == LIBC_NAMESPACE::shared::llogbf128(Float128(1.0)));
+static_assert(0L == LIBC_NAMESPACE::shared::llogbf128(Float128(1.0)));
 static_assert(0LL == LIBC_NAMESPACE::shared::llrintf128(Float128(0.0)));
 static_assert(0LL == LIBC_NAMESPACE::shared::llroundf128(Float128(0.0)));
 static_assert(Float128(0.0) == LIBC_NAMESPACE::shared::logbf128(Float128(1.0)));
diff --git a/libc/test/shared/shared_math_test.cpp b/libc/test/shared/shared_math_test.cpp
index 68526db367621..41466af9b5264 100644
--- a/libc/test/shared/shared_math_test.cpp
+++ b/libc/test/shared/shared_math_test.cpp
@@ -618,7 +618,7 @@ TEST(LlvmLibcSharedMathTest, AllEmuFloat128) {
   EXPECT_EQ(1, LIBC_NAMESPACE::shared::iscanonicalf128(Float128(0.0)));
   EXPECT_EQ(0, LIBC_NAMESPACE::shared::isnanf128(Float128(0.0)));
   EXPECT_EQ(0, LIBC_NAMESPACE::shared::issignalingf128(Float128(0.0)));
-  EXPECT_EQ(0LL, LIBC_NAMESPACE::shared::llogbf128(Float128(1.0)));
+  EXPECT_EQ(0L, LIBC_NAMESPACE::shared::llogbf128(Float128(1.0)));
   EXPECT_EQ(0LL, LIBC_NAMESPACE::shared::llrintf128(Float128(0.0)));
   EXPECT_EQ(0LL, LIBC_NAMESPACE::shared::llroundf128(Float128(0.0)));
   EXPECT_FP_EQ(Float128(0.0), LIBC_NAMESPACE::shared::logbf128(Float128(1.0)));

>From f7d5c040f0b905831d63ac3f3d3dfdd192f400be Mon Sep 17 00:00:00 2001
From: Hari Shankar Karthik <harishankarkarthik.93 at gmail.com>
Date: Sun, 6 Sep 2026 08:40:33 +0000
Subject: [PATCH 06/10] Incorporated comments on the PR, ran clang-format

---
 libc/config/darwin/x86_64/entrypoints.txt | 3 ++-
 libc/config/windows/entrypoints.txt       | 1 +
 libc/src/__support/math/CMakeLists.txt    | 6 +++---
 libc/src/__support/math/frexpf128.h       | 2 +-
 libc/src/__support/math/ilogbf128.h       | 2 +-
 libc/src/__support/math/llogbf128.h       | 2 +-
 libc/src/__support/math/logbf128.h        | 6 ++----
 libc/src/math/generic/frexpf128.cpp       | 2 +-
 libc/src/math/generic/ilogbf128.cpp       | 3 +--
 libc/src/math/generic/llogbf128.cpp       | 3 +--
 libc/src/math/generic/logbf128.cpp        | 3 +--
 11 files changed, 15 insertions(+), 18 deletions(-)

diff --git a/libc/config/darwin/x86_64/entrypoints.txt b/libc/config/darwin/x86_64/entrypoints.txt
index 802c3c7cfd6ba..788555b2256e2 100644
--- a/libc/config/darwin/x86_64/entrypoints.txt
+++ b/libc/config/darwin/x86_64/entrypoints.txt
@@ -184,7 +184,7 @@ set(TARGET_LIBM_ENTRYPOINTS
     #libc.src.math.hypotf
     #libc.src.math.ilogb
     #libc.src.math.ilogbf
-    #libc.src.math.ilogbf128b
+    #libc.src.math.ilogbf128
     #libc.src.math.ilogbl
     #libc.src.math.iscanonicalf128
     #libc.src.math.isnanf128
@@ -313,6 +313,7 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
   libc.src.math.issignalingbf16
   libc.src.math.ldexpbf16
   libc.src.math.llogbbf16
+  libc.src.math.llogbf128
   libc.src.math.llrintbf16
   libc.src.math.llroundbf16
   libc.src.math.log_bf16
diff --git a/libc/config/windows/entrypoints.txt b/libc/config/windows/entrypoints.txt
index 1e94a13c3035c..4ca5ba609e5e8 100644
--- a/libc/config/windows/entrypoints.txt
+++ b/libc/config/windows/entrypoints.txt
@@ -404,6 +404,7 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
   libc.src.math.issignalingbf16
   libc.src.math.ldexpbf16
   libc.src.math.llogbbf16
+  libc.src.math.llogbf128
   libc.src.math.llrintbf16
   libc.src.math.llroundbf16
   libc.src.math.log_bf16
diff --git a/libc/src/__support/math/CMakeLists.txt b/libc/src/__support/math/CMakeLists.txt
index 5ec717eff01ed..2315d329dc6f9 100644
--- a/libc/src/__support/math/CMakeLists.txt
+++ b/libc/src/__support/math/CMakeLists.txt
@@ -3788,9 +3788,9 @@ add_header_library(
   HDRS
     frexpf128.h
   DEPENDS
-    libc.src.__support.macros.properties.types
     libc.src.__support.FPUtil.float128
     libc.src.__support.FPUtil.manipulation_functions
+    libc.src.__support.macros.properties.types
 )
 
 add_header_library(
@@ -3974,9 +3974,9 @@ add_header_library(
   HDRS
     ilogbf128.h
   DEPENDS
-    libc.src.__support.macros.properties.types
     libc.src.__support.FPUtil.float128
     libc.src.__support.FPUtil.manipulation_functions
+    libc.src.__support.macros.properties.types
 )
 
 add_header_library(
@@ -4053,9 +4053,9 @@ add_header_library(
   HDRS
     llogbf128.h
   DEPENDS
-    libc.src.__support.macros.config
     libc.src.__support.FPUtil.float128
     libc.src.__support.FPUtil.manipulation_functions
+    libc.src.__support.macros.config
 )
 
 add_header_library(
diff --git a/libc/src/__support/math/frexpf128.h b/libc/src/__support/math/frexpf128.h
index 923eadf999ff6..d7635196ba27c 100644
--- a/libc/src/__support/math/frexpf128.h
+++ b/libc/src/__support/math/frexpf128.h
@@ -9,8 +9,8 @@
 #ifndef LLVM_LIBC_SRC___SUPPORT_MATH_FREXPF128_H
 #define LLVM_LIBC_SRC___SUPPORT_MATH_FREXPF128_H
 
-#include "src/__support/FPUtil/float128.h"
 #include "src/__support/FPUtil/ManipulationFunctions.h"
+#include "src/__support/FPUtil/float128.h"
 #include "src/__support/common.h"
 #include "src/__support/macros/config.h"
 
diff --git a/libc/src/__support/math/ilogbf128.h b/libc/src/__support/math/ilogbf128.h
index 69978373c9fea..bc7b1a2ddf43f 100644
--- a/libc/src/__support/math/ilogbf128.h
+++ b/libc/src/__support/math/ilogbf128.h
@@ -9,8 +9,8 @@
 #ifndef LLVM_LIBC_SRC___SUPPORT_MATH_ILOGBF128_H
 #define LLVM_LIBC_SRC___SUPPORT_MATH_ILOGBF128_H
 
-#include "src/__support/FPUtil/float128.h"
 #include "src/__support/FPUtil/ManipulationFunctions.h"
+#include "src/__support/FPUtil/float128.h"
 #include "src/__support/common.h"
 #include "src/__support/macros/config.h"
 
diff --git a/libc/src/__support/math/llogbf128.h b/libc/src/__support/math/llogbf128.h
index c0bf7541744cb..3bc4c876d2899 100644
--- a/libc/src/__support/math/llogbf128.h
+++ b/libc/src/__support/math/llogbf128.h
@@ -9,8 +9,8 @@
 #ifndef LLVM_LIBC_SRC___SUPPORT_MATH_LLOGBF128_H
 #define LLVM_LIBC_SRC___SUPPORT_MATH_LLOGBF128_H
 
-#include "src/__support/FPUtil/float128.h"
 #include "src/__support/FPUtil/ManipulationFunctions.h"
+#include "src/__support/FPUtil/float128.h"
 #include "src/__support/common.h"
 #include "src/__support/macros/config.h"
 
diff --git a/libc/src/__support/math/logbf128.h b/libc/src/__support/math/logbf128.h
index eeedfc1f27b92..feb4c6fa89c32 100644
--- a/libc/src/__support/math/logbf128.h
+++ b/libc/src/__support/math/logbf128.h
@@ -9,8 +9,8 @@
 #ifndef LLVM_LIBC_SRC___SUPPORT_MATH_LOGBF128_H
 #define LLVM_LIBC_SRC___SUPPORT_MATH_LOGBF128_H
 
-#include "src/__support/FPUtil/float128.h"
 #include "src/__support/FPUtil/ManipulationFunctions.h"
+#include "src/__support/FPUtil/float128.h"
 #include "src/__support/common.h"
 #include "src/__support/macros/config.h"
 
@@ -20,9 +20,7 @@ namespace math {
 
 using LIBC_NAMESPACE::fputil::Float128;
 
-LIBC_INLINE constexpr Float128 logbf128(Float128 x) { 
-    return fputil::logb(x); 
-}
+LIBC_INLINE constexpr Float128 logbf128(Float128 x) { return fputil::logb(x); }
 
 } // namespace math
 
diff --git a/libc/src/math/generic/frexpf128.cpp b/libc/src/math/generic/frexpf128.cpp
index e95e31391386a..ebdd46ae4573f 100644
--- a/libc/src/math/generic/frexpf128.cpp
+++ b/libc/src/math/generic/frexpf128.cpp
@@ -16,7 +16,7 @@ using LIBC_NAMESPACE::fputil::Float128;
 
 LLVM_LIBC_FUNCTION(float128, frexpf128, (float128 x, int *exp)) {
   return cpp::bit_cast<float128>(
-    math::frexpf128(cpp::bit_cast<Float128>(x), exp));
+      math::frexpf128(cpp::bit_cast<Float128>(x), exp));
 }
 
 } // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/ilogbf128.cpp b/libc/src/math/generic/ilogbf128.cpp
index ea59ae3ef6df5..cebb08ebea489 100644
--- a/libc/src/math/generic/ilogbf128.cpp
+++ b/libc/src/math/generic/ilogbf128.cpp
@@ -15,8 +15,7 @@ namespace LIBC_NAMESPACE_DECL {
 using LIBC_NAMESPACE::fputil::Float128;
 
 LLVM_LIBC_FUNCTION(int, ilogbf128, (float128 x)) {
-    return math::ilogbf128(
-        cpp::bit_cast<Float128>(x));
+  return math::ilogbf128(cpp::bit_cast<Float128>(x));
 }
 
 } // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/llogbf128.cpp b/libc/src/math/generic/llogbf128.cpp
index ddd1eaee5a6b4..cc81f3a4a55f7 100644
--- a/libc/src/math/generic/llogbf128.cpp
+++ b/libc/src/math/generic/llogbf128.cpp
@@ -15,8 +15,7 @@ namespace LIBC_NAMESPACE_DECL {
 using LIBC_NAMESPACE::fputil::Float128;
 
 LLVM_LIBC_FUNCTION(long, llogbf128, (float128 x)) {
-    return math::llogbf128(
-        cpp::bit_cast<Float128>(x));
+  return math::llogbf128(cpp::bit_cast<Float128>(x));
 }
 
 } // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/logbf128.cpp b/libc/src/math/generic/logbf128.cpp
index 9423001474436..b5744f0a8a36c 100644
--- a/libc/src/math/generic/logbf128.cpp
+++ b/libc/src/math/generic/logbf128.cpp
@@ -15,8 +15,7 @@ namespace LIBC_NAMESPACE_DECL {
 using LIBC_NAMESPACE::fputil::Float128;
 
 LLVM_LIBC_FUNCTION(float128, logbf128, (float128 x)) {
-  return cpp::bit_cast<Float128>(
-      math::logbf128(cpp::bit_cast<Float128>(x)));
+  return cpp::bit_cast<float128>(math::logbf128(cpp::bit_cast<Float128>(x)));
 }
 
 } // namespace LIBC_NAMESPACE_DECL

>From d98201048bd9b14da9213b87a536cbaba81ecabf Mon Sep 17 00:00:00 2001
From: Hari Shankar Karthik <harishankarkarthik.93 at gmail.com>
Date: Tue, 8 Sep 2026 05:07:21 +0000
Subject: [PATCH 07/10] Added appropriate comment headers to every source file
 touched

---
 libc/shared/math/frexpf128.h        | 6 ++++++
 libc/shared/math/ilogbf128.h        | 6 ++++++
 libc/shared/math/llogbf128.h        | 6 ++++++
 libc/shared/math/logbf128.h         | 6 ++++++
 libc/src/__support/math/frexpf128.h | 8 +++++++-
 libc/src/__support/math/ilogbf128.h | 6 ++++++
 libc/src/__support/math/llogbf128.h | 6 ++++++
 libc/src/__support/math/logbf128.h  | 6 ++++++
 libc/src/math/frexpf128.h           | 6 ++++++
 libc/src/math/ilogbf128.h           | 6 ++++++
 libc/src/math/llogbf128.h           | 6 ++++++
 libc/src/math/logbf128.h            | 6 ++++++
 12 files changed, 73 insertions(+), 1 deletion(-)

diff --git a/libc/shared/math/frexpf128.h b/libc/shared/math/frexpf128.h
index 4815fa33a874b..753d28d8a48c1 100644
--- a/libc/shared/math/frexpf128.h
+++ b/libc/shared/math/frexpf128.h
@@ -5,6 +5,12 @@
 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
+///
+/// \file
+/// This file re-exports frexpf128 through the shared::math namespace so that
+/// other LLVM components can use it without depending on libc internals.
+///
+//===----------------------------------------------------------------------===//
 
 #ifndef LLVM_LIBC_SHARED_MATH_FREXPF128_H
 #define LLVM_LIBC_SHARED_MATH_FREXPF128_H
diff --git a/libc/shared/math/ilogbf128.h b/libc/shared/math/ilogbf128.h
index e6a9d32f2464b..d9842b0195989 100644
--- a/libc/shared/math/ilogbf128.h
+++ b/libc/shared/math/ilogbf128.h
@@ -5,6 +5,12 @@
 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
+///
+/// \file
+/// This file re-exports ilogbf128 through the shared::math namespace so that
+/// other LLVM components can use it without depending on libc internals.
+///
+//===----------------------------------------------------------------------===//
 
 #ifndef LLVM_LIBC_SHARED_MATH_ILOGBF128_H
 #define LLVM_LIBC_SHARED_MATH_ILOGBF128_H
diff --git a/libc/shared/math/llogbf128.h b/libc/shared/math/llogbf128.h
index 4bf4b29081987..34310bfbae278 100644
--- a/libc/shared/math/llogbf128.h
+++ b/libc/shared/math/llogbf128.h
@@ -5,6 +5,12 @@
 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
+///
+/// \file
+/// This file re-exports llogbf128 through the shared::math namespace so that
+/// other LLVM components can use it without depending on libc internals.
+///
+//===----------------------------------------------------------------------===//
 
 #ifndef LLVM_LIBC_SHARED_MATH_LLOGBF128_H
 #define LLVM_LIBC_SHARED_MATH_LLOGBF128_H
diff --git a/libc/shared/math/logbf128.h b/libc/shared/math/logbf128.h
index 7549b41c1f821..598862652c39f 100644
--- a/libc/shared/math/logbf128.h
+++ b/libc/shared/math/logbf128.h
@@ -5,6 +5,12 @@
 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
+///
+/// \file
+/// This file re-exports logbf128 through the shared::math namespace so that
+/// other LLVM components can use it without depending on libc internals.
+///
+//===----------------------------------------------------------------------===//
 
 #ifndef LLVM_LIBC_SHARED_MATH_LOGBF128_H
 #define LLVM_LIBC_SHARED_MATH_LOGBF128_H
diff --git a/libc/src/__support/math/frexpf128.h b/libc/src/__support/math/frexpf128.h
index d7635196ba27c..893f037abc4b4 100644
--- a/libc/src/__support/math/frexpf128.h
+++ b/libc/src/__support/math/frexpf128.h
@@ -1,10 +1,16 @@
-//===-- Implementation header for expf --------------------------*- C++ -*-===//
+//===-- Implementation header for frexpf128 ---------------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
+///
+/// \file
+/// This file contains the implementation of frexpf128, the float128 variant of
+/// frexp.
+///
+//===----------------------------------------------------------------------===//
 
 #ifndef LLVM_LIBC_SRC___SUPPORT_MATH_FREXPF128_H
 #define LLVM_LIBC_SRC___SUPPORT_MATH_FREXPF128_H
diff --git a/libc/src/__support/math/ilogbf128.h b/libc/src/__support/math/ilogbf128.h
index bc7b1a2ddf43f..212205dea7aac 100644
--- a/libc/src/__support/math/ilogbf128.h
+++ b/libc/src/__support/math/ilogbf128.h
@@ -5,6 +5,12 @@
 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
+///
+/// \file
+/// This file contains the implementation of ilogbf128, the float128 variant of
+/// ilogb.
+///
+//===----------------------------------------------------------------------===//
 
 #ifndef LLVM_LIBC_SRC___SUPPORT_MATH_ILOGBF128_H
 #define LLVM_LIBC_SRC___SUPPORT_MATH_ILOGBF128_H
diff --git a/libc/src/__support/math/llogbf128.h b/libc/src/__support/math/llogbf128.h
index 3bc4c876d2899..de06812be9d9d 100644
--- a/libc/src/__support/math/llogbf128.h
+++ b/libc/src/__support/math/llogbf128.h
@@ -5,6 +5,12 @@
 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
+///
+/// \file
+/// This file contains the implementation of llogbf128, the float128 variant of
+/// llogb.
+///
+//===----------------------------------------------------------------------===//
 
 #ifndef LLVM_LIBC_SRC___SUPPORT_MATH_LLOGBF128_H
 #define LLVM_LIBC_SRC___SUPPORT_MATH_LLOGBF128_H
diff --git a/libc/src/__support/math/logbf128.h b/libc/src/__support/math/logbf128.h
index feb4c6fa89c32..7979ddf12db60 100644
--- a/libc/src/__support/math/logbf128.h
+++ b/libc/src/__support/math/logbf128.h
@@ -5,6 +5,12 @@
 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
+///
+/// \file
+/// This file contains the implementation of logbf128, the float128 variant of
+/// logb.
+///
+//===----------------------------------------------------------------------===//
 
 #ifndef LLVM_LIBC_SRC___SUPPORT_MATH_LOGBF128_H
 #define LLVM_LIBC_SRC___SUPPORT_MATH_LOGBF128_H
diff --git a/libc/src/math/frexpf128.h b/libc/src/math/frexpf128.h
index 9ea3efa8481e0..a9817524a7f83 100644
--- a/libc/src/math/frexpf128.h
+++ b/libc/src/math/frexpf128.h
@@ -5,6 +5,12 @@
 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
+///
+/// \file
+/// This file contains the declaration of the frexpf128 entrypoint, the
+/// float128 variant of the C standard frexp function.
+///
+//===----------------------------------------------------------------------===//
 
 #ifndef LLVM_LIBC_SRC_MATH_FREXPF128_H
 #define LLVM_LIBC_SRC_MATH_FREXPF128_H
diff --git a/libc/src/math/ilogbf128.h b/libc/src/math/ilogbf128.h
index f102dbe097d33..c2ab14a394125 100644
--- a/libc/src/math/ilogbf128.h
+++ b/libc/src/math/ilogbf128.h
@@ -5,6 +5,12 @@
 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
+///
+/// \file
+/// This file contains the declaration of the ilogbf128 entrypoint, the
+/// float128 variant of the C standard ilogb function.
+///
+//===----------------------------------------------------------------------===//
 
 #ifndef LLVM_LIBC_SRC_MATH_ILOGBF128_H
 #define LLVM_LIBC_SRC_MATH_ILOGBF128_H
diff --git a/libc/src/math/llogbf128.h b/libc/src/math/llogbf128.h
index 06553f9d12f3b..9a27eb0dc05ba 100644
--- a/libc/src/math/llogbf128.h
+++ b/libc/src/math/llogbf128.h
@@ -5,6 +5,12 @@
 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
+///
+/// \file
+/// This file contains the declaration of the llogbf128 entrypoint, the
+/// float128 variant of the C standard llogb function.
+///
+//===----------------------------------------------------------------------===//
 
 #ifndef LLVM_LIBC_SRC_MATH_LLOGBF128_H
 #define LLVM_LIBC_SRC_MATH_LLOGBF128_H
diff --git a/libc/src/math/logbf128.h b/libc/src/math/logbf128.h
index 366989810b8a2..0f63aabdd99b6 100644
--- a/libc/src/math/logbf128.h
+++ b/libc/src/math/logbf128.h
@@ -5,6 +5,12 @@
 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
+///
+/// \file
+/// This file contains the declaration of the logbf128 entrypoint, the
+/// float128 variant of the C standard logb function.
+///
+//===----------------------------------------------------------------------===//
 
 #ifndef LLVM_LIBC_SRC_MATH_LOGBF128_H
 #define LLVM_LIBC_SRC_MATH_LOGBF128_H

>From d638341db33a274b565e6e193447728c43ea81d7 Mon Sep 17 00:00:00 2001
From: Hari Shankar Karthik <harishankarkarthik.93 at gmail.com>
Date: Tue, 8 Sep 2026 05:33:22 +0000
Subject: [PATCH 08/10] Changed the frexpf128 test to resemble the older
 version

---
 libc/test/shared/shared_math_test.cpp | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/libc/test/shared/shared_math_test.cpp b/libc/test/shared/shared_math_test.cpp
index 41466af9b5264..bfd2a2012de45 100644
--- a/libc/test/shared/shared_math_test.cpp
+++ b/libc/test/shared/shared_math_test.cpp
@@ -581,6 +581,8 @@ TEST(LlvmLibcSharedMathTest, AllLongDouble) {
 
 // Emulated float128 tests
 TEST(LlvmLibcSharedMathTest, AllEmuFloat128) {
+  int exponent;
+
   EXPECT_FP_EQ(Float128(0.0),
                LIBC_NAMESPACE::shared::atan2f128(Float128(0.0), Float128(0.0)));
   EXPECT_FP_EQ(Float128(0.0), LIBC_NAMESPACE::shared::ceilf128(Float128(0.0)));
@@ -610,10 +612,9 @@ TEST(LlvmLibcSharedMathTest, AllEmuFloat128) {
                                   Float128(0.0), Float128(0.0)));
   EXPECT_FP_EQ(Float128(0.0), LIBC_NAMESPACE::shared::fminimum_numf128(
                                   Float128(0.0), Float128(0.0)));
-  int frexpf128_exp = 0;
-  EXPECT_FP_EQ(Float128(0.0), LIBC_NAMESPACE::shared::frexpf128(
-                                  Float128(0.0), &frexpf128_exp));
-  EXPECT_EQ(0, frexpf128_exp);
+  EXPECT_FP_EQ_ALL_ROUNDING(Float128(0.75), LIBC_NAMESPACE::shared::frexpf128(
+                                                Float128(24), &exponent));
+  EXPECT_EQ(exponent, 5);
   EXPECT_EQ(0, LIBC_NAMESPACE::shared::ilogbf128(Float128(1.0)));
   EXPECT_EQ(1, LIBC_NAMESPACE::shared::iscanonicalf128(Float128(0.0)));
   EXPECT_EQ(0, LIBC_NAMESPACE::shared::isnanf128(Float128(0.0)));

>From 20e636f2cc2a8a34b98925ff525e0ea42399257e Mon Sep 17 00:00:00 2001
From: Hari Shankar Karthik <harishankarkarthik.93 at gmail.com>
Date: Tue, 8 Sep 2026 06:00:50 +0000
Subject: [PATCH 09/10] ADDED: MPFR non-smoke test for logbf128

---
 libc/test/src/math/CMakeLists.txt    | 15 +++++++++++++++
 libc/test/src/math/logbf128_test.cpp | 18 ++++++++++++++++++
 2 files changed, 33 insertions(+)
 create mode 100644 libc/test/src/math/logbf128_test.cpp

diff --git a/libc/test/src/math/CMakeLists.txt b/libc/test/src/math/CMakeLists.txt
index 8f1a543de0a5e..0cccfaa2ba9dc 100644
--- a/libc/test/src/math/CMakeLists.txt
+++ b/libc/test/src/math/CMakeLists.txt
@@ -1742,6 +1742,21 @@ add_fp_unittest(
     libc.src.__support.FPUtil.manipulation_functions
 )
 
+add_fp_unittest(
+  logbf128_test
+  NEED_MPFR_F128
+  SUITE
+    libc-math-unittests
+  SRCS
+    logbf128_test.cpp
+  HDRS
+    LogbTest.h
+  DEPENDS
+    libc.src.math.logbf128
+    libc.src.__support.FPUtil.float128
+    libc.src.__support.FPUtil.manipulation_functions
+)
+
 add_fp_unittest(
   logbl_test
   SUITE
diff --git a/libc/test/src/math/logbf128_test.cpp b/libc/test/src/math/logbf128_test.cpp
new file mode 100644
index 0000000000000..0ccab2b5ef733
--- /dev/null
+++ b/libc/test/src/math/logbf128_test.cpp
@@ -0,0 +1,18 @@
+//===-- Unittests for logbf128 --------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "LogbTest.h"
+
+#include "src/__support/FPUtil/float128.h"
+#include "src/math/logbf128.h"
+
+#ifndef LIBC_TYPES_HAS_NATIVE_FLOAT128
+using float128 = LIBC_NAMESPACE::fputil::Float128;
+#endif // LIBC_TYPES_HAS_NATIVE_FLOAT128
+
+LIST_LOGB_TESTS(float128, LIBC_NAMESPACE::logbf128)

>From 5047a917bed03186a6fa99636ac792a3d25c9161 Mon Sep 17 00:00:00 2001
From: Hari Shankar Karthik <harishankarkarthik.93 at gmail.com>
Date: Tue, 8 Sep 2026 07:12:26 +0000
Subject: [PATCH 10/10] Added/updated headers in all source files

---
 libc/shared/math/frexpf128.h        | 3 +--
 libc/shared/math/ilogbf128.h        | 3 +--
 libc/shared/math/llogbf128.h        | 3 +--
 libc/shared/math/logbf128.h         | 3 +--
 libc/src/__support/math/frexpf128.h | 3 +--
 libc/src/__support/math/ilogbf128.h | 3 +--
 libc/src/__support/math/llogbf128.h | 3 +--
 libc/src/__support/math/logbf128.h  | 3 +--
 libc/src/math/frexpf128.h           | 3 +--
 libc/src/math/generic/frexpf128.cpp | 5 +++++
 libc/src/math/generic/ilogbf128.cpp | 5 +++++
 libc/src/math/generic/llogbf128.cpp | 5 +++++
 libc/src/math/generic/logbf128.cpp  | 5 +++++
 libc/src/math/ilogbf128.h           | 3 +--
 libc/src/math/llogbf128.h           | 3 +--
 libc/src/math/logbf128.h            | 3 +--
 16 files changed, 32 insertions(+), 24 deletions(-)

diff --git a/libc/shared/math/frexpf128.h b/libc/shared/math/frexpf128.h
index 753d28d8a48c1..2b940f2c9c78d 100644
--- a/libc/shared/math/frexpf128.h
+++ b/libc/shared/math/frexpf128.h
@@ -7,8 +7,7 @@
 //===----------------------------------------------------------------------===//
 ///
 /// \file
-/// This file re-exports frexpf128 through the shared::math namespace so that
-/// other LLVM components can use it without depending on libc internals.
+/// Shared declaration of the float128 frexp function.
 ///
 //===----------------------------------------------------------------------===//
 
diff --git a/libc/shared/math/ilogbf128.h b/libc/shared/math/ilogbf128.h
index d9842b0195989..6bb6b9bc7e709 100644
--- a/libc/shared/math/ilogbf128.h
+++ b/libc/shared/math/ilogbf128.h
@@ -7,8 +7,7 @@
 //===----------------------------------------------------------------------===//
 ///
 /// \file
-/// This file re-exports ilogbf128 through the shared::math namespace so that
-/// other LLVM components can use it without depending on libc internals.
+/// Shared declaration of the float128 ilogb function.
 ///
 //===----------------------------------------------------------------------===//
 
diff --git a/libc/shared/math/llogbf128.h b/libc/shared/math/llogbf128.h
index 34310bfbae278..c70c54b67dfc2 100644
--- a/libc/shared/math/llogbf128.h
+++ b/libc/shared/math/llogbf128.h
@@ -7,8 +7,7 @@
 //===----------------------------------------------------------------------===//
 ///
 /// \file
-/// This file re-exports llogbf128 through the shared::math namespace so that
-/// other LLVM components can use it without depending on libc internals.
+/// Shared declaration of the float128 llogb function.
 ///
 //===----------------------------------------------------------------------===//
 
diff --git a/libc/shared/math/logbf128.h b/libc/shared/math/logbf128.h
index 598862652c39f..d616181b8306e 100644
--- a/libc/shared/math/logbf128.h
+++ b/libc/shared/math/logbf128.h
@@ -7,8 +7,7 @@
 //===----------------------------------------------------------------------===//
 ///
 /// \file
-/// This file re-exports logbf128 through the shared::math namespace so that
-/// other LLVM components can use it without depending on libc internals.
+/// Shared declaration of the float128 logb function.
 ///
 //===----------------------------------------------------------------------===//
 
diff --git a/libc/src/__support/math/frexpf128.h b/libc/src/__support/math/frexpf128.h
index 893f037abc4b4..34d8067623a43 100644
--- a/libc/src/__support/math/frexpf128.h
+++ b/libc/src/__support/math/frexpf128.h
@@ -7,8 +7,7 @@
 //===----------------------------------------------------------------------===//
 ///
 /// \file
-/// This file contains the implementation of frexpf128, the float128 variant of
-/// frexp.
+/// Implementation of the float128 frexp function.
 ///
 //===----------------------------------------------------------------------===//
 
diff --git a/libc/src/__support/math/ilogbf128.h b/libc/src/__support/math/ilogbf128.h
index 212205dea7aac..d097ce46c9c3c 100644
--- a/libc/src/__support/math/ilogbf128.h
+++ b/libc/src/__support/math/ilogbf128.h
@@ -7,8 +7,7 @@
 //===----------------------------------------------------------------------===//
 ///
 /// \file
-/// This file contains the implementation of ilogbf128, the float128 variant of
-/// ilogb.
+/// Implementation of the float128 ilogb function.
 ///
 //===----------------------------------------------------------------------===//
 
diff --git a/libc/src/__support/math/llogbf128.h b/libc/src/__support/math/llogbf128.h
index de06812be9d9d..57a9af591a81a 100644
--- a/libc/src/__support/math/llogbf128.h
+++ b/libc/src/__support/math/llogbf128.h
@@ -7,8 +7,7 @@
 //===----------------------------------------------------------------------===//
 ///
 /// \file
-/// This file contains the implementation of llogbf128, the float128 variant of
-/// llogb.
+/// Implementation of the float128 llogb function.
 ///
 //===----------------------------------------------------------------------===//
 
diff --git a/libc/src/__support/math/logbf128.h b/libc/src/__support/math/logbf128.h
index 7979ddf12db60..ffabc015b5465 100644
--- a/libc/src/__support/math/logbf128.h
+++ b/libc/src/__support/math/logbf128.h
@@ -7,8 +7,7 @@
 //===----------------------------------------------------------------------===//
 ///
 /// \file
-/// This file contains the implementation of logbf128, the float128 variant of
-/// logb.
+/// Implementation of the float128 logb function.
 ///
 //===----------------------------------------------------------------------===//
 
diff --git a/libc/src/math/frexpf128.h b/libc/src/math/frexpf128.h
index a9817524a7f83..2b9c463702eb5 100644
--- a/libc/src/math/frexpf128.h
+++ b/libc/src/math/frexpf128.h
@@ -7,8 +7,7 @@
 //===----------------------------------------------------------------------===//
 ///
 /// \file
-/// This file contains the declaration of the frexpf128 entrypoint, the
-/// float128 variant of the C standard frexp function.
+/// Declaration of the float128 frexp function.
 ///
 //===----------------------------------------------------------------------===//
 
diff --git a/libc/src/math/generic/frexpf128.cpp b/libc/src/math/generic/frexpf128.cpp
index ebdd46ae4573f..1fdbf2e97549a 100644
--- a/libc/src/math/generic/frexpf128.cpp
+++ b/libc/src/math/generic/frexpf128.cpp
@@ -5,6 +5,11 @@
 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
+///
+/// \file
+/// Implementation of the float128 frexp function.
+///
+//===----------------------------------------------------------------------===//
 
 #include "src/math/frexpf128.h"
 #include "src/__support/CPP/bit.h"
diff --git a/libc/src/math/generic/ilogbf128.cpp b/libc/src/math/generic/ilogbf128.cpp
index cebb08ebea489..e3b4601c03674 100644
--- a/libc/src/math/generic/ilogbf128.cpp
+++ b/libc/src/math/generic/ilogbf128.cpp
@@ -5,6 +5,11 @@
 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
+///
+/// \file
+/// Implementation of the float128 ilogb function.
+///
+//===----------------------------------------------------------------------===//
 
 #include "src/math/ilogbf128.h"
 #include "src/__support/CPP/bit.h"
diff --git a/libc/src/math/generic/llogbf128.cpp b/libc/src/math/generic/llogbf128.cpp
index cc81f3a4a55f7..9d286c361899a 100644
--- a/libc/src/math/generic/llogbf128.cpp
+++ b/libc/src/math/generic/llogbf128.cpp
@@ -5,6 +5,11 @@
 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
+///
+/// \file
+/// Implementation of the float128 llogb function.
+///
+//===----------------------------------------------------------------------===//
 
 #include "src/math/llogbf128.h"
 #include "src/__support/CPP/bit.h"
diff --git a/libc/src/math/generic/logbf128.cpp b/libc/src/math/generic/logbf128.cpp
index b5744f0a8a36c..55b16356fcd60 100644
--- a/libc/src/math/generic/logbf128.cpp
+++ b/libc/src/math/generic/logbf128.cpp
@@ -5,6 +5,11 @@
 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
 //
 //===----------------------------------------------------------------------===//
+///
+/// \file
+/// Implementation of the float128 logb function.
+///
+//===----------------------------------------------------------------------===//
 
 #include "src/math/logbf128.h"
 #include "src/__support/CPP/bit.h"
diff --git a/libc/src/math/ilogbf128.h b/libc/src/math/ilogbf128.h
index c2ab14a394125..caf035dc6aa26 100644
--- a/libc/src/math/ilogbf128.h
+++ b/libc/src/math/ilogbf128.h
@@ -7,8 +7,7 @@
 //===----------------------------------------------------------------------===//
 ///
 /// \file
-/// This file contains the declaration of the ilogbf128 entrypoint, the
-/// float128 variant of the C standard ilogb function.
+/// Declaration of the float128 ilogb function.
 ///
 //===----------------------------------------------------------------------===//
 
diff --git a/libc/src/math/llogbf128.h b/libc/src/math/llogbf128.h
index 9a27eb0dc05ba..e2af38bdf734d 100644
--- a/libc/src/math/llogbf128.h
+++ b/libc/src/math/llogbf128.h
@@ -7,8 +7,7 @@
 //===----------------------------------------------------------------------===//
 ///
 /// \file
-/// This file contains the declaration of the llogbf128 entrypoint, the
-/// float128 variant of the C standard llogb function.
+/// Declaration of the float128 llogb function.
 ///
 //===----------------------------------------------------------------------===//
 
diff --git a/libc/src/math/logbf128.h b/libc/src/math/logbf128.h
index 0f63aabdd99b6..66cd6c2c9648f 100644
--- a/libc/src/math/logbf128.h
+++ b/libc/src/math/logbf128.h
@@ -7,8 +7,7 @@
 //===----------------------------------------------------------------------===//
 ///
 /// \file
-/// This file contains the declaration of the logbf128 entrypoint, the
-/// float128 variant of the C standard logb function.
+/// Declaration of the float128 logb function.
 ///
 //===----------------------------------------------------------------------===//
 



More information about the libc-commits mailing list