3
3
use crate :: abi:: call:: { ArgAbi , FnAbi , Reg , Uniform } ;
4
4
5
5
const NUM_ARG_GPR : u64 = 6 ;
6
- const MAX_ARG_IN_REGS_SIZE : u64 = 4 * 32 ;
6
+ const MAX_ARG_IN_REGS_SIZE : u64 = 4 * 32 ;
7
7
// const MAX_ARG_DIRECT_SIZE: u64 = MAX_ARG_IN_REGS_SIZE;
8
- const MAX_RET_IN_REGS_SIZE : u64 = 2 * 32 ;
8
+ const MAX_RET_IN_REGS_SIZE : u64 = 2 * 32 ;
9
9
10
10
fn classify_ret_ty < Ty > ( arg : & mut ArgAbi < ' _ , Ty > , xlen : u64 ) {
11
11
// The rules for return and argument types are the same, so defer to
12
12
// classifyArgumentType.
13
13
classify_arg_ty ( arg, xlen, & mut 2 ) ; // two as max return size
14
14
}
15
15
16
-
17
16
fn classify_arg_ty < Ty > ( arg : & mut ArgAbi < ' _ , Ty > , xlen : u64 , remaining_gpr : & mut u64 ) {
18
17
// Determine the number of GPRs needed to pass the current argument
19
18
// according to the ABI. 2*XLen-aligned varargs are passed in "aligned"
@@ -29,7 +28,7 @@ fn classify_arg_ty<Ty>(arg: &mut ArgAbi<'_, Ty>, xlen: u64, remaining_gpr: &mut
29
28
let mut required_gpr = 1u64 ; // at least one per arg
30
29
if alignment. bits ( ) == 2 * xlen {
31
30
required_gpr = 2 + ( * remaining_gpr % 2 ) ;
32
- } else if arg_size. bits ( ) > xlen && arg_size. bits ( ) <= MAX_ARG_IN_REGS_SIZE {
31
+ } else if arg_size. bits ( ) > xlen && arg_size. bits ( ) <= MAX_ARG_IN_REGS_SIZE {
33
32
required_gpr = ( arg_size. bits ( ) + ( xlen - 1 ) ) / xlen;
34
33
}
35
34
@@ -59,12 +58,9 @@ fn classify_arg_ty<Ty>(arg: &mut ArgAbi<'_, Ty>, xlen: u64, remaining_gpr: &mut
59
58
// arg.extend_integer_width_to(arg_size + (xlen - 1) / xlen);
60
59
// }
61
60
if alignment. bits ( ) == 2 * xlen {
62
- arg. cast_to ( Uniform {
63
- unit : Reg :: i64 ( ) ,
64
- total : arg_size
65
- } ) ;
61
+ arg. cast_to ( Uniform { unit : Reg :: i64 ( ) , total : arg_size } ) ;
66
62
} else {
67
- //TODO array type - this should be a homogenous array type
63
+ // FIXME array type - this should be a homogenous array type
68
64
// arg.extend_integer_width_to(arg_size + (xlen - 1) / xlen);
69
65
}
70
66
} else {
@@ -73,30 +69,26 @@ fn classify_arg_ty<Ty>(arg: &mut ArgAbi<'_, Ty>, xlen: u64, remaining_gpr: &mut
73
69
arg. make_indirect ( ) ;
74
70
}
75
71
76
- // if arg_size as u64 <= MAX_ARG_IN_REGS_SIZE {
77
- // let align = arg.layout.align.abi.bytes();
78
- // let total = arg.layout.size;
79
- // arg.cast_to(Uniform {
80
- // unit: if align <= 4 { Reg::i32() } else { Reg::i64() },
81
- // total
82
- // });
83
- // return;
84
- // }
72
+ // if arg_size as u64 <= MAX_ARG_IN_REGS_SIZE {
73
+ // let align = arg.layout.align.abi.bytes();
74
+ // let total = arg.layout.size;
75
+ // arg.cast_to(Uniform {
76
+ // unit: if align <= 4 { Reg::i32() } else { Reg::i64() },
77
+ // total
78
+ // });
79
+ // return;
80
+ // }
85
81
}
86
82
87
83
pub fn compute_abi_info < Ty > ( fty : & mut FnAbi < ' _ , Ty > , xlen : u64 ) {
88
84
if !fty. ret . is_ignore ( ) {
89
85
classify_ret_ty ( & mut fty. ret , xlen) ;
90
86
}
91
87
92
- let return_indirect = fty . ret . layout . size . bits ( ) > MAX_RET_IN_REGS_SIZE ||
93
- fty. ret . is_indirect ( ) ;
88
+ let return_indirect =
89
+ fty . ret . layout . size . bits ( ) > MAX_RET_IN_REGS_SIZE || fty. ret . is_indirect ( ) ;
94
90
95
- let mut remaining_gpr = if return_indirect {
96
- NUM_ARG_GPR - 1
97
- } else {
98
- NUM_ARG_GPR
99
- } ;
91
+ let mut remaining_gpr = if return_indirect { NUM_ARG_GPR - 1 } else { NUM_ARG_GPR } ;
100
92
101
93
for arg in & mut fty. args {
102
94
if arg. is_ignore ( ) {
0 commit comments