[libc-commits] [libc] [llvm] [libc][math] Refactor remainder-remquo family to header-only (PR #195421)

via libc-commits libc-commits at lists.llvm.org
Sat May 2 00:05:16 PDT 2026


https://github.com/AnonMiraj updated https://github.com/llvm/llvm-project/pull/195421

>From 36fd4c3ec1e0c68fb426a5cf1a2f2a9b3d48da08 Mon Sep 17 00:00:00 2001
From: Anonmiraj <ezzibrahimx at gmail.com>
Date: Sat, 2 May 2026 09:27:15 +0300
Subject: [PATCH] [libc][math] Refactor remainder-remquo family to header-only

Refactored functions:
  - remainder
  - remainderbf16
  - remainderf
  - remainderf128
  - remainderf16
  - remainderl
  - remquo
  - remquobf16
  - remquof
  - remquof128
  - remquof16
  - remquol
---
 libc/shared/math.h                            |  12 ++
 libc/shared/math/remainder.h                  |  23 +++
 libc/shared/math/remainderbf16.h              |  23 +++
 libc/shared/math/remainderf.h                 |  23 +++
 libc/shared/math/remainderf128.h              |  29 +++
 libc/shared/math/remainderf16.h               |  29 +++
 libc/shared/math/remainderl.h                 |  23 +++
 libc/shared/math/remquo.h                     |  23 +++
 libc/shared/math/remquobf16.h                 |  23 +++
 libc/shared/math/remquof.h                    |  23 +++
 libc/shared/math/remquof128.h                 |  29 +++
 libc/shared/math/remquof16.h                  |  29 +++
 libc/shared/math/remquol.h                    |  23 +++
 .../FPUtil/DivisionAndRemainderOperations.h   |   2 +-
 libc/src/__support/FPUtil/NormalFloat.h       |  29 +--
 libc/src/__support/math/CMakeLists.txt        | 114 +++++++++++
 libc/src/__support/math/remainder.h           |  26 +++
 libc/src/__support/math/remainderbf16.h       |  27 +++
 libc/src/__support/math/remainderf.h          |  26 +++
 libc/src/__support/math/remainderf128.h       |  32 +++
 libc/src/__support/math/remainderf16.h        |  32 +++
 libc/src/__support/math/remainderl.h          |  26 +++
 libc/src/__support/math/remquo.h              |  25 +++
 libc/src/__support/math/remquobf16.h          |  26 +++
 libc/src/__support/math/remquof.h             |  25 +++
 libc/src/__support/math/remquof128.h          |  31 +++
 libc/src/__support/math/remquof16.h           |  31 +++
 libc/src/__support/math/remquol.h             |  26 +++
 libc/src/math/generic/CMakeLists.txt          |  31 +--
 libc/src/math/generic/remainder.cpp           |   7 +-
 libc/src/math/generic/remainderbf16.cpp       |   8 +-
 libc/src/math/generic/remainderf.cpp          |   7 +-
 libc/src/math/generic/remainderf128.cpp       |   7 +-
 libc/src/math/generic/remainderf16.cpp        |   7 +-
 libc/src/math/generic/remainderl.cpp          |   7 +-
 libc/src/math/generic/remquo.cpp              |   6 +-
 libc/src/math/generic/remquobf16.cpp          |   7 +-
 libc/src/math/generic/remquof.cpp             |   6 +-
 libc/src/math/generic/remquof128.cpp          |   6 +-
 libc/src/math/generic/remquof16.cpp           |   6 +-
 libc/src/math/generic/remquol.cpp             |   6 +-
 libc/test/shared/CMakeLists.txt               |  24 +++
 .../shared/shared_math_constexpr_test.cpp     |  34 ++++
 libc/test/shared/shared_math_test.cpp         |  33 ++++
 .../llvm-project-overlay/libc/BUILD.bazel     | 182 +++++++++++++++++-
 45 files changed, 1078 insertions(+), 96 deletions(-)
 create mode 100644 libc/shared/math/remainder.h
 create mode 100644 libc/shared/math/remainderbf16.h
 create mode 100644 libc/shared/math/remainderf.h
 create mode 100644 libc/shared/math/remainderf128.h
 create mode 100644 libc/shared/math/remainderf16.h
 create mode 100644 libc/shared/math/remainderl.h
 create mode 100644 libc/shared/math/remquo.h
 create mode 100644 libc/shared/math/remquobf16.h
 create mode 100644 libc/shared/math/remquof.h
 create mode 100644 libc/shared/math/remquof128.h
 create mode 100644 libc/shared/math/remquof16.h
 create mode 100644 libc/shared/math/remquol.h
 create mode 100644 libc/src/__support/math/remainder.h
 create mode 100644 libc/src/__support/math/remainderbf16.h
 create mode 100644 libc/src/__support/math/remainderf.h
 create mode 100644 libc/src/__support/math/remainderf128.h
 create mode 100644 libc/src/__support/math/remainderf16.h
 create mode 100644 libc/src/__support/math/remainderl.h
 create mode 100644 libc/src/__support/math/remquo.h
 create mode 100644 libc/src/__support/math/remquobf16.h
 create mode 100644 libc/src/__support/math/remquof.h
 create mode 100644 libc/src/__support/math/remquof128.h
 create mode 100644 libc/src/__support/math/remquof16.h
 create mode 100644 libc/src/__support/math/remquol.h

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..5123a3e217f72 100644
--- a/libc/src/__support/FPUtil/NormalFloat.h
+++ b/libc/src/__support/FPUtil/NormalFloat.h
@@ -36,9 +36,9 @@ template <typename T> struct NormalFloat {
       (StorageType(1) << FPBits<T>::FRACTION_LEN);
 
   // Unbiased exponent value.
-  int32_t exponent;
+  int32_t exponent{};
 
-  StorageType mantissa;
+  StorageType mantissa{};
   // We want |StorageType| to have atleast one bit more than the actual mantissa
   // bit width to accommodate the implicit 1 value.
   static_assert(sizeof(StorageType) * 8 >= FPBits<T>::FRACTION_LEN + 1,
@@ -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..2be565504ee84 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.FPUtil.division_and_remainder_operations
+)
+
+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/remainderbf16.h
new file mode 100644
index 0000000000000..36d4c420bf263
--- /dev/null
+++ b/libc/src/__support/math/remainderbf16.h
@@ -0,0 +1,27 @@
+//===-- Implementation header for remainderbf16 -----------------*- 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_REMAINDERBF16_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_REMAINDERBF16_H
+
+#include "src/__support/FPUtil/DivisionAndRemainderOperations.h"
+#include "src/__support/FPUtil/bfloat16.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace math {
+
+LIBC_INLINE constexpr bfloat16 remainderbf16(bfloat16 x, bfloat16 y) {
+  int quotient{};
+  return fputil::remquo(x, y, quotient);
+}
+
+} // namespace math
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC___SUPPORT_MATH_REMAINDERBF16_H
diff --git a/libc/src/__support/math/remainderf.h b/libc/src/__support/math/remainderf.h
new file mode 100644
index 0000000000000..42e605ad2bca4
--- /dev/null
+++ b/libc/src/__support/math/remainderf.h
@@ -0,0 +1,26 @@
+//===-- Implementation header for remainderf --------------------*- 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_REMAINDERF_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_REMAINDERF_H
+
+#include "src/__support/FPUtil/DivisionAndRemainderOperations.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace math {
+
+LIBC_INLINE constexpr float remainderf(float x, float y) {
+  int quotient{};
+  return fputil::remquo(x, y, quotient);
+}
+
+} // namespace math
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC___SUPPORT_MATH_REMAINDERF_H
diff --git a/libc/src/__support/math/remainderf128.h b/libc/src/__support/math/remainderf128.h
new file mode 100644
index 0000000000000..bf749b569bd4a
--- /dev/null
+++ b/libc/src/__support/math/remainderf128.h
@@ -0,0 +1,32 @@
+//===-- Implementation header for remainderf128 -----------------*- 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_REMAINDERF128_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_REMAINDERF128_H
+
+#include "include/llvm-libc-types/float128.h"
+
+#ifdef LIBC_TYPES_HAS_FLOAT128
+
+#include "src/__support/FPUtil/DivisionAndRemainderOperations.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace math {
+
+LIBC_INLINE constexpr float128 remainderf128(float128 x, float128 y) {
+  int quotient{};
+  return fputil::remquo(x, y, quotient);
+}
+
+} // namespace math
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LIBC_TYPES_HAS_FLOAT128
+
+#endif // LLVM_LIBC_SRC___SUPPORT_MATH_REMAINDERF128_H
diff --git a/libc/src/__support/math/remainderf16.h b/libc/src/__support/math/remainderf16.h
new file mode 100644
index 0000000000000..831b86b3db782
--- /dev/null
+++ b/libc/src/__support/math/remainderf16.h
@@ -0,0 +1,32 @@
+//===-- Implementation header for remainderf16 ------------------*- 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_REMAINDERF16_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_REMAINDERF16_H
+
+#include "include/llvm-libc-macros/float16-macros.h"
+
+#ifdef LIBC_TYPES_HAS_FLOAT16
+
+#include "src/__support/FPUtil/DivisionAndRemainderOperations.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace math {
+
+LIBC_INLINE constexpr float16 remainderf16(float16 x, float16 y) {
+  int quotient{};
+  return fputil::remquo(x, y, quotient);
+}
+
+} // namespace math
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LIBC_TYPES_HAS_FLOAT16
+
+#endif // LLVM_LIBC_SRC___SUPPORT_MATH_REMAINDERF16_H
diff --git a/libc/src/__support/math/remainderl.h b/libc/src/__support/math/remainderl.h
new file mode 100644
index 0000000000000..5a715b5bfa210
--- /dev/null
+++ b/libc/src/__support/math/remainderl.h
@@ -0,0 +1,26 @@
+//===-- Implementation header for remainderl --------------------*- 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_REMAINDERL_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_REMAINDERL_H
+
+#include "src/__support/FPUtil/DivisionAndRemainderOperations.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace math {
+
+LIBC_INLINE constexpr long double remainderl(long double x, long double y) {
+  int quotient{};
+  return fputil::remquo(x, y, quotient);
+}
+
+} // namespace math
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC___SUPPORT_MATH_REMAINDERL_H
diff --git a/libc/src/__support/math/remquo.h b/libc/src/__support/math/remquo.h
new file mode 100644
index 0000000000000..45c8af4a050e4
--- /dev/null
+++ b/libc/src/__support/math/remquo.h
@@ -0,0 +1,25 @@
+//===-- Implementation header for remquo ------------------------*- 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_REMQUO_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_REMQUO_H
+
+#include "src/__support/FPUtil/DivisionAndRemainderOperations.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace math {
+
+LIBC_INLINE constexpr double remquo(double x, double y, int *exp) {
+  return fputil::remquo(x, y, *exp);
+}
+
+} // namespace math
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC___SUPPORT_MATH_REMQUO_H
diff --git a/libc/src/__support/math/remquobf16.h b/libc/src/__support/math/remquobf16.h
new file mode 100644
index 0000000000000..a0b275bf435ef
--- /dev/null
+++ b/libc/src/__support/math/remquobf16.h
@@ -0,0 +1,26 @@
+//===-- Implementation header for remquobf16 --------------------*- 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_REMQUOBF16_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_REMQUOBF16_H
+
+#include "src/__support/FPUtil/DivisionAndRemainderOperations.h"
+#include "src/__support/FPUtil/bfloat16.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace math {
+
+LIBC_INLINE constexpr bfloat16 remquobf16(bfloat16 x, bfloat16 y, int *exp) {
+  return fputil::remquo(x, y, *exp);
+}
+
+} // namespace math
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC___SUPPORT_MATH_REMQUOBF16_H
diff --git a/libc/src/__support/math/remquof.h b/libc/src/__support/math/remquof.h
new file mode 100644
index 0000000000000..a14c7ad87882c
--- /dev/null
+++ b/libc/src/__support/math/remquof.h
@@ -0,0 +1,25 @@
+//===-- Implementation header for remquof -----------------------*- 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_REMQUOF_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_REMQUOF_H
+
+#include "src/__support/FPUtil/DivisionAndRemainderOperations.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace math {
+
+LIBC_INLINE constexpr float remquof(float x, float y, int *exp) {
+  return fputil::remquo(x, y, *exp);
+}
+
+} // namespace math
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC___SUPPORT_MATH_REMQUOF_H
diff --git a/libc/src/__support/math/remquof128.h b/libc/src/__support/math/remquof128.h
new file mode 100644
index 0000000000000..d2247afc1e431
--- /dev/null
+++ b/libc/src/__support/math/remquof128.h
@@ -0,0 +1,31 @@
+//===-- Implementation header for remquof128 --------------------*- 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_REMQUOF128_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_REMQUOF128_H
+
+#include "include/llvm-libc-types/float128.h"
+
+#ifdef LIBC_TYPES_HAS_FLOAT128
+
+#include "src/__support/FPUtil/DivisionAndRemainderOperations.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace math {
+
+LIBC_INLINE constexpr float128 remquof128(float128 x, float128 y, int *exp) {
+  return fputil::remquo(x, y, *exp);
+}
+
+} // namespace math
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LIBC_TYPES_HAS_FLOAT128
+
+#endif // LLVM_LIBC_SRC___SUPPORT_MATH_REMQUOF128_H
diff --git a/libc/src/__support/math/remquof16.h b/libc/src/__support/math/remquof16.h
new file mode 100644
index 0000000000000..e9c2630d7beff
--- /dev/null
+++ b/libc/src/__support/math/remquof16.h
@@ -0,0 +1,31 @@
+//===-- Implementation header for remquof16 ---------------------*- 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_REMQUOF16_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_REMQUOF16_H
+
+#include "include/llvm-libc-macros/float16-macros.h"
+
+#ifdef LIBC_TYPES_HAS_FLOAT16
+
+#include "src/__support/FPUtil/DivisionAndRemainderOperations.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace math {
+
+LIBC_INLINE constexpr float16 remquof16(float16 x, float16 y, int *exp) {
+  return fputil::remquo(x, y, *exp);
+}
+
+} // namespace math
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LIBC_TYPES_HAS_FLOAT16
+
+#endif // LLVM_LIBC_SRC___SUPPORT_MATH_REMQUOF16_H
diff --git a/libc/src/__support/math/remquol.h b/libc/src/__support/math/remquol.h
new file mode 100644
index 0000000000000..f246a062d6520
--- /dev/null
+++ b/libc/src/__support/math/remquol.h
@@ -0,0 +1,26 @@
+//===-- Implementation header for remquol -----------------------*- 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_REMQUOL_H
+#define LLVM_LIBC_SRC___SUPPORT_MATH_REMQUOL_H
+
+#include "src/__support/FPUtil/DivisionAndRemainderOperations.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace math {
+
+LIBC_INLINE constexpr long double remquol(long double x, long double y,
+                                          int *exp) {
+  return fputil::remquo(x, y, *exp);
+}
+
+} // namespace math
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC___SUPPORT_MATH_REMQUOL_H
diff --git a/libc/src/math/generic/CMakeLists.txt b/libc/src/math/generic/CMakeLists.txt
index c20a526b39fc3..8b2a8729bf946 100644
--- a/libc/src/math/generic/CMakeLists.txt
+++ b/libc/src/math/generic/CMakeLists.txt
@@ -2785,7 +2785,7 @@ add_entrypoint_object(
   HDRS
     ../remquof.h
   DEPENDS
-    libc.src.__support.FPUtil.division_and_remainder_operations
+    libc.src.__support.math.remquof
 )
 
 add_entrypoint_object(
@@ -2795,7 +2795,7 @@ add_entrypoint_object(
   HDRS
     ../remquof128.h
   DEPENDS
-    libc.src.__support.FPUtil.division_and_remainder_operations
+    libc.src.__support.math.remquof128
 )
 
 add_entrypoint_object(
@@ -2815,7 +2815,7 @@ add_entrypoint_object(
   HDRS
     ../remquol.h
   DEPENDS
-    libc.src.__support.FPUtil.division_and_remainder_operations
+    libc.src.__support.math.remquol
 )
 
 add_entrypoint_object(
@@ -2825,8 +2825,7 @@ add_entrypoint_object(
   HDRS
     ../remquof16.h
   DEPENDS
-    libc.src.__support.macros.properties.types
-    libc.src.__support.FPUtil.division_and_remainder_operations
+    libc.src.__support.math.remquof16
 )
 
 add_entrypoint_object(
@@ -2836,11 +2835,7 @@ add_entrypoint_object(
   HDRS
     ../remquobf16.h
   DEPENDS
-    libc.src.__support.common
-    libc.src.__support.FPUtil.bfloat16
-    libc.src.__support.FPUtil.division_and_remainder_operations
-    libc.src.__support.macros.properties.types
-    libc.src.__support.macros.config
+    libc.src.__support.math.remquobf16
 )
 
 add_entrypoint_object(
@@ -2850,7 +2845,7 @@ add_entrypoint_object(
   HDRS
     ../remainderf.h
   DEPENDS
-    libc.src.__support.FPUtil.division_and_remainder_operations
+    libc.src.__support.math.remainderf
 )
 
 add_entrypoint_object(
@@ -2870,7 +2865,7 @@ add_entrypoint_object(
   HDRS
     ../remainderl.h
   DEPENDS
-    libc.src.__support.FPUtil.division_and_remainder_operations
+    libc.src.__support.math.remainderl
 )
 
 add_entrypoint_object(
@@ -2880,8 +2875,7 @@ add_entrypoint_object(
   HDRS
     ../remainderf16.h
   DEPENDS
-    libc.src.__support.macros.properties.types
-    libc.src.__support.FPUtil.division_and_remainder_operations
+    libc.src.__support.math.remainderf16
 )
 
 add_entrypoint_object(
@@ -2891,8 +2885,7 @@ add_entrypoint_object(
   HDRS
     ../remainderf128.h
   DEPENDS
-    libc.src.__support.macros.properties.types
-    libc.src.__support.FPUtil.division_and_remainder_operations
+    libc.src.__support.math.remainderf128
 )
 
 add_entrypoint_object(
@@ -2902,11 +2895,7 @@ add_entrypoint_object(
   HDRS
     ../remainderbf16.h
   DEPENDS
-    libc.src.__support.common
-    libc.src.__support.FPUtil.bfloat16
-    libc.src.__support.FPUtil.division_and_remainder_operations
-    libc.src.__support.macros.properties.types
-    libc.src.__support.macros.config
+    libc.src.__support.math.remainderbf16
 )
 
 add_entrypoint_object(
diff --git a/libc/src/math/generic/remainder.cpp b/libc/src/math/generic/remainder.cpp
index a22ffc45ead67..ded0ca7580651 100644
--- a/libc/src/math/generic/remainder.cpp
+++ b/libc/src/math/generic/remainder.cpp
@@ -7,15 +7,12 @@
 //===----------------------------------------------------------------------===//
 
 #include "src/math/remainder.h"
-#include "src/__support/FPUtil/DivisionAndRemainderOperations.h"
-#include "src/__support/common.h"
-#include "src/__support/macros/config.h"
+#include "src/__support/math/remainder.h"
 
 namespace LIBC_NAMESPACE_DECL {
 
 LLVM_LIBC_FUNCTION(double, remainder, (double x, double y)) {
-  int quotient;
-  return fputil::remquo(x, y, quotient);
+  return math::remainder(x, y);
 }
 
 } // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/remainderbf16.cpp b/libc/src/math/generic/remainderbf16.cpp
index e70726a6cbc55..3257a372cad21 100644
--- a/libc/src/math/generic/remainderbf16.cpp
+++ b/libc/src/math/generic/remainderbf16.cpp
@@ -7,16 +7,12 @@
 //===----------------------------------------------------------------------===//
 
 #include "src/math/remainderbf16.h"
-#include "src/__support/FPUtil/DivisionAndRemainderOperations.h"
-#include "src/__support/FPUtil/bfloat16.h"
-#include "src/__support/common.h"
-#include "src/__support/macros/config.h"
+#include "src/__support/math/remainderbf16.h"
 
 namespace LIBC_NAMESPACE_DECL {
 
 LLVM_LIBC_FUNCTION(bfloat16, remainderbf16, (bfloat16 x, bfloat16 y)) {
-  int quotient;
-  return fputil::remquo(x, y, quotient);
+  return math::remainderbf16(x, y);
 }
 
 } // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/remainderf.cpp b/libc/src/math/generic/remainderf.cpp
index 44e32e9047393..f54e772a5b466 100644
--- a/libc/src/math/generic/remainderf.cpp
+++ b/libc/src/math/generic/remainderf.cpp
@@ -7,15 +7,12 @@
 //===----------------------------------------------------------------------===//
 
 #include "src/math/remainderf.h"
-#include "src/__support/FPUtil/DivisionAndRemainderOperations.h"
-#include "src/__support/common.h"
-#include "src/__support/macros/config.h"
+#include "src/__support/math/remainderf.h"
 
 namespace LIBC_NAMESPACE_DECL {
 
 LLVM_LIBC_FUNCTION(float, remainderf, (float x, float y)) {
-  int quotient;
-  return fputil::remquo(x, y, quotient);
+  return math::remainderf(x, y);
 }
 
 } // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/remainderf128.cpp b/libc/src/math/generic/remainderf128.cpp
index 52b6c5149fdcf..072d19737d382 100644
--- a/libc/src/math/generic/remainderf128.cpp
+++ b/libc/src/math/generic/remainderf128.cpp
@@ -7,15 +7,12 @@
 //===----------------------------------------------------------------------===//
 
 #include "src/math/remainderf128.h"
-#include "src/__support/FPUtil/DivisionAndRemainderOperations.h"
-#include "src/__support/common.h"
-#include "src/__support/macros/config.h"
+#include "src/__support/math/remainderf128.h"
 
 namespace LIBC_NAMESPACE_DECL {
 
 LLVM_LIBC_FUNCTION(float128, remainderf128, (float128 x, float128 y)) {
-  int quotient;
-  return fputil::remquo(x, y, quotient);
+  return math::remainderf128(x, y);
 }
 
 } // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/remainderf16.cpp b/libc/src/math/generic/remainderf16.cpp
index 2b6488294fb74..cb4e696129782 100644
--- a/libc/src/math/generic/remainderf16.cpp
+++ b/libc/src/math/generic/remainderf16.cpp
@@ -7,15 +7,12 @@
 //===----------------------------------------------------------------------===//
 
 #include "src/math/remainderf16.h"
-#include "src/__support/FPUtil/DivisionAndRemainderOperations.h"
-#include "src/__support/common.h"
-#include "src/__support/macros/config.h"
+#include "src/__support/math/remainderf16.h"
 
 namespace LIBC_NAMESPACE_DECL {
 
 LLVM_LIBC_FUNCTION(float16, remainderf16, (float16 x, float16 y)) {
-  int quotient;
-  return fputil::remquo(x, y, quotient);
+  return math::remainderf16(x, y);
 }
 
 } // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/remainderl.cpp b/libc/src/math/generic/remainderl.cpp
index a61a13e27e417..4071ce0370a3a 100644
--- a/libc/src/math/generic/remainderl.cpp
+++ b/libc/src/math/generic/remainderl.cpp
@@ -7,15 +7,12 @@
 //===----------------------------------------------------------------------===//
 
 #include "src/math/remainderl.h"
-#include "src/__support/FPUtil/DivisionAndRemainderOperations.h"
-#include "src/__support/common.h"
-#include "src/__support/macros/config.h"
+#include "src/__support/math/remainderl.h"
 
 namespace LIBC_NAMESPACE_DECL {
 
 LLVM_LIBC_FUNCTION(long double, remainderl, (long double x, long double y)) {
-  int quotient;
-  return fputil::remquo(x, y, quotient);
+  return math::remainderl(x, y);
 }
 
 } // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/remquo.cpp b/libc/src/math/generic/remquo.cpp
index 45deb81993bc3..a9aff83b1ebe6 100644
--- a/libc/src/math/generic/remquo.cpp
+++ b/libc/src/math/generic/remquo.cpp
@@ -7,14 +7,12 @@
 //===----------------------------------------------------------------------===//
 
 #include "src/math/remquo.h"
-#include "src/__support/FPUtil/DivisionAndRemainderOperations.h"
-#include "src/__support/common.h"
-#include "src/__support/macros/config.h"
+#include "src/__support/math/remquo.h"
 
 namespace LIBC_NAMESPACE_DECL {
 
 LLVM_LIBC_FUNCTION(double, remquo, (double x, double y, int *exp)) {
-  return fputil::remquo(x, y, *exp);
+  return math::remquo(x, y, exp);
 }
 
 } // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/remquobf16.cpp b/libc/src/math/generic/remquobf16.cpp
index e1b13f8deb19a..359fe875a924f 100644
--- a/libc/src/math/generic/remquobf16.cpp
+++ b/libc/src/math/generic/remquobf16.cpp
@@ -7,15 +7,12 @@
 //===----------------------------------------------------------------------===//
 
 #include "src/math/remquobf16.h"
-#include "src/__support/FPUtil/DivisionAndRemainderOperations.h"
-#include "src/__support/FPUtil/bfloat16.h"
-#include "src/__support/common.h"
-#include "src/__support/macros/config.h"
+#include "src/__support/math/remquobf16.h"
 
 namespace LIBC_NAMESPACE_DECL {
 
 LLVM_LIBC_FUNCTION(bfloat16, remquobf16, (bfloat16 x, bfloat16 y, int *exp)) {
-  return fputil::remquo(x, y, *exp);
+  return math::remquobf16(x, y, exp);
 }
 
 } // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/remquof.cpp b/libc/src/math/generic/remquof.cpp
index f3616ab7bf497..b63dfc62f02eb 100644
--- a/libc/src/math/generic/remquof.cpp
+++ b/libc/src/math/generic/remquof.cpp
@@ -7,14 +7,12 @@
 //===----------------------------------------------------------------------===//
 
 #include "src/math/remquof.h"
-#include "src/__support/FPUtil/DivisionAndRemainderOperations.h"
-#include "src/__support/common.h"
-#include "src/__support/macros/config.h"
+#include "src/__support/math/remquof.h"
 
 namespace LIBC_NAMESPACE_DECL {
 
 LLVM_LIBC_FUNCTION(float, remquof, (float x, float y, int *exp)) {
-  return fputil::remquo(x, y, *exp);
+  return math::remquof(x, y, exp);
 }
 
 } // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/remquof128.cpp b/libc/src/math/generic/remquof128.cpp
index cf8f564b5c52b..779597d00eac0 100644
--- a/libc/src/math/generic/remquof128.cpp
+++ b/libc/src/math/generic/remquof128.cpp
@@ -7,14 +7,12 @@
 //===----------------------------------------------------------------------===//
 
 #include "src/math/remquof128.h"
-#include "src/__support/FPUtil/DivisionAndRemainderOperations.h"
-#include "src/__support/common.h"
-#include "src/__support/macros/config.h"
+#include "src/__support/math/remquof128.h"
 
 namespace LIBC_NAMESPACE_DECL {
 
 LLVM_LIBC_FUNCTION(float128, remquof128, (float128 x, float128 y, int *exp)) {
-  return fputil::remquo(x, y, *exp);
+  return math::remquof128(x, y, exp);
 }
 
 } // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/remquof16.cpp b/libc/src/math/generic/remquof16.cpp
index 3a5baadb3ce3a..b3a613243e227 100644
--- a/libc/src/math/generic/remquof16.cpp
+++ b/libc/src/math/generic/remquof16.cpp
@@ -7,14 +7,12 @@
 //===----------------------------------------------------------------------===//
 
 #include "src/math/remquof16.h"
-#include "src/__support/FPUtil/DivisionAndRemainderOperations.h"
-#include "src/__support/common.h"
-#include "src/__support/macros/config.h"
+#include "src/__support/math/remquof16.h"
 
 namespace LIBC_NAMESPACE_DECL {
 
 LLVM_LIBC_FUNCTION(float16, remquof16, (float16 x, float16 y, int *exp)) {
-  return fputil::remquo(x, y, *exp);
+  return math::remquof16(x, y, exp);
 }
 
 } // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/math/generic/remquol.cpp b/libc/src/math/generic/remquol.cpp
index 980f50cbcdeba..af0905d697ce2 100644
--- a/libc/src/math/generic/remquol.cpp
+++ b/libc/src/math/generic/remquol.cpp
@@ -7,15 +7,13 @@
 //===----------------------------------------------------------------------===//
 
 #include "src/math/remquol.h"
-#include "src/__support/FPUtil/DivisionAndRemainderOperations.h"
-#include "src/__support/common.h"
-#include "src/__support/macros/config.h"
+#include "src/__support/math/remquol.h"
 
 namespace LIBC_NAMESPACE_DECL {
 
 LLVM_LIBC_FUNCTION(long double, remquol,
                    (long double x, long double y, int *exp)) {
-  return fputil::remquo(x, y, *exp);
+  return math::remquol(x, y, exp);
 }
 
 } // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/test/shared/CMakeLists.txt b/libc/test/shared/CMakeLists.txt
index 0e59a53d1d8ba..e28d3a6665fe4 100644
--- a/libc/test/shared/CMakeLists.txt
+++ b/libc/test/shared/CMakeLists.txt
@@ -330,6 +330,18 @@ add_fp_unittest(
     libc.src.__support.math.nextafterf128
     libc.src.__support.math.pow
     libc.src.__support.math.powf
+    libc.src.__support.math.remainder
+    libc.src.__support.math.remainderbf16
+    libc.src.__support.math.remainderf
+    libc.src.__support.math.remainderf128
+    libc.src.__support.math.remainderf16
+    libc.src.__support.math.remainderl
+    libc.src.__support.math.remquo
+    libc.src.__support.math.remquobf16
+    libc.src.__support.math.remquof
+    libc.src.__support.math.remquof128
+    libc.src.__support.math.remquof16
+    libc.src.__support.math.remquol
     libc.src.__support.math.rsqrtf
     libc.src.__support.math.rsqrtf16
     libc.src.__support.math.setpayload
@@ -521,6 +533,18 @@ add_fp_unittest(
     libc.src.__support.math.modff128
     libc.src.__support.math.modff16
     libc.src.__support.math.modfl
+    libc.src.__support.math.remainder
+    libc.src.__support.math.remainderbf16
+    libc.src.__support.math.remainderf
+    libc.src.__support.math.remainderf128
+    libc.src.__support.math.remainderf16
+    libc.src.__support.math.remainderl
+    libc.src.__support.math.remquo
+    libc.src.__support.math.remquobf16
+    libc.src.__support.math.remquof
+    libc.src.__support.math.remquof128
+    libc.src.__support.math.remquof16
+    libc.src.__support.math.remquol
     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 ae2484b482c15..d644055e47ecc 100644
--- a/libc/test/shared/shared_math_constexpr_test.cpp
+++ b/libc/test/shared/shared_math_constexpr_test.cpp
@@ -50,6 +50,11 @@ static_assert(0.0 == [] {
   return LIBC_NAMESPACE::shared::modf(0, &iptr);
 }());
 static_assert(0.0 == LIBC_NAMESPACE::shared::fminimum_mag_num(0.0, 0.0));
+static_assert(0.0 == LIBC_NAMESPACE::shared::remainder(1.0, 1.0));
+static_assert(0.0 == [] {
+  int exp{};
+  return LIBC_NAMESPACE::shared::remquo(1.0, 1.0, &exp);
+}());
 
 //===----------------------------------------------------------------------===//
 //                       Float Tests
@@ -88,6 +93,11 @@ static_assert(0.0f == [] {
   return LIBC_NAMESPACE::shared::modff(0.0f, &iptr);
 }());
 static_assert(0.0f == LIBC_NAMESPACE::shared::fminimum_mag_numf(0.0f, 0.0f));
+static_assert(0.0f == LIBC_NAMESPACE::shared::remainderf(1.0f, 1.0f));
+static_assert(0.0f == [] {
+  int exp{};
+  return LIBC_NAMESPACE::shared::remquof(1.0f, 1.0f, &exp);
+}());
 //===----------------------------------------------------------------------===//
 //                       Float16 Tests
 //===----------------------------------------------------------------------===//
@@ -135,6 +145,11 @@ 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));
+static_assert(0.0f16 == LIBC_NAMESPACE::shared::remainderf16(1.0f16, 1.0f16));
+static_assert(0.0f16 == [] {
+  int exp{};
+  return LIBC_NAMESPACE::shared::remquof16(1.0f16, 1.0f16, &exp);
+}());
 #endif // LIBC_TYPES_HAS_FLOAT16
 
 //===----------------------------------------------------------------------===//
@@ -183,6 +198,11 @@ static_assert(0.0L == [] {
 }());
 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));
+static_assert(0.0L == LIBC_NAMESPACE::shared::remainderl(1.0L, 1.0L));
+static_assert(0.0L == [] {
+  int exp{};
+  return LIBC_NAMESPACE::shared::remquol(1.0L, 1.0L, &exp);
+}());
 
 #endif
 
@@ -262,6 +282,13 @@ static_assert(float128(0.0) ==
 static_assert(float128(0.0) ==
               LIBC_NAMESPACE::shared::fminimum_mag_numf128(float128(0.0),
                                                            float128(0.0)));
+static_assert(float128(0.0) ==
+              LIBC_NAMESPACE::shared::remainderf128(float128(1.0),
+                                                    float128(1.0)));
+static_assert(float128(0.0) == [] {
+  int exp{};
+  return LIBC_NAMESPACE::shared::remquof128(float128(1.0), float128(1.0), &exp);
+}());
 
 #endif // LIBC_TYPES_HAS_FLOAT128
 
@@ -336,5 +363,12 @@ static_assert(bfloat16(0.0) == [] {
 static_assert(bfloat16(0.0) ==
               LIBC_NAMESPACE::shared::fminimum_mag_numbf16(bfloat16(0.0),
                                                            bfloat16(0.0)));
+static_assert(bfloat16(0.0) ==
+              LIBC_NAMESPACE::shared::remainderbf16(bfloat16(1.0),
+                                                    bfloat16(1.0)));
+static_assert(bfloat16(0.0) == [] {
+  int exp{};
+  return LIBC_NAMESPACE::shared::remquobf16(bfloat16(1.0), bfloat16(1.0), &exp);
+}());
 
 TEST(LlvmLibcSharedMathTest, ConstantEvaluation) {}
diff --git a/libc/test/shared/shared_math_test.cpp b/libc/test/shared/shared_math_test.cpp
index 31cb2b1a33505..fbdf8c9340956 100644
--- a/libc/test/shared/shared_math_test.cpp
+++ b/libc/test/shared/shared_math_test.cpp
@@ -135,6 +135,11 @@ TEST(LlvmLibcSharedMathTest, AllFloat16) {
                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));
+  EXPECT_FP_EQ(0x0p+0f16, LIBC_NAMESPACE::shared::remainderf16(1.0f16, 1.0f16));
+  int remquof16_exp = 0;
+  EXPECT_FP_EQ(0x0p+0f16, LIBC_NAMESPACE::shared::remquof16(1.0f16, 1.0f16,
+                                                            &remquof16_exp));
+  EXPECT_EQ(1, remquof16_exp);
 }
 
 #endif // LIBC_TYPES_HAS_FLOAT16
@@ -270,6 +275,11 @@ TEST(LlvmLibcSharedMathTest, AllFloat) {
   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));
+  EXPECT_FP_EQ(0x0p+0f, LIBC_NAMESPACE::shared::remainderf(1.0f, 1.0f));
+  int remquof_exp = 0;
+  EXPECT_FP_EQ(0x0p+0f,
+               LIBC_NAMESPACE::shared::remquof(1.0f, 1.0f, &remquof_exp));
+  EXPECT_EQ(1, remquof_exp);
 }
 
 TEST(LlvmLibcSharedMathTest, AllDouble) {
@@ -381,6 +391,10 @@ TEST(LlvmLibcSharedMathTest, AllDouble) {
   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));
+  EXPECT_FP_EQ(0.0, LIBC_NAMESPACE::shared::remainder(1.0, 1.0));
+  int remquo_exp = 0;
+  EXPECT_FP_EQ(0.0, LIBC_NAMESPACE::shared::remquo(1.0, 1.0, &remquo_exp));
+  EXPECT_EQ(1, remquo_exp);
 }
 
 // TODO: Enable the tests when double-double type is supported.
@@ -474,6 +488,11 @@ TEST(LlvmLibcSharedMathTest, AllLongDouble) {
   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));
+  EXPECT_FP_EQ(0x0p+0L, LIBC_NAMESPACE::shared::remainderl(1.0L, 1.0L));
+  int remquol_exp = 0;
+  EXPECT_FP_EQ(0x0p+0L,
+               LIBC_NAMESPACE::shared::remquol(1.0L, 1.0L, &remquol_exp));
+  EXPECT_EQ(1, remquol_exp);
 }
 
 #endif // LIBC_TYPES_LONG_DOUBLE_IS_DOUBLE_DOUBLE
@@ -621,6 +640,13 @@ TEST(LlvmLibcSharedMathTest, AllFloat128) {
                                   float128(0.0), float128(0.0)));
   EXPECT_FP_EQ(float128(0.0), LIBC_NAMESPACE::shared::fminimum_mag_numf128(
                                   float128(0.0), float128(0.0)));
+  EXPECT_FP_EQ(float128(0.0), LIBC_NAMESPACE::shared::remainderf128(
+                                  float128(1.0), float128(1.0)));
+  int remquof128_exp = 0;
+  EXPECT_FP_EQ(float128(0.0),
+               LIBC_NAMESPACE::shared::remquof128(float128(1.0), float128(1.0),
+                                                  &remquof128_exp));
+  EXPECT_EQ(1, remquof128_exp);
 }
 
 #endif // LIBC_TYPES_HAS_FLOAT128
@@ -729,4 +755,11 @@ TEST(LlvmLibcSharedMathTest, AllBFloat16) {
   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)));
