From 4429a4871a2eb36fc8a4768b4d05b2cfc13bd381 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Fri, 28 Feb 2025 07:59:25 +0000 Subject: [PATCH 1/2] DO NOT MERGE change llvm module to my fork --- .gitmodules | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitmodules b/.gitmodules index 97a0c0c54cf9f..a70b016153d2a 100644 --- a/.gitmodules +++ b/.gitmodules @@ -28,8 +28,8 @@ shallow = true [submodule "src/llvm-project"] path = src/llvm-project - url = https://github.com/rust-lang/llvm-project.git - branch = rustc/20.1-2025-02-13 + url = https://github.com/tgross35/llvm-project.git + branch = windows-f128-abi-combined shallow = true [submodule "src/doc/embedded-book"] path = src/doc/embedded-book From 38c1ac9c83b168848060870f73091c17349d633c Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Fri, 28 Feb 2025 09:14:55 +0000 Subject: [PATCH 2/2] Change the f128 ABI to match i128 on Windows --- .../rustc_target/src/callconv/x86_win64.rs | 20 +++++++++++-------- tests/assembly/x86_64-windows-float-abi.rs | 2 +- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/compiler/rustc_target/src/callconv/x86_win64.rs b/compiler/rustc_target/src/callconv/x86_win64.rs index 4d99a9f9ba064..662774a652166 100644 --- a/compiler/rustc_target/src/callconv/x86_win64.rs +++ b/compiler/rustc_target/src/callconv/x86_win64.rs @@ -23,20 +23,24 @@ pub(crate) fn compute_abi_info(cx: &impl HasTargetSpec, fn_abi: &mut FnAbi<' // (probably what clang calls "illegal vectors"). } BackendRepr::Scalar(scalar) => { - if is_ret && matches!(scalar.primitive(), Primitive::Int(Integer::I128, _)) { + if is_ret + && matches!( + scalar.primitive(), + Primitive::Int(Integer::I128, _) | Primitive::Float(Float::F128) + ) + { + // i128 and f128 have the same ABI on Windows. if cx.target_spec().rustc_abi == Some(RustcAbi::X86Softfloat) { - // Use the native `i128` LLVM type for the softfloat ABI -- in other words, adjust nothing. + // Use the native `i128`/`f128` LLVM type for the softfloat ABI -- in other + // words, adjust nothing. } else { - // `i128` is returned in xmm0 by Clang and GCC + // `i128` and `f128` are returned in xmm0 by Clang. `i128` is returned in + // xmm0 by GCC but `f128` is indirect (Clang and GCC have a mismatch). // FIXME(#134288): This may change for the `-msvc` targets in the future. let reg = Reg { kind: RegKind::Vector, size: Size::from_bits(128) }; a.cast_to(reg); } - } else if a.layout.size.bytes() > 8 - && !matches!(scalar.primitive(), Primitive::Float(Float::F128)) - { - // Match what LLVM does for `f128` so that `compiler-builtins` builtins match up - // with what LLVM expects. + } else if a.layout.size.bytes() > 8 { a.make_indirect(); } else { a.extend_integer_width_to(32); diff --git a/tests/assembly/x86_64-windows-float-abi.rs b/tests/assembly/x86_64-windows-float-abi.rs index e8900be1aaee3..d2c35d2842cc3 100644 --- a/tests/assembly/x86_64-windows-float-abi.rs +++ b/tests/assembly/x86_64-windows-float-abi.rs @@ -37,7 +37,7 @@ pub extern "C" fn second_f64(_: f64, x: f64) -> f64 { } // CHECK-LABEL: second_f128 -// CHECK: movaps %xmm1, %xmm0 +// CHECK: movaps (%rdx), %xmm0 // CHECK-NEXT: retq #[no_mangle] pub extern "C" fn second_f128(_: f128, x: f128) -> f128 {