about summary refs log tree commit diff
path: root/compiler/rustc_target/src/callconv
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2025-02-19 18:52:07 +0100
committerGitHub <noreply@github.com>2025-02-19 18:52:07 +0100
commitd8debbdd683f2389bd84753f0f1925b25b423635 (patch)
treee14af75e4b0edf57b1221a0a9fdf4f1e76073f39 /compiler/rustc_target/src/callconv
parentce72b8d91e091eb3178cd91bd8f9a01f48f88abc (diff)
parent73b6482ead710656c14fbb86011aa0e7d65461fd (diff)
downloadrust-d8debbdd683f2389bd84753f0f1925b25b423635.tar.gz
rust-d8debbdd683f2389bd84753f0f1925b25b423635.zip
Rollup merge of #137094 - RalfJung:softfloat-means-no-simd, r=tgross35
x86_win64 ABI: do not use xmm0 with softfloat ABI

This adjusts https://github.com/rust-lang/rust/pull/134290 to not apply the new logic to targets marked as "softfloat". That fixes most instances of the issue brought up [here](https://github.com/rust-lang/rust/issues/116558#issuecomment-2661027437).

r? `@tgross35`
Diffstat (limited to 'compiler/rustc_target/src/callconv')
-rw-r--r--compiler/rustc_target/src/callconv/x86_win64.rs16
1 files changed, 10 insertions, 6 deletions
diff --git a/compiler/rustc_target/src/callconv/x86_win64.rs b/compiler/rustc_target/src/callconv/x86_win64.rs
index 23ef2cf8284..2ef5127de04 100644
--- a/compiler/rustc_target/src/callconv/x86_win64.rs
+++ b/compiler/rustc_target/src/callconv/x86_win64.rs
@@ -1,11 +1,11 @@
 use rustc_abi::{BackendRepr, Float, Integer, Primitive, RegKind, Size};
 
 use crate::callconv::{ArgAbi, FnAbi, Reg};
-use crate::spec::HasTargetSpec;
+use crate::spec::{HasTargetSpec, RustcAbi};
 
 // Win64 ABI: https://docs.microsoft.com/en-us/cpp/build/parameter-passing
 
-pub(crate) fn compute_abi_info<Ty>(_cx: &impl HasTargetSpec, fn_abi: &mut FnAbi<'_, Ty>) {
+pub(crate) fn compute_abi_info<Ty>(cx: &impl HasTargetSpec, fn_abi: &mut FnAbi<'_, Ty>) {
     let fixup = |a: &mut ArgAbi<'_, Ty>, is_ret: bool| {
         match a.layout.backend_repr {
             BackendRepr::Uninhabited | BackendRepr::Memory { sized: false } => {}
@@ -24,10 +24,14 @@ pub(crate) fn compute_abi_info<Ty>(_cx: &impl HasTargetSpec, fn_abi: &mut FnAbi<
             }
             BackendRepr::Scalar(scalar) => {
                 if is_ret && matches!(scalar.primitive(), Primitive::Int(Integer::I128, _)) {
-                    // `i128` is returned in xmm0 by Clang and GCC
-                    // 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);
+                    if cx.target_spec().rustc_abi == Some(RustcAbi::X86Softfloat) {
+                        // Use the native `i128` LLVM type for the softfloat ABI -- in other words, adjust nothing.
+                    } else {
+                        // `i128` is returned in xmm0 by Clang and GCC
+                        // 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))
                 {