rustc_target/callconv/
x86_win64.rs1use rustc_abi::{BackendRepr, Integer, Primitive, Size, TyAbiInterface};
2
3use crate::callconv::{ArgAbi, FnAbi, Reg};
4use crate::spec::{HasTargetSpec, RustcAbi};
5
6pub(crate) fn compute_abi_info<'a, Ty, C: HasTargetSpec>(cx: &C, fn_abi: &mut FnAbi<'a, Ty>)
9where
10 Ty: TyAbiInterface<'a, C> + Copy,
11{
12 let fixup = |a: &mut ArgAbi<'_, Ty>, is_ret: bool| {
13 match a.layout.backend_repr {
14 BackendRepr::Memory { sized: false } => {}
15 BackendRepr::ScalarPair { .. } | BackendRepr::Memory { sized: true } => {
16 match a.layout.size.bits() {
17 8 => a.cast_to(Reg::i8()),
18 16 => a.cast_to(Reg::i16()),
19 32 => a.cast_to(Reg::i32()),
20 64 => a.cast_to(Reg::i64()),
21 _ => a.make_indirect(),
22 }
23 }
24 BackendRepr::SimdVector { .. } => {
25 }
28 BackendRepr::SimdScalableVector { .. } => {
::core::panicking::panic_fmt(format_args!("scalable vectors are unsupported"));
}panic!("scalable vectors are unsupported"),
29 BackendRepr::Scalar(scalar) => {
30 if is_ret && #[allow(non_exhaustive_omitted_patterns)] match scalar.primitive() {
Primitive::Int(Integer::I128, _) => true,
_ => false,
}matches!(scalar.primitive(), Primitive::Int(Integer::I128, _)) {
31 if cx.target_spec().rustc_abi == Some(RustcAbi::Softfloat) {
32 } else {
34 a.cast_to(Reg::opaque_vector(Size::from_bits(128)));
37 }
38 } else if a.layout.size.bytes() > 8 {
39 a.make_indirect();
40 } else {
41 a.extend_integer_width_to(32);
42 }
43 }
44 }
45 };
46
47 if fn_abi.ret.is_ignore() {
53 if fn_abi.ret.layout.is_repr_c() {
54 fn_abi.ret.make_indirect_from_ignore();
55 }
56 } else {
57 fixup(&mut fn_abi.ret, true);
58 }
59
60 for arg in fn_abi.args.iter_mut() {
61 if arg.is_ignore() {
62 if arg.layout.is_repr_c() {
63 arg.make_indirect_from_ignore();
64 }
65
66 continue;
67 }
68 if arg.layout.pass_indirectly_in_non_rustic_abis(cx) {
69 arg.make_indirect();
70 continue;
71 }
72 fixup(arg, false);
73 }
74}