Skip to content

Commit 5ee1c0b

Browse files
authored
[windows] Always pass fp128 arguments indirectly (#128848)
LLVM currently expects `__float128` to be both passed and returned in xmm registers on Windows. However, this disagrees with the Windows x86-64 calling convention [1], which indicates values larger than 64 bits should be passed indirectly. Update LLVM's default Windows calling convention to pass `fp128` directly. Returning in xmm0 is unchanged since this seems like a reasonable extrapolation of the ABI. With this patch, the calling convention for `i128` and `f128` is the same. GCC passes `__float128` indirectly, which this also matches. However, it also returns indirectly, which is not done here. I intend to attempt a GCC change to also return in `xmm0` rather than making that change here, given the consistency with `i128`. This corresponds to the frontend change in [2], see more details there. [1]: https://learn.microsoft.com/en-us/cpp/build/x64-calling-convention?view=msvc-170 [2]: #115052
1 parent 9501275 commit 5ee1c0b

File tree

7 files changed

+3732
-17
lines changed

7 files changed

+3732
-17
lines changed

llvm/docs/ReleaseNotes.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,9 @@ Changes to the WebAssembly Backend
122122
Changes to the Windows Target
123123
-----------------------------
124124

125+
* `fp128` is now passed indirectly, meaning it uses the same calling convention
126+
as `i128`.
127+
125128
Changes to the X86 Backend
126129
--------------------------
127130

llvm/lib/Target/X86/X86CallingConv.td

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -639,8 +639,9 @@ def CC_X86_Win64_C : CallingConv<[
639639
// 512 bit vectors are passed by pointer
640640
CCIfType<[v64i8, v32i16, v16i32, v32f16, v32bf16, v16f32, v8f64, v8i64], CCPassIndirect<i64>>,
641641

642-
// Long doubles are passed by pointer
642+
// Float types larger than 64-bits (long double and fp128) are passed by pointer
643643
CCIfType<[f80], CCPassIndirect<i64>>,
644+
CCIfType<[f128], CCPassIndirect<i64>>,
644645

645646
// If SSE was disabled, pass FP values smaller than 64-bits as integers in
646647
// GPRs or on the stack.

0 commit comments

Comments
 (0)