Skip to content

Commit e52cb5f

Browse files
committed
Auto merge of #137779 - tgross35:windows-f128-abi-experiment, r=<try>
[do not merge] Windows f128 abi experiment Running tests with llvm/llvm-project#115052 and llvm/llvm-project#128848. r? `@ghost` try-job: dist-x86_64-msvc try-job: dist-x86_64-mingw try-job: x86_64-msvc-1 try-job: x86_64-msvc-2 try-job: x86_64-mingw-1 try-job: x86_64-mingw-2
2 parents cb08599 + 1bed71a commit e52cb5f

File tree

3 files changed

+15
-11
lines changed

3 files changed

+15
-11
lines changed

.gitmodules

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828
shallow = true
2929
[submodule "src/llvm-project"]
3030
path = src/llvm-project
31-
url = https://github.com/rust-lang/llvm-project.git
32-
branch = rustc/20.1-2025-02-13
31+
url = https://github.com/tgross35/llvm-project.git
32+
branch = windows-f128-abi-combined
3333
shallow = true
3434
[submodule "src/doc/embedded-book"]
3535
path = src/doc/embedded-book

compiler/rustc_target/src/callconv/x86_win64.rs

+12-8
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,24 @@ pub(crate) fn compute_abi_info<Ty>(cx: &impl HasTargetSpec, fn_abi: &mut FnAbi<'
2323
// (probably what clang calls "illegal vectors").
2424
}
2525
BackendRepr::Scalar(scalar) => {
26-
if is_ret && matches!(scalar.primitive(), Primitive::Int(Integer::I128, _)) {
26+
if is_ret
27+
&& matches!(
28+
scalar.primitive(),
29+
Primitive::Int(Integer::I128, _) | Primitive::Float(Float::F128)
30+
)
31+
{
32+
// i128 and f128 have the same ABI on Windows.
2733
if cx.target_spec().rustc_abi == Some(RustcAbi::X86Softfloat) {
28-
// Use the native `i128` LLVM type for the softfloat ABI -- in other words, adjust nothing.
34+
// Use the native `i128`/`f128` LLVM type for the softfloat ABI -- in other
35+
// words, adjust nothing.
2936
} else {
30-
// `i128` is returned in xmm0 by Clang and GCC
37+
// `i128` and `f128` are returned in xmm0 by Clang. `i128` is returned in
38+
// xmm0 by GCC but `f128` is indirect (Clang and GCC have a mismatch).
3139
// FIXME(#134288): This may change for the `-msvc` targets in the future.
3240
let reg = Reg { kind: RegKind::Vector, size: Size::from_bits(128) };
3341
a.cast_to(reg);
3442
}
35-
} else if a.layout.size.bytes() > 8
36-
&& !matches!(scalar.primitive(), Primitive::Float(Float::F128))
37-
{
38-
// Match what LLVM does for `f128` so that `compiler-builtins` builtins match up
39-
// with what LLVM expects.
43+
} else if a.layout.size.bytes() > 8 {
4044
a.make_indirect();
4145
} else {
4246
a.extend_integer_width_to(32);

tests/assembly/x86_64-windows-float-abi.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ pub extern "C" fn second_f64(_: f64, x: f64) -> f64 {
3737
}
3838

3939
// CHECK-LABEL: second_f128
40-
// CHECK: movaps %xmm1, %xmm0
40+
// CHECK: movaps (%rdi), %xmm0
4141
// CHECK-NEXT: retq
4242
#[no_mangle]
4343
pub extern "C" fn second_f128(_: f128, x: f128) -> f128 {

0 commit comments

Comments
 (0)