[libc-commits] [libc] [libc] Stub handling for the PPC double double type (PR #136614)
Joseph Huber via libc-commits
libc-commits at lists.llvm.org
Mon Apr 21 14:12:32 PDT 2025
https://github.com/jhuber6 created https://github.com/llvm/llvm-project/pull/136614
Summary:
We use the storage class for `long double` in the printing
implementations. We don't fully support the PPC double double type,
which that maps to, but we can stub out just the support needed for the
print interface to works. This required using the internal interface for
storage type, but it should be good enough.
Fixes: https://github.com/llvm/llvm-project/issues/136596
>From b28f0d35ae65f8117bb99b7f268a363d4790366f Mon Sep 17 00:00:00 2001
From: Joseph Huber <huberjn at outlook.com>
Date: Mon, 21 Apr 2025 16:10:00 -0500
Subject: [PATCH] [libc] Stub handling for the PPC double double type
Summary:
We use the storage class for `long double` in the printing
implementations. We don't fully support the PPC double double type,
which that maps to, but we can stub out just the support needed for the
print interface to works. This required using the internal interface for
storage type, but it should be good enough.
Fixes: https://github.com/llvm/llvm-project/issues/136596
---
libc/src/__support/FPUtil/FPBits.h | 12 ++++++++++++
libc/src/stdio/printf_core/core_structs.h | 3 ++-
2 files changed, 14 insertions(+), 1 deletion(-)
diff --git a/libc/src/__support/FPUtil/FPBits.h b/libc/src/__support/FPUtil/FPBits.h
index bee8d0a8dc47d..608459d53d432 100644
--- a/libc/src/__support/FPUtil/FPBits.h
+++ b/libc/src/__support/FPUtil/FPBits.h
@@ -38,6 +38,7 @@ enum class FPType {
IEEE754_Binary64,
IEEE754_Binary128,
X86_Binary80,
+ PPC_DoubleDouble,
};
// The classes hierarchy is as follows:
@@ -138,6 +139,15 @@ template <> struct FPLayout<FPType::X86_Binary80> {
LIBC_INLINE_VAR static constexpr int FRACTION_LEN = SIG_LEN - 1;
};
+// TODO: This needs an FPRepSem interface as well.
+template <> struct FPLayout<FPType::PPC_DoubleDouble> {
+ using StorageType = UInt128;
+ LIBC_INLINE_VAR static constexpr int SIGN_LEN = 1;
+ LIBC_INLINE_VAR static constexpr int EXP_LEN = 11;
+ LIBC_INLINE_VAR static constexpr int SIG_LEN = 106;
+ LIBC_INLINE_VAR static constexpr int FRACTION_LEN = SIG_LEN - 1;
+};
+
// FPStorage derives useful constants from the FPLayout above.
template <FPType fp_type> struct FPStorage : public FPLayout<fp_type> {
using UP = FPLayout<fp_type>;
@@ -790,6 +800,8 @@ template <typename T> LIBC_INLINE static constexpr FPType get_fp_type() {
return FPType::IEEE754_Binary64;
else if constexpr (__LDBL_MANT_DIG__ == 64)
return FPType::X86_Binary80;
+ else if constexpr (__LDBL_MANT_DIG__ == 106)
+ return FPType::PPC_DoubleDouble;
else if constexpr (__LDBL_MANT_DIG__ == 113)
return FPType::IEEE754_Binary128;
}
diff --git a/libc/src/stdio/printf_core/core_structs.h b/libc/src/stdio/printf_core/core_structs.h
index 4c3b81ff018ab..a0e9a3d0d2c10 100644
--- a/libc/src/stdio/printf_core/core_structs.h
+++ b/libc/src/stdio/printf_core/core_structs.h
@@ -56,7 +56,8 @@ struct FormatSection {
int precision = -1;
// Needs to be large enough to hold a long double.
- fputil::FPBits<long double>::StorageType conv_val_raw;
+ fputil::internal::FPLayout<fputil::get_fp_type<long double>()>::StorageType
+ conv_val_raw;
void *conv_val_ptr;
char conv_name;
More information about the libc-commits
mailing list