@@ -96,22 +96,30 @@ impl GccType for Reg {
9696 }
9797}
9898
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+
99107pub trait FnAbiGccExt < ' gcc , ' tcx > {
100108 // 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 > ;
102110 fn ptr_to_gcc_type ( & self , cx : & CodegenCx < ' gcc , ' tcx > ) -> Type < ' gcc > ;
103111}
104112
105113impl < ' 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 > {
107115 let mut on_stack_param_indices = FxHashSet :: default ( ) ;
108116
109117 // This capacity calculation is approximate.
110118 let mut argument_tys = Vec :: with_capacity (
111119 self . args . len ( ) + if let PassMode :: Indirect { .. } = self . ret . mode { 1 } else { 0 }
112120 ) ;
113121
114- let return_ty =
122+ let return_type =
115123 match self . ret . mode {
116124 PassMode :: Ignore => cx. type_void ( ) ,
117125 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>> {
185193 #[ cfg( not( feature = "master" ) ) ]
186194 let fn_attrs = Vec :: new ( ) ;
187195
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+ }
189203 }
190204
191205 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) ;
195215 cx. on_stack_params . borrow_mut ( ) . insert ( pointer_type. dyncast_function_ptr_type ( ) . expect ( "function ptr type" ) , on_stack_param_indices) ;
196216 pointer_type
197217 }
0 commit comments