[libc-commits] [libc] [llvm] [libc][math] Refactor remainder-remquo family to header-only (PR #195421)
via libc-commits
libc-commits at lists.llvm.org
Fri May 1 23:28:14 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-libc
Author: Anonmiraj (AnonMiraj)
<details>
<summary>Changes</summary>
Refactors the remainder-remquo math family to be header-only.
part of: #<!-- -->147386
Target Functions:
- remainder
- remainderbf16
- remainderf
- remainderf128
- remainderf16
- remainderl
- remquo
- remquobf16
- remquof
- remquof128
- remquof16
- remquol
---
Patch is 58.15 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/195421.diff
45 Files Affected:
- (modified) libc/shared/math.h (+12)
- (added) libc/shared/math/remainder.h (+23)
- (added) libc/shared/math/remainderbf16.h (+23)
- (added) libc/shared/math/remainderf.h (+23)
- (added) libc/shared/math/remainderf128.h (+29)
- (added) libc/shared/math/remainderf16.h (+29)
- (added) libc/shared/math/remainderl.h (+23)
- (added) libc/shared/math/remquo.h (+23)
- (added) libc/shared/math/remquobf16.h (+23)
- (added) libc/shared/math/remquof.h (+23)
- (added) libc/shared/math/remquof128.h (+29)
- (added) libc/shared/math/remquof16.h (+29)
- (added) libc/shared/math/remquol.h (+23)
- (modified) libc/src/__support/FPUtil/DivisionAndRemainderOperations.h (+1-1)
- (modified) libc/src/__support/FPUtil/NormalFloat.h (+15-10)
- (modified) libc/src/__support/math/CMakeLists.txt (+114)
- (added) libc/src/__support/math/remainder.h (+26)
- (added) libc/src/__support/math/remainderbf16.h (+27)
- (added) libc/src/__support/math/remainderf.h (+26)
- (added) libc/src/__support/math/remainderf128.h (+32)
- (added) libc/src/__support/math/remainderf16.h (+32)
- (added) libc/src/__support/math/remainderl.h (+26)
- (added) libc/src/__support/math/remquo.h (+25)
- (added) libc/src/__support/math/remquobf16.h (+26)
- (added) libc/src/__support/math/remquof.h (+25)
- (added) libc/src/__support/math/remquof128.h (+31)
- (added) libc/src/__support/math/remquof16.h (+31)
- (added) libc/src/__support/math/remquol.h (+26)
- (modified) libc/src/math/generic/CMakeLists.txt (+10-21)
- (modified) libc/src/math/generic/remainder.cpp (+2-5)
- (modified) libc/src/math/generic/remainderbf16.cpp (+2-6)
- (modified) libc/src/math/generic/remainderf.cpp (+2-5)
- (modified) libc/src/math/generic/remainderf128.cpp (+2-5)
- (modified) libc/src/math/generic/remainderf16.cpp (+2-5)
- (modified) libc/src/math/generic/remainderl.cpp (+2-5)
- (modified) libc/src/math/generic/remquo.cpp (+2-4)
- (modified) libc/src/math/generic/remquobf16.cpp (+2-5)
- (modified) libc/src/math/generic/remquof.cpp (+2-4)
- (modified) libc/src/math/generic/remquof128.cpp (+2-4)
- (modified) libc/src/math/generic/remquof16.cpp (+2-4)
- (modified) libc/src/math/generic/remquol.cpp (+2-4)
- (modified) libc/test/shared/CMakeLists.txt (+24)
- (modified) libc/test/shared/shared_math_constexpr_test.cpp (+34)
- (modified) libc/test/shared/shared_math_test.cpp (+33)
- (modified) utils/bazel/llvm-project-overlay/libc/BUILD.bazel (+176-6)
``````````diff
diff --git a/libc/shared/math.h b/libc/shared/math.h
index 7ee760ed2c156..293ddc21cafb9 100644
--- a/libc/shared/math.h
+++ b/libc/shared/math.h
@@ -332,6 +332,18 @@
#include "math/nextupl.h"
#include "math/pow.h"
#include "math/powf.h"
+#include "math/remainder.h"
+#include "math/remainderbf16.h"
+#include "math/remainderf.h"
+#include "math/remainderf128.h"
+#include "math/remainderf16.h"
+#include "math/remainderl.h"
+#include "math/remquo.h"
+#include "math/remquobf16.h"
+#include "math/remquof.h"
+#include "math/remquof128.h"
+#include "math/remquof16.h"
+#include "math/remquol.h"
#include "math/rsqrtf.h"
#include "math/rsqrtf16.h"
#include "math/setpayload.h"
diff --git a/libc/shared/math/remainder.h b/libc/shared/math/remainder.h
new file mode 100644
index 0000000000000..a7cd375bd38f8
--- /dev/null
+++ b/libc/shared/math/remainder.h
@@ -0,0 +1,23 @@
+//===-- Shared remainder 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_REMAINDER_H
+#define LLVM_LIBC_SHARED_MATH_REMAINDER_H
+
+#include "shared/libc_common.h"
+#include "src/__support/math/remainder.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::remainder;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SHARED_MATH_REMAINDER_H
diff --git a/libc/shared/math/remainderbf16.h b/libc/shared/math/remainderbf16.h
new file mode 100644
index 0000000000000..dd3064b30a3e1
--- /dev/null
+++ b/libc/shared/math/remainderbf16.h
@@ -0,0 +1,23 @@
+//===-- Shared remainderbf16 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_REMAINDERBF16_H
+#define LLVM_LIBC_SHARED_MATH_REMAINDERBF16_H
+
+#include "shared/libc_common.h"
+#include "src/__support/math/remainderbf16.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::remainderbf16;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SHARED_MATH_REMAINDERBF16_H
diff --git a/libc/shared/math/remainderf.h b/libc/shared/math/remainderf.h
new file mode 100644
index 0000000000000..5544e503739eb
--- /dev/null
+++ b/libc/shared/math/remainderf.h
@@ -0,0 +1,23 @@
+//===-- Shared remainderf 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_REMAINDERF_H
+#define LLVM_LIBC_SHARED_MATH_REMAINDERF_H
+
+#include "shared/libc_common.h"
+#include "src/__support/math/remainderf.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::remainderf;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SHARED_MATH_REMAINDERF_H
diff --git a/libc/shared/math/remainderf128.h b/libc/shared/math/remainderf128.h
new file mode 100644
index 0000000000000..97ff5e2eaf481
--- /dev/null
+++ b/libc/shared/math/remainderf128.h
@@ -0,0 +1,29 @@
+//===-- Shared remainderf128 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_REMAINDERF128_H
+#define LLVM_LIBC_SHARED_MATH_REMAINDERF128_H
+
+#include "include/llvm-libc-types/float128.h"
+
+#ifdef LIBC_TYPES_HAS_FLOAT128
+
+#include "shared/libc_common.h"
+#include "src/__support/math/remainderf128.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::remainderf128;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LIBC_TYPES_HAS_FLOAT128
+
+#endif // LLVM_LIBC_SHARED_MATH_REMAINDERF128_H
diff --git a/libc/shared/math/remainderf16.h b/libc/shared/math/remainderf16.h
new file mode 100644
index 0000000000000..74693494cee11
--- /dev/null
+++ b/libc/shared/math/remainderf16.h
@@ -0,0 +1,29 @@
+//===-- Shared remainderf16 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_REMAINDERF16_H
+#define LLVM_LIBC_SHARED_MATH_REMAINDERF16_H
+
+#include "include/llvm-libc-macros/float16-macros.h"
+
+#ifdef LIBC_TYPES_HAS_FLOAT16
+
+#include "shared/libc_common.h"
+#include "src/__support/math/remainderf16.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::remainderf16;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LIBC_TYPES_HAS_FLOAT16
+
+#endif // LLVM_LIBC_SHARED_MATH_REMAINDERF16_H
diff --git a/libc/shared/math/remainderl.h b/libc/shared/math/remainderl.h
new file mode 100644
index 0000000000000..b84ef297738ee
--- /dev/null
+++ b/libc/shared/math/remainderl.h
@@ -0,0 +1,23 @@
+//===-- Shared remainderl 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_REMAINDERL_H
+#define LLVM_LIBC_SHARED_MATH_REMAINDERL_H
+
+#include "shared/libc_common.h"
+#include "src/__support/math/remainderl.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::remainderl;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SHARED_MATH_REMAINDERL_H
diff --git a/libc/shared/math/remquo.h b/libc/shared/math/remquo.h
new file mode 100644
index 0000000000000..3ba0565507610
--- /dev/null
+++ b/libc/shared/math/remquo.h
@@ -0,0 +1,23 @@
+//===-- Shared remquo 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_REMQUO_H
+#define LLVM_LIBC_SHARED_MATH_REMQUO_H
+
+#include "shared/libc_common.h"
+#include "src/__support/math/remquo.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::remquo;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SHARED_MATH_REMQUO_H
diff --git a/libc/shared/math/remquobf16.h b/libc/shared/math/remquobf16.h
new file mode 100644
index 0000000000000..549c181aa1dfa
--- /dev/null
+++ b/libc/shared/math/remquobf16.h
@@ -0,0 +1,23 @@
+//===-- Shared remquobf16 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_REMQUOBF16_H
+#define LLVM_LIBC_SHARED_MATH_REMQUOBF16_H
+
+#include "shared/libc_common.h"
+#include "src/__support/math/remquobf16.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::remquobf16;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SHARED_MATH_REMQUOBF16_H
diff --git a/libc/shared/math/remquof.h b/libc/shared/math/remquof.h
new file mode 100644
index 0000000000000..18512becf90b4
--- /dev/null
+++ b/libc/shared/math/remquof.h
@@ -0,0 +1,23 @@
+//===-- Shared remquof 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_REMQUOF_H
+#define LLVM_LIBC_SHARED_MATH_REMQUOF_H
+
+#include "shared/libc_common.h"
+#include "src/__support/math/remquof.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::remquof;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SHARED_MATH_REMQUOF_H
diff --git a/libc/shared/math/remquof128.h b/libc/shared/math/remquof128.h
new file mode 100644
index 0000000000000..d2054c266fcc8
--- /dev/null
+++ b/libc/shared/math/remquof128.h
@@ -0,0 +1,29 @@
+//===-- Shared remquof128 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_REMQUOF128_H
+#define LLVM_LIBC_SHARED_MATH_REMQUOF128_H
+
+#include "include/llvm-libc-types/float128.h"
+
+#ifdef LIBC_TYPES_HAS_FLOAT128
+
+#include "shared/libc_common.h"
+#include "src/__support/math/remquof128.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::remquof128;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LIBC_TYPES_HAS_FLOAT128
+
+#endif // LLVM_LIBC_SHARED_MATH_REMQUOF128_H
diff --git a/libc/shared/math/remquof16.h b/libc/shared/math/remquof16.h
new file mode 100644
index 0000000000000..e80281adf8634
--- /dev/null
+++ b/libc/shared/math/remquof16.h
@@ -0,0 +1,29 @@
+//===-- Shared remquof16 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_REMQUOF16_H
+#define LLVM_LIBC_SHARED_MATH_REMQUOF16_H
+
+#include "include/llvm-libc-macros/float16-macros.h"
+
+#ifdef LIBC_TYPES_HAS_FLOAT16
+
+#include "shared/libc_common.h"
+#include "src/__support/math/remquof16.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::remquof16;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LIBC_TYPES_HAS_FLOAT16
+
+#endif // LLVM_LIBC_SHARED_MATH_REMQUOF16_H
diff --git a/libc/shared/math/remquol.h b/libc/shared/math/remquol.h
new file mode 100644
index 0000000000000..cda1133e6c4a1
--- /dev/null
+++ b/libc/shared/math/remquol.h
@@ -0,0 +1,23 @@
+//===-- Shared remquol 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_REMQUOL_H
+#define LLVM_LIBC_SHARED_MATH_REMQUOL_H
+
+#include "shared/libc_common.h"
+#include "src/__support/math/remquol.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace shared {
+
+using math::remquol;
+
+} // namespace shared
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SHARED_MATH_REMQUOL_H
diff --git a/libc/src/__support/FPUtil/DivisionAndRemainderOperations.h b/libc/src/__support/FPUtil/DivisionAndRemainderOperations.h
index fda33875f25bc..bc22a2331f12d 100644
--- a/libc/src/__support/FPUtil/DivisionAndRemainderOperations.h
+++ b/libc/src/__support/FPUtil/DivisionAndRemainderOperations.h
@@ -25,7 +25,7 @@ static constexpr int QUOTIENT_LSB_BITS = 3;
// The implementation is a bit-by-bit algorithm which uses integer division
// to evaluate the quotient and remainder.
template <typename T, cpp::enable_if_t<cpp::is_floating_point_v<T>, int> = 0>
-LIBC_INLINE T remquo(T x, T y, int &q) {
+LIBC_INLINE constexpr T remquo(T x, T y, int &q) {
FPBits<T> xbits(x), ybits(y);
if (xbits.is_nan())
return x;
diff --git a/libc/src/__support/FPUtil/NormalFloat.h b/libc/src/__support/FPUtil/NormalFloat.h
index b30e36fd03e9f..a60329df89941 100644
--- a/libc/src/__support/FPUtil/NormalFloat.h
+++ b/libc/src/__support/FPUtil/NormalFloat.h
@@ -46,7 +46,7 @@ template <typename T> struct NormalFloat {
Sign sign = Sign::POS;
- LIBC_INLINE NormalFloat(Sign s, int32_t e, StorageType m)
+ LIBC_INLINE constexpr NormalFloat(Sign s, int32_t e, StorageType m)
: exponent(e), mantissa(m), sign(s) {
if (mantissa >= ONE)
return;
@@ -56,14 +56,18 @@ template <typename T> struct NormalFloat {
exponent -= normalization_shift;
}
- LIBC_INLINE explicit NormalFloat(T x) { init_from_bits(FPBits<T>(x)); }
+ LIBC_INLINE constexpr explicit NormalFloat(T x) {
+ init_from_bits(FPBits<T>(x));
+ }
- LIBC_INLINE explicit NormalFloat(FPBits<T> bits) { init_from_bits(bits); }
+ LIBC_INLINE constexpr explicit NormalFloat(FPBits<T> bits) {
+ init_from_bits(bits);
+ }
// Compares this normalized number with another normalized number.
// Returns -1 is this number is less than |other|, 0 if this number is equal
// to |other|, and 1 if this number is greater than |other|.
- LIBC_INLINE int cmp(const NormalFloat<T> &other) const {
+ LIBC_INLINE constexpr int cmp(const NormalFloat<T> &other) const {
const int result = sign.is_neg() ? -1 : 1;
if (sign != other.sign)
return result;
@@ -85,13 +89,13 @@ template <typename T> struct NormalFloat {
// Returns a new normalized floating point number which is equal in value
// to this number multiplied by 2^e. That is:
// new = this * 2^e
- LIBC_INLINE NormalFloat<T> mul2(int e) const {
+ LIBC_INLINE constexpr NormalFloat<T> mul2(int e) const {
NormalFloat<T> result = *this;
result.exponent += e;
return result;
}
- LIBC_INLINE operator T() const {
+ LIBC_INLINE constexpr operator T() const {
int biased_exponent = exponent + FPBits<T>::EXP_BIAS;
// Max exponent is of the form 0xFF...E. That is why -2 and not -1.
constexpr int MAX_EXPONENT_VALUE = (1 << FPBits<T>::EXP_LEN) - 2;
@@ -144,7 +148,7 @@ template <typename T> struct NormalFloat {
}
private:
- LIBC_INLINE void init_from_bits(FPBits<T> bits) {
+ LIBC_INLINE constexpr void init_from_bits(FPBits<T> bits) {
sign = bits.sign();
if (bits.is_inf_or_nan() || bits.is_zero()) {
@@ -166,7 +170,7 @@ template <typename T> struct NormalFloat {
}
}
- LIBC_INLINE unsigned evaluate_normalization_shift(StorageType m) {
+ LIBC_INLINE constexpr unsigned evaluate_normalization_shift(StorageType m) {
unsigned shift = 0;
for (; (ONE & m) == 0 && (shift < FPBits<T>::FRACTION_LEN);
m <<= 1, ++shift)
@@ -177,7 +181,7 @@ template <typename T> struct NormalFloat {
#ifdef LIBC_TYPES_LONG_DOUBLE_IS_X86_FLOAT80
template <>
-LIBC_INLINE void
+LIBC_INLINE constexpr void
NormalFloat<long double>::init_from_bits(FPBits<long double> bits) {
sign = bits.sign();
@@ -212,7 +216,8 @@ NormalFloat<long double>::init_from_bits(FPBits<long double> bits) {
}
}
-template <> LIBC_INLINE NormalFloat<long double>::operator long double() const {
+template <>
+LIBC_INLINE constexpr NormalFloat<long double>::operator long double() const {
using LDBits = FPBits<long double>;
int biased_exponent = exponent + LDBits::EXP_BIAS;
// Max exponent is of the form 0xFF...E. That is why -2 and not -1.
diff --git a/libc/src/__support/math/CMakeLists.txt b/libc/src/__support/math/CMakeLists.txt
index 9c7338995226c..4e4615314364c 100644
--- a/libc/src/__support/math/CMakeLists.txt
+++ b/libc/src/__support/math/CMakeLists.txt
@@ -1611,6 +1611,120 @@ add_header_library(
libc.src.__support.macros.config
)
+add_header_library(
+ remainder
+ HDRS
+ remainder.h
+ DEPENDS
+ libc.src.__support.FPUtil.division_and_remainder_operations
+ libc.src.__support.macros.config
+)
+
+add_header_library(
+ remainderbf16
+ HDRS
+ remainderbf16.h
+ DEPENDS
+ libc.src.__support.FPUtil.bfloat16
+ libc.src.__support.FPUtil.division_and_remainder_operations
+ libc.src.__support.macros.config
+)
+
+add_header_library(
+ remainderf
+ HDRS
+ remainderf.h
+ DEPENDS
+ libc.src.__support.macros.config
+ libc.src.__support.FPUtil.division_and_remainder_operations
+)
+
+add_header_library(
+ remainderf128
+ HDRS
+ remainderf128.h
+ DEPENDS
+ libc.include.llvm-libc-types.float128
+ libc.src.__support.FPUtil.division_and_remainder_operations
+ libc.src.__support.macros.config
+)
+
+add_header_library(
+ remainderf16
+ HDRS
+ remainderf16.h
+ DEPENDS
+ libc.include.llvm-libc-macros.float16_macros
+ libc.src.__support.FPUtil.division_and_remainder_operations
+ libc.src.__support.macros.config
+)
+
+add_header_library(
+ remainderl
+ HDRS
+ remainderl.h
+ DEPENDS
+ libc.src.__support.FPUtil.division_and_remainder_operations
+ libc.src.__support.macros.config
+)
+
+add_header_library(
+ remquo
+ HDRS
+ remquo.h
+ DEPENDS
+ libc.src.__support.FPUtil.division_and_remainder_operations
+ libc.src.__support.macros.config
+)
+
+add_header_library(
+ remquobf16
+ HDRS
+ remquobf16.h
+ DEPENDS
+ libc.src.__support.FPUtil.bfloat16
+ libc.src.__support.FPUtil.division_and_remainder_operations
+ libc.src.__support.macros.config
+)
+
+add_header_library(
+ remquof
+ HDRS
+ remquof.h
+ DEPENDS
+ libc.src.__support.macros.config
+ libc.src.__support.math.remquo
+)
+
+add_header_library(
+ remquof128
+ HDRS
+ remquof128.h
+ DEPENDS
+ libc.include.llvm-libc-types.float128
+ libc.src.__support.FPUtil.division_and_remainder_operations
+ libc.src.__support.macros.config
+)
+
+add_header_library(
+ remquof16
+ HDRS
+ remquof16.h
+ DEPENDS
+ libc.include.llvm-libc-macros.float16_macros
+ libc.src.__support.FPUtil.division_and_remainder_operations
+ libc.src.__support.macros.config
+)
+
+add_header_library(
+ remquol
+ HDRS
+ remquol.h
+ DEPENDS
+ libc.src.__support.FPUtil.division_and_remainder_operations
+ libc.src.__support.macros.config
+)
+
add_header_library(
sincos_integer_utils
HDRS
diff --git a/libc/src/__support/math/remainder.h b/libc/src/__support/math/remainder.h
new file mode 100644
index 0000000000000..247076d50f2c8
--- /dev/null
+++ b/libc/src/__support/math/remainder.h
@@ -0,0 +1,26 @@
+//===-- Implementation header for remainder ---------------------*- 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_REMAINDER_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_REMAINDER_H
+
+#include "src/__support/FPUtil/DivisionAndRemainderOperations.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace math {
+
+LIBC_INLINE constexpr double remainder(double x, double y) {
+ int quotient{};
+ return fputil::remquo(x, y, quotient);
+}
+
+} // namespace math
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC___SUPPORT_MATH_REMAINDER_H
diff --git a/libc/src/__support/math/remainderbf16.h b/libc/src/__support/math/remainderbf1...
[truncated]
``````````
</details>
https://github.com/llvm/llvm-project/pull/195421
More information about the libc-commits
mailing list