+  EXPECT_FP_EQ(bfloat16(0.0), LIBC_NAMESPACE::shared::remainderbf16(
+                                  bfloat16(1.0), bfloat16(1.0)));
+  int remquobf16_exp = 0;
+  EXPECT_FP_EQ(bfloat16(0.0),
+               LIBC_NAMESPACE::shared::remquobf16(bfloat16(1.0), bfloat16(1.0),
+                                                  &remquobf16_exp));
+  EXPECT_EQ(1, remquobf16_exp);
 }
diff --git a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
index 0297f432942db..f4dc6d7e2e8db 100644
--- a/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
+++ b/utils/bazel/llvm-project-overlay/libc/BUILD.bazel
@@ -4800,6 +4800,120 @@ libc_support_library(
     ],
 )
 
+libc_support_library(
+    name = "__support_math_remainder",
+    hdrs = ["src/__support/math/remainder.h"],
+    deps = [
+        ":__support_fputil_division_and_remainder_operations",
+        ":__support_macros_config",
+    ],
+)
+
+libc_support_library(
+    name = "__support_math_remainderbf16",
+    hdrs = ["src/__support/math/remainderbf16.h"],
+    deps = [
+        ":__support_fputil_bfloat16",
+        ":__support_fputil_division_and_remainder_operations",
+        ":__support_macros_config",
+    ],
+)
+
+libc_support_library(
+    name = "__support_math_remainderf",
+    hdrs = ["src/__support/math/remainderf.h"],
+    deps = [
+        ":__support_fputil_division_and_remainder_operations",
+        ":__support_macros_config",
+    ],
+)
+
+libc_support_library(
+    name = "__support_math_remainderf128",
+    hdrs = ["src/__support/math/remainderf128.h"],
+    deps = [
+        ":__support_fputil_division_and_remainder_operations",
+        ":__support_macros_config",
+        ":llvm_libc_types_float128",
+    ],
+)
+
+libc_support_library(
+    name = "__support_math_remainderf16",
+    hdrs = ["src/__support/math/remainderf16.h"],
+    deps = [
+        ":__support_fputil_division_and_remainder_operations",
+        ":__support_macros_config",
+        ":llvm_libc_macros_float16_macros",
+    ],
+)
+
+libc_support_library(
+    name = "__support_math_remainderl",
+    hdrs = ["src/__support/math/remainderl.h"],
+    deps = [
+        ":__support_fputil_division_and_remainder_operations",
+        ":__support_macros_config",
+    ],
+)
+
+libc_support_library(
+    name = "__support_math_remquo",
+    hdrs = ["src/__support/math/remquo.h"],
+    deps = [
+        ":__support_fputil_division_and_remainder_operations",
+        ":__support_macros_config",
+    ],
+)
+
+libc_support_library(
+    name = "__support_math_remquobf16",
+    hdrs = ["src/__support/math/remquobf16.h"],
+    deps = [
+        ":__support_fputil_bfloat16",
+        ":__support_fputil_division_and_remainder_operations",
+        ":__support_macros_config",
+    ],
+)
+
+libc_support_library(
+    name = "__support_math_remquof",
+    hdrs = ["src/__support/math/remquof.h"],
+    deps = [
+        ":__support_fputil_division_and_remainder_operations",
+        ":__support_macros_config",
+    ],
+)
+
+libc_support_library(
+    name = "__support_math_remquof128",
+    hdrs = ["src/__support/math/remquof128.h"],
+    deps = [
+        ":__support_fputil_division_and_remainder_operations",
+        ":__support_macros_config",
+        ":llvm_libc_types_float128",
+    ],
+)
+
+libc_support_library(
+    name = "__support_math_remquof16",
+    hdrs = ["src/__support/math/remquof16.h"],
+    deps = [
+        ":__support_fputil_division_and_remainder_operations",
+        ":__support_macros_config",
+        ":llvm_libc_macros_float16_macros",
+    ],
+)
+
+libc_support_library(
+    name = "__support_math_remquol",
+    hdrs = ["src/__support/math/remquol.h"],
+    deps = [
+        ":__support_fputil_division_and_remainder_operations",
+        ":__support_macros_config",
+    ],
+)
+
 libc_support_library(
     name = "__support_math_llogbbf16",
     hdrs = ["src/__support/math/llogbbf16.h"],
@@ -10280,32 +10394,88 @@ libc_math_function(
     ],
 )
 
