[libc-commits] [libc] [libc] Make `ceilf128` use the emulated float128 type (PR #206450)

via libc-commits libc-commits at lists.llvm.org
Mon Jul 6 04:30:23 PDT 2026


llvmorg-github-actions[bot] wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-libc

Author: Zorojuro (Sukumarsawant)

<details>
<summary>Changes</summary>

This tests the emulated float128 type using `ceilf128`
This PR is stacked on #<!-- -->200565

---

Patch is 38.10 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/206450.diff


29 Files Affected:

- (modified) libc/shared/math/ceilf128.h (+3-6) 
- (modified) libc/src/__support/CPP/type_traits/is_floating_point.h (+6-1) 
- (modified) libc/src/__support/FPUtil/CMakeLists.txt (+18) 
- (modified) libc/src/__support/FPUtil/FPBits.h (+2) 
- (modified) libc/src/__support/FPUtil/cast.h (+3-1) 
- (modified) libc/src/__support/FPUtil/dyadic_float.h (+1-1) 
- (added) libc/src/__support/FPUtil/float128.h (+153) 
- (modified) libc/src/__support/FPUtil/generic/add_sub.h (+2-2) 
- (modified) libc/src/__support/big_int.h (+22-44) 
- (modified) libc/src/__support/macros/properties/types.h (+11) 
- (modified) libc/src/__support/math/CMakeLists.txt (+1-1) 
- (modified) libc/src/__support/math/ceilf128.h (+4-7) 
- (modified) libc/src/math/ceilf128.h (+4-1) 
- (modified) libc/src/math/generic/CMakeLists.txt (+1) 
- (modified) libc/src/math/generic/ceilf128.cpp (+4-1) 
- (modified) libc/test/shared/CMakeLists.txt (+2) 
- (modified) libc/test/shared/shared_math_constexpr_test.cpp (+7-1) 
- (modified) libc/test/shared/shared_math_test.cpp (+10-1) 
- (modified) libc/test/src/__support/FPUtil/CMakeLists.txt (+11) 
- (added) libc/test/src/__support/FPUtil/float128_test.cpp (+91) 
- (modified) libc/test/src/__support/integer_literals_test.cpp (+1-1) 
- (modified) libc/test/src/math/CMakeLists.txt (+1) 
- (modified) libc/test/src/math/ceilf128_test.cpp (+4-1) 
- (modified) libc/test/src/math/smoke/CMakeLists.txt (+1) 
- (modified) libc/test/src/math/smoke/ceilf128_test.cpp (+4-1) 
- (modified) libc/utils/MPFRWrapper/CMakeLists.txt (+2) 
- (modified) libc/utils/MPFRWrapper/MPCommon.cpp (+7) 
- (modified) libc/utils/MPFRWrapper/MPCommon.h (+25-2) 
- (modified) libc/utils/MPFRWrapper/MPFRUtils.cpp (+13) 


``````````diff
diff --git a/libc/shared/math/ceilf128.h b/libc/shared/math/ceilf128.h
index b9e6655393e14..d7fe00fe86a3e 100644
--- a/libc/shared/math/ceilf128.h
+++ b/libc/shared/math/ceilf128.h
@@ -9,13 +9,12 @@
 #ifndef LLVM_LIBC_SHARED_MATH_CEILF128_H
 #define LLVM_LIBC_SHARED_MATH_CEILF128_H
 
-#include "include/llvm-libc-types/float128.h"
-
-#ifdef LIBC_TYPES_HAS_FLOAT128
-
 #include "shared/libc_common.h"
+#include "src/__support/FPUtil/float128.h"
 #include "src/__support/math/ceilf128.h"
 
+using LIBC_NAMESPACE::fputil::Float128;
+
 namespace LIBC_NAMESPACE_DECL {
 namespace shared {
 
@@ -24,6 +23,4 @@ using math::ceilf128;
 } // namespace shared
 } // namespace LIBC_NAMESPACE_DECL
 
-#endif // LIBC_TYPES_HAS_FLOAT128
-
 #endif // LLVM_LIBC_SHARED_MATH_CEILF128_H
diff --git a/libc/src/__support/CPP/type_traits/is_floating_point.h b/libc/src/__support/CPP/type_traits/is_floating_point.h
index 9dc77ad7ee0ea..b7fa71bde2f93 100644
--- a/libc/src/__support/CPP/type_traits/is_floating_point.h
+++ b/libc/src/__support/CPP/type_traits/is_floating_point.h
@@ -37,7 +37,12 @@ template <typename T> struct is_floating_point {
                               float128
 #endif
                               ,
-                              bfloat16>();
+                              bfloat16
+
+                              ,
+                              // TODO: Replace as float128 once the alias is
+                              // fixed
+                              fputil::Float128>();
 };
 template <typename T>
 LIBC_INLINE_VAR constexpr bool is_floating_point_v =
diff --git a/libc/src/__support/FPUtil/CMakeLists.txt b/libc/src/__support/FPUtil/CMakeLists.txt
index d45dd82560788..8b6ac8027b52d 100644
--- a/libc/src/__support/FPUtil/CMakeLists.txt
+++ b/libc/src/__support/FPUtil/CMakeLists.txt
@@ -294,4 +294,22 @@ add_header_library(
     libc.src.__support.macros.properties.types
 )
 
+add_header_library(
+  float128
+  HDRS
+    float128.h
+  DEPENDS
+    .cast
+    .comparison_operations
+    .dyadic_float
+    libc.hdr.stdint_proxy
+    libc.src.__support.CPP.type_traits
+    libc.src.__support.FPUtil.generic.add_sub
+    libc.src.__support.FPUtil.generic.div
+    libc.src.__support.FPUtil.generic.mul
+    libc.src.__support.macros.attributes
+    libc.src.__support.macros.config
+    libc.src.__support.uint128
+)
+
 add_subdirectory(generic)
diff --git a/libc/src/__support/FPUtil/FPBits.h b/libc/src/__support/FPUtil/FPBits.h
index c52699e17e225..83219b7573f46 100644
--- a/libc/src/__support/FPUtil/FPBits.h
+++ b/libc/src/__support/FPUtil/FPBits.h
@@ -813,6 +813,8 @@ template <typename T> LIBC_INLINE static constexpr FPType get_fp_type() {
 #endif
   else if constexpr (cpp::is_same_v<UnqualT, bfloat16>)
     return FPType::BFloat16;
+  else if constexpr (cpp::is_same_v<UnqualT, Float128>)
+    return FPType::IEEE754_Binary128;
   else
     static_assert(cpp::always_false<UnqualT>, "Unsupported type");
 }
diff --git a/libc/src/__support/FPUtil/cast.h b/libc/src/__support/FPUtil/cast.h
index 54c80e862523a..4fc5ea0893ebe 100644
--- a/libc/src/__support/FPUtil/cast.h
+++ b/libc/src/__support/FPUtil/cast.h
@@ -31,7 +31,9 @@ cast(InType x) {
     return x;
   } else {
     if constexpr (cpp::is_same_v<OutType, bfloat16> ||
-                  cpp::is_same_v<InType, bfloat16>
+                  cpp::is_same_v<InType, bfloat16> ||
+                  cpp::is_same_v<OutType, Float128> ||
+                  cpp::is_same_v<InType, Float128>
 #if defined(LIBC_TYPES_HAS_FLOAT16) && !defined(__LIBC_USE_FLOAT16_CONVERSION)
                   || cpp::is_same_v<OutType, float16> ||
                   cpp::is_same_v<InType, float16>
diff --git a/libc/src/__support/FPUtil/dyadic_float.h b/libc/src/__support/FPUtil/dyadic_float.h
index f1ac39e97c52b..c218632131934 100644
--- a/libc/src/__support/FPUtil/dyadic_float.h
+++ b/libc/src/__support/FPUtil/dyadic_float.h
@@ -438,7 +438,7 @@ template <size_t Bits> struct DyadicFloat {
                                             (FPBits<T>::FRACTION_LEN < Bits),
                                         void>>
   LIBC_INLINE LIBC_CONSTEXPR_DEFAULT T as() const {
-    if constexpr (cpp::is_same_v<T, bfloat16>
+    if constexpr (cpp::is_same_v<T, bfloat16> || cpp::is_same_v<T, Float128>
 #if defined(LIBC_TYPES_HAS_FLOAT16) && !defined(__LIBC_USE_FLOAT16_CONVERSION)
                   || cpp::is_same_v<T, float16>
 #endif
diff --git a/libc/src/__support/FPUtil/float128.h b/libc/src/__support/FPUtil/float128.h
new file mode 100644
index 0000000000000..661dfe808f8b2
--- /dev/null
+++ b/libc/src/__support/FPUtil/float128.h
@@ -0,0 +1,153 @@
+//===-- Definition for Float128 data type -----------------------*- 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_FPUTIL_FLOAT128_H
+#define LLVM_LIBC_SRC___SUPPORT_FPUTIL_FLOAT128_H
+
+#include "hdr/stdint_proxy.h"
+#include "src/__support/CPP/type_traits.h"
+#include "src/__support/FPUtil/cast.h"
+#include "src/__support/FPUtil/comparison_operations.h"
+#include "src/__support/FPUtil/dyadic_float.h"
+#include "src/__support/FPUtil/generic/add_sub.h"
+#include "src/__support/FPUtil/generic/div.h"
+#include "src/__support/FPUtil/generic/mul.h"
+#include "src/__support/macros/attributes.h"
+#include "src/__support/macros/config.h"
+#include "src/__support/uint128.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace fputil {
+
+struct Float128 {
+  UInt128 bits;
+
+  LIBC_INLINE Float128() = default;
+  LIBC_INLINE constexpr Float128(const Float128 &) = default;
+  LIBC_INLINE constexpr Float128(Float128 &&) = default;
+  LIBC_INLINE constexpr Float128 &operator=(const Float128 &) = default;
+  LIBC_INLINE constexpr Float128 &operator=(Float128 &&) = default;
+
+  // Floating point type and integer type
+  template <typename T>
+  LIBC_INLINE constexpr explicit Float128(T value)
+      : bits(static_cast<UInt128>(0U)) {
+    if constexpr (cpp::is_floating_point_v<T>) {
+      bits = fputil::cast<Float128>(value).bits;
+    } else if constexpr (cpp::is_integral_v<T>) {
+      Sign sign = Sign::POS;
+
+      if constexpr (cpp::is_signed_v<T>) {
+        if (value < 0) {
+          sign = Sign::NEG;
+          value = -value;
+        }
+      }
+
+      fputil::DyadicFloat<FPBits<Float128>::STORAGE_LEN> xd(sign, 0, value);
+      bits = xd.template as<Float128, /*ShouldSignalExceptions=*/true>().bits;
+
+    } else if constexpr (cpp::is_convertible_v<T, Float128>) {
+      bits = value.operator Float128().bits;
+    } else {
+      bits = fputil::cast<Float128>(static_cast<float>(value)).bits;
+    }
+  }
+
+  template <typename T, cpp::enable_if_t<cpp::is_floating_point_v<T> &&
+                                             !cpp::is_same_v<T, Float128>,
+                                         int> = 0>
+  LIBC_INLINE LIBC_CONSTEXPR_DEFAULT operator T() const {
+    return fputil::cast<T>(*this);
+  }
+
+  template <typename T, cpp::enable_if_t<cpp::is_integral_v<T>, int> = 0>
+  LIBC_INLINE constexpr explicit operator T() const {
+    FPBits<Float128> x_bits(*this);
+    int x_bits_exp =
+        x_bits.get_explicit_exponent() - FPBits<Float128>::FRACTION_LEN;
+    // sign * mantissa * 2(exp-bias)
+    DyadicFloat<FPBits<Float128>::STORAGE_LEN> xd(
+        x_bits.sign(), x_bits_exp, x_bits.get_explicit_mantissa());
+    return static_cast<T>(xd.as_mantissa_type());
+  }
+
+  // unary
+  LIBC_INLINE LIBC_BIT_CAST_CONSTEXPR Float128 operator-() const {
+    fputil::FPBits<Float128> result(*this);
+    result.set_sign(result.is_pos() ? Sign::NEG : Sign::POS);
+    return result.get_val();
+  }
+  // operator overloads
+  LIBC_INLINE constexpr Float128 operator+(const Float128 &other) const {
+    return fputil::generic::add<Float128>(*this, other);
+  }
+
+  LIBC_INLINE constexpr Float128 operator-(const Float128 &other) const {
+    return fputil::generic::sub<Float128>(*this, other);
+  }
+
+  LIBC_INLINE constexpr Float128 operator*(const Float128 &other) const {
+    return fputil::generic::mul<Float128>(*this, other);
+  }
+
+  LIBC_INLINE constexpr Float128 operator/(const Float128 &other) const {
+    return fputil::generic::div<Float128>(*this, other);
+  }
+
+  LIBC_INLINE constexpr bool operator==(const Float128 &other) const {
+    return fputil::equals(*this, other);
+  }
+
+  LIBC_INLINE constexpr bool operator!=(const Float128 &other) const {
+    return !fputil::equals(*this, other);
+  }
+
+  LIBC_INLINE constexpr bool operator<(const Float128 &other) const {
+    return fputil::less_than(*this, other);
+  }
+
+  LIBC_INLINE constexpr bool operator<=(const Float128 &other) const {
+    return fputil::less_than_or_equals(*this, other);
+  }
+
+  LIBC_INLINE constexpr bool operator>(const Float128 &other) const {
+    return fputil::greater_than(*this, other);
+  }
+
+  LIBC_INLINE constexpr bool operator>=(const Float128 &other) const {
+    return fputil::greater_than_or_equals(*this, other);
+  }
+
+  LIBC_INLINE constexpr Float128 &operator*=(const Float128 &other) {
+    *this = *this * other;
+    return *this;
+  }
+  LIBC_INLINE constexpr Float128 &operator+=(const Float128 &other) {
+    *this = *this + other;
+    return *this;
+  }
+  LIBC_INLINE constexpr Float128 &operator-=(const Float128 &other) {
+    *this = *this - other;
+    return *this;
+  }
+  LIBC_INLINE constexpr Float128 &operator/=(const Float128 &other) {
+    *this = *this / other;
+    return *this;
+  }
+};
+
+static_assert(LIBC_NAMESPACE::cpp::is_trivially_constructible<
+              LIBC_NAMESPACE::fputil::Float128>::value);
+static_assert(LIBC_NAMESPACE::cpp::is_trivially_copyable<
+              LIBC_NAMESPACE::fputil::Float128>::value);
+
+} // namespace fputil
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC___SUPPORT_FPUTIL_FLOAT128_H
diff --git a/libc/src/__support/FPUtil/generic/add_sub.h b/libc/src/__support/FPUtil/generic/add_sub.h
index cf662d051c162..71e50daa9a996 100644
--- a/libc/src/__support/FPUtil/generic/add_sub.h
+++ b/libc/src/__support/FPUtil/generic/add_sub.h
@@ -110,8 +110,7 @@ add_or_sub(InType x, InType y) {
 #endif // LIBC_MATH_HAS_ASSUME_ROUND_NEAREST_ONLY
       }
 
-      if constexpr (cpp::is_same_v<InType, bfloat16> &&
-                    cpp::is_same_v<OutType, bfloat16>) {
+      if constexpr (cpp::is_same_v<InType, OutType>) {
         OutFPBits out_y_bits(y);
         if constexpr (IsSub)
           out_y_bits.set_sign(out_y_bits.sign().negate());
@@ -126,6 +125,7 @@ add_or_sub(InType x, InType y) {
         // rounding.
         volatile InType tmp = y;
 #endif // LIBC_USE_CONSTEXPR
+
         if constexpr (IsSub)
           tmp = -tmp;
         return cast<OutType>(tmp);
diff --git a/libc/src/__support/big_int.h b/libc/src/__support/big_int.h
index 0e5c038ec356e..653b817e3dee7 100644
--- a/libc/src/__support/big_int.h
+++ b/libc/src/__support/big_int.h
@@ -339,8 +339,8 @@ struct BigInt {
                 "WordType must be unsigned integer.");
 
   struct Division {
-    BigInt quotient;
-    BigInt remainder;
+    BigInt quotient{};
+    BigInt remainder{};
   };
 
 public:
@@ -358,7 +358,7 @@ struct BigInt {
 
   LIBC_INLINE_VAR static constexpr size_t WORD_COUNT = Bits / WORD_SIZE;
 
-  cpp::array<WordType, WORD_COUNT> val{}; // zero initialized.
+  cpp::array<WordType, WORD_COUNT> val;
 
   LIBC_INLINE constexpr BigInt() = default;
 
@@ -366,7 +366,8 @@ struct BigInt {
 
   template <size_t OtherBits, bool OtherSigned, typename OtherWordType>
   LIBC_INLINE constexpr BigInt(
-      const BigInt<OtherBits, OtherSigned, OtherWordType> &other) {
+      const BigInt<OtherBits, OtherSigned, OtherWordType> &other)
+      : val{} {
     using BigIntOther = BigInt<OtherBits, OtherSigned, OtherWordType>;
     [[maybe_unused]] const bool should_sign_extend = Signed && other.is_neg();
 
@@ -456,20 +457,22 @@ struct BigInt {
   }
 
   // Construct a BigInt from a C array.
-  template <size_t N> LIBC_INLINE constexpr BigInt(const WordType (&nums)[N]) {
+  template <size_t N>
+  LIBC_INLINE constexpr BigInt(const WordType (&nums)[N]) : val{} {
     static_assert(N == WORD_COUNT);
     for (size_t i = 0; i < WORD_COUNT; ++i)
       val[i] = nums[i];
   }
 
   LIBC_INLINE constexpr explicit BigInt(
-      const cpp::array<WordType, WORD_COUNT> &words) {
+      const cpp::array<WordType, WORD_COUNT> &words)
+      : val{} {
     val = words;
   }
 
   // Initialize the first word to |v| and the rest to 0.
   template <typename T, typename = cpp::enable_if_t<cpp::is_integral_v<T>>>
-  LIBC_INLINE constexpr BigInt(T v) {
+  LIBC_INLINE constexpr BigInt(T v) : val{} {
     constexpr size_t T_SIZE = sizeof(T) * CHAR_BIT;
     const bool is_neg = v < 0;
     for (size_t i = 0; i < WORD_COUNT; ++i) {
@@ -491,7 +494,7 @@ struct BigInt {
   LIBC_INLINE static constexpr BigInt one() { return BigInt(1); }
   LIBC_INLINE static constexpr BigInt all_ones() { return ~zero(); }
   LIBC_INLINE static constexpr BigInt min() {
-    BigInt out;
+    BigInt out{};
     if constexpr (SIGNED)
       out.set_msb();
     return out;
@@ -604,7 +607,7 @@ struct BigInt {
   template <size_t OtherBits>
   LIBC_INLINE constexpr auto
   ful_mul(const BigInt<OtherBits, Signed, WordType> &other) const {
-    BigInt<Bits + OtherBits, Signed, WordType> result;
+    BigInt<Bits + OtherBits, Signed, WordType> result{};
     multiword::multiply_with_carry(result.val, val, other.val);
     return result;
   }
@@ -636,7 +639,7 @@ struct BigInt {
   //    256      4        16          10            3
   //    512      8        64          36            7
   LIBC_INLINE constexpr BigInt quick_mul_hi(const BigInt &other) const {
-    BigInt result;
+    BigInt result{};
     multiword::quick_mul_hi(result.val, val, other.val);
     return result;
   }
@@ -689,7 +692,7 @@ struct BigInt {
   //   And finally we perform some extra alignment steps for the remaining bits.
   LIBC_INLINE constexpr cpp::optional<BigInt>
   div_uint_half_times_pow_2(multiword::half_width_t<WordType> x, size_t e) {
-    BigInt remainder;
+    BigInt remainder{};
     if (x == 0)
       return cpp::nullopt;
     if (e >= Bits) {
@@ -697,7 +700,7 @@ struct BigInt {
       *this = BigInt<Bits, false, WordType>();
       return remainder;
     }
-    BigInt quotient;
+    BigInt quotient{};
     WordType x_word = static_cast<WordType>(x);
     constexpr size_t LOG2_WORD_SIZE =
         static_cast<size_t>(cpp::bit_width(WORD_SIZE) - 1);
@@ -849,13 +852,13 @@ struct BigInt {
 #define DEFINE_BINOP(OP)                                                       \
   LIBC_INLINE friend constexpr BigInt operator OP(const BigInt &lhs,           \
                                                   const BigInt &rhs) {         \
-    BigInt result;                                                             \
+    BigInt result{};                                                           \
     for (size_t i = 0; i < WORD_COUNT; ++i)                                    \
       result[i] = lhs[i] OP rhs[i];                                            \
     return result;                                                             \
   }                                                                            \
-  LIBC_INLINE friend constexpr BigInt operator OP##=(BigInt &lhs,              \
-                                                     const BigInt &rhs) {      \
+  LIBC_INLINE friend constexpr BigInt operator OP## =                          \
+      (BigInt & lhs, const BigInt &rhs) {                                      \
     for (size_t i = 0; i < WORD_COUNT; ++i)                                    \
       lhs[i] OP## = rhs[i];                                                    \
     return lhs;                                                                \
@@ -867,7 +870,7 @@ struct BigInt {
 #undef DEFINE_BINOP
 
   LIBC_INLINE constexpr BigInt operator~() const {
-    BigInt result;
+    BigInt result{};
     for (size_t i = 0; i < WORD_COUNT; ++i)
       result[i] = static_cast<WordType>(~val[i]);
     return result;
@@ -1007,7 +1010,7 @@ struct BigInt {
   LIBC_INLINE constexpr static Division divide_unsigned(const BigInt &dividend,
                                                         const BigInt &divider) {
     BigInt remainder = dividend;
-    BigInt quotient;
+    BigInt quotient{};
     if (remainder >= divider) {
       BigInt subtractor = divider;
       int cur_bit = multiword::countl_zero(subtractor.val) -
@@ -1184,31 +1187,6 @@ LIBC_INLINE_VAR constexpr bool is_unsigned_integral_or_big_int_v =
 
 namespace cpp {
 
-// Specialization of cpp::bit_cast ('bit.h') from T to BigInt.
-template <typename To, typename From>
-LIBC_INLINE LIBC_BIT_CAST_CONSTEXPR cpp::enable_if_t<
-    (sizeof(To) == sizeof(From)) && cpp::is_trivially_copyable<To>::value &&
-        cpp::is_trivially_copyable<From>::value && is_big_int<To>::value,
-    To>
-bit_cast(const From &from) {
-  To out;
-  using Storage = decltype(out.val);
-  out.val = cpp::bit_cast<Storage>(from);
-  return out;
-}
-
-// Specialization of cpp::bit_cast ('bit.h') from BigInt to T.
-template <typename To, size_t Bits>
-LIBC_INLINE LIBC_BIT_CAST_CONSTEXPR
-    cpp::enable_if_t<sizeof(To) == sizeof(UInt<Bits>) &&
-                         cpp::is_trivially_constructible<To>::value &&
-                         cpp::is_trivially_copyable<To>::value &&
-                         cpp::is_trivially_copyable<UInt<Bits>>::value,
-                     To>
-    bit_cast(const UInt<Bits> &from) {
-  return cpp::bit_cast<To>(from.val);
-}
-
 // Specialization of cpp::popcount ('bit.h') for BigInt.
 template <typename T>
 [[nodiscard]] LIBC_INLINE constexpr cpp::enable_if_t<is_big_int_v<T>, int>
@@ -1314,7 +1292,7 @@ mask_trailing_ones() {
     return T::all_ones();
   constexpr size_t QUOTIENT = count / T::WORD_SIZE;
   constexpr size_t REMAINDER = count % T::WORD_SIZE;
-  T out; // zero initialized
+  T out{};
   for (size_t i = 0; i <= QUOTIENT; ++i)
     out[i] = i < QUOTIENT
                  ? cpp::numeric_limits<typename T::word_type>::max()
@@ -1330,7 +1308,7 @@ LIBC_INLINE constexpr cpp::enable_if_t<is_big_int_v<T>, T> mask_leading_ones() {
     return T::all_ones();
   constexpr size_t QUOTIENT = (T::BITS - count - 1U) / T::WORD_SIZE;
   constexpr size_t REMAINDER = count % T::WORD_SIZE;
-  T out; // zero initialized
+  T out{};
   for (size_t i = QUOTIENT; i < T::WORD_COUNT; ++i)
     out[i] = i > QUOTIENT
                  ? cpp::numeric_limits<typename T::word_type>::max()
diff --git a/libc/src/__support/macros/properties/types.h b/libc/src/__support/macros/properties/types.h
index 3259c8a6a1d12..7b861640c785d 100644
--- a/libc/src/__support/macros/properties/types.h
+++ b/libc/src/__support/macros/properties/types.h
@@ -58,6 +58,17 @@ using float16 = _Float16;
 // LIBC_TYPES_HAS_FLOAT128 and 'float128' type are provided by
 // "include/llvm-libc-types/float128.h"
 
+// -- Emulated float128 support ------------------------------------------------
+// Float128 is always available regardless of native __float128 support.
+namespace LIBC_NAMESPACE_DECL {
+namespace fputil {
+struct Float128;
+}
+} // namespace LIBC_NAMESPACE_DECL
+
+// #ifndef LIBC_TYPES_HAS_FLOAT128
+// using float128 = LIBC_NAMESPACE::fputil::Float128;
+// #endif // LIBC_TYPES_HAS_FLOAT128
 // -- bfloat16 support ---------------------------------------------------------
 
 namespace LIBC_NAMESPACE_DECL {
diff --git a/libc/src/__support/math/CMakeLists.txt b/libc/src/__support/math/CMakeLists.txt
index deafc85b487a6..a2699355a18e8 100644
--- a/libc/src/__support/math/CMakeLists.txt
+++ b/libc/src/__support/math/CMakeLists.txt
@@ -813,7 +813,7 @@ add_header_library(
   HDRS
     ceilf128.h
   DEPENDS
-    libc.include.llvm-libc-types.float128
+    libc.src.__support.FPUtil.float128
     libc.src.__support.FPUtil.nearest_integer_operations
     libc.src.__support.macros.config
 )
diff --git a/libc/src/__support/math/ceilf128.h b/libc/src/__support/math/ceilf128.h
index 8877594d58d68..31b3debb890da 100644
--- a/libc/src/__support/math/ceilf128.h
+++ b/libc/src/__support/math/ceilf128.h
@@ -9,21 +9,18 @@
 #ifndef LLVM_LIBC_SRC___SUPPORT_MATH_CEILF128_H
 #define LLVM_L...
[truncated]

``````````

</details>


https://github.com/llvm/llvm-project/pull/206450


More information about the libc-commits mailing list