Support u128/i128 c-variadic arguments#155429
Conversation
|
@bors try jobs=dist-various-1,dist-various-2,aarch64-apple,x86_64-mingw-1 |
This comment has been minimized.
This comment has been minimized.
Support `u128`/`i128` c-variadic arguments try-job: dist-various-1 try-job: dist-various-2 try-job: aarch64-apple try-job: x86_64-mingw-1
This comment has been minimized.
This comment has been minimized.
3f2ff65 to
5e8c8b5
Compare
|
@bors try jobs=dist-various-1,dist-various-2,aarch64-apple,x86_64-mingw-1 |
Support `u128`/`i128` c-variadic arguments try-job: dist-various-1 try-job: dist-various-2 try-job: aarch64-apple try-job: x86_64-mingw-1
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
5e8c8b5 to
bcf4cfa
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
💔 Test for d3bd26f failed: CI. Failed job:
|
bcf4cfa to
8e7c3b1
Compare
|
@bors try jobs=dist-various-1,dist-various-2,aarch64-apple,x86_64-mingw-1 |
This comment has been minimized.
This comment has been minimized.
Support `u128`/`i128` c-variadic arguments try-job: dist-various-1 try-job: dist-various-2 try-job: aarch64-apple try-job: x86_64-mingw-1
8e7c3b1 to
d765f82
Compare
This comment has been minimized.
This comment has been minimized.
d765f82 to
1b40600
Compare
| crate::cfg_select! { | ||
| target_pointer_width = "32" => { | ||
| // GCC says <https://gcc.gnu.org/onlinedocs/gcc-15.2.0/gcc/_005f_005fint128.html> | ||
| // | ||
| // > There is no support in GCC for expressing an integer constant of type __int128 for targets | ||
| // > with long long integer less than 128 bits wide. | ||
| } | ||
| target_env = "msvc" => { | ||
| // Per https://learn.microsoft.com/en-us/cpp/cpp/data-type-ranges?view=msvc-170, __int128 is | ||
| // not recognized by msvc. | ||
| } | ||
| any( | ||
| target_arch = "x86_64", | ||
| target_arch = "aarch64", | ||
| target_arch = "riscv64", | ||
| target_arch = "loongarch64", | ||
| target_arch = "s390x", | ||
| target_arch = "powerpc64" | ||
| ) => { | ||
| unsafe impl VaArgSafe for i128 {} | ||
| unsafe impl VaArgSafe for u128 {} | ||
| } | ||
| _ => { | ||
| } | ||
| } |
There was a problem hiding this comment.
cc @Amanieu @joshtriplett @workingjubilee thoughts on this as an initial set of targets to support i128 varargs on?
| Primitive::Int(integer, _) => match integer { | ||
| Integer::I8 | Integer::I16 => unreachable!(), | ||
| Integer::I32 | Integer::I64 => { /* fall through */ } | ||
| Integer::I128 => return Align::EIGHT, |
There was a problem hiding this comment.
It has custom behavior, the va_arg implementation for powerpc64 is here
and it uses the implementation here
The logic falls through to the last line for i128, returning 8. For f128 it curiously does use an alignment of 16, so I've just added that already because it would be easy to miss down the line.
|
|
|
may as well @bors try jobs=dist-various-1,dist-various-2,aarch64-apple,x86_64-mingw-1 |
This comment has been minimized.
This comment has been minimized.
Support `u128`/`i128` c-variadic arguments try-job: dist-various-1 try-job: dist-various-2 try-job: aarch64-apple try-job: x86_64-mingw-1
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
50b74c4 to
52d37d3
Compare
| ) -> &'ll Value { | ||
| if layout.layout.align.abi > src_align { | ||
| let tmp = bx.alloca(layout.layout.size(), layout.layout.align().abi); | ||
| let tmp = bx.alloca_with_ty(layout); |
There was a problem hiding this comment.
Using a typed alloca solves an issue with the memcpy not being optimized out, see llvm/llvm-project#194158. Normally rust type erases allocas (e.g. [16 x i8]) and that confuses LLVM apparently.
|
💔 Test for 9d4c015 failed: CI. Failed job:
|
52d37d3 to
a34dc03
Compare
This comment has been minimized.
This comment has been minimized.
|
@bors try jobs=dist-various-1,dist-various-2,aarch64-apple,x86_64-mingw-1 |
This comment has been minimized.
This comment has been minimized.
Support `u128`/`i128` c-variadic arguments try-job: dist-various-1 try-job: dist-various-2 try-job: aarch64-apple try-job: x86_64-mingw-1
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
a34dc03 to
6f9049b
Compare
This comment has been minimized.
This comment has been minimized.
2db94a6 to
7d2a6d2
Compare
This comment has been minimized.
This comment has been minimized.
On platforms where `clang` defines `__int128`.
7d2a6d2 to
8616c8b
Compare
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
|
didn't realize I had never pushed/marked as ready. @rustbot ready |
View all comments
The restriction on
u128is kind of arbitrary, so let's see what it would take to support it.r? @ghost