-
Notifications
You must be signed in to change notification settings - Fork 12.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[llvm-libc] support for 96b long double (i386) #110894
Comments
@llvm/issue-subscribers-libc Author: Nick Desaulniers (nickdesaulniers)
building llvm-libc for i386 fails to build in the printf code; it seems that `sizeof(long double)` on i386 is `12`. example:
```
In file included from /android0/llvm-project/libc/src/stdio/printf_core/converter.cpp:9:
In file included from /android0/llvm-project/libc/src/stdio/printf_core/converter.h:13:
In file included from /android0/llvm-project/libc/src/stdio/printf_core/core_structs.h:16:
/android0/llvm-project/libc/src/__support/FPUtil/FPBits.h:824:52: error: no matching function for call to 'bit_cast'
824 | LIBC_INLINE constexpr T get_val() const { return cpp::bit_cast<T>(UP::bits); }
| ^~~~~~~~~~~~~~~~
/android0/llvm-project/libc/src/stdio/printf_core/float_dec_converter.h:502:47: note: in instantiation of member function '__llvm_libc_19_0_0_git::fputil::FPBits<long double>::get_val' requested here
502 | FloatToString<T> float_converter(float_bits.get_val());
| ^
/android0/llvm-project/libc/src/stdio/printf_core/float_dec_converter.h:1116:14: note: in instantiation of function template specialization '__llvm_libc_19_0_0_git::printf_core::convert_float_decimal_typed<long double, 0>' requested here
1116 | return convert_float_decimal_typed<long double>(writer, to_conv,
| ^
/android0/llvm-project/libc/src/__support/CPP/bit.h:38:1: note: candidate template ignored: substitution failure [with To = long double, From = StorageType]: implicit instantiation of undefined template '__llvm_libc_19_0_0_git::cpp::enable_if<false, long double>'
38 | bit_cast(const From &from) {
| ^
/android0/llvm-project/libc/src/__support/big_int.h:1099:1: note: candidate template ignored: substitution failure [with To = long double, From = StorageType]: implicit instantiation of undefined template '__llvm_libc_19_0_0_git::cpp::enable_if<false, long double>'
1099 | bit_cast(const From &from) {
| ^
/android0/llvm-project/libc/src/__support/big_int.h:1114:1: note: candidate template ignored: substitution failure [with To = long double, Bits = 128]: implicit instantiation of undefined template '__llvm_libc_19_0_0_git::cpp::enable_if<false, long double>'
1114 | bit_cast(const UInt<Bits> &from) {
| ^
```
perhaps the Filing a bug to track this, as it's a blocker for i386 support. cc @michaelrj-google |
We will need to explicitly specialize:
https://github.com/llvm/llvm-project/blob/main/libc/src/__support/big_int.h#L983 |
@nickdesaulniers I'm still blocked on the syscall issues when trying to compile for i386 (i.e., |
I've pushed a WIP branch: https://github.com/nickdesaulniers/llvm-project/commits/i386/. The syscall implementation, and most changes aren't yet correct (I need to be able to compile for i386 to verify some of these changes) but eliminate the low hanging fruit blocking compilation. |
Should that be: using StorageType = BigInt<__SIZEOF_LONG_DOUBLE__ * CHAR_BIT, false, uint32_t>;` |
Once
in general then? Let the default |
https://gist.github.com/nickdesaulniers/3c9892af61273db863fc08626ac69c75 (ah looks like some of the resulting errors from:
|
Probably the correct one is:
|
I synced to nickdesaulniers@0d46082 and tried to compile Here is the log (a bit redacted) it's quite different from the errors I could spot in your gist #110894 (comment). I'll work on fixing them and report back.
|
So ultimately it has to do with how |
I'm happy to take a look, what cmake command are you using to build for i386? |
I've been using the following cmd lines
|
I'm just setting |
Previously you could cast between bigints with different numbers of bits, but only if they had the same underlying type. This patch adds the ability to cast between bigints with different underlying types, which is needed for llvm#110894
Needed for llvm#110894 The strtointeger code was updated to support some bigint types in llvm#85201 but not all. This patch finishes the cleanup so that it can work for a wider range of types.
Previously you could cast between bigints with different numbers of bits, but only if they had the same underlying type. This patch adds the ability to cast between bigints with different underlying types, which is needed for llvm#110894
Previously you could cast between bigints with different numbers of bits, but only if they had the same underlying type. This patch adds the ability to cast between bigints with different underlying types, which is needed for #110894
Previously you could cast between bigints with different numbers of bits, but only if they had the same underlying type. This patch adds the ability to cast between bigints with different underlying types, which is needed for llvm#110894
Needed for llvm#110894 The strtointeger code was updated to support some bigint types in llvm#85201 but not all. This patch finishes the cleanup so that it can work for a wider range of types.
Previously you could cast between bigints with different numbers of bits, but only if they had the same underlying type. This patch adds the ability to cast between bigints with different underlying types, which is needed for llvm#110894
Thanks @michaelrj-google for those patches! The next issue I run into is that the
diff --git a/libc/src/__support/FPUtil/FPBits.h b/libc/src/__support/FPUtil/FPBits.h
index 5d1f633bb56e..b87ef6281051 100644
--- a/libc/src/__support/FPUtil/FPBits.h
+++ b/libc/src/__support/FPUtil/FPBits.h
@@ -121,7 +121,7 @@ template <> struct FPLayout<FPType::IEEE754_Binary128> {
};
template <> struct FPLayout<FPType::X86_Binary80> {
- using StorageType = UInt128;
+ using StorageType = UInt<__SIZEOF_LONG_DOUBLE__* CHAR_BIT>;
LIBC_INLINE_VAR static constexpr int SIGN_LEN = 1;
LIBC_INLINE_VAR static constexpr int EXP_LEN = 15;
LIBC_INLINE_VAR static constexpr int SIG_LEN = 64;
diff --git a/libc/src/__support/big_int.h b/libc/src/__support/big_int.h
index 246b89f08f2f..4ec57b8d4f98 100644
--- a/libc/src/__support/big_int.h
+++ b/libc/src/__support/big_int.h
@@ -1055,9 +1055,10 @@ struct WordTypeSelector : cpp::type_identity<
#endif // LIBC_TYPES_HAS_INT64
> {
};
-// Except if we request 16 or 32 bits explicitly.
+// Except if we request 16, 32, or 96 bits explicitly.
template <> struct WordTypeSelector<16> : cpp::type_identity<uint16_t> {};
template <> struct WordTypeSelector<32> : cpp::type_identity<uint32_t> {};
+template <> struct WordTypeSelector<96> : cpp::type_identity<uint32_t> {};
template <size_t Bits>
using WordTypeSelectorT = typename WordTypeSelector<Bits>::type;
} // namespace internal |
Needed for llvm#110894 The strtointeger code was updated to support some bigint types in llvm#85201 but not all. This patch finishes the cleanup so that it can work for a wider range of types.
Previously you could cast between bigints with different numbers of bits, but only if they had the same underlying type. This patch adds the ability to cast between bigints with different underlying types, which is needed for llvm#110894
Previously you could cast between bigints with different numbers of bits, but only if they had the same underlying type. This patch adds the ability to cast between bigints with different underlying types, which is needed for llvm#110894
`long double` is haunted on most architectures, but it is especially so on i386-linux-gnu. While have 80b of significant data, on i386-linux-gnu this type has 96b of storage. Fixes for supporting printf family of conversions for `long double` on i386-linux-gnu. This allows the libc-stdlib-tests and libc_stdio_unittests ninja target tests to pass on i386-linux-gnu. Fixes: llvm#110894 Link: llvm#93709 Link: https://developer.android.com/ndk/guides/abis Co-authored-by: Michael Jones <michaelrj@google.com>
`long double` is haunted on most architectures, but it is especially so on i386-linux-gnu. While have 80b of significant data, on i386-linux-gnu this type has 96b of storage. Fixes for supporting printf family of conversions for `long double` on i386-linux-gnu. This allows the libc-stdlib-tests and libc_stdio_unittests ninja target tests to pass on i386-linux-gnu. Fixes: llvm#110894 Link: llvm#93709 Link: https://developer.android.com/ndk/guides/abis Co-authored-by: Michael Jones <michaelrj@google.com>
`long double` is haunted on most architectures, but it is especially so on i386-linux-gnu. While have 80b of significant data, on i386-linux-gnu this type has 96b of storage. Fixes for supporting printf family of conversions for `long double` on i386-linux-gnu. This allows the libc-stdlib-tests and libc_stdio_unittests ninja target tests to pass on i386-linux-gnu. Fixes: #110894 Link: #93709 Co-authored-by: Michael Jones <michaelrj@google.com>
`long double` is haunted on most architectures, but it is especially so on i386-linux-gnu. While have 80b of significant data, on i386-linux-gnu this type has 96b of storage. Fixes for supporting printf family of conversions for `long double` on i386-linux-gnu. This allows the libc-stdlib-tests and libc_stdio_unittests ninja target tests to pass on i386-linux-gnu. Fixes: llvm#110894 Link: llvm#93709 Link: https://developer.android.com/ndk/guides/abis Co-authored-by: Michael Jones <michaelrj@google.com>
building llvm-libc for i386 fails to build in the printf code; it seems that
sizeof(long double)
on i386 is12
. example:perhaps the
StorageType
forFPLayout<FPType::X86_Binary80>
should be a 96bUInt
for i386, but that leads to other errors?Filing a bug to track this, as it's a blocker for i386 support.
cc @michaelrj-google
The text was updated successfully, but these errors were encountered: