x86_win64 ABI: do not use xmm0 with softfloat ABI
This commit is contained in:
parent
608e228ca9
commit
73b6482ead
3 changed files with 59 additions and 21 deletions
|
@ -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))
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue