[llvm-branch-commits] [libc] [llvm] [libc][math] Adds exponent decomposition functions for float80 (PR #238687)
via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Wed Nov 4 01:54:44 PST 2026
https://github.com/Sukumarsawant updated https://github.com/llvm/llvm-project/pull/238687
>From 97b0925141b25f46c23581f4ea5b5006986d59e3 Mon Sep 17 00:00:00 2001
From: Sukumarsawant <sawantsukumar at gmail.com>
Date: Wed, 4 Nov 2026 11:13:17 +0530
Subject: [PATCH 1/4] adds frexpf80, ilogbf80, llogbf80, logbf80
---
do_commit_exp_decomp.py | 31 +++++++
libc/config/baremetal/aarch64/entrypoints.txt | 4 +
libc/config/baremetal/arm/entrypoints.txt | 4 +
libc/config/baremetal/hexagon/entrypoints.txt | 4 +
libc/config/baremetal/riscv/entrypoints.txt | 4 +
libc/config/darwin/aarch64/entrypoints.txt | 4 +
libc/config/darwin/x86_64/entrypoints.txt | 4 +
libc/config/freebsd/x86_64/entrypoints.txt | 4 +
libc/config/gpu/amdgpu/entrypoints.txt | 4 +
libc/config/gpu/nvptx/entrypoints.txt | 4 +
libc/config/linux/aarch64/entrypoints.txt | 4 +
libc/config/linux/arm/entrypoints.txt | 4 +
libc/config/linux/riscv/entrypoints.txt | 4 +
libc/config/linux/x86_64/entrypoints.txt | 4 +
libc/config/windows/entrypoints.txt | 4 +
libc/docs/headers/math/index.md | 8 +-
libc/shared/math.h | 4 +
libc/shared/math/frexpf80.h | 24 ++++++
libc/shared/math/ilogbf80.h | 24 ++++++
libc/shared/math/llogbf80.h | 24 ++++++
libc/shared/math/logbf80.h | 24 ++++++
libc/src/__support/math/CMakeLists.txt | 40 +++++++++
libc/src/__support/math/frexpf80.h | 29 +++++++
libc/src/__support/math/ilogbf80.h | 29 +++++++
libc/src/__support/math/llogbf80.h | 29 +++++++
libc/src/__support/math/logbf80.h | 29 +++++++
libc/src/math/CMakeLists.txt | 4 +
libc/src/math/frexpf80.h | 21 +++++
libc/src/math/generic/CMakeLists.txt | 44 ++++++++++
libc/src/math/generic/frexpf80.cpp | 22 +++++
libc/src/math/generic/ilogbf80.cpp | 21 +++++
libc/src/math/generic/llogbf80.cpp | 21 +++++
libc/src/math/generic/logbf80.cpp | 22 +++++
libc/src/math/ilogbf80.h | 21 +++++
libc/src/math/llogbf80.h | 21 +++++
libc/src/math/logbf80.h | 21 +++++
libc/test/shared/CMakeLists.txt | 8 ++
.../shared/shared_math_constexpr_test.cpp | 7 ++
libc/test/shared/shared_math_test.cpp | 7 ++
libc/test/src/math/smoke/CMakeLists.txt | 12 +++
libc/test/src/math/smoke/frexpf80_test.cpp | 13 +++
libc/test/src/math/smoke/ilogbf80_test.cpp | 13 +++
libc/test/src/math/smoke/llogbf80_test.cpp | 13 +++
libc/test/src/math/smoke/logbf80_test.cpp | 13 +++
.../llvm-project-overlay/libc/BUILD.bazel | 84 +++++++++++++++++++
.../libc/test/src/math/smoke/BUILD.bazel | 8 ++
46 files changed, 743 insertions(+), 4 deletions(-)
create mode 100644 do_commit_exp_decomp.py
create mode 100644 libc/shared/math/frexpf80.h
create mode 100644 libc/shared/math/ilogbf80.h
create mode 100644 libc/shared/math/llogbf80.h
create mode 100644 libc/shared/math/logbf80.h
create mode 100644 libc/src/__support/math/frexpf80.h
create mode 100644 libc/src/__support/math/ilogbf80.h
create mode 100644 libc/src/__support/math/llogbf80.h
create mode 100644 libc/src/__support/math/logbf80.h
create mode 100644 libc/src/math/frexpf80.h
create mode 100644 libc/src/math/generic/frexpf80.cpp
create mode 100644 libc/src/math/generic/ilogbf80.cpp
create mode 100644 libc/src/math/generic/llogbf80.cpp
create mode 100644 libc/src/math/generic/logbf80.cpp
create mode 100644 libc/src/math/ilogbf80.h
create mode 100644 libc/src/math/llogbf80.h
create mode 100644 libc/src/math/logbf80.h
create mode 100644 libc/test/src/math/smoke/frexpf80_test.cpp
create mode 100644 libc/test/src/math/smoke/ilogbf80_test.cpp
create mode 100644 libc/test/src/math/smoke/llogbf80_test.cpp
create mode 100644 libc/test/src/math/smoke/logbf80_test.cpp
diff --git a/do_commit_exp_decomp.py b/do_commit_exp_decomp.py
new file mode 100644
index 0000000000000..a040d61081d3e
--- /dev/null
+++ b/do_commit_exp_decomp.py
@@ -0,0 +1,31 @@
+import subprocess
+
+def run(cmd):
+ p = subprocess.run(cmd, cwd='c:/work/VM/llvm-project', capture_output=True, text=True, check=True)
+ return p.stdout.strip()
+
+run(['git', 'add', '-A'])
+tree = run(['git', 'write-tree'])
+print('Tree:', tree)
+
+parent = run(['git', 'rev-parse', 'HEAD'])
+print('Parent:', parent)
+
+author_name = run(['git', 'config', 'user.name'])
+author_email = run(['git', 'config', 'user.email'])
+print('Author:', author_name, author_email)
+
+msg = 'adds frexpf80, ilogbf80, llogbf80, logbf80'
+
+p = subprocess.run(
+ ['git', 'commit-tree', tree, '-p', parent, '-m', msg],
+ cwd='c:/work/VM/llvm-project',
+ capture_output=True,
+ text=True,
+ check=True
+)
+commit = p.stdout.strip()
+print('Commit:', commit)
+
+run(['git', 'update-ref', 'refs/heads/users/sukumarsawant/f80/exp_decomp', commit])
+print('Branch users/sukumarsawant/f80/exp_decomp updated successfully!')
diff --git a/libc/config/baremetal/aarch64/entrypoints.txt b/libc/config/baremetal/aarch64/entrypoints.txt
index 51a7e841be644..74db1c53279c7 100644
--- a/libc/config/baremetal/aarch64/entrypoints.txt
+++ b/libc/config/baremetal/aarch64/entrypoints.txt
@@ -801,6 +801,10 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
# math.h C23 _Float128 entrypoints
libc.src.math.canonicalizef128
libc.src.math.canonicalizef80
+ libc.src.math.frexpf80
+ libc.src.math.ilogbf80
+ libc.src.math.llogbf80
+ libc.src.math.logbf80
libc.src.math.daddf128
libc.src.math.ddivf128
libc.src.math.dfmaf128
diff --git a/libc/config/baremetal/arm/entrypoints.txt b/libc/config/baremetal/arm/entrypoints.txt
index 9dbf5b174f485..2d3ecbfcc9d17 100644
--- a/libc/config/baremetal/arm/entrypoints.txt
+++ b/libc/config/baremetal/arm/entrypoints.txt
@@ -812,6 +812,10 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
# math.h C23 _Float128 entrypoints
libc.src.math.canonicalizef128
libc.src.math.canonicalizef80
+ libc.src.math.frexpf80
+ libc.src.math.ilogbf80
+ libc.src.math.llogbf80
+ libc.src.math.logbf80
libc.src.math.daddf128
libc.src.math.ddivf128
libc.src.math.dfmaf128
diff --git a/libc/config/baremetal/hexagon/entrypoints.txt b/libc/config/baremetal/hexagon/entrypoints.txt
index 70770f335cea2..5420faf0a385b 100644
--- a/libc/config/baremetal/hexagon/entrypoints.txt
+++ b/libc/config/baremetal/hexagon/entrypoints.txt
@@ -756,6 +756,10 @@ if(LIBC_TYPES_HAS_FLOAT128)
libc.src.math.atan2f128
libc.src.math.canonicalizef128
libc.src.math.canonicalizef80
+ libc.src.math.frexpf80
+ libc.src.math.ilogbf80
+ libc.src.math.llogbf80
+ libc.src.math.logbf80
libc.src.math.ceilf128
libc.src.math.copysignf128
libc.src.math.daddf128
diff --git a/libc/config/baremetal/riscv/entrypoints.txt b/libc/config/baremetal/riscv/entrypoints.txt
index 50860421640ab..b288fa665d6db 100644
--- a/libc/config/baremetal/riscv/entrypoints.txt
+++ b/libc/config/baremetal/riscv/entrypoints.txt
@@ -804,6 +804,10 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
# math.h C23 _Float128 entrypoints
libc.src.math.canonicalizef128
libc.src.math.canonicalizef80
+ libc.src.math.frexpf80
+ libc.src.math.ilogbf80
+ libc.src.math.llogbf80
+ libc.src.math.logbf80
libc.src.math.daddf128
libc.src.math.ddivf128
libc.src.math.dfmaf128
diff --git a/libc/config/darwin/aarch64/entrypoints.txt b/libc/config/darwin/aarch64/entrypoints.txt
index d8f87db7b1dfd..02407658ad3a8 100644
--- a/libc/config/darwin/aarch64/entrypoints.txt
+++ b/libc/config/darwin/aarch64/entrypoints.txt
@@ -623,6 +623,10 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
# math.h C23 _Float128 entrypoints
libc.src.math.canonicalizef128
libc.src.math.canonicalizef80
+ libc.src.math.frexpf80
+ libc.src.math.ilogbf80
+ libc.src.math.llogbf80
+ libc.src.math.logbf80
libc.src.math.daddf128
libc.src.math.ddivf128
libc.src.math.dfmaf128
diff --git a/libc/config/darwin/x86_64/entrypoints.txt b/libc/config/darwin/x86_64/entrypoints.txt
index 2ed69d3132f66..eb5c2f3f10c68 100644
--- a/libc/config/darwin/x86_64/entrypoints.txt
+++ b/libc/config/darwin/x86_64/entrypoints.txt
@@ -307,6 +307,10 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
libc.src.math.bf16subl
libc.src.math.canonicalizebf16
libc.src.math.canonicalizef80
+ libc.src.math.frexpf80
+ libc.src.math.ilogbf80
+ libc.src.math.llogbf80
+ libc.src.math.logbf80
libc.src.math.ceilbf16
libc.src.math.copysignbf16
libc.src.math.exp2bf16
diff --git a/libc/config/freebsd/x86_64/entrypoints.txt b/libc/config/freebsd/x86_64/entrypoints.txt
index 58e01f56eb2e6..77433fcb58d54 100644
--- a/libc/config/freebsd/x86_64/entrypoints.txt
+++ b/libc/config/freebsd/x86_64/entrypoints.txt
@@ -556,6 +556,10 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
libc.src.math.atan2l
libc.src.math.canonicalizef128
libc.src.math.canonicalizef80
+ libc.src.math.frexpf80
+ libc.src.math.ilogbf80
+ libc.src.math.llogbf80
+ libc.src.math.logbf80
libc.src.math.daddf128
libc.src.math.ddivf128
libc.src.math.dfmaf128
diff --git a/libc/config/gpu/amdgpu/entrypoints.txt b/libc/config/gpu/amdgpu/entrypoints.txt
index 89f406302063f..3baa336b23caf 100644
--- a/libc/config/gpu/amdgpu/entrypoints.txt
+++ b/libc/config/gpu/amdgpu/entrypoints.txt
@@ -319,6 +319,10 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.canonicalizef
libc.src.math.canonicalizel
libc.src.math.canonicalizef80
+ libc.src.math.frexpf80
+ libc.src.math.ilogbf80
+ libc.src.math.llogbf80
+ libc.src.math.logbf80
libc.src.math.cbrt
libc.src.math.cbrtf
libc.src.math.cbrtbf16
diff --git a/libc/config/gpu/nvptx/entrypoints.txt b/libc/config/gpu/nvptx/entrypoints.txt
index d4711b17cdc86..fdb09b0de2391 100644
--- a/libc/config/gpu/nvptx/entrypoints.txt
+++ b/libc/config/gpu/nvptx/entrypoints.txt
@@ -315,6 +315,10 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.canonicalizef
libc.src.math.canonicalizel
libc.src.math.canonicalizef80
+ libc.src.math.frexpf80
+ libc.src.math.ilogbf80
+ libc.src.math.llogbf80
+ libc.src.math.logbf80
libc.src.math.cbrt
libc.src.math.cbrtf
libc.src.math.cbrtbf16
diff --git a/libc/config/linux/aarch64/entrypoints.txt b/libc/config/linux/aarch64/entrypoints.txt
index f8ec339978c09..67876ec77d165 100644
--- a/libc/config/linux/aarch64/entrypoints.txt
+++ b/libc/config/linux/aarch64/entrypoints.txt
@@ -1038,6 +1038,10 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
# math.h C23 _Float128 entrypoints
libc.src.math.canonicalizef128
libc.src.math.canonicalizef80
+ libc.src.math.frexpf80
+ libc.src.math.ilogbf80
+ libc.src.math.llogbf80
+ libc.src.math.logbf80
libc.src.math.daddf128
libc.src.math.ddivf128
libc.src.math.dfmaf128
diff --git a/libc/config/linux/arm/entrypoints.txt b/libc/config/linux/arm/entrypoints.txt
index 4ecc4fb107c43..482ceb1a25c77 100644
--- a/libc/config/linux/arm/entrypoints.txt
+++ b/libc/config/linux/arm/entrypoints.txt
@@ -699,6 +699,10 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
libc.src.math.bf16subl
libc.src.math.canonicalizebf16
libc.src.math.canonicalizef80
+ libc.src.math.frexpf80
+ libc.src.math.ilogbf80
+ libc.src.math.llogbf80
+ libc.src.math.logbf80
libc.src.math.ceilbf16
libc.src.math.copysignbf16
libc.src.math.exp2bf16
diff --git a/libc/config/linux/riscv/entrypoints.txt b/libc/config/linux/riscv/entrypoints.txt
index 3282e0963429a..db899add1e2c8 100644
--- a/libc/config/linux/riscv/entrypoints.txt
+++ b/libc/config/linux/riscv/entrypoints.txt
@@ -1118,6 +1118,10 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
libc.src.math.atan2l
libc.src.math.canonicalizef128
libc.src.math.canonicalizef80
+ libc.src.math.frexpf80
+ libc.src.math.ilogbf80
+ libc.src.math.llogbf80
+ libc.src.math.logbf80
libc.src.math.daddf128
libc.src.math.ddivf128
libc.src.math.dfmaf128
diff --git a/libc/config/linux/x86_64/entrypoints.txt b/libc/config/linux/x86_64/entrypoints.txt
index f98111980f480..ab315d2df94a9 100644
--- a/libc/config/linux/x86_64/entrypoints.txt
+++ b/libc/config/linux/x86_64/entrypoints.txt
@@ -1140,6 +1140,10 @@ if(LIBC_TYPES_HAS_NATIVE_FLOAT128)
libc.src.math.atan2l
libc.src.math.canonicalizef128
libc.src.math.canonicalizef80
+ libc.src.math.frexpf80
+ libc.src.math.ilogbf80
+ libc.src.math.llogbf80
+ libc.src.math.logbf80
libc.src.math.daddf128
libc.src.math.ddivf128
libc.src.math.dfmaf128
diff --git a/libc/config/windows/entrypoints.txt b/libc/config/windows/entrypoints.txt
index 11c9a454e69a1..1ce9264d7fd3d 100644
--- a/libc/config/windows/entrypoints.txt
+++ b/libc/config/windows/entrypoints.txt
@@ -406,6 +406,10 @@ list(APPEND TARGET_LIBM_ENTRYPOINTS
libc.src.math.bf16subl
libc.src.math.canonicalizebf16
libc.src.math.canonicalizef80
+ libc.src.math.frexpf80
+ libc.src.math.ilogbf80
+ libc.src.math.llogbf80
+ libc.src.math.logbf80
libc.src.math.ceilbf16
libc.src.math.copysignbf16
libc.src.math.exp2bf16
diff --git a/libc/docs/headers/math/index.md b/libc/docs/headers/math/index.md
index 897e6d3186949..4dee94e517fd7 100644
--- a/libc/docs/headers/math/index.md
+++ b/libc/docs/headers/math/index.md
@@ -125,19 +125,19 @@ log
| fminimum_num | {{ check }} | {{ check }} | {{ check }} | | {{ check }} | {{ check }} | {{ check }} | 7.12.12.9 | F.10.9.5 |
| fmod | {{ check }} | {{ check }} | | | {{ check }} | {{ check }} | {{ check }} | 7.12.10.1 | F.10.7.1 |
| fmul | N/A | {{ check }} | | | N/A | {{ check }}\* | N/A | 7.12.14.3 | F.10.11 |
-| frexp | {{ check }} | {{ check }} | | | {{ check }} | {{ check }} | {{ check }} | 7.12.6.7 | F.10.3.7 |
+| frexp | {{ check }} | {{ check }} | {{ check }} | | {{ check }} | {{ check }} | {{ check }} | 7.12.6.7 | F.10.3.7 |
| fromfp | {{ check }} | {{ check }} | | | {{ check }} | {{ check }} | {{ check }} | 7.12.9.10 | F.10.6.10 |
| fromfpx | {{ check }} | {{ check }} | | | {{ check }} | {{ check }} | {{ check }} | 7.12.9.11 | F.10.6.11 |
| fsub | N/A | {{ check }} | | | N/A | {{ check }}\* | N/A | 7.12.14.2 | F.10.11 |
| getpayload | {{ check }} | {{ check }} | | | {{ check }} | {{ check }} | {{ check }} | F.10.13.1 | N/A |
-| ilogb | {{ check }} | {{ check }} | | | {{ check }} | {{ check }} | {{ check }} | 7.12.6.8 | F.10.3.8 |
+| ilogb | {{ check }} | {{ check }} | {{ check }} | | {{ check }} | {{ check }} | {{ check }} | 7.12.6.8 | F.10.3.8 |
| iscanonical | {{ check }} | {{ check }} | {{ check }} | | {{ check }} | {{ check }} | {{ check }} | 7.12.3.2 | N/A |
| issignaling | {{ check }} | {{ check }} | {{ check }} | | {{ check }} | {{ check }} | {{ check }} | 7.12.3.8 | N/A |
| ldexp | {{ check }} | {{ check }} | | | {{ check }} | {{ check }} | {{ check }} | 7.12.6.9 | F.10.3.9 |
-| llogb | {{ check }} | {{ check }} | | | {{ check }} | {{ check }} | {{ check }} | 7.12.6.10 | F.10.3.10 |
+| llogb | {{ check }} | {{ check }} | {{ check }} | | {{ check }} | {{ check }} | {{ check }} | 7.12.6.10 | F.10.3.10 |
| llrint | {{ check }} | {{ check }} | | | {{ check }} | {{ check }} | {{ check }} | 7.12.9.5 | F.10.6.5 |
| llround | {{ check }} | {{ check }} | | | {{ check }} | {{ check }} | {{ check }} | 7.12.9.7 | F.10.6.7 |
-| logb | {{ check }} | {{ check }} | | | {{ check }} | {{ check }} | {{ check }} | 7.12.6.17 | F.10.3.17 |
+| logb | {{ check }} | {{ check }} | {{ check }} | | {{ check }} | {{ check }} | {{ check }} | 7.12.6.17 | F.10.3.17 |
| lrint | {{ check }} | {{ check }} | | | {{ check }} | {{ check }} | {{ check }} | 7.12.9.5 | F.10.6.5 |
| lround | {{ check }} | {{ check }} | | | {{ check }} | {{ check }} | {{ check }} | 7.12.9.7 | F.10.6.7 |
| modf | {{ check }} | {{ check }} | | | {{ check }} | {{ check }} | {{ check }} | 7.12.6.18 | F.10.3.18 |
diff --git a/libc/shared/math.h b/libc/shared/math.h
index 1bf0723ff44d1..21d79cea896d9 100644
--- a/libc/shared/math.h
+++ b/libc/shared/math.h
@@ -265,6 +265,7 @@
#include "math/frexpf.h"
#include "math/frexpf128.h"
#include "math/frexpf16.h"
+#include "math/frexpf80.h"
#include "math/frexpl.h"
#include "math/fromfp.h"
#include "math/fromfpbf16.h"
@@ -299,6 +300,7 @@
#include "math/ilogbf.h"
#include "math/ilogbf128.h"
#include "math/ilogbf16.h"
+#include "math/ilogbf80.h"
#include "math/ilogbl.h"
// TODO: iscanonical is a macro in <math.h>
// #include "math/iscanonical.h"
@@ -336,6 +338,7 @@
#include "math/llogbf.h"
#include "math/llogbf128.h"
#include "math/llogbf16.h"
+#include "math/llogbf80.h"
#include "math/llogbl.h"
#include "math/llrint.h"
#include "math/llrintbf16.h"
@@ -366,6 +369,7 @@
#include "math/logbf.h"
#include "math/logbf128.h"
#include "math/logbf16.h"
+#include "math/logbf80.h"
#include "math/logbl.h"
#include "math/logf.h"
#include "math/logf16.h"
diff --git a/libc/shared/math/frexpf80.h b/libc/shared/math/frexpf80.h
new file mode 100644
index 0000000000000..160f712020e17
--- /dev/null
+++ b/libc/shared/math/frexpf80.h
@@ -0,0 +1,24 @@
+//===-- Shared header for frexpf80 ------------------------------*- 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
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SHARED_MATH_FREXPF80_H
+#define LLVM_LIBC_SHARED_MATH_FREXPF80_H
+
+#include "src/__support/math/frexpf80.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+namespace shared {
+
+using math::frexpf80;
+
+} // namespace shared
+
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SHARED_MATH_FREXPF80_H
diff --git a/libc/shared/math/ilogbf80.h b/libc/shared/math/ilogbf80.h
new file mode 100644
index 0000000000000..cae9508e3ba5f
--- /dev/null
+++ b/libc/shared/math/ilogbf80.h
@@ -0,0 +1,24 @@
+//===-- Shared header for ilogbf80 ------------------------------*- 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
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SHARED_MATH_ILOGBF80_H
+#define LLVM_LIBC_SHARED_MATH_ILOGBF80_H
+
+#include "src/__support/math/ilogbf80.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+namespace shared {
+
+using math::ilogbf80;
+
+} // namespace shared
+
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SHARED_MATH_ILOGBF80_H
diff --git a/libc/shared/math/llogbf80.h b/libc/shared/math/llogbf80.h
new file mode 100644
index 0000000000000..e61fc3162e499
--- /dev/null
+++ b/libc/shared/math/llogbf80.h
@@ -0,0 +1,24 @@
+//===-- Shared header for llogbf80 ------------------------------*- 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
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SHARED_MATH_LLOGBF80_H
+#define LLVM_LIBC_SHARED_MATH_LLOGBF80_H
+
+#include "src/__support/math/llogbf80.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+namespace shared {
+
+using math::llogbf80;
+
+} // namespace shared
+
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SHARED_MATH_LLOGBF80_H
diff --git a/libc/shared/math/logbf80.h b/libc/shared/math/logbf80.h
new file mode 100644
index 0000000000000..74d9aea70dec0
--- /dev/null
+++ b/libc/shared/math/logbf80.h
@@ -0,0 +1,24 @@
+//===-- Shared header for logbf80 -------------------------------*- 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
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SHARED_MATH_LOGBF80_H
+#define LLVM_LIBC_SHARED_MATH_LOGBF80_H
+
+#include "src/__support/math/logbf80.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+namespace shared {
+
+using math::logbf80;
+
+} // namespace shared
+
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SHARED_MATH_LOGBF80_H
diff --git a/libc/src/__support/math/CMakeLists.txt b/libc/src/__support/math/CMakeLists.txt
index e96433f83d153..58e5400254cff 100644
--- a/libc/src/__support/math/CMakeLists.txt
+++ b/libc/src/__support/math/CMakeLists.txt
@@ -4165,6 +4165,16 @@ add_header_library(
libc.src.__support.FPUtil.manipulation_functions
)
+add_header_library(
+ frexpf80
+ HDRS
+ frexpf80.h
+ DEPENDS
+ libc.src.__support.macros.config
+ libc.src.__support.macros.properties.types
+ libc.src.__support.FPUtil.manipulation_functions
+)
+
add_header_library(
frexpf
HDRS
@@ -4246,6 +4256,16 @@ add_header_library(
libc.include.llvm-libc-macros.float16_macros
)
+add_header_library(
+ ilogbf80
+ HDRS
+ ilogbf80.h
+ DEPENDS
+ libc.src.__support.macros.config
+ libc.src.__support.macros.properties.types
+ libc.src.__support.FPUtil.manipulation_functions
+)
+
add_header_library(
ilogbf128
HDRS
@@ -4308,6 +4328,16 @@ add_header_library(
libc.include.llvm-libc-macros.float16_macros
)
+add_header_library(
+ llogbf80
+ HDRS
+ llogbf80.h
+ DEPENDS
+ libc.src.__support.macros.config
+ libc.src.__support.macros.properties.types
+ libc.src.__support.FPUtil.manipulation_functions
+)
+
add_header_library(
ilogbf
HDRS
@@ -5649,6 +5679,16 @@ add_header_library(
libc.src.__support.macros.properties.types
)
+add_header_library(
+ logbf80
+ HDRS
+ logbf80.h
+ DEPENDS
+ libc.src.__support.macros.config
+ libc.src.__support.macros.properties.types
+ libc.src.__support.FPUtil.manipulation_functions
+)
+
add_header_library(
logbf
HDRS
diff --git a/libc/src/__support/math/frexpf80.h b/libc/src/__support/math/frexpf80.h
new file mode 100644
index 0000000000000..3c8fab1be8753
--- /dev/null
+++ b/libc/src/__support/math/frexpf80.h
@@ -0,0 +1,29 @@
+//===-- Implementation header for frexpf80 ----------------------*- 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
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC___SUPPORT_MATH_FREXPF80_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_FREXPF80_H
+
+#include "src/__support/FPUtil/ManipulationFunctions.h"
+#include "src/__support/common.h"
+#include "src/__support/macros/config.h"
+#include "src/__support/macros/properties/types.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+namespace math {
+
+LIBC_INLINE constexpr Float80 frexpf80(Float80 x, int *exp) {
+ return fputil::frexp(x, *exp);
+}
+
+} // namespace math
+
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC___SUPPORT_MATH_FREXPF80_H
diff --git a/libc/src/__support/math/ilogbf80.h b/libc/src/__support/math/ilogbf80.h
new file mode 100644
index 0000000000000..34977245c0346
--- /dev/null
+++ b/libc/src/__support/math/ilogbf80.h
@@ -0,0 +1,29 @@
+//===-- Implementation header for ilogbf80 ----------------------*- 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
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC___SUPPORT_MATH_ILOGBF80_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_ILOGBF80_H
+
+#include "src/__support/FPUtil/ManipulationFunctions.h"
+#include "src/__support/common.h"
+#include "src/__support/macros/config.h"
+#include "src/__support/macros/properties/types.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+namespace math {
+
+LIBC_INLINE constexpr int ilogbf80(Float80 x) {
+ return fputil::intlogb<int>(x);
+}
+
+} // namespace math
+
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC___SUPPORT_MATH_ILOGBF80_H
diff --git a/libc/src/__support/math/llogbf80.h b/libc/src/__support/math/llogbf80.h
new file mode 100644
index 0000000000000..68dfcb425a086
--- /dev/null
+++ b/libc/src/__support/math/llogbf80.h
@@ -0,0 +1,29 @@
+//===-- Implementation header for llogbf80 ----------------------*- 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
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC___SUPPORT_MATH_LLOGBF80_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_LLOGBF80_H
+
+#include "src/__support/FPUtil/ManipulationFunctions.h"
+#include "src/__support/common.h"
+#include "src/__support/macros/config.h"
+#include "src/__support/macros/properties/types.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+namespace math {
+
+LIBC_INLINE constexpr long llogbf80(Float80 x) {
+ return fputil::intlogb<long>(x);
+}
+
+} // namespace math
+
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC___SUPPORT_MATH_LLOGBF80_H
diff --git a/libc/src/__support/math/logbf80.h b/libc/src/__support/math/logbf80.h
new file mode 100644
index 0000000000000..4a967f0c830ac
--- /dev/null
+++ b/libc/src/__support/math/logbf80.h
@@ -0,0 +1,29 @@
+//===-- Implementation header for logbf80 -----------------------*- 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
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC___SUPPORT_MATH_LOGBF80_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_LOGBF80_H
+
+#include "src/__support/FPUtil/ManipulationFunctions.h"
+#include "src/__support/common.h"
+#include "src/__support/macros/config.h"
+#include "src/__support/macros/properties/types.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+namespace math {
+
+LIBC_INLINE constexpr Float80 logbf80(Float80 x) {
+ return fputil::logb(x);
+}
+
+} // namespace math
+
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC___SUPPORT_MATH_LOGBF80_H
diff --git a/libc/src/math/CMakeLists.txt b/libc/src/math/CMakeLists.txt
index d642038357981..24f0955999fbd 100644
--- a/libc/src/math/CMakeLists.txt
+++ b/libc/src/math/CMakeLists.txt
@@ -344,6 +344,7 @@ add_math_entrypoint_object(frexp)
add_math_entrypoint_object(frexpf)
add_math_entrypoint_object(frexpl)
add_math_entrypoint_object(frexpf16)
+add_math_entrypoint_object(frexpf80)
add_math_entrypoint_object(frexpf128)
add_math_entrypoint_object(frexpbf16)
@@ -381,6 +382,7 @@ add_math_entrypoint_object(ilogb)
add_math_entrypoint_object(ilogbf)
add_math_entrypoint_object(ilogbl)
add_math_entrypoint_object(ilogbf16)
+add_math_entrypoint_object(ilogbf80)
add_math_entrypoint_object(ilogbf128)
add_math_entrypoint_object(ilogbbf16)
@@ -406,6 +408,7 @@ add_math_entrypoint_object(llogb)
add_math_entrypoint_object(llogbf)
add_math_entrypoint_object(llogbl)
add_math_entrypoint_object(llogbf16)
+add_math_entrypoint_object(llogbf80)
add_math_entrypoint_object(llogbf128)
add_math_entrypoint_object(llogbbf16)
@@ -438,6 +441,7 @@ add_math_entrypoint_object(logb)
add_math_entrypoint_object(logbf)
add_math_entrypoint_object(logbl)
add_math_entrypoint_object(logbf16)
+add_math_entrypoint_object(logbf80)
add_math_entrypoint_object(logbf128)
add_math_entrypoint_object(logbbf16)
diff --git a/libc/src/math/frexpf80.h b/libc/src/math/frexpf80.h
new file mode 100644
index 0000000000000..671b093990c6f
--- /dev/null
+++ b/libc/src/math/frexpf80.h
@@ -0,0 +1,21 @@
+//===-- Implementation header for frexpf80 ----------------------*- 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
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC_MATH_FREXPF80_H
+#define LLVM_LIBC_SRC_MATH_FREXPF80_H
+
+#include "src/__support/macros/config.h"
+#include "src/__support/macros/properties/types.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+float80 frexpf80(float80 x, int *exp);
+
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC_MATH_FREXPF80_H
diff --git a/libc/src/math/generic/CMakeLists.txt b/libc/src/math/generic/CMakeLists.txt
index 72e6967363566..fcdbe7cef1273 100644
--- a/libc/src/math/generic/CMakeLists.txt
+++ b/libc/src/math/generic/CMakeLists.txt
@@ -1557,6 +1557,17 @@ add_entrypoint_object(
libc.src.__support.math.frexpf16
)
+add_entrypoint_object(
+ frexpf80
+ SRCS
+ frexpf80.cpp
+ HDRS
+ ../frexpf80.h
+ DEPENDS
+ libc.src.__support.CPP.bit
+ libc.src.__support.math.frexpf80
+)
+
add_entrypoint_object(
frexpf128
SRCS
@@ -1618,6 +1629,17 @@ add_entrypoint_object(
libc.src.__support.math.ilogbf16
)
+add_entrypoint_object(
+ ilogbf80
+ SRCS
+ ilogbf80.cpp
+ HDRS
+ ../ilogbf80.h
+ DEPENDS
+ libc.src.__support.CPP.bit
+ libc.src.__support.math.ilogbf80
+)
+
add_entrypoint_object(
ilogbf128
SRCS
@@ -1703,6 +1725,17 @@ add_entrypoint_object(
libc.src.__support.math.llogbf16
)
+add_entrypoint_object(
+ llogbf80
+ SRCS
+ llogbf80.cpp
+ HDRS
+ ../llogbf80.h
+ DEPENDS
+ libc.src.__support.CPP.bit
+ libc.src.__support.math.llogbf80
+)
+
add_entrypoint_object(
llogbf128
SRCS
@@ -1965,6 +1998,17 @@ add_entrypoint_object(
libc.src.__support.math.logbf16
)
+add_entrypoint_object(
+ logbf80
+ SRCS
+ logbf80.cpp
+ HDRS
+ ../logbf80.h
+ DEPENDS
+ libc.src.__support.CPP.bit
+ libc.src.__support.math.logbf80
+)
+
add_entrypoint_object(
logbf128
SRCS
diff --git a/libc/src/math/generic/frexpf80.cpp b/libc/src/math/generic/frexpf80.cpp
new file mode 100644
index 0000000000000..47793ba18d7cf
--- /dev/null
+++ b/libc/src/math/generic/frexpf80.cpp
@@ -0,0 +1,22 @@
+//===-- Implementation of frexpf80 function -------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "src/math/frexpf80.h"
+#include "src/__support/CPP/bit.h"
+#include "src/__support/common.h"
+#include "src/__support/macros/config.h"
+#include "src/__support/math/frexpf80.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+LLVM_LIBC_FUNCTION(float80, frexpf80, (float80 x, int *exp)) {
+ return cpp::bit_cast<float80>(
+ math::frexpf80(cpp::bit_cast<Float80>(x), exp));
+}
+
+} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/ilogbf80.cpp b/libc/src/math/generic/ilogbf80.cpp
new file mode 100644
index 0000000000000..f31a6d81ebf5c
--- /dev/null
+++ b/libc/src/math/generic/ilogbf80.cpp
@@ -0,0 +1,21 @@
+//===-- Implementation of ilogbf80 function -------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "src/math/ilogbf80.h"
+#include "src/__support/CPP/bit.h"
+#include "src/__support/common.h"
+#include "src/__support/macros/config.h"
+#include "src/__support/math/ilogbf80.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+LLVM_LIBC_FUNCTION(int, ilogbf80, (float80 x)) {
+ return math::ilogbf80(cpp::bit_cast<Float80>(x));
+}
+
+} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/llogbf80.cpp b/libc/src/math/generic/llogbf80.cpp
new file mode 100644
index 0000000000000..ab13954344113
--- /dev/null
+++ b/libc/src/math/generic/llogbf80.cpp
@@ -0,0 +1,21 @@
+//===-- Implementation of llogbf80 function -------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "src/math/llogbf80.h"
+#include "src/__support/CPP/bit.h"
+#include "src/__support/common.h"
+#include "src/__support/macros/config.h"
+#include "src/__support/math/llogbf80.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+LLVM_LIBC_FUNCTION(long, llogbf80, (float80 x)) {
+ return math::llogbf80(cpp::bit_cast<Float80>(x));
+}
+
+} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/logbf80.cpp b/libc/src/math/generic/logbf80.cpp
new file mode 100644
index 0000000000000..44e401b7b9cb8
--- /dev/null
+++ b/libc/src/math/generic/logbf80.cpp
@@ -0,0 +1,22 @@
+//===-- Implementation of logbf80 function --------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "src/math/logbf80.h"
+#include "src/__support/CPP/bit.h"
+#include "src/__support/common.h"
+#include "src/__support/macros/config.h"
+#include "src/__support/math/logbf80.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+LLVM_LIBC_FUNCTION(float80, logbf80, (float80 x)) {
+ return cpp::bit_cast<float80>(
+ math::logbf80(cpp::bit_cast<Float80>(x)));
+}
+
+} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/ilogbf80.h b/libc/src/math/ilogbf80.h
new file mode 100644
index 0000000000000..8e2ab8c7e946e
--- /dev/null
+++ b/libc/src/math/ilogbf80.h
@@ -0,0 +1,21 @@
+//===-- Implementation header for ilogbf80 ----------------------*- 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
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC_MATH_ILOGBF80_H
+#define LLVM_LIBC_SRC_MATH_ILOGBF80_H
+
+#include "src/__support/macros/config.h"
+#include "src/__support/macros/properties/types.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+int ilogbf80(float80 x);
+
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC_MATH_ILOGBF80_H
diff --git a/libc/src/math/llogbf80.h b/libc/src/math/llogbf80.h
new file mode 100644
index 0000000000000..0ed78b63108f2
--- /dev/null
+++ b/libc/src/math/llogbf80.h
@@ -0,0 +1,21 @@
+//===-- Implementation header for llogbf80 ----------------------*- 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
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC_MATH_LLOGBF80_H
+#define LLVM_LIBC_SRC_MATH_LLOGBF80_H
+
+#include "src/__support/macros/config.h"
+#include "src/__support/macros/properties/types.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+long llogbf80(float80 x);
+
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC_MATH_LLOGBF80_H
diff --git a/libc/src/math/logbf80.h b/libc/src/math/logbf80.h
new file mode 100644
index 0000000000000..66e30feee6cee
--- /dev/null
+++ b/libc/src/math/logbf80.h
@@ -0,0 +1,21 @@
+//===-- Implementation header for logbf80 -----------------------*- 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
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC_MATH_LOGBF80_H
+#define LLVM_LIBC_SRC_MATH_LOGBF80_H
+
+#include "src/__support/macros/config.h"
+#include "src/__support/macros/properties/types.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+float80 logbf80(float80 x);
+
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC_MATH_LOGBF80_H
diff --git a/libc/test/shared/CMakeLists.txt b/libc/test/shared/CMakeLists.txt
index 88e3d044dc554..0ae62328ae0cf 100644
--- a/libc/test/shared/CMakeLists.txt
+++ b/libc/test/shared/CMakeLists.txt
@@ -80,6 +80,10 @@ else()
libc.src.__support.math.canonicalizef
libc.src.__support.math.canonicalizef128
libc.src.__support.math.canonicalizef80
+ libc.src.__support.math.frexpf80
+ libc.src.__support.math.ilogbf80
+ libc.src.__support.math.llogbf80
+ libc.src.__support.math.logbf80
libc.src.__support.math.canonicalizef16
libc.src.__support.math.canonicalizel
libc.src.__support.math.cbrt
@@ -567,6 +571,10 @@ else()
libc.src.__support.math.canonicalizef
libc.src.__support.math.canonicalizef128
libc.src.__support.math.canonicalizef80
+ libc.src.__support.math.frexpf80
+ libc.src.__support.math.ilogbf80
+ libc.src.__support.math.llogbf80
+ libc.src.__support.math.logbf80
libc.src.__support.math.canonicalizef16
libc.src.__support.math.canonicalizel
libc.src.__support.math.ceil
diff --git a/libc/test/shared/shared_math_constexpr_test.cpp b/libc/test/shared/shared_math_constexpr_test.cpp
index 4543e4e5f785f..19d02d6584034 100644
--- a/libc/test/shared/shared_math_constexpr_test.cpp
+++ b/libc/test/shared/shared_math_constexpr_test.cpp
@@ -461,6 +461,13 @@ static_assert(0 == [] {
Float80 x(0.0);
return LIBC_NAMESPACE::shared::canonicalizef80(&cx, &x);
}());
+static_assert(Float80(0.0) == [] {
+ int exp = 0;
+ return LIBC_NAMESPACE::shared::frexpf80(Float80(0.0), &exp);
+}());
+static_assert(0 == LIBC_NAMESPACE::shared::ilogbf80(Float80(1.0)));
+static_assert(0L == LIBC_NAMESPACE::shared::llogbf80(Float80(1.0)));
+static_assert(Float80(0.0) == LIBC_NAMESPACE::shared::logbf80(Float80(1.0)));
static_assert(Float128(1.0) ==
LIBC_NAMESPACE::shared::fdimf128(Float128(1.0), 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 8e1d98ee2a008..06226976ffc26 100644
--- a/libc/test/shared/shared_math_test.cpp
+++ b/libc/test/shared/shared_math_test.cpp
@@ -721,6 +721,13 @@ TEST(LlvmLibcSharedMathTest, AllFloat80) {
Float80 canonicalizef80_x = Float80(0.0);
EXPECT_EQ(0, LIBC_NAMESPACE::shared::canonicalizef80(&canonicalizef80_cx,
&canonicalizef80_x));
+ int frexpf80_exp = 0;
+ EXPECT_FP_EQ(Float80(0.0),
+ LIBC_NAMESPACE::shared::frexpf80(Float80(0.0), &frexpf80_exp));
+ EXPECT_EQ(frexpf80_exp, 0);
+ EXPECT_EQ(0, LIBC_NAMESPACE::shared::ilogbf80(Float80(1.0)));
+ EXPECT_EQ(0L, LIBC_NAMESPACE::shared::llogbf80(Float80(1.0)));
+ EXPECT_FP_EQ(Float80(0.0), LIBC_NAMESPACE::shared::logbf80(Float80(1.0)));
}
#ifdef LIBC_TYPES_HAS_NATIVE_FLOAT128
diff --git a/libc/test/src/math/smoke/CMakeLists.txt b/libc/test/src/math/smoke/CMakeLists.txt
index a206d328ceb35..a482d101bad65 100644
--- a/libc/test/src/math/smoke/CMakeLists.txt
+++ b/libc/test/src/math/smoke/CMakeLists.txt
@@ -1799,6 +1799,18 @@ add_fp_unittest(
libc.src.math.frexpf16
)
+add_fp_unittest(
+ frexpf80_test
+ SUITE
+ libc-math-smoke-tests
+ SRCS
+ frexpf80_test.cpp
+ HDRS
+ FrexpTest.h
+ DEPENDS
+ libc.src.math.frexpf80
+)
+
add_fp_unittest(
frexpf128_test
SUITE
diff --git a/libc/test/src/math/smoke/frexpf80_test.cpp b/libc/test/src/math/smoke/frexpf80_test.cpp
new file mode 100644
index 0000000000000..ec821b5e2be0c
--- /dev/null
+++ b/libc/test/src/math/smoke/frexpf80_test.cpp
@@ -0,0 +1,13 @@
+//===-- Unittests for frexpf80 --------------------------------------------===//
+//
+// 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 "FrexpTest.h"
+
+#include "src/math/frexpf80.h"
+
+LIST_FREXP_TESTS(Frexpf80, Float80, LIBC_NAMESPACE::frexpf80);
diff --git a/libc/test/src/math/smoke/ilogbf80_test.cpp b/libc/test/src/math/smoke/ilogbf80_test.cpp
new file mode 100644
index 0000000000000..cffdd5b3d3780
--- /dev/null
+++ b/libc/test/src/math/smoke/ilogbf80_test.cpp
@@ -0,0 +1,13 @@
+//===-- Unittests for ilogbf80 --------------------------------------------===//
+//
+// 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 "ILogbTest.h"
+
+#include "src/math/ilogbf80.h"
+
+LIST_INTLOGB_TESTS(Ilogbf80, int, Float80, LIBC_NAMESPACE::ilogbf80);
diff --git a/libc/test/src/math/smoke/llogbf80_test.cpp b/libc/test/src/math/smoke/llogbf80_test.cpp
new file mode 100644
index 0000000000000..9aa9880a6e4da
--- /dev/null
+++ b/libc/test/src/math/smoke/llogbf80_test.cpp
@@ -0,0 +1,13 @@
+//===-- Unittests for llogbf80 --------------------------------------------===//
+//
+// 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 "ILogbTest.h"
+
+#include "src/math/llogbf80.h"
+
+LIST_INTLOGB_TESTS(Llogbf80, long, Float80, LIBC_NAMESPACE::llogbf80);
diff --git a/libc/test/src/math/smoke/logbf80_test.cpp b/libc/test/src/math/smoke/logbf80_test.cpp
new file mode 100644
index 0000000000000..409a92f0c1c01
--- /dev/null
+++ b/libc/test/src/math/smoke/logbf80_test.cpp
@@ -0,0 +1,13 @@
+//===-- Unittests for logbf80 ---------------------------------------------===//
+//
+// 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/math/logbf80.h"
+
+LIST_LOGB_TESTS(Logbf80, Float80, LIBC_NAMESPACE::logbf80)
diff --git a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
index a3111da849026..8fad6854fa9cf 100644
--- a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
@@ -10482,6 +10482,18 @@ libc_support_library(
],
)
+libc_support_library(
+ name = "__support_math_frexpf80",
+ hdrs = ["src/__support/math/frexpf80.h"],
+ deps = [
+ ":__support_common",
+ ":__support_fputil_float80",
+ ":__support_fputil_manipulation_functions",
+ ":__support_macros_config",
+ ":__support_macros_properties_types",
+ ],
+)
+
libc_support_library(
name = "__support_math_frexpf16",
hdrs = ["src/__support/math/frexpf16.h"],
@@ -10514,6 +10526,18 @@ libc_support_library(
],
)
+libc_support_library(
+ name = "__support_math_ilogbf80",
+ hdrs = ["src/__support/math/ilogbf80.h"],
+ deps = [
+ ":__support_common",
+ ":__support_fputil_float80",
+ ":__support_fputil_manipulation_functions",
+ ":__support_macros_config",
+ ":__support_macros_properties_types",
+ ],
+)
+
libc_support_library(
name = "__support_math_ilogbf16",
hdrs = ["src/__support/math/ilogbf16.h"],
@@ -10877,6 +10901,18 @@ libc_support_library(
],
)
+libc_support_library(
+ name = "__support_math_llogbf80",
+ hdrs = ["src/__support/math/llogbf80.h"],
+ deps = [
+ ":__support_common",
+ ":__support_fputil_float80",
+ ":__support_fputil_manipulation_functions",
+ ":__support_macros_config",
+ ":__support_macros_properties_types",
+ ],
+)
+
libc_support_library(
name = "__support_math_llogbf16",
hdrs = ["src/__support/math/llogbf16.h"],
@@ -11164,6 +11200,18 @@ libc_support_library(
],
)
+libc_support_library(
+ name = "__support_math_logbf80",
+ hdrs = ["src/__support/math/logbf80.h"],
+ deps = [
+ ":__support_common",
+ ":__support_fputil_float80",
+ ":__support_fputil_manipulation_functions",
+ ":__support_macros_config",
+ ":__support_macros_properties_types",
+ ],
+)
+
libc_support_library(
name = "__support_math_logbf16",
hdrs = ["src/__support/math/logbf16.h"],
@@ -14993,6 +15041,15 @@ libc_math_function(
],
)
+libc_math_function(
+ name = "frexpf80",
+ additional_deps = [
+ ":__support_cpp_bit",
+ ":__support_fputil_float80",
+ ":__support_math_frexpf80",
+ ],
+)
+
libc_math_function(
name = "frexpf16",
additional_deps = [
@@ -15204,6 +15261,15 @@ libc_math_function(
],
)
+libc_math_function(
+ name = "ilogbf80",
+ additional_deps = [
+ ":__support_cpp_bit",
+ ":__support_fputil_float80",
+ ":__support_math_ilogbf80",
+ ],
+)
+
libc_math_function(
name = "ilogbf16",
additional_deps = [
@@ -15300,6 +15366,15 @@ libc_math_function(
],
)
+libc_math_function(
+ name = "llogbf80",
+ additional_deps = [
+ ":__support_cpp_bit",
+ ":__support_fputil_float80",
+ ":__support_math_llogbf80",
+ ],
+)
+
libc_math_function(
name = "llogbf16",
additional_deps = [
@@ -15509,6 +15584,15 @@ libc_math_function(
],
)
+libc_math_function(
+ name = "logbf80",
+ additional_deps = [
+ ":__support_cpp_bit",
+ ":__support_fputil_float80",
+ ":__support_math_logbf80",
+ ],
+)
+
libc_math_function(
name = "logbf16",
additional_deps = [
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 56f48fd31598d..067c9ea7bec17 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
@@ -1346,6 +1346,14 @@ math_test(
],
)
+math_test(
+ name = "frexpf80",
+ hdrs = ["FrexpTest.h"],
+ deps = [
+ "//libc:__support_fputil_float80",
+ ],
+)
+
math_test(
name = "frexpf16",
hdrs = ["FrexpTest.h"],
>From 0c739ad1b099af9219f0e23e22bf5bf716eae62d Mon Sep 17 00:00:00 2001
From: Sukumarsawant <sawantsukumar at gmail.com>
Date: Wed, 4 Nov 2026 12:03:36 +0530
Subject: [PATCH 2/4] clang-format
---
libc/src/__support/math/logbf80.h | 4 +---
libc/src/math/generic/frexpf80.cpp | 3 +--
libc/src/math/generic/logbf80.cpp | 3 +--
3 files changed, 3 insertions(+), 7 deletions(-)
diff --git a/libc/src/__support/math/logbf80.h b/libc/src/__support/math/logbf80.h
index 4a967f0c830ac..ca312d404d880 100644
--- a/libc/src/__support/math/logbf80.h
+++ b/libc/src/__support/math/logbf80.h
@@ -18,9 +18,7 @@ namespace LIBC_NAMESPACE_DECL {
namespace math {
-LIBC_INLINE constexpr Float80 logbf80(Float80 x) {
- return fputil::logb(x);
-}
+LIBC_INLINE constexpr Float80 logbf80(Float80 x) { return fputil::logb(x); }
} // namespace math
diff --git a/libc/src/math/generic/frexpf80.cpp b/libc/src/math/generic/frexpf80.cpp
index 47793ba18d7cf..bf671e88a2aae 100644
--- a/libc/src/math/generic/frexpf80.cpp
+++ b/libc/src/math/generic/frexpf80.cpp
@@ -15,8 +15,7 @@
namespace LIBC_NAMESPACE_DECL {
LLVM_LIBC_FUNCTION(float80, frexpf80, (float80 x, int *exp)) {
- return cpp::bit_cast<float80>(
- math::frexpf80(cpp::bit_cast<Float80>(x), exp));
+ return cpp::bit_cast<float80>(math::frexpf80(cpp::bit_cast<Float80>(x), exp));
}
} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/logbf80.cpp b/libc/src/math/generic/logbf80.cpp
index 44e401b7b9cb8..a505ff388257a 100644
--- a/libc/src/math/generic/logbf80.cpp
+++ b/libc/src/math/generic/logbf80.cpp
@@ -15,8 +15,7 @@
namespace LIBC_NAMESPACE_DECL {
LLVM_LIBC_FUNCTION(float80, logbf80, (float80 x)) {
- return cpp::bit_cast<float80>(
- math::logbf80(cpp::bit_cast<Float80>(x)));
+ return cpp::bit_cast<float80>(math::logbf80(cpp::bit_cast<Float80>(x)));
}
} // namespace LIBC_NAMESPACE_DECL
>From 26356803c37cc31cd44c901c44a8b584b8ccc9a4 Mon Sep 17 00:00:00 2001
From: Sukumarsawant <sawantsukumar at gmail.com>
Date: Wed, 4 Nov 2026 12:46:00 +0530
Subject: [PATCH 3/4] nits
---
do_commit_exp_decomp.py | 31 -----------------
libc/src/__support/math/CMakeLists.txt | 16 ++++-----
libc/src/__support/math/frexpf80.h | 7 ++--
libc/src/__support/math/ilogbf80.h | 7 ++--
libc/src/__support/math/llogbf80.h | 7 ++--
libc/src/__support/math/logbf80.h | 7 ++--
libc/src/math/generic/frexpf80.cpp | 3 +-
libc/src/math/generic/ilogbf80.cpp | 3 +-
libc/src/math/generic/llogbf80.cpp | 3 +-
libc/src/math/generic/logbf80.cpp | 3 +-
libc/test/src/math/smoke/CMakeLists.txt | 40 ++++++++++++++++++++++
libc/test/src/math/smoke/frexpf80_test.cpp | 3 ++
libc/test/src/math/smoke/ilogbf80_test.cpp | 3 ++
libc/test/src/math/smoke/llogbf80_test.cpp | 3 ++
libc/test/src/math/smoke/logbf80_test.cpp | 3 ++
15 files changed, 80 insertions(+), 59 deletions(-)
delete mode 100644 do_commit_exp_decomp.py
diff --git a/do_commit_exp_decomp.py b/do_commit_exp_decomp.py
deleted file mode 100644
index a040d61081d3e..0000000000000
--- a/do_commit_exp_decomp.py
+++ /dev/null
@@ -1,31 +0,0 @@
-import subprocess
-
-def run(cmd):
- p = subprocess.run(cmd, cwd='c:/work/VM/llvm-project', capture_output=True, text=True, check=True)
- return p.stdout.strip()
-
-run(['git', 'add', '-A'])
-tree = run(['git', 'write-tree'])
-print('Tree:', tree)
-
-parent = run(['git', 'rev-parse', 'HEAD'])
-print('Parent:', parent)
-
-author_name = run(['git', 'config', 'user.name'])
-author_email = run(['git', 'config', 'user.email'])
-print('Author:', author_name, author_email)
-
-msg = 'adds frexpf80, ilogbf80, llogbf80, logbf80'
-
-p = subprocess.run(
- ['git', 'commit-tree', tree, '-p', parent, '-m', msg],
- cwd='c:/work/VM/llvm-project',
- capture_output=True,
- text=True,
- check=True
-)
-commit = p.stdout.strip()
-print('Commit:', commit)
-
-run(['git', 'update-ref', 'refs/heads/users/sukumarsawant/f80/exp_decomp', commit])
-print('Branch users/sukumarsawant/f80/exp_decomp updated successfully!')
diff --git a/libc/src/__support/math/CMakeLists.txt b/libc/src/__support/math/CMakeLists.txt
index 58e5400254cff..3b7db81a3ac28 100644
--- a/libc/src/__support/math/CMakeLists.txt
+++ b/libc/src/__support/math/CMakeLists.txt
@@ -4170,9 +4170,9 @@ add_header_library(
HDRS
frexpf80.h
DEPENDS
- libc.src.__support.macros.config
- libc.src.__support.macros.properties.types
+ libc.src.__support.FPUtil.float80
libc.src.__support.FPUtil.manipulation_functions
+ libc.src.__support.macros.config
)
add_header_library(
@@ -4261,9 +4261,9 @@ add_header_library(
HDRS
ilogbf80.h
DEPENDS
- libc.src.__support.macros.config
- libc.src.__support.macros.properties.types
+ libc.src.__support.FPUtil.float80
libc.src.__support.FPUtil.manipulation_functions
+ libc.src.__support.macros.config
)
add_header_library(
@@ -4333,9 +4333,9 @@ add_header_library(
HDRS
llogbf80.h
DEPENDS
- libc.src.__support.macros.config
- libc.src.__support.macros.properties.types
+ libc.src.__support.FPUtil.float80
libc.src.__support.FPUtil.manipulation_functions
+ libc.src.__support.macros.config
)
add_header_library(
@@ -5684,9 +5684,9 @@ add_header_library(
HDRS
logbf80.h
DEPENDS
- libc.src.__support.macros.config
- libc.src.__support.macros.properties.types
+ libc.src.__support.FPUtil.float80
libc.src.__support.FPUtil.manipulation_functions
+ libc.src.__support.macros.config
)
add_header_library(
diff --git a/libc/src/__support/math/frexpf80.h b/libc/src/__support/math/frexpf80.h
index 3c8fab1be8753..e0f54274d103d 100644
--- a/libc/src/__support/math/frexpf80.h
+++ b/libc/src/__support/math/frexpf80.h
@@ -10,20 +10,19 @@
#define LLVM_LIBC_SRC___SUPPORT_MATH_FREXPF80_H
#include "src/__support/FPUtil/ManipulationFunctions.h"
-#include "src/__support/common.h"
+#include "src/__support/FPUtil/float80.h"
#include "src/__support/macros/config.h"
-#include "src/__support/macros/properties/types.h"
namespace LIBC_NAMESPACE_DECL {
-
namespace math {
+using LIBC_NAMESPACE::fputil::Float80;
+
LIBC_INLINE constexpr Float80 frexpf80(Float80 x, int *exp) {
return fputil::frexp(x, *exp);
}
} // namespace math
-
} // namespace LIBC_NAMESPACE_DECL
#endif // LLVM_LIBC_SRC___SUPPORT_MATH_FREXPF80_H
diff --git a/libc/src/__support/math/ilogbf80.h b/libc/src/__support/math/ilogbf80.h
index 34977245c0346..cc7e4d8079715 100644
--- a/libc/src/__support/math/ilogbf80.h
+++ b/libc/src/__support/math/ilogbf80.h
@@ -10,20 +10,19 @@
#define LLVM_LIBC_SRC___SUPPORT_MATH_ILOGBF80_H
#include "src/__support/FPUtil/ManipulationFunctions.h"
-#include "src/__support/common.h"
+#include "src/__support/FPUtil/float80.h"
#include "src/__support/macros/config.h"
-#include "src/__support/macros/properties/types.h"
namespace LIBC_NAMESPACE_DECL {
-
namespace math {
+using LIBC_NAMESPACE::fputil::Float80;
+
LIBC_INLINE constexpr int ilogbf80(Float80 x) {
return fputil::intlogb<int>(x);
}
} // namespace math
-
} // namespace LIBC_NAMESPACE_DECL
#endif // LLVM_LIBC_SRC___SUPPORT_MATH_ILOGBF80_H
diff --git a/libc/src/__support/math/llogbf80.h b/libc/src/__support/math/llogbf80.h
index 68dfcb425a086..710d6a4717c12 100644
--- a/libc/src/__support/math/llogbf80.h
+++ b/libc/src/__support/math/llogbf80.h
@@ -10,20 +10,19 @@
#define LLVM_LIBC_SRC___SUPPORT_MATH_LLOGBF80_H
#include "src/__support/FPUtil/ManipulationFunctions.h"
-#include "src/__support/common.h"
+#include "src/__support/FPUtil/float80.h"
#include "src/__support/macros/config.h"
-#include "src/__support/macros/properties/types.h"
namespace LIBC_NAMESPACE_DECL {
-
namespace math {
+using LIBC_NAMESPACE::fputil::Float80;
+
LIBC_INLINE constexpr long llogbf80(Float80 x) {
return fputil::intlogb<long>(x);
}
} // namespace math
-
} // namespace LIBC_NAMESPACE_DECL
#endif // LLVM_LIBC_SRC___SUPPORT_MATH_LLOGBF80_H
diff --git a/libc/src/__support/math/logbf80.h b/libc/src/__support/math/logbf80.h
index ca312d404d880..f66a9d7d0d2ae 100644
--- a/libc/src/__support/math/logbf80.h
+++ b/libc/src/__support/math/logbf80.h
@@ -10,18 +10,17 @@
#define LLVM_LIBC_SRC___SUPPORT_MATH_LOGBF80_H
#include "src/__support/FPUtil/ManipulationFunctions.h"
-#include "src/__support/common.h"
+#include "src/__support/FPUtil/float80.h"
#include "src/__support/macros/config.h"
-#include "src/__support/macros/properties/types.h"
namespace LIBC_NAMESPACE_DECL {
-
namespace math {
+using LIBC_NAMESPACE::fputil::Float80;
+
LIBC_INLINE constexpr Float80 logbf80(Float80 x) { return fputil::logb(x); }
} // namespace math
-
} // namespace LIBC_NAMESPACE_DECL
#endif // LLVM_LIBC_SRC___SUPPORT_MATH_LOGBF80_H
diff --git a/libc/src/math/generic/frexpf80.cpp b/libc/src/math/generic/frexpf80.cpp
index bf671e88a2aae..c4d34e1ccacc7 100644
--- a/libc/src/math/generic/frexpf80.cpp
+++ b/libc/src/math/generic/frexpf80.cpp
@@ -9,11 +9,12 @@
#include "src/math/frexpf80.h"
#include "src/__support/CPP/bit.h"
#include "src/__support/common.h"
-#include "src/__support/macros/config.h"
#include "src/__support/math/frexpf80.h"
namespace LIBC_NAMESPACE_DECL {
+using LIBC_NAMESPACE::fputil::Float80;
+
LLVM_LIBC_FUNCTION(float80, frexpf80, (float80 x, int *exp)) {
return cpp::bit_cast<float80>(math::frexpf80(cpp::bit_cast<Float80>(x), exp));
}
diff --git a/libc/src/math/generic/ilogbf80.cpp b/libc/src/math/generic/ilogbf80.cpp
index f31a6d81ebf5c..b1ee7921655fe 100644
--- a/libc/src/math/generic/ilogbf80.cpp
+++ b/libc/src/math/generic/ilogbf80.cpp
@@ -9,11 +9,12 @@
#include "src/math/ilogbf80.h"
#include "src/__support/CPP/bit.h"
#include "src/__support/common.h"
-#include "src/__support/macros/config.h"
#include "src/__support/math/ilogbf80.h"
namespace LIBC_NAMESPACE_DECL {
+using LIBC_NAMESPACE::fputil::Float80;
+
LLVM_LIBC_FUNCTION(int, ilogbf80, (float80 x)) {
return math::ilogbf80(cpp::bit_cast<Float80>(x));
}
diff --git a/libc/src/math/generic/llogbf80.cpp b/libc/src/math/generic/llogbf80.cpp
index ab13954344113..50fbc7f8ca32b 100644
--- a/libc/src/math/generic/llogbf80.cpp
+++ b/libc/src/math/generic/llogbf80.cpp
@@ -9,11 +9,12 @@
#include "src/math/llogbf80.h"
#include "src/__support/CPP/bit.h"
#include "src/__support/common.h"
-#include "src/__support/macros/config.h"
#include "src/__support/math/llogbf80.h"
namespace LIBC_NAMESPACE_DECL {
+using LIBC_NAMESPACE::fputil::Float80;
+
LLVM_LIBC_FUNCTION(long, llogbf80, (float80 x)) {
return math::llogbf80(cpp::bit_cast<Float80>(x));
}
diff --git a/libc/src/math/generic/logbf80.cpp b/libc/src/math/generic/logbf80.cpp
index a505ff388257a..7b698d26085e3 100644
--- a/libc/src/math/generic/logbf80.cpp
+++ b/libc/src/math/generic/logbf80.cpp
@@ -9,11 +9,12 @@
#include "src/math/logbf80.h"
#include "src/__support/CPP/bit.h"
#include "src/__support/common.h"
-#include "src/__support/macros/config.h"
#include "src/__support/math/logbf80.h"
namespace LIBC_NAMESPACE_DECL {
+using LIBC_NAMESPACE::fputil::Float80;
+
LLVM_LIBC_FUNCTION(float80, logbf80, (float80 x)) {
return cpp::bit_cast<float80>(math::logbf80(cpp::bit_cast<Float80>(x)));
}
diff --git a/libc/test/src/math/smoke/CMakeLists.txt b/libc/test/src/math/smoke/CMakeLists.txt
index a482d101bad65..c93e9ad0366f9 100644
--- a/libc/test/src/math/smoke/CMakeLists.txt
+++ b/libc/test/src/math/smoke/CMakeLists.txt
@@ -1809,6 +1809,7 @@ add_fp_unittest(
FrexpTest.h
DEPENDS
libc.src.math.frexpf80
+ libc.src.__support.FPUtil.float80
)
add_fp_unittest(
@@ -2190,6 +2191,19 @@ add_fp_unittest(
libc.src.__support.FPUtil.manipulation_functions
)
+add_fp_unittest(
+ ilogbf80_test
+ SUITE
+ libc-math-smoke-tests
+ SRCS
+ ilogbf80_test.cpp
+ HDRS
+ ILogbTest.h
+ DEPENDS
+ libc.src.math.ilogbf80
+ libc.src.__support.FPUtil.float80
+)
+
add_fp_unittest(
ilogbf128_test
SUITE
@@ -2381,6 +2395,19 @@ add_fp_unittest(
libc.src.__support.FPUtil.manipulation_functions
)
+add_fp_unittest(
+ llogbf80_test
+ SUITE
+ libc-math-smoke-tests
+ SRCS
+ llogbf80_test.cpp
+ HDRS
+ ILogbTest.h
+ DEPENDS
+ libc.src.math.llogbf80
+ libc.src.__support.FPUtil.float80
+)
+
add_fp_unittest(
llogbf128_test
SUITE
@@ -2567,6 +2594,19 @@ add_fp_unittest(
libc.src.__support.FPUtil.manipulation_functions
)
+add_fp_unittest(
+ logbf80_test
+ SUITE
+ libc-math-smoke-tests
+ SRCS
+ logbf80_test.cpp
+ HDRS
+ LogbTest.h
+ DEPENDS
+ libc.src.math.logbf80
+ libc.src.__support.FPUtil.float80
+)
+
add_fp_unittest(
logbf128_test
SUITE
diff --git a/libc/test/src/math/smoke/frexpf80_test.cpp b/libc/test/src/math/smoke/frexpf80_test.cpp
index ec821b5e2be0c..b6115b0e53d29 100644
--- a/libc/test/src/math/smoke/frexpf80_test.cpp
+++ b/libc/test/src/math/smoke/frexpf80_test.cpp
@@ -8,6 +8,9 @@
#include "FrexpTest.h"
+#include "src/__support/FPUtil/float80.h"
#include "src/math/frexpf80.h"
+using LIBC_NAMESPACE::fputil::Float80;
+
LIST_FREXP_TESTS(Frexpf80, Float80, LIBC_NAMESPACE::frexpf80);
diff --git a/libc/test/src/math/smoke/ilogbf80_test.cpp b/libc/test/src/math/smoke/ilogbf80_test.cpp
index cffdd5b3d3780..08cef5ce0a717 100644
--- a/libc/test/src/math/smoke/ilogbf80_test.cpp
+++ b/libc/test/src/math/smoke/ilogbf80_test.cpp
@@ -8,6 +8,9 @@
#include "ILogbTest.h"
+#include "src/__support/FPUtil/float80.h"
#include "src/math/ilogbf80.h"
+using LIBC_NAMESPACE::fputil::Float80;
+
LIST_INTLOGB_TESTS(Ilogbf80, int, Float80, LIBC_NAMESPACE::ilogbf80);
diff --git a/libc/test/src/math/smoke/llogbf80_test.cpp b/libc/test/src/math/smoke/llogbf80_test.cpp
index 9aa9880a6e4da..4756e6351818e 100644
--- a/libc/test/src/math/smoke/llogbf80_test.cpp
+++ b/libc/test/src/math/smoke/llogbf80_test.cpp
@@ -8,6 +8,9 @@
#include "ILogbTest.h"
+#include "src/__support/FPUtil/float80.h"
#include "src/math/llogbf80.h"
+using LIBC_NAMESPACE::fputil::Float80;
+
LIST_INTLOGB_TESTS(Llogbf80, long, Float80, LIBC_NAMESPACE::llogbf80);
diff --git a/libc/test/src/math/smoke/logbf80_test.cpp b/libc/test/src/math/smoke/logbf80_test.cpp
index 409a92f0c1c01..e29d439c54b24 100644
--- a/libc/test/src/math/smoke/logbf80_test.cpp
+++ b/libc/test/src/math/smoke/logbf80_test.cpp
@@ -8,6 +8,9 @@
#include "LogbTest.h"
+#include "src/__support/FPUtil/float80.h"
#include "src/math/logbf80.h"
+using LIBC_NAMESPACE::fputil::Float80;
+
LIST_LOGB_TESTS(Logbf80, Float80, LIBC_NAMESPACE::logbf80)
>From 18dc650d1a7639800dc6a70746fa098d416396e2 Mon Sep 17 00:00:00 2001
From: Sukumarsawant <sawantsukumar at gmail.com>
Date: Wed, 4 Nov 2026 15:22:21 +0530
Subject: [PATCH 4/4] cast from f128
---
libc/src/__support/math/CMakeLists.txt | 2 ++
libc/src/__support/math/frexpf80.h | 7 ++++++-
utils/bazel/llvm-project-overlay/libc/BUILD.bazel | 2 ++
3 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/libc/src/__support/math/CMakeLists.txt b/libc/src/__support/math/CMakeLists.txt
index 3b7db81a3ac28..ed29a2ca33133 100644
--- a/libc/src/__support/math/CMakeLists.txt
+++ b/libc/src/__support/math/CMakeLists.txt
@@ -4170,6 +4170,8 @@ add_header_library(
HDRS
frexpf80.h
DEPENDS
+ libc.src.__support.FPUtil.cast
+ libc.src.__support.FPUtil.float128
libc.src.__support.FPUtil.float80
libc.src.__support.FPUtil.manipulation_functions
libc.src.__support.macros.config
diff --git a/libc/src/__support/math/frexpf80.h b/libc/src/__support/math/frexpf80.h
index e0f54274d103d..e15385282b885 100644
--- a/libc/src/__support/math/frexpf80.h
+++ b/libc/src/__support/math/frexpf80.h
@@ -10,16 +10,21 @@
#define LLVM_LIBC_SRC___SUPPORT_MATH_FREXPF80_H
#include "src/__support/FPUtil/ManipulationFunctions.h"
+#include "src/__support/FPUtil/cast.h"
+#include "src/__support/FPUtil/float128.h"
#include "src/__support/FPUtil/float80.h"
#include "src/__support/macros/config.h"
namespace LIBC_NAMESPACE_DECL {
namespace math {
+using LIBC_NAMESPACE::fputil::Float128;
using LIBC_NAMESPACE::fputil::Float80;
+// Upcast to Float128 to evaluate frexp cleanly without loss of precision,
+// matching the arithmetic operator pattern in FPUtil/float80.h.
LIBC_INLINE constexpr Float80 frexpf80(Float80 x, int *exp) {
- return fputil::frexp(x, *exp);
+ return fputil::cast<Float80>(fputil::frexp(fputil::cast<Float128>(x), *exp));
}
} // namespace math
diff --git a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
index 8fad6854fa9cf..b5949aa06fb5e 100644
--- a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
@@ -10487,6 +10487,8 @@ libc_support_library(
hdrs = ["src/__support/math/frexpf80.h"],
deps = [
":__support_common",
+ ":__support_fputil_cast",
+ ":__support_fputil_float128",
":__support_fputil_float80",
":__support_fputil_manipulation_functions",
":__support_macros_config",
More information about the llvm-branch-commits
mailing list