@@ -96,22 +96,30 @@ impl GccType for Reg {
96
96
}
97
97
}
98
98
99
+ pub struct FnAbiGcc < ' gcc > {
100
+ pub return_type : Type < ' gcc > ,
101
+ pub arguments_type : Vec < Type < ' gcc > > ,
102
+ pub is_c_variadic : bool ,
103
+ pub on_stack_param_indices : FxHashSet < usize > ,
104
+ pub fn_attributes : Vec < FnAttribute < ' gcc > > ,
105
+ }
106
+
99
107
pub trait FnAbiGccExt < ' gcc , ' tcx > {
100
108
// TODO(antoyo): return a function pointer type instead?
101
- fn gcc_type ( & self , cx : & CodegenCx < ' gcc , ' tcx > ) -> ( Type < ' gcc > , Vec < Type < ' gcc > > , bool , FxHashSet < usize > , Vec < FnAttribute < ' gcc > > ) ;
109
+ fn gcc_type ( & self , cx : & CodegenCx < ' gcc , ' tcx > ) -> FnAbiGcc < ' gcc > ;
102
110
fn ptr_to_gcc_type ( & self , cx : & CodegenCx < ' gcc , ' tcx > ) -> Type < ' gcc > ;
103
111
}
104
112
105
113
impl < ' gcc , ' tcx > FnAbiGccExt < ' gcc , ' tcx > for FnAbi < ' tcx , Ty < ' tcx > > {
106
- fn gcc_type ( & self , cx : & CodegenCx < ' gcc , ' tcx > ) -> ( Type < ' gcc > , Vec < Type < ' gcc > > , bool , FxHashSet < usize > , Vec < FnAttribute < ' gcc > > ) {
114
+ fn gcc_type ( & self , cx : & CodegenCx < ' gcc , ' tcx > ) -> FnAbiGcc < ' gcc > {
107
115
let mut on_stack_param_indices = FxHashSet :: default ( ) ;
108
116
109
117
// This capacity calculation is approximate.
110
118
let mut argument_tys = Vec :: with_capacity (
111
119
self . args . len ( ) + if let PassMode :: Indirect { .. } = self . ret . mode { 1 } else { 0 }
112
120
) ;
113
121
114
- let return_ty =
122
+ let return_type =
115
123
match self . ret . mode {
116
124
PassMode :: Ignore => cx. type_void ( ) ,
117
125
PassMode :: Direct ( _) | PassMode :: Pair ( ..) => self . ret . layout . immediate_gcc_type ( cx) ,
@@ -185,13 +193,25 @@ impl<'gcc, 'tcx> FnAbiGccExt<'gcc, 'tcx> for FnAbi<'tcx, Ty<'tcx>> {
185
193
#[ cfg( not( feature = "master" ) ) ]
186
194
let fn_attrs = Vec :: new ( ) ;
187
195
188
- ( return_ty, argument_tys, self . c_variadic , on_stack_param_indices, fn_attrs)
196
+ FnAbiGcc {
197
+ return_type,
198
+ arguments_type : argument_tys,
199
+ is_c_variadic : self . c_variadic ,
200
+ on_stack_param_indices,
201
+ fn_attributes : fn_attrs,
202
+ }
189
203
}
190
204
191
205
fn ptr_to_gcc_type ( & self , cx : & CodegenCx < ' gcc , ' tcx > ) -> Type < ' gcc > {
192
- // FIXME: Should we do something with `fn_attrs`?
193
- let ( return_type, params, variadic, on_stack_param_indices, _fn_attrs) = self . gcc_type ( cx) ;
194
- let pointer_type = cx. context . new_function_pointer_type ( None , return_type, & params, variadic) ;
206
+ // FIXME(antoyo): Should we do something with `FnAbiGcc::fn_attributes`?
207
+ let FnAbiGcc {
208
+ return_type,
209
+ arguments_type,
210
+ is_c_variadic,
211
+ on_stack_param_indices,
212
+ ..
213
+ } = self . gcc_type ( cx) ;
214
+ let pointer_type = cx. context . new_function_pointer_type ( None , return_type, & arguments_type, is_c_variadic) ;
195
215
cx. on_stack_params . borrow_mut ( ) . insert ( pointer_type. dyncast_function_ptr_type ( ) . expect ( "function ptr type" ) , on_stack_param_indices) ;
196
216
pointer_type
197
217
}
0 commit comments