]> git.proxmox.com Git - rustc.git/blob - compiler/rustc_target/src/abi/call/s390x.rs
New upstream version 1.76.0+dfsg1
[rustc.git] / compiler / rustc_target / src / abi / call / s390x.rs
1 // FIXME: The assumes we're using the non-vector ABI, i.e., compiling
2 // for a pre-z13 machine or using -mno-vx.
3
4 use crate::abi::call::{ArgAbi, FnAbi, Reg};
5 use crate::abi::{HasDataLayout, TyAbiInterface};
6
7 fn classify_ret<Ty>(ret: &mut ArgAbi<'_, Ty>) {
8 if !ret.layout.is_aggregate() && ret.layout.size.bits() <= 64 {
9 ret.extend_integer_width_to(64);
10 } else {
11 ret.make_indirect();
12 }
13 }
14
15 fn classify_arg<'a, Ty, C>(cx: &C, arg: &mut ArgAbi<'a, Ty>)
16 where
17 Ty: TyAbiInterface<'a, C> + Copy,
18 C: HasDataLayout,
19 {
20 if !arg.layout.is_sized() {
21 // Not touching this...
22 return;
23 }
24 if !arg.layout.is_aggregate() && arg.layout.size.bits() <= 64 {
25 arg.extend_integer_width_to(64);
26 return;
27 }
28
29 if arg.layout.is_single_fp_element(cx) {
30 match arg.layout.size.bytes() {
31 4 => arg.cast_to(Reg::f32()),
32 8 => arg.cast_to(Reg::f64()),
33 _ => arg.make_indirect(),
34 }
35 } else {
36 match arg.layout.size.bytes() {
37 1 => arg.cast_to(Reg::i8()),
38 2 => arg.cast_to(Reg::i16()),
39 4 => arg.cast_to(Reg::i32()),
40 8 => arg.cast_to(Reg::i64()),
41 _ => arg.make_indirect(),
42 }
43 }
44 }
45
46 pub fn compute_abi_info<'a, Ty, C>(cx: &C, fn_abi: &mut FnAbi<'a, Ty>)
47 where
48 Ty: TyAbiInterface<'a, C> + Copy,
49 C: HasDataLayout,
50 {
51 if !fn_abi.ret.is_ignore() {
52 classify_ret(&mut fn_abi.ret);
53 }
54
55 for arg in fn_abi.args.iter_mut() {
56 if arg.is_ignore() {
57 continue;
58 }
59 classify_arg(cx, arg);
60 }
61 }