[libc-commits] [libc] test: float128 skeleton (PR #200565)

via libc-commits libc-commits at lists.llvm.org
Sat May 30 04:19:58 PDT 2026


llvmorg-github-actions[bot] wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-libc

Author: Zorojuro (Sukumarsawant)

<details>
<summary>Changes</summary>

PR for introducing float128 in LLVM libc ( Draft )

---
Full diff: https://github.com/llvm/llvm-project/pull/200565.diff


2 Files Affected:

- (modified) libc/src/__support/FPUtil/CMakeLists.txt (+11) 
- (added) libc/src/__support/FPUtil/float128.h (+45) 


``````````diff
diff --git a/libc/src/__support/FPUtil/CMakeLists.txt b/libc/src/__support/FPUtil/CMakeLists.txt
index d45dd82560788..a88986b4992f8 100644
--- a/libc/src/__support/FPUtil/CMakeLists.txt
+++ b/libc/src/__support/FPUtil/CMakeLists.txt
@@ -294,4 +294,15 @@ add_header_library(
     libc.src.__support.macros.properties.types
 )
 
+add_header_library(
+  float128
+  HDRS
+    float128.h
+  DEPENDS
+    .fp_bits
+    libc.hdr.fenv_macros
+    libc.src.__support.CPP.bit
+    libc.src.__support.uint128
+)
+
 add_subdirectory(generic)
diff --git a/libc/src/__support/FPUtil/float128.h b/libc/src/__support/FPUtil/float128.h
new file mode 100644
index 0000000000000..73f450f1d41a8
--- /dev/null
+++ b/libc/src/__support/FPUtil/float128.h
@@ -0,0 +1,45 @@
+//===-- Utilities 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 "FPBits.h"
+#include "hdr/fenv_macros.h"
+#include "src/__support/CPP/bit.h"
+#include "src/__support/uint128.h"
+
+namespace LIBC_NAMESPACE_DECL {
+namespace fputil {
+
+struct Float128 {
+  UInt128 bits;
+  // Testing
+  constexpr Float128() = default;
+  /* TODO: precision
+     TODO: explicit so it does not convert without warn ( Done )
+     VERIFY :   template <cpp::enable_if_t<fputil::get_fp_type<Double>() ==
+                                 fputil::FPType::IEEE754_Binary64,
+                             int> = 0>
+  */
+  constexpr explicit Float128(double x) {
+    FPBits<double> x_bits(x);
+    uint64_t val = x_bits.uintval();
+    bits = static_cast<UInt128>(val) << 64;
+  }
+
+  constexpr explicit operator double() const {
+    uint64_t val = static_cast<uint64_t>(bits >> 64U);
+    return cpp::bit_cast<double>(val);
+  }
+};
+
+} // namespace fputil
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC___SUPPORT_FPUTIL_FLOAT128_H

``````````

</details>


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


More information about the libc-commits mailing list