Skip to content

Commit

Permalink
x86_win64 ABI: do not use xmm0 with softfloat ABI
Browse files Browse the repository at this point in the history
  • Loading branch information
RalfJung committed Feb 15, 2025
1 parent 608e228 commit f91c8f4
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions compiler/rustc_target/src/callconv/x86_win64.rs
Original file line number Diff line number Diff line change
@@ -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 } => {}
Expand All @@ -23,7 +23,10 @@ pub(crate) fn compute_abi_info<Ty>(_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
&& cx.target_spec().rustc_abi != Some(RustcAbi::X86Softfloat)
&& 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) };
Expand Down

0 comments on commit f91c8f4

Please sign in to comment.