1
- // FIXME: The assumes we're using the non-vector ABI, i.e., compiling
2
- // for a pre-z13 machine or using -mno-vx.
1
+ // Reference: ELF Application Binary Interface s390x Supplement
2
+ // https://github.com/IBM/s390x-abi
3
3
4
- use crate :: abi:: call:: { ArgAbi , FnAbi , Reg } ;
5
- use crate :: abi:: { HasDataLayout , TyAbiInterface } ;
4
+ use crate :: abi:: call:: { ArgAbi , FnAbi , Reg , RegKind } ;
5
+ use crate :: abi:: { BackendRepr , HasDataLayout , TyAbiInterface } ;
6
6
use crate :: spec:: HasTargetSpec ;
7
7
8
8
fn classify_ret < Ty > ( ret : & mut ArgAbi < ' _ , Ty > ) {
9
- if !ret. layout . is_aggregate ( ) && ret. layout . size . bits ( ) <= 64 {
9
+ let size = ret. layout . size ;
10
+ if size. bits ( ) <= 128 && matches ! ( ret. layout. backend_repr, BackendRepr :: Vector { .. } ) {
11
+ return ;
12
+ }
13
+ if !ret. layout . is_aggregate ( ) && size. bits ( ) <= 64 {
10
14
ret. extend_integer_width_to ( 64 ) ;
11
15
} else {
12
16
ret. make_indirect ( ) ;
@@ -32,19 +36,25 @@ where
32
36
}
33
37
return ;
34
38
}
35
- if !arg. layout . is_aggregate ( ) && arg. layout . size . bits ( ) <= 64 {
39
+
40
+ let size = arg. layout . size ;
41
+ if size. bits ( ) <= 128 && arg. layout . is_single_vector_element ( cx) {
42
+ arg. cast_to ( Reg { kind : RegKind :: Vector , size } ) ;
43
+ return ;
44
+ }
45
+ if !arg. layout . is_aggregate ( ) && size. bits ( ) <= 64 {
36
46
arg. extend_integer_width_to ( 64 ) ;
37
47
return ;
38
48
}
39
49
40
50
if arg. layout . is_single_fp_element ( cx) {
41
- match arg . layout . size . bytes ( ) {
51
+ match size. bytes ( ) {
42
52
4 => arg. cast_to ( Reg :: f32 ( ) ) ,
43
53
8 => arg. cast_to ( Reg :: f64 ( ) ) ,
44
54
_ => arg. make_indirect ( ) ,
45
55
}
46
56
} else {
47
- match arg . layout . size . bytes ( ) {
57
+ match size. bytes ( ) {
48
58
1 => arg. cast_to ( Reg :: i8 ( ) ) ,
49
59
2 => arg. cast_to ( Reg :: i16 ( ) ) ,
50
60
4 => arg. cast_to ( Reg :: i32 ( ) ) ,
0 commit comments