[libc-commits] [libc] [llvm] [libc][math] Refactor fmaximum-mag-num-fminimum-mag-num family to header-only (PR #195415)
via libc-commits
libc-commits at lists.llvm.org
Fri May 1 22:35:31 PDT 2026
https://github.com/AnonMiraj created https://github.com/llvm/llvm-project/pull/195415
Refactors the fmaximum-mag-num-fminimum-mag-num math family to be header-only.
part of: #147386
Target Functions:
- fmaximum_mag_numf128
- fmaximum_mag_numf16
- fmaximum_mag_numl
- fminimum_mag_num
- fminimum_mag_numbf16
- fminimum_mag_numf
- fminimum_mag_numf128
- fminimum_mag_numf16
- fminimum_mag_numl
>From a26a6715341012e5694c75a657b42f6c229763d2 Mon Sep 17 00:00:00 2001
From: Anonmiraj <ezzibrahimx at gmail.com>
Date: Sat, 2 May 2026 08:35:17 +0300
Subject: [PATCH] [libc][math] Refactor fmaximum-mag-num-fminimum-mag-num
family to header-only
Refactored functions:
- fmaximum_mag_numf128
- fmaximum_mag_numf16
- fmaximum_mag_numl
- fminimum_mag_num
- fminimum_mag_numbf16
- fminimum_mag_numf
- fminimum_mag_numf128
- fminimum_mag_numf16
- fminimum_mag_numl
---
libc/shared/math.h | 9 ++
libc/shared/math/fmaximum_mag_numf128.h | 29 ++++
libc/shared/math/fmaximum_mag_numf16.h | 29 ++++
libc/shared/math/fmaximum_mag_numl.h | 23 +++
libc/shared/math/fminimum_mag_num.h | 23 +++
libc/shared/math/fminimum_mag_numbf16.h | 23 +++
libc/shared/math/fminimum_mag_numf.h | 23 +++
libc/shared/math/fminimum_mag_numf128.h | 29 ++++
libc/shared/math/fminimum_mag_numf16.h | 29 ++++
libc/shared/math/fminimum_mag_numl.h | 23 +++
libc/src/__support/FPUtil/BasicOperations.h | 2 +-
libc/src/__support/math/CMakeLists.txt | 88 ++++++++++++
.../src/__support/math/fmaximum_mag_numf128.h | 31 ++++
libc/src/__support/math/fmaximum_mag_numf16.h | 31 ++++
libc/src/__support/math/fmaximum_mag_numl.h | 26 ++++
libc/src/__support/math/fminimum_mag_num.h | 25 ++++
.../src/__support/math/fminimum_mag_numbf16.h | 26 ++++
libc/src/__support/math/fminimum_mag_numf.h | 25 ++++
.../src/__support/math/fminimum_mag_numf128.h | 31 ++++
libc/src/__support/math/fminimum_mag_numf16.h | 31 ++++
libc/src/__support/math/fminimum_mag_numl.h | 26 ++++
libc/src/math/generic/CMakeLists.txt | 27 ++--
.../src/math/generic/fmaximum_mag_numf128.cpp | 6 +-
libc/src/math/generic/fmaximum_mag_numf16.cpp | 6 +-
libc/src/math/generic/fmaximum_mag_numl.cpp | 6 +-
libc/src/math/generic/fminimum_mag_num.cpp | 6 +-
.../src/math/generic/fminimum_mag_numbf16.cpp | 7 +-
libc/src/math/generic/fminimum_mag_numf.cpp | 6 +-
.../src/math/generic/fminimum_mag_numf128.cpp | 6 +-
libc/src/math/generic/fminimum_mag_numf16.cpp | 6 +-
libc/src/math/generic/fminimum_mag_numl.cpp | 6 +-
libc/test/shared/CMakeLists.txt | 18 +++
.../shared/shared_math_constexpr_test.cpp | 17 +++
libc/test/shared/shared_math_test.cpp | 14 ++
.../llvm-project-overlay/libc/BUILD.bazel | 133 +++++++++++++++++-
35 files changed, 786 insertions(+), 60 deletions(-)
create mode 100644 libc/shared/math/fmaximum_mag_numf128.h
create mode 100644 libc/shared/math/fmaximum_mag_numf16.h
create mode 100644 libc/shared/math/fmaximum_mag_numl.h
create mode 100644 libc/shared/math/fminimum_mag_num.h
create mode 100644 libc/shared/math/fminimum_mag_numbf16.h
create mode 100644 libc/shared/math/fminimum_mag_numf.h
create mode 100644 libc/shared/math/fminimum_mag_numf128.h
create mode 100644 libc/shared/math/fminimum_mag_numf16.h
create mode 100644 libc/shared/math/fminimum_mag_numl.h
create mode 100644 libc/src/__support/math/fmaximum_mag_numf128.h
create mode 100644 libc/src/__support/math/fmaximum_mag_numf16.h
create mode 100644 libc/src/__support/math/fmaximum_mag_numl.h
create mode 100644 libc/src/__support/math/fminimum_mag_num.h
create mode 100644 libc/src/__support/math/fminimum_mag_numbf16.h
create mode 100644 libc/src/__support/math/fminimum_mag_numf.h
create mode 100644 libc/src/__support/math/fminimum_mag_numf128.h
create mode 100644 libc/src/__support/math/fminimum_mag_numf16.h
create mode 100644 libc/src/__support/math/fminimum_mag_numl.h
diff --git a/libc/shared/math.h b/libc/shared/math.h
index b5fd88dd026f5..7ee760ed2c156 100644
--- a/libc/shared/math.h
+++ b/libc/shared/math.h
@@ -182,6 +182,9 @@
#include "math/fmaximum_mag_num.h"
#include "math/fmaximum_mag_numbf16.h"
#include "math/fmaximum_mag_numf.h"
+#include "math/fmaximum_mag_numf128.h"
+#include "math/fmaximum_mag_numf16.h"
+#include "math/fmaximum_mag_numl.h"
#include "math/fmaximum_magbf16.h"
#include "math/fmaximum_magf.h"
#include "math/fmaximum_magf128.h"
@@ -206,6 +209,12 @@
#include "math/fminf16.h"
#include "math/fminimum.h"
#include "math/fminimum_mag.h"
+#include "math/fminimum_mag_num.h"
+#include "math/fminimum_mag_numbf16.h"
+#include "math/fminimum_mag_numf.h"
+#include "math/fminimum_mag_numf128.h"
+#include "math/fminimum_mag_numf16.h"
+#include "math/fminimum_mag_numl.h"
#include "math/fminimum_magbf16.h"
#include "math/fminimum_magf.h"
#include "math/fminimum_magf128.h"
diff --git a/libc/shared/math/fmaximum_mag_numf128.h b/libc/shared/math/fmaximum_mag_numf128.h
new file mode 100644
index 0000000000000..26fcc8e1db585
--- /dev/null
+++ b/libc/shared/math/fmaximum_mag_numf128.h
@@ -0,0 +1,29 @@
+//===-- Shared fmaximum_mag_numf128 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_FMAXIMUM_MAG_NUMF128_H
+#define LLVM_LIBC_SHARED_MATH_FMAXIMUM_MAG_NUMF128_H
+
+#include "include/llvm-libc-types/float128.h"
+
+#ifdef LIBC_TYPES_HAS_FLOAT128
+
+#include "shared/libc_common.h"
+#include "src/__support/math/fmaximum_mag_numf128.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::fmaximum_mag_numf128;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LIBC_TYPES_HAS_FLOAT128
+
+#endif // LLVM_LIBC_SHARED_MATH_FMAXIMUM_MAG_NUMF128_H
diff --git a/libc/shared/math/fmaximum_mag_numf16.h b/libc/shared/math/fmaximum_mag_numf16.h
new file mode 100644
index 0000000000000..db5861c0222f0
--- /dev/null
+++ b/libc/shared/math/fmaximum_mag_numf16.h
@@ -0,0 +1,29 @@
+//===-- Shared fmaximum_mag_numf16 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_FMAXIMUM_MAG_NUMF16_H
+#define LLVM_LIBC_SHARED_MATH_FMAXIMUM_MAG_NUMF16_H
+
+#include "include/llvm-libc-macros/float16-macros.h"
+
+#ifdef LIBC_TYPES_HAS_FLOAT16
+
+#include "shared/libc_common.h"
+#include "src/__support/math/fmaximum_mag_numf16.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::fmaximum_mag_numf16;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LIBC_TYPES_HAS_FLOAT16
+
+#endif // LLVM_LIBC_SHARED_MATH_FMAXIMUM_MAG_NUMF16_H
diff --git a/libc/shared/math/fmaximum_mag_numl.h b/libc/shared/math/fmaximum_mag_numl.h
new file mode 100644
index 0000000000000..359d19323a102
--- /dev/null
+++ b/libc/shared/math/fmaximum_mag_numl.h
@@ -0,0 +1,23 @@
+//===-- Shared fmaximum_mag_numl 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_FMAXIMUM_MAG_NUML_H
+#define LLVM_LIBC_SHARED_MATH_FMAXIMUM_MAG_NUML_H
+
+#include "shared/libc_common.h"
+#include "src/__support/math/fmaximum_mag_numl.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::fmaximum_mag_numl;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SHARED_MATH_FMAXIMUM_MAG_NUML_H
diff --git a/libc/shared/math/fminimum_mag_num.h b/libc/shared/math/fminimum_mag_num.h
new file mode 100644
index 0000000000000..74944eec036ed
--- /dev/null
+++ b/libc/shared/math/fminimum_mag_num.h
@@ -0,0 +1,23 @@
+//===-- Shared fminimum_mag_num 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_FMINIMUM_MAG_NUM_H
+#define LLVM_LIBC_SHARED_MATH_FMINIMUM_MAG_NUM_H
+
+#include "shared/libc_common.h"
+#include "src/__support/math/fminimum_mag_num.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::fminimum_mag_num;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SHARED_MATH_FMINIMUM_MAG_NUM_H
diff --git a/libc/shared/math/fminimum_mag_numbf16.h b/libc/shared/math/fminimum_mag_numbf16.h
new file mode 100644
index 0000000000000..4e17a99b016c0
--- /dev/null
+++ b/libc/shared/math/fminimum_mag_numbf16.h
@@ -0,0 +1,23 @@
+//===-- Shared fminimum_mag_numbf16 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_FMINIMUM_MAG_NUMBF16_H
+#define LLVM_LIBC_SHARED_MATH_FMINIMUM_MAG_NUMBF16_H
+
+#include "shared/libc_common.h"
+#include "src/__support/math/fminimum_mag_numbf16.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::fminimum_mag_numbf16;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SHARED_MATH_FMINIMUM_MAG_NUMBF16_H
diff --git a/libc/shared/math/fminimum_mag_numf.h b/libc/shared/math/fminimum_mag_numf.h
new file mode 100644
index 0000000000000..cf7824634a356
--- /dev/null
+++ b/libc/shared/math/fminimum_mag_numf.h
@@ -0,0 +1,23 @@
+//===-- Shared fminimum_mag_numf 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_FMINIMUM_MAG_NUMF_H
+#define LLVM_LIBC_SHARED_MATH_FMINIMUM_MAG_NUMF_H
+
+#include "shared/libc_common.h"
+#include "src/__support/math/fminimum_mag_numf.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::fminimum_mag_numf;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SHARED_MATH_FMINIMUM_MAG_NUMF_H
diff --git a/libc/shared/math/fminimum_mag_numf128.h b/libc/shared/math/fminimum_mag_numf128.h
new file mode 100644
index 0000000000000..3a386602c9fd8
--- /dev/null
+++ b/libc/shared/math/fminimum_mag_numf128.h
@@ -0,0 +1,29 @@
+//===-- Shared fminimum_mag_numf128 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_FMINIMUM_MAG_NUMF128_H
+#define LLVM_LIBC_SHARED_MATH_FMINIMUM_MAG_NUMF128_H
+
+#include "include/llvm-libc-types/float128.h"
+
+#ifdef LIBC_TYPES_HAS_FLOAT128
+
+#include "shared/libc_common.h"
+#include "src/__support/math/fminimum_mag_numf128.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::fminimum_mag_numf128;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LIBC_TYPES_HAS_FLOAT128
+
+#endif // LLVM_LIBC_SHARED_MATH_FMINIMUM_MAG_NUMF128_H
diff --git a/libc/shared/math/fminimum_mag_numf16.h b/libc/shared/math/fminimum_mag_numf16.h
new file mode 100644
index 0000000000000..5ab40512aeb62
--- /dev/null
+++ b/libc/shared/math/fminimum_mag_numf16.h
@@ -0,0 +1,29 @@
+//===-- Shared fminimum_mag_numf16 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_FMINIMUM_MAG_NUMF16_H
+#define LLVM_LIBC_SHARED_MATH_FMINIMUM_MAG_NUMF16_H
+
+#include "include/llvm-libc-macros/float16-macros.h"
+
+#ifdef LIBC_TYPES_HAS_FLOAT16
+
+#include "shared/libc_common.h"
+#include "src/__support/math/fminimum_mag_numf16.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::fminimum_mag_numf16;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LIBC_TYPES_HAS_FLOAT16
+
+#endif // LLVM_LIBC_SHARED_MATH_FMINIMUM_MAG_NUMF16_H
diff --git a/libc/shared/math/fminimum_mag_numl.h b/libc/shared/math/fminimum_mag_numl.h
new file mode 100644
index 0000000000000..6d0b534306540
--- /dev/null
+++ b/libc/shared/math/fminimum_mag_numl.h
@@ -0,0 +1,23 @@
+//===-- Shared fminimum_mag_numl 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_FMINIMUM_MAG_NUML_H
+#define LLVM_LIBC_SHARED_MATH_FMINIMUM_MAG_NUML_H
+
+#include "shared/libc_common.h"
+#include "src/__support/math/fminimum_mag_numl.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::fminimum_mag_numl;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SHARED_MATH_FMINIMUM_MAG_NUML_H
diff --git a/libc/src/__support/FPUtil/BasicOperations.h b/libc/src/__support/FPUtil/BasicOperations.h
index e9a357c53a670..2cbb1f8a04ee7 100644
--- a/libc/src/__support/FPUtil/BasicOperations.h
+++ b/libc/src/__support/FPUtil/BasicOperations.h
@@ -248,7 +248,7 @@ LIBC_INLINE constexpr T fmaximum_mag_num(T x, T y) {
}
template <typename T, cpp::enable_if_t<cpp::is_floating_point_v<T>, int> = 0>
-LIBC_INLINE T fminimum_mag_num(T x, T y) {
+LIBC_INLINE constexpr T fminimum_mag_num(T x, T y) {
FPBits<T> bitx(x), bity(y);
if (abs(x) < abs(y))
diff --git a/libc/src/__support/math/CMakeLists.txt b/libc/src/__support/math/CMakeLists.txt
index eb36df1e823c9..9c7338995226c 100644
--- a/libc/src/__support/math/CMakeLists.txt
+++ b/libc/src/__support/math/CMakeLists.txt
@@ -954,6 +954,35 @@ add_header_library(
libc.src.__support.macros.config
)
+add_header_library(
+ fmaximum_mag_numf128
+ HDRS
+ fmaximum_mag_numf128.h
+ DEPENDS
+ libc.include.llvm-libc-types.float128
+ libc.src.__support.FPUtil.basic_operations
+ libc.src.__support.macros.config
+)
+
+add_header_library(
+ fmaximum_mag_numf16
+ HDRS
+ fmaximum_mag_numf16.h
+ DEPENDS
+ libc.include.llvm-libc-macros.float16_macros
+ libc.src.__support.FPUtil.basic_operations
+ libc.src.__support.macros.config
+)
+
+add_header_library(
+ fmaximum_mag_numl
+ HDRS
+ fmaximum_mag_numl.h
+ DEPENDS
+ libc.src.__support.FPUtil.basic_operations
+ libc.src.__support.macros.config
+)
+
add_header_library(
fmaximum_num
HDRS
@@ -1201,6 +1230,65 @@ add_header_library(
libc.src.__support.macros.config
)
+add_header_library(
+ fminimum_mag_num
+ HDRS
+ fminimum_mag_num.h
+ DEPENDS
+ libc.src.__support.FPUtil.basic_operations
+ libc.src.__support.macros.config
+)
+
+add_header_library(
+ fminimum_mag_numbf16
+ HDRS
+ fminimum_mag_numbf16.h
+ DEPENDS
+ libc.src.__support.FPUtil.basic_operations
+ libc.src.__support.FPUtil.bfloat16
+ libc.src.__support.macros.config
+ FLAGS
+ MISC_MATH_BASIC_OPS_OPT
+)
+
+add_header_library(
+ fminimum_mag_numf
+ HDRS
+ fminimum_mag_numf.h
+ DEPENDS
+ libc.src.__support.FPUtil.basic_operations
+ libc.src.__support.macros.config
+)
+
+add_header_library(
+ fminimum_mag_numf128
+ HDRS
+ fminimum_mag_numf128.h
+ DEPENDS
+ libc.include.llvm-libc-types.float128
+ libc.src.__support.FPUtil.basic_operations
+ libc.src.__support.macros.config
+)
+
+add_header_library(
+ fminimum_mag_numf16
+ HDRS
+ fminimum_mag_numf16.h
+ DEPENDS
+ libc.include.llvm-libc-macros.float16_macros
+ libc.src.__support.FPUtil.basic_operations
+ libc.src.__support.macros.config
+)
+
+add_header_library(
+ fminimum_mag_numl
+ HDRS
+ fminimum_mag_numl.h
+ DEPENDS
+ libc.src.__support.FPUtil.basic_operations
+ libc.src.__support.macros.config
+)
+
add_header_library(
fminimum_num
HDRS
diff --git a/libc/src/__support/math/fmaximum_mag_numf128.h b/libc/src/__support/math/fmaximum_mag_numf128.h
new file mode 100644
index 0000000000000..656ef803559bb
--- /dev/null
+++ b/libc/src/__support/math/fmaximum_mag_numf128.h
@@ -0,0 +1,31 @@
+//===-- Implementation header for fmaximum_mag_numf128 ----------*- 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_FMAXIMUM_MAG_NUMF128_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_FMAXIMUM_MAG_NUMF128_H
+
+#include "include/llvm-libc-types/float128.h"
+
+#ifdef LIBC_TYPES_HAS_FLOAT128
+
+#include "src/__support/FPUtil/BasicOperations.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace math {
+
+LIBC_INLINE constexpr float128 fmaximum_mag_numf128(float128 x, float128 y) {
+ return fputil::fmaximum_mag_num(x, y);
+}
+
+} // namespace math
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LIBC_TYPES_HAS_FLOAT128
+
+#endif // LLVM_LIBC_SRC___SUPPORT_MATH_FMAXIMUM_MAG_NUMF128_H
diff --git a/libc/src/__support/math/fmaximum_mag_numf16.h b/libc/src/__support/math/fmaximum_mag_numf16.h
new file mode 100644
index 0000000000000..f321f62746ee1
--- /dev/null
+++ b/libc/src/__support/math/fmaximum_mag_numf16.h
@@ -0,0 +1,31 @@
+//===-- Implementation header for fmaximum_mag_numf16 -----------*- 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_FMAXIMUM_MAG_NUMF16_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_FMAXIMUM_MAG_NUMF16_H
+
+#include "include/llvm-libc-macros/float16-macros.h"
+
+#ifdef LIBC_TYPES_HAS_FLOAT16
+
+#include "src/__support/FPUtil/BasicOperations.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace math {
+
+LIBC_INLINE constexpr float16 fmaximum_mag_numf16(float16 x, float16 y) {
+ return fputil::fmaximum_mag_num(x, y);
+}
+
+} // namespace math
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LIBC_TYPES_HAS_FLOAT16
+
+#endif // LLVM_LIBC_SRC___SUPPORT_MATH_FMAXIMUM_MAG_NUMF16_H
diff --git a/libc/src/__support/math/fmaximum_mag_numl.h b/libc/src/__support/math/fmaximum_mag_numl.h
new file mode 100644
index 0000000000000..c96ff362ea004
--- /dev/null
+++ b/libc/src/__support/math/fmaximum_mag_numl.h
@@ -0,0 +1,26 @@
+//===-- Implementation header for fmaximum_mag_numl -------------*- 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_FMAXIMUM_MAG_NUML_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_FMAXIMUM_MAG_NUML_H
+
+#include "src/__support/FPUtil/BasicOperations.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace math {
+
+LIBC_INLINE constexpr long double fmaximum_mag_numl(long double x,
+ long double y) {
+ return fputil::fmaximum_mag_num(x, y);
+}
+
+} // namespace math
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC___SUPPORT_MATH_FMAXIMUM_MAG_NUML_H
diff --git a/libc/src/__support/math/fminimum_mag_num.h b/libc/src/__support/math/fminimum_mag_num.h
new file mode 100644
index 0000000000000..0c6a73b259ea6
--- /dev/null
+++ b/libc/src/__support/math/fminimum_mag_num.h
@@ -0,0 +1,25 @@
+//===-- Implementation header for fminimum_mag_num --------------*- 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_FMINIMUM_MAG_NUM_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_FMINIMUM_MAG_NUM_H
+
+#include "src/__support/FPUtil/BasicOperations.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace math {
+
+LIBC_INLINE constexpr double fminimum_mag_num(double x, double y) {
+ return fputil::fminimum_mag_num(x, y);
+}
+
+} // namespace math
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC___SUPPORT_MATH_FMINIMUM_MAG_NUM_H
diff --git a/libc/src/__support/math/fminimum_mag_numbf16.h b/libc/src/__support/math/fminimum_mag_numbf16.h
new file mode 100644
index 0000000000000..cd876873576ae
--- /dev/null
+++ b/libc/src/__support/math/fminimum_mag_numbf16.h
@@ -0,0 +1,26 @@
+//===-- Implementation header for fminimum_mag_numbf16 ----------*- 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_FMINIMUM_MAG_NUMBF16_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_FMINIMUM_MAG_NUMBF16_H
+
+#include "src/__support/FPUtil/BasicOperations.h"
+#include "src/__support/FPUtil/bfloat16.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace math {
+
+LIBC_INLINE constexpr bfloat16 fminimum_mag_numbf16(bfloat16 x, bfloat16 y) {
+ return fputil::fminimum_mag_num(x, y);
+}
+
+} // namespace math
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC___SUPPORT_MATH_FMINIMUM_MAG_NUMBF16_H
diff --git a/libc/src/__support/math/fminimum_mag_numf.h b/libc/src/__support/math/fminimum_mag_numf.h
new file mode 100644
index 0000000000000..0c9eba2571fe7
--- /dev/null
+++ b/libc/src/__support/math/fminimum_mag_numf.h
@@ -0,0 +1,25 @@
+//===-- Implementation header for fminimum_mag_numf -------------*- 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_FMINIMUM_MAG_NUMF_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_FMINIMUM_MAG_NUMF_H
+
+#include "src/__support/FPUtil/BasicOperations.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace math {
+
+LIBC_INLINE constexpr float fminimum_mag_numf(float x, float y) {
+ return fputil::fminimum_mag_num(x, y);
+}
+
+} // namespace math
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC___SUPPORT_MATH_FMINIMUM_MAG_NUMF_H
diff --git a/libc/src/__support/math/fminimum_mag_numf128.h b/libc/src/__support/math/fminimum_mag_numf128.h
new file mode 100644
index 0000000000000..8a1bc35a3735f
--- /dev/null
+++ b/libc/src/__support/math/fminimum_mag_numf128.h
@@ -0,0 +1,31 @@
+//===-- Implementation header for fminimum_mag_numf128 ----------*- 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_FMINIMUM_MAG_NUMF128_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_FMINIMUM_MAG_NUMF128_H
+
+#include "include/llvm-libc-types/float128.h"
+
+#ifdef LIBC_TYPES_HAS_FLOAT128
+
+#include "src/__support/FPUtil/BasicOperations.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace math {
+
+LIBC_INLINE constexpr float128 fminimum_mag_numf128(float128 x, float128 y) {
+ return fputil::fminimum_mag_num(x, y);
+}
+
+} // namespace math
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LIBC_TYPES_HAS_FLOAT128
+
+#endif // LLVM_LIBC_SRC___SUPPORT_MATH_FMINIMUM_MAG_NUMF128_H
diff --git a/libc/src/__support/math/fminimum_mag_numf16.h b/libc/src/__support/math/fminimum_mag_numf16.h
new file mode 100644
index 0000000000000..359f7a88934d6
--- /dev/null
+++ b/libc/src/__support/math/fminimum_mag_numf16.h
@@ -0,0 +1,31 @@
+//===-- Implementation header for fminimum_mag_numf16 -----------*- 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_FMINIMUM_MAG_NUMF16_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_FMINIMUM_MAG_NUMF16_H
+
+#include "include/llvm-libc-macros/float16-macros.h"
+
+#ifdef LIBC_TYPES_HAS_FLOAT16
+
+#include "src/__support/FPUtil/BasicOperations.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace math {
+
+LIBC_INLINE constexpr float16 fminimum_mag_numf16(float16 x, float16 y) {
+ return fputil::fminimum_mag_num(x, y);
+}
+
+} // namespace math
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LIBC_TYPES_HAS_FLOAT16
+
+#endif // LLVM_LIBC_SRC___SUPPORT_MATH_FMINIMUM_MAG_NUMF16_H
diff --git a/libc/src/__support/math/fminimum_mag_numl.h b/libc/src/__support/math/fminimum_mag_numl.h
new file mode 100644
index 0000000000000..329f443da88e5
--- /dev/null
+++ b/libc/src/__support/math/fminimum_mag_numl.h
@@ -0,0 +1,26 @@
+//===-- Implementation header for fminimum_mag_numl -------------*- 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_FMINIMUM_MAG_NUML_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_FMINIMUM_MAG_NUML_H
+
+#include "src/__support/FPUtil/BasicOperations.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace math {
+
+LIBC_INLINE constexpr long double fminimum_mag_numl(long double x,
+ long double y) {
+ return fputil::fminimum_mag_num(x, y);
+}
+
+} // namespace math
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC___SUPPORT_MATH_FMINIMUM_MAG_NUML_H
diff --git a/libc/src/math/generic/CMakeLists.txt b/libc/src/math/generic/CMakeLists.txt
index de4bc06eb636a..c20a526b39fc3 100644
--- a/libc/src/math/generic/CMakeLists.txt
+++ b/libc/src/math/generic/CMakeLists.txt
@@ -2381,7 +2381,7 @@ add_entrypoint_object(
HDRS
../fmaximum_mag_numl.h
DEPENDS
- libc.src.__support.FPUtil.basic_operations
+ libc.src.__support.math.fmaximum_mag_numl
)
add_entrypoint_object(
@@ -2391,8 +2391,7 @@ add_entrypoint_object(
HDRS
../fmaximum_mag_numf16.h
DEPENDS
- libc.src.__support.macros.properties.types
- libc.src.__support.FPUtil.basic_operations
+ libc.src.__support.math.fmaximum_mag_numf16
)
add_entrypoint_object(
@@ -2402,8 +2401,7 @@ add_entrypoint_object(
HDRS
../fmaximum_mag_numf128.h
DEPENDS
- libc.src.__support.macros.properties.types
- libc.src.__support.FPUtil.basic_operations
+ libc.src.__support.math.fmaximum_mag_numf128
)
add_entrypoint_object(
@@ -2603,7 +2601,7 @@ add_entrypoint_object(
HDRS
../fminimum_mag_num.h
DEPENDS
- libc.src.__support.FPUtil.basic_operations
+ libc.src.__support.math.fminimum_mag_num
)
add_entrypoint_object(
@@ -2613,7 +2611,7 @@ add_entrypoint_object(
HDRS
../fminimum_mag_numf.h
DEPENDS
- libc.src.__support.FPUtil.basic_operations
+ libc.src.__support.math.fminimum_mag_numf
)
add_entrypoint_object(
@@ -2623,7 +2621,7 @@ add_entrypoint_object(
HDRS
../fminimum_mag_numl.h
DEPENDS
- libc.src.__support.FPUtil.basic_operations
+ libc.src.__support.math.fminimum_mag_numl
)
add_entrypoint_object(
@@ -2633,8 +2631,7 @@ add_entrypoint_object(
HDRS
../fminimum_mag_numf16.h
DEPENDS
- libc.src.__support.macros.properties.types
- libc.src.__support.FPUtil.basic_operations
+ libc.src.__support.math.fminimum_mag_numf16
)
add_entrypoint_object(
@@ -2644,8 +2641,7 @@ add_entrypoint_object(
HDRS
../fminimum_mag_numf128.h
DEPENDS
- libc.src.__support.macros.properties.types
- libc.src.__support.FPUtil.basic_operations
+ libc.src.__support.math.fminimum_mag_numf128
)
add_entrypoint_object(
@@ -2655,12 +2651,7 @@ add_entrypoint_object(
HDRS
../fminimum_mag_numbf16.h
DEPENDS
- libc.src.__support.FPUtil.basic_operations
- libc.src.__support.FPUtil.bfloat16
- libc.src.__support.macros.config
- libc.src.__support.macros.properties.types
- FLAGS
- MISC_MATH_BASIC_OPS_OPT
+ libc.src.__support.math.fminimum_mag_numbf16
)
add_entrypoint_object(
diff --git a/libc/src/math/generic/fmaximum_mag_numf128.cpp b/libc/src/math/generic/fmaximum_mag_numf128.cpp
index 09e72481d8908..e3fac9dbbadf4 100644
--- a/libc/src/math/generic/fmaximum_mag_numf128.cpp
+++ b/libc/src/math/generic/fmaximum_mag_numf128.cpp
@@ -7,14 +7,12 @@
//===----------------------------------------------------------------------===//
#include "src/math/fmaximum_mag_numf128.h"
-#include "src/__support/FPUtil/BasicOperations.h"
-#include "src/__support/common.h"
-#include "src/__support/macros/config.h"
+#include "src/__support/math/fmaximum_mag_numf128.h"
namespace LIBC_NAMESPACE_DECL {
LLVM_LIBC_FUNCTION(float128, fmaximum_mag_numf128, (float128 x, float128 y)) {
- return fputil::fmaximum_mag_num(x, y);
+ return math::fmaximum_mag_numf128(x, y);
}
} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/fmaximum_mag_numf16.cpp b/libc/src/math/generic/fmaximum_mag_numf16.cpp
index d81b9fe790783..db7b3fcd353e3 100644
--- a/libc/src/math/generic/fmaximum_mag_numf16.cpp
+++ b/libc/src/math/generic/fmaximum_mag_numf16.cpp
@@ -7,14 +7,12 @@
//===----------------------------------------------------------------------===//
#include "src/math/fmaximum_mag_numf16.h"
-#include "src/__support/FPUtil/BasicOperations.h"
-#include "src/__support/common.h"
-#include "src/__support/macros/config.h"
+#include "src/__support/math/fmaximum_mag_numf16.h"
namespace LIBC_NAMESPACE_DECL {
LLVM_LIBC_FUNCTION(float16, fmaximum_mag_numf16, (float16 x, float16 y)) {
- return fputil::fmaximum_mag_num(x, y);
+ return math::fmaximum_mag_numf16(x, y);
}
} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/fmaximum_mag_numl.cpp b/libc/src/math/generic/fmaximum_mag_numl.cpp
index 3816bdd142697..a02dc5f5a6372 100644
--- a/libc/src/math/generic/fmaximum_mag_numl.cpp
+++ b/libc/src/math/generic/fmaximum_mag_numl.cpp
@@ -7,15 +7,13 @@
//===----------------------------------------------------------------------===//
#include "src/math/fmaximum_mag_numl.h"
-#include "src/__support/FPUtil/BasicOperations.h"
-#include "src/__support/common.h"
-#include "src/__support/macros/config.h"
+#include "src/__support/math/fmaximum_mag_numl.h"
namespace LIBC_NAMESPACE_DECL {
LLVM_LIBC_FUNCTION(long double, fmaximum_mag_numl,
(long double x, long double y)) {
- return fputil::fmaximum_mag_num(x, y);
+ return math::fmaximum_mag_numl(x, y);
}
} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/fminimum_mag_num.cpp b/libc/src/math/generic/fminimum_mag_num.cpp
index ab049b5861145..18e52e8448d04 100644
--- a/libc/src/math/generic/fminimum_mag_num.cpp
+++ b/libc/src/math/generic/fminimum_mag_num.cpp
@@ -7,14 +7,12 @@
//===----------------------------------------------------------------------===//
#include "src/math/fminimum_mag_num.h"
-#include "src/__support/FPUtil/BasicOperations.h"
-#include "src/__support/common.h"
-#include "src/__support/macros/config.h"
+#include "src/__support/math/fminimum_mag_num.h"
namespace LIBC_NAMESPACE_DECL {
LLVM_LIBC_FUNCTION(double, fminimum_mag_num, (double x, double y)) {
- return fputil::fminimum_mag_num(x, y);
+ return math::fminimum_mag_num(x, y);
}
} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/fminimum_mag_numbf16.cpp b/libc/src/math/generic/fminimum_mag_numbf16.cpp
index 5056fc7e0cad2..e700e4a9dbd57 100644
--- a/libc/src/math/generic/fminimum_mag_numbf16.cpp
+++ b/libc/src/math/generic/fminimum_mag_numbf16.cpp
@@ -7,15 +7,12 @@
//===----------------------------------------------------------------------===//
#include "src/math/fminimum_mag_numbf16.h"
-#include "src/__support/FPUtil/BasicOperations.h"
-#include "src/__support/FPUtil/bfloat16.h"
-#include "src/__support/common.h"
-#include "src/__support/macros/config.h"
+#include "src/__support/math/fminimum_mag_numbf16.h"
namespace LIBC_NAMESPACE_DECL {
LLVM_LIBC_FUNCTION(bfloat16, fminimum_mag_numbf16, (bfloat16 x, bfloat16 y)) {
- return fputil::fminimum_mag_num(x, y);
+ return math::fminimum_mag_numbf16(x, y);
}
} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/fminimum_mag_numf.cpp b/libc/src/math/generic/fminimum_mag_numf.cpp
index 2aa88c74105d4..6d6e52b61694f 100644
--- a/libc/src/math/generic/fminimum_mag_numf.cpp
+++ b/libc/src/math/generic/fminimum_mag_numf.cpp
@@ -7,14 +7,12 @@
//===----------------------------------------------------------------------===//
#include "src/math/fminimum_mag_numf.h"
-#include "src/__support/FPUtil/BasicOperations.h"
-#include "src/__support/common.h"
-#include "src/__support/macros/config.h"
+#include "src/__support/math/fminimum_mag_numf.h"
namespace LIBC_NAMESPACE_DECL {
LLVM_LIBC_FUNCTION(float, fminimum_mag_numf, (float x, float y)) {
- return fputil::fminimum_mag_num(x, y);
+ return math::fminimum_mag_numf(x, y);
}
} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/fminimum_mag_numf128.cpp b/libc/src/math/generic/fminimum_mag_numf128.cpp
index ec7ab54054e3d..27f7656733d27 100644
--- a/libc/src/math/generic/fminimum_mag_numf128.cpp
+++ b/libc/src/math/generic/fminimum_mag_numf128.cpp
@@ -7,14 +7,12 @@
//===----------------------------------------------------------------------===//
#include "src/math/fminimum_mag_numf128.h"
-#include "src/__support/FPUtil/BasicOperations.h"
-#include "src/__support/common.h"
-#include "src/__support/macros/config.h"
+#include "src/__support/math/fminimum_mag_numf128.h"
namespace LIBC_NAMESPACE_DECL {
LLVM_LIBC_FUNCTION(float128, fminimum_mag_numf128, (float128 x, float128 y)) {
- return fputil::fminimum_mag_num(x, y);
+ return math::fminimum_mag_numf128(x, y);
}
} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/fminimum_mag_numf16.cpp b/libc/src/math/generic/fminimum_mag_numf16.cpp
index 5805514b83f68..7872d3db3d698 100644
--- a/libc/src/math/generic/fminimum_mag_numf16.cpp
+++ b/libc/src/math/generic/fminimum_mag_numf16.cpp
@@ -7,14 +7,12 @@
//===----------------------------------------------------------------------===//
#include "src/math/fminimum_mag_numf16.h"
-#include "src/__support/FPUtil/BasicOperations.h"
-#include "src/__support/common.h"
-#include "src/__support/macros/config.h"
+#include "src/__support/math/fminimum_mag_numf16.h"
namespace LIBC_NAMESPACE_DECL {
LLVM_LIBC_FUNCTION(float16, fminimum_mag_numf16, (float16 x, float16 y)) {
- return fputil::fminimum_mag_num(x, y);
+ return math::fminimum_mag_numf16(x, y);
}
} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/fminimum_mag_numl.cpp b/libc/src/math/generic/fminimum_mag_numl.cpp
index 70fea1f5ef282..0d132d8f94803 100644
--- a/libc/src/math/generic/fminimum_mag_numl.cpp
+++ b/libc/src/math/generic/fminimum_mag_numl.cpp
@@ -7,15 +7,13 @@
//===----------------------------------------------------------------------===//
#include "src/math/fminimum_mag_numl.h"
-#include "src/__support/FPUtil/BasicOperations.h"
-#include "src/__support/common.h"
-#include "src/__support/macros/config.h"
+#include "src/__support/math/fminimum_mag_numl.h"
namespace LIBC_NAMESPACE_DECL {
LLVM_LIBC_FUNCTION(long double, fminimum_mag_numl,
(long double x, long double y)) {
- return fputil::fminimum_mag_num(x, y);
+ return math::fminimum_mag_numl(x, y);
}
} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/test/shared/CMakeLists.txt b/libc/test/shared/CMakeLists.txt
index f0c4dc9983326..0e59a53d1d8ba 100644
--- a/libc/test/shared/CMakeLists.txt
+++ b/libc/test/shared/CMakeLists.txt
@@ -179,6 +179,9 @@ add_fp_unittest(
libc.src.__support.math.fmaximum_mag_num
libc.src.__support.math.fmaximum_mag_numbf16
libc.src.__support.math.fmaximum_mag_numf
+ libc.src.__support.math.fmaximum_mag_numf128
+ libc.src.__support.math.fmaximum_mag_numf16
+ libc.src.__support.math.fmaximum_mag_numl
libc.src.__support.math.fmaximum_magbf16
libc.src.__support.math.fmaximum_magf
libc.src.__support.math.fmaximum_magf128
@@ -203,6 +206,12 @@ add_fp_unittest(
libc.src.__support.math.fminf16
libc.src.__support.math.fminimum
libc.src.__support.math.fminimum_mag
+ libc.src.__support.math.fminimum_mag_num
+ libc.src.__support.math.fminimum_mag_numbf16
+ libc.src.__support.math.fminimum_mag_numf
+ libc.src.__support.math.fminimum_mag_numf128
+ libc.src.__support.math.fminimum_mag_numf16
+ libc.src.__support.math.fminimum_mag_numl
libc.src.__support.math.fminimum_magbf16
libc.src.__support.math.fminimum_magf
libc.src.__support.math.fminimum_magf128
@@ -435,6 +444,9 @@ add_fp_unittest(
libc.src.__support.math.fmaximum_mag_num
libc.src.__support.math.fmaximum_mag_numbf16
libc.src.__support.math.fmaximum_mag_numf
+ libc.src.__support.math.fmaximum_mag_numf128
+ libc.src.__support.math.fmaximum_mag_numf16
+ libc.src.__support.math.fmaximum_mag_numl
libc.src.__support.math.fmaximum_magbf16
libc.src.__support.math.fmaximum_magf
libc.src.__support.math.fmaximum_magf128
@@ -458,6 +470,12 @@ add_fp_unittest(
libc.src.__support.math.fminf16
libc.src.__support.math.fminimum
libc.src.__support.math.fminimum_mag
+ libc.src.__support.math.fminimum_mag_num
+ libc.src.__support.math.fminimum_mag_numbf16
+ libc.src.__support.math.fminimum_mag_numf
+ libc.src.__support.math.fminimum_mag_numf128
+ libc.src.__support.math.fminimum_mag_numf16
+ libc.src.__support.math.fminimum_mag_numl
libc.src.__support.math.fminimum_magbf16
libc.src.__support.math.fminimum_magf
libc.src.__support.math.fminimum_magf128
diff --git a/libc/test/shared/shared_math_constexpr_test.cpp b/libc/test/shared/shared_math_constexpr_test.cpp
index c893c597cb7c6..ae2484b482c15 100644
--- a/libc/test/shared/shared_math_constexpr_test.cpp
+++ b/libc/test/shared/shared_math_constexpr_test.cpp
@@ -49,6 +49,7 @@ static_assert(0.0 == [] {
double iptr = 0;
return LIBC_NAMESPACE::shared::modf(0, &iptr);
}());
+static_assert(0.0 == LIBC_NAMESPACE::shared::fminimum_mag_num(0.0, 0.0));
//===----------------------------------------------------------------------===//
// Float Tests
@@ -86,6 +87,7 @@ static_assert(0.0f == [] {
float iptr = 0.0f;
return LIBC_NAMESPACE::shared::modff(0.0f, &iptr);
}());
+static_assert(0.0f == LIBC_NAMESPACE::shared::fminimum_mag_numf(0.0f, 0.0f));
//===----------------------------------------------------------------------===//
// Float16 Tests
//===----------------------------------------------------------------------===//
@@ -129,6 +131,10 @@ static_assert(0.0f16 == [] {
float16 iptr{};
return LIBC_NAMESPACE::shared::modff16(0.0f16, &iptr);
}());
+static_assert(0.0f16 ==
+ LIBC_NAMESPACE::shared::fmaximum_mag_numf16(0.0f16, 0.0f16));
+static_assert(0.0f16 ==
+ LIBC_NAMESPACE::shared::fminimum_mag_numf16(0.0f16, 0.0f16));
#endif // LIBC_TYPES_HAS_FLOAT16
//===----------------------------------------------------------------------===//
@@ -175,6 +181,8 @@ static_assert(0.0L == [] {
long double iptr{};
return LIBC_NAMESPACE::shared::modfl(0.0L, &iptr);
}());
+static_assert(0.0L == LIBC_NAMESPACE::shared::fmaximum_mag_numl(0.0L, 0.0L));
+static_assert(0.0L == LIBC_NAMESPACE::shared::fminimum_mag_numl(0.0L, 0.0L));
#endif
@@ -248,6 +256,12 @@ static_assert(float128(0.0) == [] {
float128 iptr{};
return LIBC_NAMESPACE::shared::modff128(float128(0.0), &iptr);
}());
+static_assert(float128(0.0) ==
+ LIBC_NAMESPACE::shared::fmaximum_mag_numf128(float128(0.0),
+ float128(0.0)));
+static_assert(float128(0.0) ==
+ LIBC_NAMESPACE::shared::fminimum_mag_numf128(float128(0.0),
+ float128(0.0)));
#endif // LIBC_TYPES_HAS_FLOAT128
@@ -319,5 +333,8 @@ static_assert(bfloat16(0.0) == [] {
bfloat16 iptr{};
return LIBC_NAMESPACE::shared::modfbf16(bfloat16(0.0), &iptr);
}());
+static_assert(bfloat16(0.0) ==
+ LIBC_NAMESPACE::shared::fminimum_mag_numbf16(bfloat16(0.0),
+ bfloat16(0.0)));
TEST(LlvmLibcSharedMathTest, ConstantEvaluation) {}
diff --git a/libc/test/shared/shared_math_test.cpp b/libc/test/shared/shared_math_test.cpp
index 403950ee74e17..31cb2b1a33505 100644
--- a/libc/test/shared/shared_math_test.cpp
+++ b/libc/test/shared/shared_math_test.cpp
@@ -131,6 +131,10 @@ TEST(LlvmLibcSharedMathTest, AllFloat16) {
EXPECT_FP_EQ(0x0p+0f16,
LIBC_NAMESPACE::shared::modff16(0.0f16, &modff16_iptr));
EXPECT_FP_EQ(0.0f16, modff16_iptr);
+ EXPECT_FP_EQ(0x0p+0f16,
+ LIBC_NAMESPACE::shared::fmaximum_mag_numf16(0.0f16, 0.0f16));
+ EXPECT_FP_EQ(0x0p+0f16,
+ LIBC_NAMESPACE::shared::fminimum_mag_numf16(0.0f16, 0.0f16));
}
#endif // LIBC_TYPES_HAS_FLOAT16
@@ -265,6 +269,7 @@ TEST(LlvmLibcSharedMathTest, AllFloat) {
float modff_iptr = 0.0f;
EXPECT_FP_EQ(0x0p+0f, LIBC_NAMESPACE::shared::modff(0.0f, &modff_iptr));
EXPECT_FP_EQ(0.0f, modff_iptr);
+ EXPECT_FP_EQ(0x0p+0f, LIBC_NAMESPACE::shared::fminimum_mag_numf(0.0f, 0.0f));
}
TEST(LlvmLibcSharedMathTest, AllDouble) {
@@ -375,6 +380,7 @@ TEST(LlvmLibcSharedMathTest, AllDouble) {
double modf_iptr = 0.0;
EXPECT_FP_EQ(0.0, LIBC_NAMESPACE::shared::modf(0.0, &modf_iptr));
EXPECT_FP_EQ(0.0, modf_iptr);
+ EXPECT_FP_EQ(0.0, LIBC_NAMESPACE::shared::fminimum_mag_num(0.0, 0.0));
}
// TODO: Enable the tests when double-double type is supported.
@@ -466,6 +472,8 @@ TEST(LlvmLibcSharedMathTest, AllLongDouble) {
long double modfl_iptr = 0.0L;
EXPECT_FP_EQ(0x0p+0L, LIBC_NAMESPACE::shared::modfl(0.0L, &modfl_iptr));
EXPECT_FP_EQ(0.0L, modfl_iptr);
+ EXPECT_FP_EQ(0x0p+0L, LIBC_NAMESPACE::shared::fmaximum_mag_numl(0.0L, 0.0L));
+ EXPECT_FP_EQ(0x0p+0L, LIBC_NAMESPACE::shared::fminimum_mag_numl(0.0L, 0.0L));
}
#endif // LIBC_TYPES_LONG_DOUBLE_IS_DOUBLE_DOUBLE
@@ -609,6 +617,10 @@ TEST(LlvmLibcSharedMathTest, AllFloat128) {
EXPECT_FP_EQ(float128(0.0),
LIBC_NAMESPACE::shared::modff128(float128(0.0), &modff128_iptr));
EXPECT_FP_EQ(float128(0.0), modff128_iptr);
+ EXPECT_FP_EQ(float128(0.0), LIBC_NAMESPACE::shared::fmaximum_mag_numf128(
+ float128(0.0), float128(0.0)));
+ EXPECT_FP_EQ(float128(0.0), LIBC_NAMESPACE::shared::fminimum_mag_numf128(
+ float128(0.0), float128(0.0)));
}
#endif // LIBC_TYPES_HAS_FLOAT128
@@ -715,4 +727,6 @@ TEST(LlvmLibcSharedMathTest, AllBFloat16) {
EXPECT_FP_EQ(bfloat16(0.0),
LIBC_NAMESPACE::shared::modfbf16(bfloat16(0.0), &modfbf16_iptr));
EXPECT_FP_EQ(bfloat16(0.0), modfbf16_iptr);
+ EXPECT_FP_EQ(bfloat16(0.0), LIBC_NAMESPACE::shared::fminimum_mag_numbf16(
+ bfloat16(0.0), bfloat16(0.0)));
}
diff --git a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
index cad548e343894..0297f432942db 100644
--- a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
@@ -4191,6 +4191,35 @@ libc_support_library(
],
)
+libc_support_library(
+ name = "__support_math_fmaximum_mag_numf128",
+ hdrs = ["src/__support/math/fmaximum_mag_numf128.h"],
+ deps = [
+ ":__support_fputil_basic_operations",
+ ":__support_macros_config",
+ ":llvm_libc_types_float128",
+ ],
+)
+
+libc_support_library(
+ name = "__support_math_fmaximum_mag_numf16",
+ hdrs = ["src/__support/math/fmaximum_mag_numf16.h"],
+ deps = [
+ ":__support_fputil_basic_operations",
+ ":__support_macros_config",
+ ":llvm_libc_macros_float16_macros",
+ ],
+)
+
+libc_support_library(
+ name = "__support_math_fmaximum_mag_numl",
+ hdrs = ["src/__support/math/fmaximum_mag_numl.h"],
+ deps = [
+ ":__support_fputil_basic_operations",
+ ":__support_macros_config",
+ ],
+)
+
libc_support_library(
name = "__support_math_fmaximum_num",
hdrs = ["src/__support/math/fmaximum_num.h"],
@@ -4410,6 +4439,63 @@ libc_support_library(
],
)
+libc_support_library(
+ name = "__support_math_fminimum_mag_num",
+ hdrs = ["src/__support/math/fminimum_mag_num.h"],
+ deps = [
+ ":__support_fputil_basic_operations",
+ ":__support_macros_config",
+ ],
+)
+
+libc_support_library(
+ name = "__support_math_fminimum_mag_numbf16",
+ hdrs = ["src/__support/math/fminimum_mag_numbf16.h"],
+ deps = [
+ ":__support_fputil_basic_operations",
+ ":__support_fputil_bfloat16",
+ ":__support_macros_config",
+ ],
+)
+
+libc_support_library(
+ name = "__support_math_fminimum_mag_numf",
+ hdrs = ["src/__support/math/fminimum_mag_numf.h"],
+ deps = [
+ ":__support_fputil_basic_operations",
+ ":__support_macros_config",
+ ],
+)
+
+libc_support_library(
+ name = "__support_math_fminimum_mag_numf128",
+ hdrs = ["src/__support/math/fminimum_mag_numf128.h"],
+ deps = [
+ ":__support_fputil_basic_operations",
+ ":__support_macros_config",
+ ":llvm_libc_types_float128",
+ ],
+)
+
+libc_support_library(
+ name = "__support_math_fminimum_mag_numf16",
+ hdrs = ["src/__support/math/fminimum_mag_numf16.h"],
+ deps = [
+ ":__support_fputil_basic_operations",
+ ":__support_macros_config",
+ ":llvm_libc_macros_float16_macros",
+ ],
+)
+
+libc_support_library(
+ name = "__support_math_fminimum_mag_numl",
+ hdrs = ["src/__support/math/fminimum_mag_numl.h"],
+ deps = [
+ ":__support_fputil_basic_operations",
+ ":__support_macros_config",
+ ],
+)
+
libc_support_library(
name = "__support_math_fminimum_num",
hdrs = ["src/__support/math/fminimum_num.h"],
@@ -8251,6 +8337,13 @@ libc_math_function(
],
)
+libc_math_function(
+ name = "fminimum_mag_numbf16",
+ additional_deps = [
+ ":__support_math_fminimum_mag_numbf16",
+ ],
+)
+
libc_math_function(
name = "fminimum_numbf16",
additional_deps = [
@@ -9162,14 +9255,25 @@ libc_math_function(
],
)
-libc_math_function(name = "fmaximum_mag_numl")
+libc_math_function(
+ name = "fmaximum_mag_numl",
+ additional_deps = [
+ ":__support_math_fmaximum_mag_numl",
+ ],
+)
libc_math_function(
name = "fmaximum_mag_numf128",
+ additional_deps = [
+ ":__support_math_fmaximum_mag_numf128",
+ ],
)
libc_math_function(
name = "fmaximum_mag_numf16",
+ additional_deps = [
+ ":__support_math_fmaximum_mag_numf16",
+ ],
)
libc_math_function(
@@ -9312,18 +9416,39 @@ libc_math_function(
],
)
-libc_math_function(name = "fminimum_mag_num")
+libc_math_function(
+ name = "fminimum_mag_num",
+ additional_deps = [
+ ":__support_math_fminimum_mag_num",
+ ],
+)
-libc_math_function(name = "fminimum_mag_numf")
+libc_math_function(
+ name = "fminimum_mag_numf",
+ additional_deps = [
+ ":__support_math_fminimum_mag_numf",
+ ],
+)
-libc_math_function(name = "fminimum_mag_numl")
+libc_math_function(
+ name = "fminimum_mag_numl",
+ additional_deps = [
+ ":__support_math_fminimum_mag_numl",
+ ],
+)
libc_math_function(
name = "fminimum_mag_numf128",
+ additional_deps = [
+ ":__support_math_fminimum_mag_numf128",
+ ],
)
libc_math_function(
name = "fminimum_mag_numf16",
+ additional_deps = [
+ ":__support_math_fminimum_mag_numf16",
+ ],
)
libc_math_function(
More information about the libc-commits
mailing list