[libc-commits] [libc] [libc] Float128 Emulation in LLVM libc (PR #200565)

via libc-commits libc-commits at lists.llvm.org
Tue Jun 2 12:02:55 PDT 2026


================
@@ -0,0 +1,65 @@
+//===-- 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 "src/__support/CPP/bit.h"
+#include "src/__support/CPP/type_traits.h"
+#include "src/__support/FPUtil/comparison_operations.h"
+#include "src/__support/macros/attributes.h"
+#include "src/__support/macros/config.h"
+#include "src/__support/uint128.h"
+#include <stdint.h>
+
+namespace LIBC_NAMESPACE_DECL {
+namespace fputil {
+
+struct Float128 {
+  UInt128 bits;
+
+  LIBC_INLINE constexpr Float128() = default;
+
+  LIBC_INLINE constexpr explicit Float128(double x) : bits(0) {
+    uint64_t x_bits = cpp::bit_cast<uint64_t>(x);
+    bits = static_cast<UInt128>(x_bits) << 64U;
+  }
+
+  LIBC_INLINE constexpr explicit operator double() const {
+    return cpp::bit_cast<double>(static_cast<uint64_t>(bits >> 64U));
+  }
----------------
Sukumarsawant wrote:

Only this part uses bit_cast in my code which is exact similar to bfloat16 . 
If the problem would have been related to this then just changing the name from float128 to EFloat128 shouldn't have pass CI, should it ?

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


More information about the libc-commits mailing list