8
8
// option. This file may not be copied, modified, or distributed
9
9
// except according to those terms.
10
10
11
- use libc:: c_uint;
12
11
use llvm;
13
- use llvm:: { Integer , Pointer , Float , Double , Struct , Array } ;
12
+ use llvm:: { Integer , Pointer , Float , Double , Struct , Array , Attribute } ;
14
13
use abi:: { FnType , ArgType } ;
15
14
use context:: CrateContext ;
16
15
use type_:: Type ;
@@ -91,19 +90,18 @@ fn classify_ret_ty(ccx: &CrateContext, ret: &mut ArgType) {
91
90
}
92
91
93
92
fn classify_arg_ty ( ccx : & CrateContext , arg : & mut ArgType , offset : & mut usize ) {
94
- let orig_offset = * offset;
95
93
let size = ty_size ( arg. ty ) * 8 ;
96
94
let mut align = ty_align ( arg. ty ) ;
97
95
98
96
align = cmp:: min ( cmp:: max ( align, 4 ) , 8 ) ;
99
97
* offset = align_up_to ( * offset, align) ;
100
98
* offset += align_up_to ( size, align * 8 ) / 8 ;
101
99
102
- if !is_reg_ty ( arg. ty ) {
103
- arg. cast = Some ( struct_ty ( ccx, arg. ty ) ) ;
104
- arg. pad = padding_ty ( ccx, align, orig_offset) ;
105
- } else {
100
+ if is_reg_ty ( arg. ty ) {
106
101
arg. extend_integer_width_to ( 32 ) ;
102
+ } else {
103
+ arg. make_indirect ( ccx) ;
104
+ arg. attrs . set ( Attribute :: ByVal ) ;
107
105
}
108
106
}
109
107
@@ -117,39 +115,6 @@ fn is_reg_ty(ty: Type) -> bool {
117
115
} ;
118
116
}
119
117
120
- fn padding_ty ( ccx : & CrateContext , align : usize , offset : usize ) -> Option < Type > {
121
- if ( ( align - 1 ) & offset) > 0 {
122
- Some ( Type :: i32 ( ccx) )
123
- } else {
124
- None
125
- }
126
- }
127
-
128
- fn coerce_to_int ( ccx : & CrateContext , size : usize ) -> Vec < Type > {
129
- let int_ty = Type :: i32 ( ccx) ;
130
- let mut args = Vec :: new ( ) ;
131
-
132
- let mut n = size / 32 ;
133
- while n > 0 {
134
- args. push ( int_ty) ;
135
- n -= 1 ;
136
- }
137
-
138
- let r = size % 32 ;
139
- if r > 0 {
140
- unsafe {
141
- args. push ( Type :: from_ref ( llvm:: LLVMIntTypeInContext ( ccx. llcx ( ) , r as c_uint ) ) ) ;
142
- }
143
- }
144
-
145
- args
146
- }
147
-
148
- fn struct_ty ( ccx : & CrateContext , ty : Type ) -> Type {
149
- let size = ty_size ( ty) * 8 ;
150
- Type :: struct_ ( ccx, & coerce_to_int ( ccx, size) , false )
151
- }
152
-
153
118
pub fn compute_abi_info ( ccx : & CrateContext , fty : & mut FnType ) {
154
119
if !fty. ret . is_ignore ( ) {
155
120
classify_ret_ty ( ccx, & mut fty. ret ) ;
0 commit comments