-libc_math_function(name = "remainder")
+libc_math_function(
+    name = "remainder",
+    additional_deps = [
+        ":__support_math_remainder",
+    ],
+)
 
-libc_math_function(name = "remainderf")
+libc_math_function(
+    name = "remainderbf16",
+    additional_deps = [
+        ":__support_math_remainderbf16",
+    ],
+)
+
+libc_math_function(
+    name = "remainderf",
+    additional_deps = [
+        ":__support_math_remainderf",
+    ],
+)
 
-libc_math_function(name = "remainderl")
+libc_math_function(
+    name = "remainderl",
+    additional_deps = [
+        ":__support_math_remainderl",
+    ],
+)
 
 libc_math_function(
     name = "remainderf128",
+    additional_deps = [
+        ":__support_math_remainderf128",
+    ],
 )
 
 libc_math_function(
     name = "remainderf16",
+    additional_deps = [
+        ":__support_math_remainderf16",
+    ],
 )
 
-libc_math_function(name = "remquo")
+libc_math_function(
+    name = "remquo",
+    additional_deps = [
+        ":__support_math_remquo",
+    ],
+)
+
+libc_math_function(
+    name = "remquobf16",
+    additional_deps = [
+        ":__support_math_remquobf16",
+    ],
+)
 
-libc_math_function(name = "remquof")
+libc_math_function(
+    name = "remquof",
+    additional_deps = [
+        ":__support_math_remquof",
+    ],
+)
 
-libc_math_function(name = "remquol")
+libc_math_function(
+    name = "remquol",
+    additional_deps = [
+        ":__support_math_remquol",
+    ],
+)
 
 libc_math_function(
     name = "remquof128",
+    additional_deps = [
+        ":__support_math_remquof128",
+    ],
 )
 
 libc_math_function(
     name = "remquof16",
+    additional_deps = [
+        ":__support_math_remquof16",
+    ],
 )
 
 libc_math_function(name = "rint")



More information about the libc-commits mailing list