[libc-commits] [libc] [llvm] [libc][math] Refactor scalbln-scalbn-ldexp family to header-only (PR #195423)
via libc-commits
libc-commits at lists.llvm.org
Sat May 2 00:53:47 PDT 2026
https://github.com/AnonMiraj updated https://github.com/llvm/llvm-project/pull/195423
>From e5dc0349d0362dda0ff5a781d960ca6efc2db6fe Mon Sep 17 00:00:00 2001
From: Anonmiraj <ezzibrahimx at gmail.com>
Date: Sat, 2 May 2026 09:56:49 +0300
Subject: [PATCH] [libc][math] Refactor scalbln-scalbn-ldexp family to
header-only#195423
---
libc/shared/math.h | 15 ++
libc/shared/math/ldexp.h | 23 ++
libc/shared/math/ldexpbf16.h | 23 ++
libc/shared/math/ldexpl.h | 23 ++
libc/shared/math/scalbln.h | 23 ++
libc/shared/math/scalblnbf16.h | 23 ++
libc/shared/math/scalblnf.h | 23 ++
libc/shared/math/scalblnf128.h | 29 +++
libc/shared/math/scalblnf16.h | 29 +++
libc/shared/math/scalblnl.h | 23 ++
libc/shared/math/scalbn.h | 23 ++
libc/shared/math/scalbnbf16.h | 23 ++
libc/shared/math/scalbnf.h | 23 ++
libc/shared/math/scalbnf128.h | 29 +++
libc/shared/math/scalbnf16.h | 29 +++
libc/shared/math/scalbnl.h | 23 ++
libc/src/__support/math/CMakeLists.txt | 158 ++++++++++++-
libc/src/__support/math/ldexp.h | 25 ++
libc/src/__support/math/ldexpbf16.h | 26 +++
libc/src/__support/math/ldexpl.h | 25 ++
libc/src/__support/math/scalbln.h | 30 +++
libc/src/__support/math/scalblnbf16.h | 31 +++
libc/src/__support/math/scalblnf.h | 30 +++
libc/src/__support/math/scalblnf128.h | 36 +++
libc/src/__support/math/scalblnf16.h | 36 +++
libc/src/__support/math/scalblnl.h | 30 +++
libc/src/__support/math/scalbn.h | 30 +++
libc/src/__support/math/scalbnbf16.h | 31 +++
libc/src/__support/math/scalbnf.h | 30 +++
libc/src/__support/math/scalbnf128.h | 36 +++
libc/src/__support/math/scalbnf16.h | 36 +++
libc/src/__support/math/scalbnl.h | 30 +++
libc/src/math/generic/CMakeLists.txt | 58 ++---
libc/src/math/generic/ldexp.cpp | 6 +-
libc/src/math/generic/ldexpbf16.cpp | 7 +-
libc/src/math/generic/ldexpl.cpp | 6 +-
libc/src/math/generic/scalbln.cpp | 11 +-
libc/src/math/generic/scalblnbf16.cpp | 12 +-
libc/src/math/generic/scalblnf.cpp | 11 +-
libc/src/math/generic/scalblnf128.cpp | 11 +-
libc/src/math/generic/scalblnf16.cpp | 12 +-
libc/src/math/generic/scalblnl.cpp | 11 +-
libc/src/math/generic/scalbn.cpp | 11 +-
libc/src/math/generic/scalbnbf16.cpp | 12 +-
libc/src/math/generic/scalbnf.cpp | 11 +-
libc/src/math/generic/scalbnf128.cpp | 11 +-
libc/src/math/generic/scalbnf16.cpp | 12 +-
libc/src/math/generic/scalbnl.cpp | 11 +-
libc/test/shared/CMakeLists.txt | 30 +++
.../shared/shared_math_constexpr_test.cpp | 20 ++
libc/test/shared/shared_math_test.cpp | 20 ++
.../llvm-project-overlay/libc/BUILD.bazel | 221 +++++++++++++++++-
52 files changed, 1326 insertions(+), 182 deletions(-)
create mode 100644 libc/shared/math/ldexp.h
create mode 100644 libc/shared/math/ldexpbf16.h
create mode 100644 libc/shared/math/ldexpl.h
create mode 100644 libc/shared/math/scalbln.h
create mode 100644 libc/shared/math/scalblnbf16.h
create mode 100644 libc/shared/math/scalblnf.h
create mode 100644 libc/shared/math/scalblnf128.h
create mode 100644 libc/shared/math/scalblnf16.h
create mode 100644 libc/shared/math/scalblnl.h
create mode 100644 libc/shared/math/scalbn.h
create mode 100644 libc/shared/math/scalbnbf16.h
create mode 100644 libc/shared/math/scalbnf.h
create mode 100644 libc/shared/math/scalbnf128.h
create mode 100644 libc/shared/math/scalbnf16.h
create mode 100644 libc/shared/math/scalbnl.h
create mode 100644 libc/src/__support/math/ldexp.h
create mode 100644 libc/src/__support/math/ldexpbf16.h
create mode 100644 libc/src/__support/math/ldexpl.h
create mode 100644 libc/src/__support/math/scalbln.h
create mode 100644 libc/src/__support/math/scalblnbf16.h
create mode 100644 libc/src/__support/math/scalblnf.h
create mode 100644 libc/src/__support/math/scalblnf128.h
create mode 100644 libc/src/__support/math/scalblnf16.h
create mode 100644 libc/src/__support/math/scalblnl.h
create mode 100644 libc/src/__support/math/scalbn.h
create mode 100644 libc/src/__support/math/scalbnbf16.h
create mode 100644 libc/src/__support/math/scalbnf.h
create mode 100644 libc/src/__support/math/scalbnf128.h
create mode 100644 libc/src/__support/math/scalbnf16.h
create mode 100644 libc/src/__support/math/scalbnl.h
diff --git a/libc/shared/math.h b/libc/shared/math.h
index 293ddc21cafb9..2641e0e71676f 100644
--- a/libc/shared/math.h
+++ b/libc/shared/math.h
@@ -272,9 +272,12 @@
#include "math/ilogbf128.h"
#include "math/ilogbf16.h"
#include "math/ilogbl.h"
+#include "math/ldexp.h"
+#include "math/ldexpbf16.h"
#include "math/ldexpf.h"
#include "math/ldexpf128.h"
#include "math/ldexpf16.h"
+#include "math/ldexpl.h"
#include "math/llogb.h"
#include "math/llogbbf16.h"
#include "math/llogbf.h"
@@ -346,6 +349,18 @@
#include "math/remquol.h"
#include "math/rsqrtf.h"
#include "math/rsqrtf16.h"
+#include "math/scalbln.h"
+#include "math/scalblnbf16.h"
+#include "math/scalblnf.h"
+#include "math/scalblnf128.h"
+#include "math/scalblnf16.h"
+#include "math/scalblnl.h"
+#include "math/scalbn.h"
+#include "math/scalbnbf16.h"
+#include "math/scalbnf.h"
+#include "math/scalbnf128.h"
+#include "math/scalbnf16.h"
+#include "math/scalbnl.h"
#include "math/setpayload.h"
#include "math/setpayloadbf16.h"
#include "math/setpayloadf.h"
diff --git a/libc/shared/math/ldexp.h b/libc/shared/math/ldexp.h
new file mode 100644
index 0000000000000..413d8b286921a
--- /dev/null
+++ b/libc/shared/math/ldexp.h
@@ -0,0 +1,23 @@
+//===-- Shared ldexp function -----------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SHARED_MATH_LDEXP_H
+#define LLVM_LIBC_SHARED_MATH_LDEXP_H
+
+#include "shared/libc_common.h"
+#include "src/__support/math/ldexp.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::ldexp;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SHARED_MATH_LDEXP_H
diff --git a/libc/shared/math/ldexpbf16.h b/libc/shared/math/ldexpbf16.h
new file mode 100644
index 0000000000000..9ac92c916c401
--- /dev/null
+++ b/libc/shared/math/ldexpbf16.h
@@ -0,0 +1,23 @@
+//===-- Shared ldexpbf16 function -------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SHARED_MATH_LDEXPBF16_H
+#define LLVM_LIBC_SHARED_MATH_LDEXPBF16_H
+
+#include "shared/libc_common.h"
+#include "src/__support/math/ldexpbf16.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::ldexpbf16;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SHARED_MATH_LDEXPBF16_H
diff --git a/libc/shared/math/ldexpl.h b/libc/shared/math/ldexpl.h
new file mode 100644
index 0000000000000..47b86cb96f7e1
--- /dev/null
+++ b/libc/shared/math/ldexpl.h
@@ -0,0 +1,23 @@
+//===-- Shared ldexpl function ----------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SHARED_MATH_LDEXPL_H
+#define LLVM_LIBC_SHARED_MATH_LDEXPL_H
+
+#include "shared/libc_common.h"
+#include "src/__support/math/ldexpl.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::ldexpl;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SHARED_MATH_LDEXPL_H
diff --git a/libc/shared/math/scalbln.h b/libc/shared/math/scalbln.h
new file mode 100644
index 0000000000000..055d50b9efef9
--- /dev/null
+++ b/libc/shared/math/scalbln.h
@@ -0,0 +1,23 @@
+//===-- Shared scalbln function ---------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SHARED_MATH_SCALBLN_H
+#define LLVM_LIBC_SHARED_MATH_SCALBLN_H
+
+#include "shared/libc_common.h"
+#include "src/__support/math/scalbln.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::scalbln;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SHARED_MATH_SCALBLN_H
diff --git a/libc/shared/math/scalblnbf16.h b/libc/shared/math/scalblnbf16.h
new file mode 100644
index 0000000000000..e8e42115083e7
--- /dev/null
+++ b/libc/shared/math/scalblnbf16.h
@@ -0,0 +1,23 @@
+//===-- Shared scalblnbf16 function -----------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SHARED_MATH_SCALBLNBF16_H
+#define LLVM_LIBC_SHARED_MATH_SCALBLNBF16_H
+
+#include "shared/libc_common.h"
+#include "src/__support/math/scalblnbf16.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::scalblnbf16;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SHARED_MATH_SCALBLNBF16_H
diff --git a/libc/shared/math/scalblnf.h b/libc/shared/math/scalblnf.h
new file mode 100644
index 0000000000000..274de5fbdffb6
--- /dev/null
+++ b/libc/shared/math/scalblnf.h
@@ -0,0 +1,23 @@
+//===-- Shared scalblnf function --------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SHARED_MATH_SCALBLNF_H
+#define LLVM_LIBC_SHARED_MATH_SCALBLNF_H
+
+#include "shared/libc_common.h"
+#include "src/__support/math/scalblnf.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::scalblnf;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SHARED_MATH_SCALBLNF_H
diff --git a/libc/shared/math/scalblnf128.h b/libc/shared/math/scalblnf128.h
new file mode 100644
index 0000000000000..088c6b39e97c0
--- /dev/null
+++ b/libc/shared/math/scalblnf128.h
@@ -0,0 +1,29 @@
+//===-- Shared scalblnf128 function -----------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SHARED_MATH_SCALBLNF128_H
+#define LLVM_LIBC_SHARED_MATH_SCALBLNF128_H
+
+#include "include/llvm-libc-types/float128.h"
+
+#ifdef LIBC_TYPES_HAS_FLOAT128
+
+#include "shared/libc_common.h"
+#include "src/__support/math/scalblnf128.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::scalblnf128;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LIBC_TYPES_HAS_FLOAT128
+
+#endif // LLVM_LIBC_SHARED_MATH_SCALBLNF128_H
diff --git a/libc/shared/math/scalblnf16.h b/libc/shared/math/scalblnf16.h
new file mode 100644
index 0000000000000..cfcd4bc4252d9
--- /dev/null
+++ b/libc/shared/math/scalblnf16.h
@@ -0,0 +1,29 @@
+//===-- Shared scalblnf16 function ------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SHARED_MATH_SCALBLNF16_H
+#define LLVM_LIBC_SHARED_MATH_SCALBLNF16_H
+
+#include "include/llvm-libc-macros/float16-macros.h"
+
+#ifdef LIBC_TYPES_HAS_FLOAT16
+
+#include "shared/libc_common.h"
+#include "src/__support/math/scalblnf16.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::scalblnf16;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LIBC_TYPES_HAS_FLOAT16
+
+#endif // LLVM_LIBC_SHARED_MATH_SCALBLNF16_H
diff --git a/libc/shared/math/scalblnl.h b/libc/shared/math/scalblnl.h
new file mode 100644
index 0000000000000..359a4af50a4b8
--- /dev/null
+++ b/libc/shared/math/scalblnl.h
@@ -0,0 +1,23 @@
+//===-- Shared scalblnl function --------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SHARED_MATH_SCALBLNL_H
+#define LLVM_LIBC_SHARED_MATH_SCALBLNL_H
+
+#include "shared/libc_common.h"
+#include "src/__support/math/scalblnl.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::scalblnl;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SHARED_MATH_SCALBLNL_H
diff --git a/libc/shared/math/scalbn.h b/libc/shared/math/scalbn.h
new file mode 100644
index 0000000000000..2ea53d7b2512f
--- /dev/null
+++ b/libc/shared/math/scalbn.h
@@ -0,0 +1,23 @@
+//===-- Shared scalbn function ----------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SHARED_MATH_SCALBN_H
+#define LLVM_LIBC_SHARED_MATH_SCALBN_H
+
+#include "shared/libc_common.h"
+#include "src/__support/math/scalbn.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::scalbn;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SHARED_MATH_SCALBN_H
diff --git a/libc/shared/math/scalbnbf16.h b/libc/shared/math/scalbnbf16.h
new file mode 100644
index 0000000000000..efda2014dd918
--- /dev/null
+++ b/libc/shared/math/scalbnbf16.h
@@ -0,0 +1,23 @@
+//===-- Shared scalbnbf16 function ------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SHARED_MATH_SCALBNBF16_H
+#define LLVM_LIBC_SHARED_MATH_SCALBNBF16_H
+
+#include "shared/libc_common.h"
+#include "src/__support/math/scalbnbf16.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::scalbnbf16;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SHARED_MATH_SCALBNBF16_H
diff --git a/libc/shared/math/scalbnf.h b/libc/shared/math/scalbnf.h
new file mode 100644
index 0000000000000..7e8b920b273a3
--- /dev/null
+++ b/libc/shared/math/scalbnf.h
@@ -0,0 +1,23 @@
+//===-- Shared scalbnf function ---------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SHARED_MATH_SCALBNF_H
+#define LLVM_LIBC_SHARED_MATH_SCALBNF_H
+
+#include "shared/libc_common.h"
+#include "src/__support/math/scalbnf.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::scalbnf;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SHARED_MATH_SCALBNF_H
diff --git a/libc/shared/math/scalbnf128.h b/libc/shared/math/scalbnf128.h
new file mode 100644
index 0000000000000..5b232910ff518
--- /dev/null
+++ b/libc/shared/math/scalbnf128.h
@@ -0,0 +1,29 @@
+//===-- Shared scalbnf128 function ------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SHARED_MATH_SCALBNF128_H
+#define LLVM_LIBC_SHARED_MATH_SCALBNF128_H
+
+#include "include/llvm-libc-types/float128.h"
+
+#ifdef LIBC_TYPES_HAS_FLOAT128
+
+#include "shared/libc_common.h"
+#include "src/__support/math/scalbnf128.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::scalbnf128;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LIBC_TYPES_HAS_FLOAT128
+
+#endif // LLVM_LIBC_SHARED_MATH_SCALBNF128_H
diff --git a/libc/shared/math/scalbnf16.h b/libc/shared/math/scalbnf16.h
new file mode 100644
index 0000000000000..28d695802a1b1
--- /dev/null
+++ b/libc/shared/math/scalbnf16.h
@@ -0,0 +1,29 @@
+//===-- Shared scalbnf16 function -------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SHARED_MATH_SCALBNF16_H
+#define LLVM_LIBC_SHARED_MATH_SCALBNF16_H
+
+#include "include/llvm-libc-macros/float16-macros.h"
+
+#ifdef LIBC_TYPES_HAS_FLOAT16
+
+#include "shared/libc_common.h"
+#include "src/__support/math/scalbnf16.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::scalbnf16;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LIBC_TYPES_HAS_FLOAT16
+
+#endif // LLVM_LIBC_SHARED_MATH_SCALBNF16_H
diff --git a/libc/shared/math/scalbnl.h b/libc/shared/math/scalbnl.h
new file mode 100644
index 0000000000000..1409c657ccfe8
--- /dev/null
+++ b/libc/shared/math/scalbnl.h
@@ -0,0 +1,23 @@
+//===-- Shared scalbnl function ---------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SHARED_MATH_SCALBNL_H
+#define LLVM_LIBC_SHARED_MATH_SCALBNL_H
+
+#include "shared/libc_common.h"
+#include "src/__support/math/scalbnl.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::scalbnl;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SHARED_MATH_SCALBNL_H
diff --git a/libc/src/__support/math/CMakeLists.txt b/libc/src/__support/math/CMakeLists.txt
index 2be565504ee84..3100dca01d68e 100644
--- a/libc/src/__support/math/CMakeLists.txt
+++ b/libc/src/__support/math/CMakeLists.txt
@@ -1534,6 +1534,34 @@ add_header_library(
libc.src.__support.macros.config
)
+add_header_library(
+ ldexp
+ HDRS
+ ldexp.h
+ DEPENDS
+ libc.src.__support.FPUtil.manipulation_functions
+ libc.src.__support.macros.config
+)
+
+add_header_library(
+ ldexpbf16
+ HDRS
+ ldexpbf16.h
+ DEPENDS
+ libc.src.__support.FPUtil.bfloat16
+ libc.src.__support.FPUtil.manipulation_functions
+ libc.src.__support.macros.config
+)
+
+add_header_library(
+ ldexpl
+ HDRS
+ ldexpl.h
+ DEPENDS
+ libc.src.__support.FPUtil.manipulation_functions
+ libc.src.__support.macros.config
+)
+
add_header_library(
llogbbf16
HDRS
@@ -1635,8 +1663,8 @@ add_header_library(
HDRS
remainderf.h
DEPENDS
- libc.src.__support.macros.config
libc.src.__support.FPUtil.division_and_remainder_operations
+ libc.src.__support.macros.config
)
add_header_library(
@@ -1692,8 +1720,8 @@ add_header_library(
HDRS
remquof.h
DEPENDS
- libc.src.__support.macros.config
libc.src.__support.FPUtil.division_and_remainder_operations
+ libc.src.__support.macros.config
)
add_header_library(
@@ -1725,6 +1753,132 @@ add_header_library(
libc.src.__support.macros.config
)
+add_header_library(
+ scalbln
+ HDRS
+ scalbln.h
+ DEPENDS
+ libc.hdr.float_macros
+ libc.src.__support.FPUtil.manipulation_functions
+ libc.src.__support.macros.config
+)
+
+add_header_library(
+ scalblnbf16
+ HDRS
+ scalblnbf16.h
+ DEPENDS
+ libc.hdr.float_macros
+ libc.src.__support.FPUtil.bfloat16
+ libc.src.__support.FPUtil.manipulation_functions
+ libc.src.__support.macros.config
+)
+
+add_header_library(
+ scalblnf
+ HDRS
+ scalblnf.h
+ DEPENDS
+ libc.hdr.float_macros
+ libc.src.__support.FPUtil.manipulation_functions
+ libc.src.__support.macros.config
+)
+
+add_header_library(
+ scalblnf128
+ HDRS
+ scalblnf128.h
+ DEPENDS
+ libc.hdr.float_macros
+ libc.include.llvm-libc-types.float128
+ libc.src.__support.FPUtil.manipulation_functions
+ libc.src.__support.macros.config
+)
+
+add_header_library(
+ scalblnf16
+ HDRS
+ scalblnf16.h
+ DEPENDS
+ libc.hdr.float_macros
+ libc.include.llvm-libc-macros.float16_macros
+ libc.src.__support.FPUtil.manipulation_functions
+ libc.src.__support.macros.config
+)
+
+add_header_library(
+ scalblnl
+ HDRS
+ scalblnl.h
+ DEPENDS
+ libc.hdr.float_macros
+ libc.src.__support.FPUtil.manipulation_functions
+ libc.src.__support.macros.config
+)
+
+add_header_library(
+ scalbn
+ HDRS
+ scalbn.h
+ DEPENDS
+ libc.hdr.float_macros
+ libc.src.__support.FPUtil.manipulation_functions
+ libc.src.__support.macros.config
+)
+
+add_header_library(
+ scalbnbf16
+ HDRS
+ scalbnbf16.h
+ DEPENDS
+ libc.hdr.float_macros
+ libc.src.__support.FPUtil.bfloat16
+ libc.src.__support.FPUtil.manipulation_functions
+ libc.src.__support.macros.config
+)
+
+add_header_library(
+ scalbnf
+ HDRS
+ scalbnf.h
+ DEPENDS
+ libc.hdr.float_macros
+ libc.src.__support.FPUtil.manipulation_functions
+ libc.src.__support.macros.config
+)
+
+add_header_library(
+ scalbnf128
+ HDRS
+ scalbnf128.h
+ DEPENDS
+ libc.hdr.float_macros
+ libc.include.llvm-libc-types.float128
+ libc.src.__support.FPUtil.manipulation_functions
+ libc.src.__support.macros.config
+)
+
+add_header_library(
+ scalbnf16
+ HDRS
+ scalbnf16.h
+ DEPENDS
+ libc.hdr.float_macros
+ libc.include.llvm-libc-macros.float16_macros
+ libc.src.__support.FPUtil.manipulation_functions
+ libc.src.__support.macros.config
+)
+
+add_header_library(
+ scalbnl
+ HDRS
+ scalbnl.h
+ DEPENDS
+ libc.hdr.float_macros
+ libc.src.__support.FPUtil.manipulation_functions
+ libc.src.__support.macros.config
+)
+
add_header_library(
sincos_integer_utils
HDRS
diff --git a/libc/src/__support/math/ldexp.h b/libc/src/__support/math/ldexp.h
new file mode 100644
index 0000000000000..95523407d57e0
--- /dev/null
+++ b/libc/src/__support/math/ldexp.h
@@ -0,0 +1,25 @@
+//===-- Implementation header for ldexp -------------------------*- 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_LDEXP_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_LDEXP_H
+
+#include "src/__support/FPUtil/ManipulationFunctions.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace math {
+
+LIBC_INLINE constexpr double ldexp(double x, int exp) {
+ return fputil::ldexp(x, exp);
+}
+
+} // namespace math
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC___SUPPORT_MATH_LDEXP_H
diff --git a/libc/src/__support/math/ldexpbf16.h b/libc/src/__support/math/ldexpbf16.h
new file mode 100644
index 0000000000000..9882f3573afcf
--- /dev/null
+++ b/libc/src/__support/math/ldexpbf16.h
@@ -0,0 +1,26 @@
+//===-- Implementation header for ldexpbf16 ---------------------*- 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_LDEXPBF16_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_LDEXPBF16_H
+
+#include "src/__support/FPUtil/ManipulationFunctions.h"
+#include "src/__support/FPUtil/bfloat16.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace math {
+
+LIBC_INLINE constexpr bfloat16 ldexpbf16(bfloat16 x, int exp) {
+ return fputil::ldexp(x, exp);
+}
+
+} // namespace math
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC___SUPPORT_MATH_LDEXPBF16_H
diff --git a/libc/src/__support/math/ldexpl.h b/libc/src/__support/math/ldexpl.h
new file mode 100644
index 0000000000000..44bcf3176d73c
--- /dev/null
+++ b/libc/src/__support/math/ldexpl.h
@@ -0,0 +1,25 @@
+//===-- Implementation header for ldexpl ------------------------*- 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_LDEXPL_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_LDEXPL_H
+
+#include "src/__support/FPUtil/ManipulationFunctions.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace math {
+
+LIBC_INLINE constexpr long double ldexpl(long double x, int exp) {
+ return fputil::ldexp(x, exp);
+}
+
+} // namespace math
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC___SUPPORT_MATH_LDEXPL_H
diff --git a/libc/src/__support/math/scalbln.h b/libc/src/__support/math/scalbln.h
new file mode 100644
index 0000000000000..bb7a63bef5af3
--- /dev/null
+++ b/libc/src/__support/math/scalbln.h
@@ -0,0 +1,30 @@
+//===-- Implementation header for scalbln -----------------------*- 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_SCALBLN_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_SCALBLN_H
+
+#include "hdr/float_macros.h"
+#include "src/__support/FPUtil/ManipulationFunctions.h"
+#include "src/__support/macros/config.h"
+
+#if FLT_RADIX != 2
+#error "FLT_RADIX != 2 is not supported."
+#endif
+
+namespace LIBC_NAMESPACE_DECL {
+namespace math {
+
+LIBC_INLINE constexpr double scalbln(double x, long n) {
+ return fputil::ldexp(x, n);
+}
+
+} // namespace math
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC___SUPPORT_MATH_SCALBLN_H
diff --git a/libc/src/__support/math/scalblnbf16.h b/libc/src/__support/math/scalblnbf16.h
new file mode 100644
index 0000000000000..3630c1e811c7b
--- /dev/null
+++ b/libc/src/__support/math/scalblnbf16.h
@@ -0,0 +1,31 @@
+//===-- Implementation header for scalblnbf16 -------------------*- 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_SCALBLNBF16_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_SCALBLNBF16_H
+
+#include "hdr/float_macros.h"
+#include "src/__support/FPUtil/ManipulationFunctions.h"
+#include "src/__support/FPUtil/bfloat16.h"
+#include "src/__support/macros/config.h"
+
+#if FLT_RADIX != 2
+#error "FLT_RADIX != 2 is not supported."
+#endif
+
+namespace LIBC_NAMESPACE_DECL {
+namespace math {
+
+LIBC_INLINE constexpr bfloat16 scalblnbf16(bfloat16 x, long n) {
+ return fputil::ldexp(x, n);
+}
+
+} // namespace math
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC___SUPPORT_MATH_SCALBLNBF16_H
diff --git a/libc/src/__support/math/scalblnf.h b/libc/src/__support/math/scalblnf.h
new file mode 100644
index 0000000000000..3dbe78310526a
--- /dev/null
+++ b/libc/src/__support/math/scalblnf.h
@@ -0,0 +1,30 @@
+//===-- Implementation header for scalblnf ----------------------*- 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_SCALBLNF_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_SCALBLNF_H
+
+#include "hdr/float_macros.h"
+#include "src/__support/FPUtil/ManipulationFunctions.h"
+#include "src/__support/macros/config.h"
+
+#if FLT_RADIX != 2
+#error "FLT_RADIX != 2 is not supported."
+#endif
+
+namespace LIBC_NAMESPACE_DECL {
+namespace math {
+
+LIBC_INLINE constexpr float scalblnf(float x, long n) {
+ return fputil::ldexp(x, n);
+}
+
+} // namespace math
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC___SUPPORT_MATH_SCALBLNF_H
diff --git a/libc/src/__support/math/scalblnf128.h b/libc/src/__support/math/scalblnf128.h
new file mode 100644
index 0000000000000..5265265487f82
--- /dev/null
+++ b/libc/src/__support/math/scalblnf128.h
@@ -0,0 +1,36 @@
+//===-- Implementation header for scalblnf128 -------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC___SUPPORT_MATH_SCALBLNF128_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_SCALBLNF128_H
+
+#include "include/llvm-libc-types/float128.h"
+
+#ifdef LIBC_TYPES_HAS_FLOAT128
+
+#include "hdr/float_macros.h"
+#include "src/__support/FPUtil/ManipulationFunctions.h"
+#include "src/__support/macros/config.h"
+
+#if FLT_RADIX != 2
+#error "FLT_RADIX != 2 is not supported."
+#endif
+
+namespace LIBC_NAMESPACE_DECL {
+namespace math {
+
+LIBC_INLINE constexpr float128 scalblnf128(float128 x, long n) {
+ return fputil::ldexp(x, n);
+}
+
+} // namespace math
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LIBC_TYPES_HAS_FLOAT128
+
+#endif // LLVM_LIBC_SRC___SUPPORT_MATH_SCALBLNF128_H
diff --git a/libc/src/__support/math/scalblnf16.h b/libc/src/__support/math/scalblnf16.h
new file mode 100644
index 0000000000000..f19a212364dce
--- /dev/null
+++ b/libc/src/__support/math/scalblnf16.h
@@ -0,0 +1,36 @@
+//===-- Implementation header for scalblnf16 --------------------*- 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_SCALBLNF16_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_SCALBLNF16_H
+
+#include "include/llvm-libc-macros/float16-macros.h"
+
+#ifdef LIBC_TYPES_HAS_FLOAT16
+
+#include "src/__support/FPUtil/ManipulationFunctions.h"
+#include "hdr/float_macros.h"
+#include "src/__support/macros/config.h"
+
+#if FLT_RADIX != 2
+#error "FLT_RADIX != 2 is not supported."
+#endif
+
+namespace LIBC_NAMESPACE_DECL {
+namespace math {
+
+LIBC_INLINE constexpr float16 scalblnf16(float16 x, long n) {
+ return fputil::ldexp(x, n);
+}
+
+} // namespace math
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LIBC_TYPES_HAS_FLOAT16
+
+#endif // LLVM_LIBC_SRC___SUPPORT_MATH_SCALBLNF16_H
diff --git a/libc/src/__support/math/scalblnl.h b/libc/src/__support/math/scalblnl.h
new file mode 100644
index 0000000000000..e10b30564b0b3
--- /dev/null
+++ b/libc/src/__support/math/scalblnl.h
@@ -0,0 +1,30 @@
+//===-- Implementation header for scalblnl ----------------------*- 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_SCALBLNL_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_SCALBLNL_H
+
+#include "hdr/float_macros.h"
+#include "src/__support/FPUtil/ManipulationFunctions.h"
+#include "src/__support/macros/config.h"
+
+#if FLT_RADIX != 2
+#error "FLT_RADIX != 2 is not supported."
+#endif
+
+namespace LIBC_NAMESPACE_DECL {
+namespace math {
+
+LIBC_INLINE constexpr long double scalblnl(long double x, long n) {
+ return fputil::ldexp(x, n);
+}
+
+} // namespace math
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC___SUPPORT_MATH_SCALBLNL_H
diff --git a/libc/src/__support/math/scalbn.h b/libc/src/__support/math/scalbn.h
new file mode 100644
index 0000000000000..ab4dc5baff487
--- /dev/null
+++ b/libc/src/__support/math/scalbn.h
@@ -0,0 +1,30 @@
+//===-- Implementation header for scalbn ------------------------*- 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_SCALBN_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_SCALBN_H
+
+#include "hdr/float_macros.h"
+#include "src/__support/FPUtil/ManipulationFunctions.h"
+#include "src/__support/macros/config.h"
+
+#if FLT_RADIX != 2
+#error "FLT_RADIX != 2 is not supported."
+#endif
+
+namespace LIBC_NAMESPACE_DECL {
+namespace math {
+
+LIBC_INLINE constexpr double scalbn(double x, int n) {
+ return fputil::ldexp(x, n);
+}
+
+} // namespace math
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC___SUPPORT_MATH_SCALBN_H
diff --git a/libc/src/__support/math/scalbnbf16.h b/libc/src/__support/math/scalbnbf16.h
new file mode 100644
index 0000000000000..08aeb4fe33dc0
--- /dev/null
+++ b/libc/src/__support/math/scalbnbf16.h
@@ -0,0 +1,31 @@
+//===-- Implementation header for scalbnbf16 --------------------*- 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_SCALBNBF16_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_SCALBNBF16_H
+
+#include "hdr/float_macros.h"
+#include "src/__support/FPUtil/ManipulationFunctions.h"
+#include "src/__support/FPUtil/bfloat16.h"
+#include "src/__support/macros/config.h"
+
+#if FLT_RADIX != 2
+#error "FLT_RADIX != 2 is not supported."
+#endif
+
+namespace LIBC_NAMESPACE_DECL {
+namespace math {
+
+LIBC_INLINE constexpr bfloat16 scalbnbf16(bfloat16 x, int n) {
+ return fputil::ldexp(x, n);
+}
+
+} // namespace math
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC___SUPPORT_MATH_SCALBNBF16_H
diff --git a/libc/src/__support/math/scalbnf.h b/libc/src/__support/math/scalbnf.h
new file mode 100644
index 0000000000000..2bf9513466191
--- /dev/null
+++ b/libc/src/__support/math/scalbnf.h
@@ -0,0 +1,30 @@
+//===-- Implementation header for scalbnf -----------------------*- 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_SCALBNF_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_SCALBNF_H
+
+#include "hdr/float_macros.h"
+#include "src/__support/FPUtil/ManipulationFunctions.h"
+#include "src/__support/macros/config.h"
+
+#if FLT_RADIX != 2
+#error "FLT_RADIX != 2 is not supported."
+#endif
+
+namespace LIBC_NAMESPACE_DECL {
+namespace math {
+
+LIBC_INLINE constexpr float scalbnf(float x, int n) {
+ return fputil::ldexp(x, n);
+}
+
+} // namespace math
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC___SUPPORT_MATH_SCALBNF_H
diff --git a/libc/src/__support/math/scalbnf128.h b/libc/src/__support/math/scalbnf128.h
new file mode 100644
index 0000000000000..58963d1702c27
--- /dev/null
+++ b/libc/src/__support/math/scalbnf128.h
@@ -0,0 +1,36 @@
+//===-- Implementation header for scalbnf128 --------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC___SUPPORT_MATH_SCALBNF128_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_SCALBNF128_H
+
+#include "include/llvm-libc-types/float128.h"
+
+#ifdef LIBC_TYPES_HAS_FLOAT128
+
+#include "hdr/float_macros.h"
+#include "src/__support/FPUtil/ManipulationFunctions.h"
+#include "src/__support/macros/config.h"
+
+#if FLT_RADIX != 2
+#error "FLT_RADIX != 2 is not supported."
+#endif
+
+namespace LIBC_NAMESPACE_DECL {
+namespace math {
+
+LIBC_INLINE constexpr float128 scalbnf128(float128 x, int n) {
+ return fputil::ldexp(x, n);
+}
+
+} // namespace math
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LIBC_TYPES_HAS_FLOAT128
+
+#endif // LLVM_LIBC_SRC___SUPPORT_MATH_SCALBNF128_H
diff --git a/libc/src/__support/math/scalbnf16.h b/libc/src/__support/math/scalbnf16.h
new file mode 100644
index 0000000000000..7bda6f2f74323
--- /dev/null
+++ b/libc/src/__support/math/scalbnf16.h
@@ -0,0 +1,36 @@
+//===-- Implementation header for scalbnf16 ---------------------*- 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_SCALBNF16_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_SCALBNF16_H
+
+#include "include/llvm-libc-macros/float16-macros.h"
+
+#ifdef LIBC_TYPES_HAS_FLOAT16
+
+#include "hdr/float_macros.h"
+#include "src/__support/FPUtil/ManipulationFunctions.h"
+#include "src/__support/macros/config.h"
+
+#if FLT_RADIX != 2
+#error "FLT_RADIX != 2 is not supported."
+#endif
+
+namespace LIBC_NAMESPACE_DECL {
+namespace math {
+
+LIBC_INLINE constexpr float16 scalbnf16(float16 x, int n) {
+ return fputil::ldexp(x, n);
+}
+
+} // namespace math
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LIBC_TYPES_HAS_FLOAT16
+
+#endif // LLVM_LIBC_SRC___SUPPORT_MATH_SCALBNF16_H
diff --git a/libc/src/__support/math/scalbnl.h b/libc/src/__support/math/scalbnl.h
new file mode 100644
index 0000000000000..76eaf12722ada
--- /dev/null
+++ b/libc/src/__support/math/scalbnl.h
@@ -0,0 +1,30 @@
+//===-- Implementation header for scalbnl -----------------------*- 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_SCALBNL_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_SCALBNL_H
+
+#include "hdr/float_macros.h"
+#include "src/__support/FPUtil/ManipulationFunctions.h"
+#include "src/__support/macros/config.h"
+
+#if FLT_RADIX != 2
+#error "FLT_RADIX != 2 is not supported."
+#endif
+
+namespace LIBC_NAMESPACE_DECL {
+namespace math {
+
+LIBC_INLINE constexpr long double scalbnl(long double x, int n) {
+ return fputil::ldexp(x, n);
+}
+
+} // namespace math
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC___SUPPORT_MATH_SCALBNL_H
diff --git a/libc/src/math/generic/CMakeLists.txt b/libc/src/math/generic/CMakeLists.txt
index 8b2a8729bf946..b750e273091f6 100644
--- a/libc/src/math/generic/CMakeLists.txt
+++ b/libc/src/math/generic/CMakeLists.txt
@@ -1729,7 +1729,7 @@ add_entrypoint_object(
HDRS
../ldexp.h
DEPENDS
- libc.src.__support.FPUtil.manipulation_functions
+ libc.src.__support.math.ldexp
)
add_entrypoint_object(
@@ -1749,7 +1749,7 @@ add_entrypoint_object(
HDRS
../ldexpl.h
DEPENDS
- libc.src.__support.FPUtil.manipulation_functions
+ libc.src.__support.math.ldexpl
)
add_entrypoint_object(
@@ -1779,11 +1779,7 @@ add_entrypoint_object(
HDRS
../ldexpbf16.h
DEPENDS
- libc.src.__support.common
- libc.src.__support.FPUtil.bfloat16
- libc.src.__support.FPUtil.manipulation_functions
- libc.src.__support.macros.config
- libc.src.__support.macros.properties.types
+ libc.src.__support.math.ldexpbf16
)
add_entrypoint_object(
@@ -4095,8 +4091,7 @@ add_entrypoint_object(
HDRS
../scalbln.h
DEPENDS
- libc.hdr.float_macros
- libc.src.__support.FPUtil.manipulation_functions
+ libc.src.__support.math.scalbln
)
add_entrypoint_object(
@@ -4106,8 +4101,7 @@ add_entrypoint_object(
HDRS
../scalblnf.h
DEPENDS
- libc.hdr.float_macros
- libc.src.__support.FPUtil.manipulation_functions
+ libc.src.__support.math.scalblnf
)
add_entrypoint_object(
@@ -4117,8 +4111,7 @@ add_entrypoint_object(
HDRS
../scalblnl.h
DEPENDS
- libc.hdr.float_macros
- libc.src.__support.FPUtil.manipulation_functions
+ libc.src.__support.math.scalblnl
)
add_entrypoint_object(
@@ -4128,9 +4121,7 @@ add_entrypoint_object(
HDRS
../scalblnf16.h
DEPENDS
- libc.hdr.float_macros
- libc.src.__support.macros.properties.types
- libc.src.__support.FPUtil.manipulation_functions
+ libc.src.__support.math.scalblnf16
)
add_entrypoint_object(
@@ -4140,9 +4131,7 @@ add_entrypoint_object(
HDRS
../scalblnf128.h
DEPENDS
- libc.hdr.float_macros
- libc.src.__support.macros.properties.types
- libc.src.__support.FPUtil.manipulation_functions
+ libc.src.__support.math.scalblnf128
)
add_entrypoint_object(
@@ -4152,12 +4141,7 @@ add_entrypoint_object(
HDRS
../scalblnbf16.h
DEPENDS
- libc.hdr.float_macros
- libc.src.__support.common
- libc.src.__support.macros.config
- libc.src.__support.macros.properties.types
- libc.src.__support.FPUtil.bfloat16
- libc.src.__support.FPUtil.manipulation_functions
+ libc.src.__support.math.scalblnbf16
)
add_entrypoint_object(
@@ -4167,8 +4151,7 @@ add_entrypoint_object(
HDRS
../scalbn.h
DEPENDS
- libc.hdr.float_macros
- libc.src.__support.FPUtil.manipulation_functions
+ libc.src.__support.math.scalbn
)
add_entrypoint_object(
@@ -4178,8 +4161,7 @@ add_entrypoint_object(
HDRS
../scalbnf.h
DEPENDS
- libc.hdr.float_macros
- libc.src.__support.FPUtil.manipulation_functions
+ libc.src.__support.math.scalbnf
)
add_entrypoint_object(
@@ -4189,8 +4171,7 @@ add_entrypoint_object(
HDRS
../scalbnl.h
DEPENDS
- libc.hdr.float_macros
- libc.src.__support.FPUtil.manipulation_functions
+ libc.src.__support.math.scalbnl
)
add_entrypoint_object(
@@ -4200,9 +4181,7 @@ add_entrypoint_object(
HDRS
../scalbnf16.h
DEPENDS
- libc.hdr.float_macros
- libc.src.__support.macros.properties.types
- libc.src.__support.FPUtil.manipulation_functions
+ libc.src.__support.math.scalbnf16
)
add_entrypoint_object(
@@ -4212,9 +4191,7 @@ add_entrypoint_object(
HDRS
../scalbnf128.h
DEPENDS
- libc.hdr.float_macros
- libc.src.__support.macros.properties.types
- libc.src.__support.FPUtil.manipulation_functions
+ libc.src.__support.math.scalbnf128
)
add_entrypoint_object(
@@ -4224,12 +4201,7 @@ add_entrypoint_object(
HDRS
../scalblnbf16.h
DEPENDS
- libc.hdr.float_macros
- libc.src.__support.common
- libc.src.__support.macros.config
- libc.src.__support.macros.properties.types
- libc.src.__support.FPUtil.bfloat16
- libc.src.__support.FPUtil.manipulation_functions
+ libc.src.__support.math.scalbnbf16
)
add_entrypoint_object(
diff --git a/libc/src/math/generic/ldexp.cpp b/libc/src/math/generic/ldexp.cpp
index 93ed328671f2c..38ca91937b8f6 100644
--- a/libc/src/math/generic/ldexp.cpp
+++ b/libc/src/math/generic/ldexp.cpp
@@ -7,14 +7,12 @@
//===----------------------------------------------------------------------===//
#include "src/math/ldexp.h"
-#include "src/__support/FPUtil/ManipulationFunctions.h"
-#include "src/__support/common.h"
-#include "src/__support/macros/config.h"
+#include "src/__support/math/ldexp.h"
namespace LIBC_NAMESPACE_DECL {
LLVM_LIBC_FUNCTION(double, ldexp, (double x, int exp)) {
- return fputil::ldexp(x, exp);
+ return math::ldexp(x, exp);
}
} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/ldexpbf16.cpp b/libc/src/math/generic/ldexpbf16.cpp
index 42a5039e81bc0..a41b49bdef88e 100644
--- a/libc/src/math/generic/ldexpbf16.cpp
+++ b/libc/src/math/generic/ldexpbf16.cpp
@@ -7,15 +7,12 @@
//===----------------------------------------------------------------------===//
#include "src/math/ldexpbf16.h"
-#include "src/__support/FPUtil/ManipulationFunctions.h"
-#include "src/__support/FPUtil/bfloat16.h"
-#include "src/__support/common.h"
-#include "src/__support/macros/config.h"
+#include "src/__support/math/ldexpbf16.h"
namespace LIBC_NAMESPACE_DECL {
LLVM_LIBC_FUNCTION(bfloat16, ldexpbf16, (bfloat16 x, int exp)) {
- return fputil::ldexp(x, exp);
+ return math::ldexpbf16(x, exp);
}
} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/ldexpl.cpp b/libc/src/math/generic/ldexpl.cpp
index 9e1de5c5cf4a7..0012e75b8e0ff 100644
--- a/libc/src/math/generic/ldexpl.cpp
+++ b/libc/src/math/generic/ldexpl.cpp
@@ -7,14 +7,12 @@
//===----------------------------------------------------------------------===//
#include "src/math/ldexpl.h"
-#include "src/__support/FPUtil/ManipulationFunctions.h"
-#include "src/__support/common.h"
-#include "src/__support/macros/config.h"
+#include "src/__support/math/ldexpl.h"
namespace LIBC_NAMESPACE_DECL {
LLVM_LIBC_FUNCTION(long double, ldexpl, (long double x, int exp)) {
- return fputil::ldexp(x, exp);
+ return math::ldexpl(x, exp);
}
} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/scalbln.cpp b/libc/src/math/generic/scalbln.cpp
index f97619954237e..b4214271ff9f9 100644
--- a/libc/src/math/generic/scalbln.cpp
+++ b/libc/src/math/generic/scalbln.cpp
@@ -7,19 +7,12 @@
//===----------------------------------------------------------------------===//
#include "src/math/scalbln.h"
-#include "hdr/float_macros.h"
-#include "src/__support/FPUtil/ManipulationFunctions.h"
-#include "src/__support/common.h"
-#include "src/__support/macros/config.h"
-
-#if FLT_RADIX != 2
-#error "FLT_RADIX != 2 is not supported."
-#endif
+#include "src/__support/math/scalbln.h"
namespace LIBC_NAMESPACE_DECL {
LLVM_LIBC_FUNCTION(double, scalbln, (double x, long n)) {
- return fputil::ldexp(x, n);
+ return math::scalbln(x, n);
}
} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/scalblnbf16.cpp b/libc/src/math/generic/scalblnbf16.cpp
index f85f702660ed2..0b189f9e04b2d 100644
--- a/libc/src/math/generic/scalblnbf16.cpp
+++ b/libc/src/math/generic/scalblnbf16.cpp
@@ -7,20 +7,12 @@
//===----------------------------------------------------------------------===//
#include "src/math/scalblnbf16.h"
-#include "hdr/float_macros.h"
-#include "src/__support/FPUtil/ManipulationFunctions.h"
-#include "src/__support/FPUtil/bfloat16.h"
-#include "src/__support/common.h"
-#include "src/__support/macros/config.h"
-
-#if FLT_RADIX != 2
-#error "FLT_RADIX != 2 is not supported."
-#endif
+#include "src/__support/math/scalblnbf16.h"
namespace LIBC_NAMESPACE_DECL {
LLVM_LIBC_FUNCTION(bfloat16, scalblnbf16, (bfloat16 x, long n)) {
- return fputil::ldexp(x, n);
+ return math::scalblnbf16(x, n);
}
} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/scalblnf.cpp b/libc/src/math/generic/scalblnf.cpp
index aa11a552a9194..c596e27ee71c1 100644
--- a/libc/src/math/generic/scalblnf.cpp
+++ b/libc/src/math/generic/scalblnf.cpp
@@ -7,19 +7,12 @@
//===----------------------------------------------------------------------===//
#include "src/math/scalblnf.h"
-#include "hdr/float_macros.h"
-#include "src/__support/FPUtil/ManipulationFunctions.h"
-#include "src/__support/common.h"
-#include "src/__support/macros/config.h"
-
-#if FLT_RADIX != 2
-#error "FLT_RADIX != 2 is not supported."
-#endif
+#include "src/__support/math/scalblnf.h"
namespace LIBC_NAMESPACE_DECL {
LLVM_LIBC_FUNCTION(float, scalblnf, (float x, long n)) {
- return fputil::ldexp(x, n);
+ return math::scalblnf(x, n);
}
} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/scalblnf128.cpp b/libc/src/math/generic/scalblnf128.cpp
index fda6ea0bfe030..151b75a913dac 100644
--- a/libc/src/math/generic/scalblnf128.cpp
+++ b/libc/src/math/generic/scalblnf128.cpp
@@ -7,19 +7,12 @@
//===----------------------------------------------------------------------===//
#include "src/math/scalblnf128.h"
-#include "hdr/float_macros.h"
-#include "src/__support/FPUtil/ManipulationFunctions.h"
-#include "src/__support/common.h"
-#include "src/__support/macros/config.h"
-
-#if FLT_RADIX != 2
-#error "FLT_RADIX != 2 is not supported."
-#endif
+#include "src/__support/math/scalblnf128.h"
namespace LIBC_NAMESPACE_DECL {
LLVM_LIBC_FUNCTION(float128, scalblnf128, (float128 x, long n)) {
- return fputil::ldexp(x, n);
+ return math::scalblnf128(x, n);
}
} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/scalblnf16.cpp b/libc/src/math/generic/scalblnf16.cpp
index 7f43841291e43..d33dd2af6aede 100644
--- a/libc/src/math/generic/scalblnf16.cpp
+++ b/libc/src/math/generic/scalblnf16.cpp
@@ -7,20 +7,12 @@
//===----------------------------------------------------------------------===//
#include "src/math/scalblnf16.h"
-#include "src/__support/FPUtil/ManipulationFunctions.h"
-#include "src/__support/common.h"
-
-#include "hdr/float_macros.h"
-#include "src/__support/macros/config.h"
-
-#if FLT_RADIX != 2
-#error "FLT_RADIX != 2 is not supported."
-#endif
+#include "src/__support/math/scalblnf16.h"
namespace LIBC_NAMESPACE_DECL {
LLVM_LIBC_FUNCTION(float16, scalblnf16, (float16 x, long n)) {
- return fputil::ldexp(x, n);
+ return math::scalblnf16(x, n);
}
} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/scalblnl.cpp b/libc/src/math/generic/scalblnl.cpp
index 5823c498ba3ec..8292dbc9afb9a 100644
--- a/libc/src/math/generic/scalblnl.cpp
+++ b/libc/src/math/generic/scalblnl.cpp
@@ -7,19 +7,12 @@
//===----------------------------------------------------------------------===//
#include "src/math/scalblnl.h"
-#include "hdr/float_macros.h"
-#include "src/__support/FPUtil/ManipulationFunctions.h"
-#include "src/__support/common.h"
-#include "src/__support/macros/config.h"
-
-#if FLT_RADIX != 2
-#error "FLT_RADIX != 2 is not supported."
-#endif
+#include "src/__support/math/scalblnl.h"
namespace LIBC_NAMESPACE_DECL {
LLVM_LIBC_FUNCTION(long double, scalblnl, (long double x, long n)) {
- return fputil::ldexp(x, n);
+ return math::scalblnl(x, n);
}
} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/scalbn.cpp b/libc/src/math/generic/scalbn.cpp
index c1ee994197f52..e9798a7eb69b6 100644
--- a/libc/src/math/generic/scalbn.cpp
+++ b/libc/src/math/generic/scalbn.cpp
@@ -7,19 +7,12 @@
//===----------------------------------------------------------------------===//
#include "src/math/scalbn.h"
-#include "hdr/float_macros.h"
-#include "src/__support/FPUtil/ManipulationFunctions.h"
-#include "src/__support/common.h"
-#include "src/__support/macros/config.h"
-
-#if FLT_RADIX != 2
-#error "FLT_RADIX != 2 is not supported."
-#endif
+#include "src/__support/math/scalbn.h"
namespace LIBC_NAMESPACE_DECL {
LLVM_LIBC_FUNCTION(double, scalbn, (double x, int n)) {
- return fputil::ldexp(x, n);
+ return math::scalbn(x, n);
}
} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/scalbnbf16.cpp b/libc/src/math/generic/scalbnbf16.cpp
index 108f9e7d4d057..daf0eb047c3c3 100644
--- a/libc/src/math/generic/scalbnbf16.cpp
+++ b/libc/src/math/generic/scalbnbf16.cpp
@@ -7,20 +7,12 @@
//===----------------------------------------------------------------------===//
#include "src/math/scalbnbf16.h"
-#include "hdr/float_macros.h"
-#include "src/__support/FPUtil/ManipulationFunctions.h"
-#include "src/__support/FPUtil/bfloat16.h"
-#include "src/__support/common.h"
-#include "src/__support/macros/config.h"
-
-#if FLT_RADIX != 2
-#error "FLT_RADIX != 2 is not supported."
-#endif
+#include "src/__support/math/scalbnbf16.h"
namespace LIBC_NAMESPACE_DECL {
LLVM_LIBC_FUNCTION(bfloat16, scalbnbf16, (bfloat16 x, int n)) {
- return fputil::ldexp(x, n);
+ return math::scalbnbf16(x, n);
}
} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/scalbnf.cpp b/libc/src/math/generic/scalbnf.cpp
index 4281b0093c54b..1216f3ded0135 100644
--- a/libc/src/math/generic/scalbnf.cpp
+++ b/libc/src/math/generic/scalbnf.cpp
@@ -7,19 +7,12 @@
//===----------------------------------------------------------------------===//
#include "src/math/scalbnf.h"
-#include "hdr/float_macros.h"
-#include "src/__support/FPUtil/ManipulationFunctions.h"
-#include "src/__support/common.h"
-#include "src/__support/macros/config.h"
-
-#if FLT_RADIX != 2
-#error "FLT_RADIX != 2 is not supported."
-#endif
+#include "src/__support/math/scalbnf.h"
namespace LIBC_NAMESPACE_DECL {
LLVM_LIBC_FUNCTION(float, scalbnf, (float x, int n)) {
- return fputil::ldexp(x, n);
+ return math::scalbnf(x, n);
}
} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/scalbnf128.cpp b/libc/src/math/generic/scalbnf128.cpp
index e3e284613cdc5..f2655a3782f33 100644
--- a/libc/src/math/generic/scalbnf128.cpp
+++ b/libc/src/math/generic/scalbnf128.cpp
@@ -7,19 +7,12 @@
//===----------------------------------------------------------------------===//
#include "src/math/scalbnf128.h"
-#include "hdr/float_macros.h"
-#include "src/__support/FPUtil/ManipulationFunctions.h"
-#include "src/__support/common.h"
-#include "src/__support/macros/config.h"
-
-#if FLT_RADIX != 2
-#error "FLT_RADIX != 2 is not supported."
-#endif
+#include "src/__support/math/scalbnf128.h"
namespace LIBC_NAMESPACE_DECL {
LLVM_LIBC_FUNCTION(float128, scalbnf128, (float128 x, int n)) {
- return fputil::ldexp(x, n);
+ return math::scalbnf128(x, n);
}
} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/scalbnf16.cpp b/libc/src/math/generic/scalbnf16.cpp
index 641e2d0da0013..d23599092d935 100644
--- a/libc/src/math/generic/scalbnf16.cpp
+++ b/libc/src/math/generic/scalbnf16.cpp
@@ -7,20 +7,12 @@
//===----------------------------------------------------------------------===//
#include "src/math/scalbnf16.h"
-#include "src/__support/FPUtil/ManipulationFunctions.h"
-#include "src/__support/common.h"
-
-#include "hdr/float_macros.h"
-#include "src/__support/macros/config.h"
-
-#if FLT_RADIX != 2
-#error "FLT_RADIX != 2 is not supported."
-#endif
+#include "src/__support/math/scalbnf16.h"
namespace LIBC_NAMESPACE_DECL {
LLVM_LIBC_FUNCTION(float16, scalbnf16, (float16 x, int n)) {
- return fputil::ldexp(x, n);
+ return math::scalbnf16(x, n);
}
} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/scalbnl.cpp b/libc/src/math/generic/scalbnl.cpp
index 3015c3c6c7f41..184cfdf622e97 100644
--- a/libc/src/math/generic/scalbnl.cpp
+++ b/libc/src/math/generic/scalbnl.cpp
@@ -7,19 +7,12 @@
//===----------------------------------------------------------------------===//
#include "src/math/scalbnl.h"
-#include "hdr/float_macros.h"
-#include "src/__support/FPUtil/ManipulationFunctions.h"
-#include "src/__support/common.h"
-#include "src/__support/macros/config.h"
-
-#if FLT_RADIX != 2
-#error "FLT_RADIX != 2 is not supported."
-#endif
+#include "src/__support/math/scalbnl.h"
namespace LIBC_NAMESPACE_DECL {
LLVM_LIBC_FUNCTION(long double, scalbnl, (long double x, int n)) {
- return fputil::ldexp(x, n);
+ return math::scalbnl(x, n);
}
} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/test/shared/CMakeLists.txt b/libc/test/shared/CMakeLists.txt
index 92b0418a3a559..bf92e4cbdbcf2 100644
--- a/libc/test/shared/CMakeLists.txt
+++ b/libc/test/shared/CMakeLists.txt
@@ -269,7 +269,10 @@ add_fp_unittest(
libc.src.__support.math.ilogbf16
libc.src.__support.math.ilogbf128
libc.src.__support.math.ilogbl
+ libc.src.__support.math.ldexp
+ libc.src.__support.math.ldexpbf16
libc.src.__support.math.ldexpf
+ libc.src.__support.math.ldexpl
libc.src.__support.math.llogb
libc.src.__support.math.llogbbf16
libc.src.__support.math.log
@@ -344,6 +347,18 @@ add_fp_unittest(
libc.src.__support.math.remquol
libc.src.__support.math.rsqrtf
libc.src.__support.math.rsqrtf16
+ libc.src.__support.math.scalbln
+ libc.src.__support.math.scalblnbf16
+ libc.src.__support.math.scalblnf
+ libc.src.__support.math.scalblnf128
+ libc.src.__support.math.scalblnf16
+ libc.src.__support.math.scalblnl
+ libc.src.__support.math.scalbn
+ libc.src.__support.math.scalbnbf16
+ libc.src.__support.math.scalbnf
+ libc.src.__support.math.scalbnf128
+ libc.src.__support.math.scalbnf16
+ libc.src.__support.math.scalbnl
libc.src.__support.math.setpayload
libc.src.__support.math.setpayloadbf16
libc.src.__support.math.setpayloadf
@@ -526,6 +541,9 @@ add_fp_unittest(
libc.src.__support.math.fromfpxf128
libc.src.__support.math.fromfpxf16
libc.src.__support.math.fromfpxl
+ libc.src.__support.math.ldexp
+ libc.src.__support.math.ldexpbf16
+ libc.src.__support.math.ldexpl
libc.src.__support.math.llogbbf16
libc.src.__support.math.log
libc.src.__support.math.logbbf16
@@ -548,6 +566,18 @@ add_fp_unittest(
libc.src.__support.math.remquof128
libc.src.__support.math.remquof16
libc.src.__support.math.remquol
+ libc.src.__support.math.scalbln
+ libc.src.__support.math.scalblnbf16
+ libc.src.__support.math.scalblnf
+ libc.src.__support.math.scalblnf128
+ libc.src.__support.math.scalblnf16
+ libc.src.__support.math.scalblnl
+ libc.src.__support.math.scalbn
+ libc.src.__support.math.scalbnbf16
+ libc.src.__support.math.scalbnf
+ libc.src.__support.math.scalbnf128
+ libc.src.__support.math.scalbnf16
+ libc.src.__support.math.scalbnl
libc.src.__support.math.sqrtl
libc.src.__support.math.ufromfp
libc.src.__support.math.ufromfpbf16
diff --git a/libc/test/shared/shared_math_constexpr_test.cpp b/libc/test/shared/shared_math_constexpr_test.cpp
index 8be1bfc0bc4ac..d53287c978e76 100644
--- a/libc/test/shared/shared_math_constexpr_test.cpp
+++ b/libc/test/shared/shared_math_constexpr_test.cpp
@@ -55,6 +55,9 @@ static_assert(0.0 == [] {
int exp{};
return LIBC_NAMESPACE::shared::remquo(1.0, 1.0, &exp);
}());
+static_assert(0.0 == LIBC_NAMESPACE::shared::ldexp(0.0, 0.0));
+static_assert(0.0 == LIBC_NAMESPACE::shared::scalbln(0.0, 0.0));
+static_assert(0.0 == LIBC_NAMESPACE::shared::scalbn(0.0, 0.0));
//===----------------------------------------------------------------------===//
// Float Tests
@@ -99,6 +102,8 @@ static_assert(0.0f == [] {
int exp{};
return LIBC_NAMESPACE::shared::remquof(1.0f, 1.0f, &exp);
}());
+static_assert(0.0f == LIBC_NAMESPACE::shared::scalblnf(0.0f, 0.0));
+static_assert(0.0f == LIBC_NAMESPACE::shared::scalbnf(0.0f, 0.0));
//===----------------------------------------------------------------------===//
// Float16 Tests
//===----------------------------------------------------------------------===//
@@ -151,6 +156,8 @@ static_assert(0.0f16 == [] {
int exp{};
return LIBC_NAMESPACE::shared::remquof16(1.0f16, 1.0f16, &exp);
}());
+static_assert(0.0f16 == LIBC_NAMESPACE::shared::scalblnf16(0.0f16, 0.0));
+static_assert(0.0f16 == LIBC_NAMESPACE::shared::scalbnf16(0.0f16, 0.0));
#endif // LIBC_TYPES_HAS_FLOAT16
//===----------------------------------------------------------------------===//
@@ -205,6 +212,9 @@ static_assert(0.0L == [] {
int exp{};
return LIBC_NAMESPACE::shared::remquol(1.0L, 1.0L, &exp);
}());
+static_assert(0.0L == LIBC_NAMESPACE::shared::ldexpl(0.0L, 0.0));
+static_assert(0.0L == LIBC_NAMESPACE::shared::scalblnl(0.0L, 0.0));
+static_assert(0.0L == LIBC_NAMESPACE::shared::scalbnl(0.0L, 0.0));
#endif
@@ -293,6 +303,10 @@ static_assert(float128(0.0) == [] {
int exp{};
return LIBC_NAMESPACE::shared::remquof128(float128(1.0), float128(1.0), &exp);
}());
+static_assert(float128(0.0) ==
+ LIBC_NAMESPACE::shared::scalblnf128(float128(0.0), 0.0));
+static_assert(float128(0.0) ==
+ LIBC_NAMESPACE::shared::scalbnf128(float128(0.0), 0.0));
#endif // LIBC_TYPES_HAS_FLOAT128
@@ -374,5 +388,11 @@ static_assert(bfloat16(0.0) == [] {
int exp{};
return LIBC_NAMESPACE::shared::remquobf16(bfloat16(1.0), bfloat16(1.0), &exp);
}());
+static_assert(bfloat16(0.0) ==
+ LIBC_NAMESPACE::shared::ldexpbf16(bfloat16(0.0), 0.0));
+static_assert(bfloat16(0.0) ==
+ LIBC_NAMESPACE::shared::scalblnbf16(bfloat16(0.0), 0.0));
+static_assert(bfloat16(0.0) ==
+ LIBC_NAMESPACE::shared::scalbnbf16(bfloat16(0.0), 0.0));
TEST(LlvmLibcSharedMathTest, ConstantEvaluation) {}
diff --git a/libc/test/shared/shared_math_test.cpp b/libc/test/shared/shared_math_test.cpp
index fbdf8c9340956..2f2893c407766 100644
--- a/libc/test/shared/shared_math_test.cpp
+++ b/libc/test/shared/shared_math_test.cpp
@@ -140,6 +140,8 @@ TEST(LlvmLibcSharedMathTest, AllFloat16) {
EXPECT_FP_EQ(0x0p+0f16, LIBC_NAMESPACE::shared::remquof16(1.0f16, 1.0f16,
&remquof16_exp));
EXPECT_EQ(1, remquof16_exp);
+ EXPECT_FP_EQ(0x0p+0f16, LIBC_NAMESPACE::shared::scalblnf16(0.0f16, 0L));
+ EXPECT_FP_EQ(0x0p+0f16, LIBC_NAMESPACE::shared::scalbnf16(0.0f16, 0));
}
#endif // LIBC_TYPES_HAS_FLOAT16
@@ -280,6 +282,8 @@ TEST(LlvmLibcSharedMathTest, AllFloat) {
EXPECT_FP_EQ(0x0p+0f,
LIBC_NAMESPACE::shared::remquof(1.0f, 1.0f, &remquof_exp));
EXPECT_EQ(1, remquof_exp);
+ EXPECT_FP_EQ(0x0p+0f, LIBC_NAMESPACE::shared::scalblnf(0.0f, 0L));
+ EXPECT_FP_EQ(0x0p+0f, LIBC_NAMESPACE::shared::scalbnf(0.0f, 0));
}
TEST(LlvmLibcSharedMathTest, AllDouble) {
@@ -395,6 +399,9 @@ TEST(LlvmLibcSharedMathTest, AllDouble) {
int remquo_exp = 0;
EXPECT_FP_EQ(0.0, LIBC_NAMESPACE::shared::remquo(1.0, 1.0, &remquo_exp));
EXPECT_EQ(1, remquo_exp);
+ EXPECT_FP_EQ(0.0, LIBC_NAMESPACE::shared::ldexp(0.0, 0));
+ EXPECT_FP_EQ(0.0, LIBC_NAMESPACE::shared::scalbln(0.0, 0L));
+ EXPECT_FP_EQ(0.0, LIBC_NAMESPACE::shared::scalbn(0.0, 0));
}
// TODO: Enable the tests when double-double type is supported.
@@ -493,6 +500,9 @@ TEST(LlvmLibcSharedMathTest, AllLongDouble) {
EXPECT_FP_EQ(0x0p+0L,
LIBC_NAMESPACE::shared::remquol(1.0L, 1.0L, &remquol_exp));
EXPECT_EQ(1, remquol_exp);
+ EXPECT_FP_EQ(0x0p+0L, LIBC_NAMESPACE::shared::ldexpl(0.0L, 0));
+ EXPECT_FP_EQ(0x0p+0L, LIBC_NAMESPACE::shared::scalblnl(0.0L, 0L));
+ EXPECT_FP_EQ(0x0p+0L, LIBC_NAMESPACE::shared::scalbnl(0.0L, 0));
}
#endif // LIBC_TYPES_LONG_DOUBLE_IS_DOUBLE_DOUBLE
@@ -647,6 +657,10 @@ TEST(LlvmLibcSharedMathTest, AllFloat128) {
LIBC_NAMESPACE::shared::remquof128(float128(1.0), float128(1.0),
&remquof128_exp));
EXPECT_EQ(1, remquof128_exp);
+ EXPECT_FP_EQ(float128(0.0),
+ LIBC_NAMESPACE::shared::scalblnf128(float128(0.0), 0L));
+ EXPECT_FP_EQ(float128(0.0),
+ LIBC_NAMESPACE::shared::scalbnf128(float128(0.0), 0));
}
#endif // LIBC_TYPES_HAS_FLOAT128
@@ -762,4 +776,10 @@ TEST(LlvmLibcSharedMathTest, AllBFloat16) {
LIBC_NAMESPACE::shared::remquobf16(bfloat16(1.0), bfloat16(1.0),
&remquobf16_exp));
EXPECT_EQ(1, remquobf16_exp);
+ EXPECT_FP_EQ(bfloat16(0.0),
+ LIBC_NAMESPACE::shared::ldexpbf16(bfloat16(0.0), 0));
+ EXPECT_FP_EQ(bfloat16(0.0),
+ LIBC_NAMESPACE::shared::scalblnbf16(bfloat16(0.0), 0L));
+ EXPECT_FP_EQ(bfloat16(0.0),
+ LIBC_NAMESPACE::shared::scalbnbf16(bfloat16(0.0), 0));
}
diff --git a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
index f4dc6d7e2e8db..c9f7dbc6a113e 100644
--- a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
@@ -4733,6 +4733,34 @@ libc_support_library(
],
)
+libc_support_library(
+ name = "__support_math_ldexp",
+ hdrs = ["src/__support/math/ldexp.h"],
+ deps = [
+ ":__support_fputil_manipulation_functions",
+ ":__support_macros_config",
+ ],
+)
+
+libc_support_library(
+ name = "__support_math_ldexpbf16",
+ hdrs = ["src/__support/math/ldexpbf16.h"],
+ deps = [
+ ":__support_fputil_bfloat16",
+ ":__support_fputil_manipulation_functions",
+ ":__support_macros_config",
+ ],
+)
+
+libc_support_library(
+ name = "__support_math_ldexpl",
+ hdrs = ["src/__support/math/ldexpl.h"],
+ deps = [
+ ":__support_fputil_manipulation_functions",
+ ":__support_macros_config",
+ ],
+)
+
libc_support_library(
name = "__support_math_ilogbbf16",
hdrs = ["src/__support/math/ilogbbf16.h"],
@@ -4914,6 +4942,132 @@ libc_support_library(
],
)
+libc_support_library(
+ name = "__support_math_scalbln",
+ hdrs = ["src/__support/math/scalbln.h"],
+ deps = [
+ ":__support_fputil_manipulation_functions",
+ ":__support_macros_config",
+ ":hdr_float_macros",
+ ],
+)
+
+libc_support_library(
+ name = "__support_math_scalblnbf16",
+ hdrs = ["src/__support/math/scalblnbf16.h"],
+ deps = [
+ ":__support_fputil_bfloat16",
+ ":__support_fputil_manipulation_functions",
+ ":__support_macros_config",
+ ":hdr_float_macros",
+ ],
+)
+
+libc_support_library(
+ name = "__support_math_scalblnf",
+ hdrs = ["src/__support/math/scalblnf.h"],
+ deps = [
+ ":__support_fputil_manipulation_functions",
+ ":__support_macros_config",
+ ":hdr_float_macros",
+ ],
+)
+
+libc_support_library(
+ name = "__support_math_scalblnf128",
+ hdrs = ["src/__support/math/scalblnf128.h"],
+ deps = [
+ ":__support_fputil_manipulation_functions",
+ ":__support_macros_config",
+ ":hdr_float_macros",
+ ":llvm_libc_types_float128",
+ ],
+)
+
+libc_support_library(
+ name = "__support_math_scalblnf16",
+ hdrs = ["src/__support/math/scalblnf16.h"],
+ deps = [
+ ":__support_fputil_manipulation_functions",
+ ":__support_macros_config",
+ ":hdr_float_macros",
+ ":llvm_libc_macros_float16_macros",
+ ],
+)
+
+libc_support_library(
+ name = "__support_math_scalblnl",
+ hdrs = ["src/__support/math/scalblnl.h"],
+ deps = [
+ ":__support_fputil_manipulation_functions",
+ ":__support_macros_config",
+ ":hdr_float_macros",
+ ],
+)
+
+libc_support_library(
+ name = "__support_math_scalbn",
+ hdrs = ["src/__support/math/scalbn.h"],
+ deps = [
+ ":__support_fputil_manipulation_functions",
+ ":__support_macros_config",
+ ":hdr_float_macros",
+ ],
+)
+
+libc_support_library(
+ name = "__support_math_scalbnbf16",
+ hdrs = ["src/__support/math/scalbnbf16.h"],
+ deps = [
+ ":__support_fputil_bfloat16",
+ ":__support_fputil_manipulation_functions",
+ ":__support_macros_config",
+ ":hdr_float_macros",
+ ],
+)
+
+libc_support_library(
+ name = "__support_math_scalbnf",
+ hdrs = ["src/__support/math/scalbnf.h"],
+ deps = [
+ ":__support_fputil_manipulation_functions",
+ ":__support_macros_config",
+ ":hdr_float_macros",
+ ],
+)
+
+libc_support_library(
+ name = "__support_math_scalbnf128",
+ hdrs = ["src/__support/math/scalbnf128.h"],
+ deps = [
+ ":__support_fputil_manipulation_functions",
+ ":__support_macros_config",
+ ":hdr_float_macros",
+ ":llvm_libc_types_float128",
+ ],
+)
+
+libc_support_library(
+ name = "__support_math_scalbnf16",
+ hdrs = ["src/__support/math/scalbnf16.h"],
+ deps = [
+ ":__support_fputil_manipulation_functions",
+ ":__support_macros_config",
+ ":hdr_float_macros",
+ ":llvm_libc_macros_float16_macros",
+ ],
+)
+
+libc_support_library(
+ name = "__support_math_scalbnl",
+ hdrs = ["src/__support/math/scalbnl.h"],
+ deps = [
+ ":__support_fputil_manipulation_functions",
+ ":__support_macros_config",
+ ":hdr_float_macros",
+ ],
+)
+
libc_support_library(
name = "__support_math_llogbbf16",
hdrs = ["src/__support/math/llogbbf16.h"],
@@ -9869,14 +10023,31 @@ libc_math_function(
],
)
-libc_math_function(name = "ldexp")
+libc_math_function(
+ name = "ldexp",
+ additional_deps = [
+ ":__support_math_ldexp",
+ ],
+)
+
+libc_math_function(
+ name = "ldexpbf16",
+ additional_deps = [
+ ":__support_math_ldexpbf16",
+ ],
+)
libc_math_function(
name = "ldexpf",
additional_deps = [":__support_math_ldexpf"],
)
-libc_math_function(name = "ldexpl")
+libc_math_function(
+ name = "ldexpl",
+ additional_deps = [
+ ":__support_math_ldexpl",
+ ],
+)
libc_math_function(
name = "ldexpf128",
@@ -10546,59 +10717,85 @@ libc_math_function(
libc_math_function(
name = "scalbln",
- additional_deps = [":hdr_float_macros"],
+ additional_deps = [
+ ":__support_math_scalbln",
+ ],
+)
+
+libc_math_function(
+ name = "scalblnbf16",
+ additional_deps = [
+ ":__support_math_scalblnbf16",
+ ],
)
libc_math_function(
name = "scalblnf",
- additional_deps = [":hdr_float_macros"],
+ additional_deps = [
+ ":__support_math_scalblnf",
+ ],
)
libc_math_function(
name = "scalblnl",
- additional_deps = [":hdr_float_macros"],
+ additional_deps = [
+ ":__support_math_scalblnl",
+ ],
)
libc_math_function(
name = "scalblnf128",
additional_deps = [
- ":hdr_float_macros",
+ ":__support_math_scalblnf128",
],
)
libc_math_function(
name = "scalblnf16",
additional_deps = [
- ":hdr_float_macros",
+ ":__support_math_scalblnf16",
],
)
libc_math_function(
name = "scalbn",
- additional_deps = [":hdr_float_macros"],
+ additional_deps = [
+ ":__support_math_scalbn",
+ ],
+)
+
+libc_math_function(
+ name = "scalbnbf16",
+ additional_deps = [
+ ":__support_math_scalbnbf16",
+ ],
)
libc_math_function(
name = "scalbnf",
- additional_deps = [":hdr_float_macros"],
+ additional_deps = [
+ ":__support_math_scalbnf",
+ ],
)
libc_math_function(
name = "scalbnl",
- additional_deps = [":hdr_float_macros"],
+ additional_deps = [
+ ":__support_math_scalbnl",
+ ],
)
libc_math_function(
name = "scalbnf128",
additional_deps = [
- ":hdr_float_macros",
+ ":__support_math_scalbnf128",
],
)
libc_math_function(
name = "scalbnf16",
additional_deps = [
- ":hdr_float_macros",
+ ":__support_math_scalbnf16",
],
)
More information about the libc-commits
mailing list