88// option. This file may not be copied, modified, or distributed
99// except according to those terms.
1010
11- use llvm:: { self , ValueRef , AttributePlace } ;
11+ use llvm:: { self , AttributePlace } ;
1212use base;
1313use builder:: { Builder , MemFlags } ;
1414use common:: { ty_fn_sig, C_usize } ;
@@ -17,6 +17,7 @@ use mir::place::PlaceRef;
1717use mir:: operand:: OperandValue ;
1818use type_:: Type ;
1919use type_of:: { LayoutLlvmExt , PointerKind } ;
20+ use value:: Value ;
2021
2122use rustc_target:: abi:: { LayoutOf , Size , TyLayout } ;
2223use rustc:: ty:: { self , Ty } ;
@@ -46,12 +47,12 @@ impl ArgAttributeExt for ArgAttribute {
4647}
4748
4849pub trait ArgAttributesExt {
49- fn apply_llfn ( & self , idx : AttributePlace , llfn : ValueRef ) ;
50- fn apply_callsite ( & self , idx : AttributePlace , callsite : ValueRef ) ;
50+ fn apply_llfn ( & self , idx : AttributePlace , llfn : & Value ) ;
51+ fn apply_callsite ( & self , idx : AttributePlace , callsite : & Value ) ;
5152}
5253
5354impl ArgAttributesExt for ArgAttributes {
54- fn apply_llfn ( & self , idx : AttributePlace , llfn : ValueRef ) {
55+ fn apply_llfn ( & self , idx : AttributePlace , llfn : & Value ) {
5556 let mut regular = self . regular ;
5657 unsafe {
5758 let deref = self . pointee_size . bytes ( ) ;
@@ -76,7 +77,7 @@ impl ArgAttributesExt for ArgAttributes {
7677 }
7778 }
7879
79- fn apply_callsite ( & self , idx : AttributePlace , callsite : ValueRef ) {
80+ fn apply_callsite ( & self , idx : AttributePlace , callsite : & Value ) {
8081 let mut regular = self . regular ;
8182 unsafe {
8283 let deref = self . pointee_size . bytes ( ) ;
@@ -103,11 +104,11 @@ impl ArgAttributesExt for ArgAttributes {
103104}
104105
105106pub trait LlvmType {
106- fn llvm_type ( & self , cx : & CodegenCx ) -> Type ;
107+ fn llvm_type ( & self , cx : & CodegenCx < ' ll , ' _ > ) -> & ' ll Type ;
107108}
108109
109110impl LlvmType for Reg {
110- fn llvm_type ( & self , cx : & CodegenCx ) -> Type {
111+ fn llvm_type ( & self , cx : & CodegenCx < ' ll , ' _ > ) -> & ' ll Type {
111112 match self . kind {
112113 RegKind :: Integer => Type :: ix ( cx, self . size . bits ( ) ) ,
113114 RegKind :: Float => {
@@ -118,14 +119,14 @@ impl LlvmType for Reg {
118119 }
119120 }
120121 RegKind :: Vector => {
121- Type :: vector ( & Type :: i8 ( cx) , self . size . bytes ( ) )
122+ Type :: vector ( Type :: i8 ( cx) , self . size . bytes ( ) )
122123 }
123124 }
124125 }
125126}
126127
127128impl LlvmType for CastTarget {
128- fn llvm_type ( & self , cx : & CodegenCx ) -> Type {
129+ fn llvm_type ( & self , cx : & CodegenCx < ' ll , ' _ > ) -> & ' ll Type {
129130 let rest_ll_unit = self . rest . unit . llvm_type ( cx) ;
130131 let ( rest_count, rem_bytes) = if self . rest . unit . size . bytes ( ) == 0 {
131132 ( 0 , 0 )
@@ -142,7 +143,7 @@ impl LlvmType for CastTarget {
142143
143144 // Simplify to array when all chunks are the same size and type
144145 if rem_bytes == 0 {
145- return Type :: array ( & rest_ll_unit, rest_count) ;
146+ return Type :: array ( rest_ll_unit, rest_count) ;
146147 }
147148 }
148149
@@ -164,24 +165,24 @@ impl LlvmType for CastTarget {
164165 }
165166}
166167
167- pub trait ArgTypeExt < ' a , ' tcx > {
168- fn memory_ty ( & self , cx : & CodegenCx < ' a , ' tcx > ) -> Type ;
169- fn store ( & self , bx : & Builder < ' a , ' tcx > , val : ValueRef , dst : PlaceRef < ' tcx > ) ;
170- fn store_fn_arg ( & self , bx : & Builder < ' a , ' tcx > , idx : & mut usize , dst : PlaceRef < ' tcx > ) ;
168+ pub trait ArgTypeExt < ' ll , ' tcx > {
169+ fn memory_ty ( & self , cx : & CodegenCx < ' ll , ' tcx > ) -> & ' ll Type ;
170+ fn store ( & self , bx : & Builder < ' _ , ' ll , ' tcx > , val : & ' ll Value , dst : PlaceRef < ' ll , ' tcx > ) ;
171+ fn store_fn_arg ( & self , bx : & Builder < ' _ , ' ll , ' tcx > , idx : & mut usize , dst : PlaceRef < ' ll , ' tcx > ) ;
171172}
172173
173- impl < ' a , ' tcx > ArgTypeExt < ' a , ' tcx > for ArgType < ' tcx , Ty < ' tcx > > {
174+ impl ArgTypeExt < ' ll , ' tcx > for ArgType < ' tcx , Ty < ' tcx > > {
174175 /// Get the LLVM type for a place of the original Rust type of
175176 /// this argument/return, i.e. the result of `type_of::type_of`.
176- fn memory_ty ( & self , cx : & CodegenCx < ' a , ' tcx > ) -> Type {
177+ fn memory_ty ( & self , cx : & CodegenCx < ' ll , ' tcx > ) -> & ' ll Type {
177178 self . layout . llvm_type ( cx)
178179 }
179180
180181 /// Store a direct/indirect value described by this ArgType into a
181182 /// place for the original Rust type of this argument/return.
182183 /// Can be used for both storing formal arguments into Rust variables
183184 /// or results of call/invoke instructions into their destinations.
184- fn store ( & self , bx : & Builder < ' a , ' tcx > , val : ValueRef , dst : PlaceRef < ' tcx > ) {
185+ fn store ( & self , bx : & Builder < ' _ , ' ll , ' tcx > , val : & ' ll Value , dst : PlaceRef < ' ll , ' tcx > ) {
185186 if self . is_ignore ( ) {
186187 return ;
187188 }
@@ -234,7 +235,7 @@ impl<'a, 'tcx> ArgTypeExt<'a, 'tcx> for ArgType<'tcx, Ty<'tcx>> {
234235 }
235236 }
236237
237- fn store_fn_arg ( & self , bx : & Builder < ' a , ' tcx > , idx : & mut usize , dst : PlaceRef < ' tcx > ) {
238+ fn store_fn_arg ( & self , bx : & Builder < ' a , ' ll , ' tcx > , idx : & mut usize , dst : PlaceRef < ' ll , ' tcx > ) {
238239 let mut next = || {
239240 let val = llvm:: get_param ( bx. llfn ( ) , * idx as c_uint ) ;
240241 * idx += 1 ;
@@ -252,48 +253,48 @@ impl<'a, 'tcx> ArgTypeExt<'a, 'tcx> for ArgType<'tcx, Ty<'tcx>> {
252253 }
253254}
254255
255- pub trait FnTypeExt < ' a , ' tcx > {
256- fn of_instance ( cx : & CodegenCx < ' a , ' tcx > , instance : & ty:: Instance < ' tcx > )
256+ pub trait FnTypeExt < ' tcx > {
257+ fn of_instance ( cx : & CodegenCx < ' ll , ' tcx > , instance : & ty:: Instance < ' tcx > )
257258 -> Self ;
258- fn new ( cx : & CodegenCx < ' a , ' tcx > ,
259+ fn new ( cx : & CodegenCx < ' ll , ' tcx > ,
259260 sig : ty:: FnSig < ' tcx > ,
260261 extra_args : & [ Ty < ' tcx > ] ) -> Self ;
261- fn new_vtable ( cx : & CodegenCx < ' a , ' tcx > ,
262+ fn new_vtable ( cx : & CodegenCx < ' ll , ' tcx > ,
262263 sig : ty:: FnSig < ' tcx > ,
263264 extra_args : & [ Ty < ' tcx > ] ) -> Self ;
264265 fn new_internal (
265- cx : & CodegenCx < ' a , ' tcx > ,
266+ cx : & CodegenCx < ' ll , ' tcx > ,
266267 sig : ty:: FnSig < ' tcx > ,
267268 extra_args : & [ Ty < ' tcx > ] ,
268269 mk_arg_type : impl Fn ( Ty < ' tcx > , Option < usize > ) -> ArgType < ' tcx , Ty < ' tcx > > ,
269270 ) -> Self ;
270271 fn adjust_for_abi ( & mut self ,
271- cx : & CodegenCx < ' a , ' tcx > ,
272+ cx : & CodegenCx < ' ll , ' tcx > ,
272273 abi : Abi ) ;
273- fn llvm_type ( & self , cx : & CodegenCx < ' a , ' tcx > ) -> Type ;
274+ fn llvm_type ( & self , cx : & CodegenCx < ' ll , ' tcx > ) -> & ' ll Type ;
274275 fn llvm_cconv ( & self ) -> llvm:: CallConv ;
275- fn apply_attrs_llfn ( & self , llfn : ValueRef ) ;
276- fn apply_attrs_callsite ( & self , bx : & Builder < ' a , ' tcx > , callsite : ValueRef ) ;
276+ fn apply_attrs_llfn ( & self , llfn : & ' ll Value ) ;
277+ fn apply_attrs_callsite ( & self , bx : & Builder < ' a , ' ll , ' tcx > , callsite : & ' ll Value ) ;
277278}
278279
279- impl < ' a , ' tcx > FnTypeExt < ' a , ' tcx > for FnType < ' tcx , Ty < ' tcx > > {
280- fn of_instance ( cx : & CodegenCx < ' a , ' tcx > , instance : & ty:: Instance < ' tcx > )
280+ impl < ' tcx > FnTypeExt < ' tcx > for FnType < ' tcx , Ty < ' tcx > > {
281+ fn of_instance ( cx : & CodegenCx < ' ll , ' tcx > , instance : & ty:: Instance < ' tcx > )
281282 -> Self {
282283 let fn_ty = instance. ty ( cx. tcx ) ;
283284 let sig = ty_fn_sig ( cx, fn_ty) ;
284285 let sig = cx. tcx . normalize_erasing_late_bound_regions ( ty:: ParamEnv :: reveal_all ( ) , & sig) ;
285286 FnType :: new ( cx, sig, & [ ] )
286287 }
287288
288- fn new ( cx : & CodegenCx < ' a , ' tcx > ,
289+ fn new ( cx : & CodegenCx < ' ll , ' tcx > ,
289290 sig : ty:: FnSig < ' tcx > ,
290291 extra_args : & [ Ty < ' tcx > ] ) -> Self {
291292 FnType :: new_internal ( cx, sig, extra_args, |ty, _| {
292293 ArgType :: new ( cx. layout_of ( ty) )
293294 } )
294295 }
295296
296- fn new_vtable ( cx : & CodegenCx < ' a , ' tcx > ,
297+ fn new_vtable ( cx : & CodegenCx < ' ll , ' tcx > ,
297298 sig : ty:: FnSig < ' tcx > ,
298299 extra_args : & [ Ty < ' tcx > ] ) -> Self {
299300 FnType :: new_internal ( cx, sig, extra_args, |ty, arg_idx| {
@@ -316,7 +317,7 @@ impl<'a, 'tcx> FnTypeExt<'a, 'tcx> for FnType<'tcx, Ty<'tcx>> {
316317 }
317318
318319 fn new_internal (
319- cx : & CodegenCx < ' a , ' tcx > ,
320+ cx : & CodegenCx < ' ll , ' tcx > ,
320321 sig : ty:: FnSig < ' tcx > ,
321322 extra_args : & [ Ty < ' tcx > ] ,
322323 mk_arg_type : impl Fn ( Ty < ' tcx > , Option < usize > ) -> ArgType < ' tcx , Ty < ' tcx > > ,
@@ -497,7 +498,7 @@ impl<'a, 'tcx> FnTypeExt<'a, 'tcx> for FnType<'tcx, Ty<'tcx>> {
497498 }
498499
499500 fn adjust_for_abi ( & mut self ,
500- cx : & CodegenCx < ' a , ' tcx > ,
501+ cx : & CodegenCx < ' ll , ' tcx > ,
501502 abi : Abi ) {
502503 if abi == Abi :: Unadjusted { return }
503504
@@ -564,7 +565,7 @@ impl<'a, 'tcx> FnTypeExt<'a, 'tcx> for FnType<'tcx, Ty<'tcx>> {
564565 }
565566 }
566567
567- fn llvm_type ( & self , cx : & CodegenCx < ' a , ' tcx > ) -> Type {
568+ fn llvm_type ( & self , cx : & CodegenCx < ' ll , ' tcx > ) -> & ' ll Type {
568569 let args_capacity: usize = self . args . iter ( ) . map ( |arg|
569570 if arg. pad . is_some ( ) { 1 } else { 0 } +
570571 if let PassMode :: Pair ( _, _) = arg. mode { 2 } else { 1 }
@@ -606,9 +607,9 @@ impl<'a, 'tcx> FnTypeExt<'a, 'tcx> for FnType<'tcx, Ty<'tcx>> {
606607 }
607608
608609 if self . variadic {
609- Type :: variadic_func ( & llargument_tys, & llreturn_ty)
610+ Type :: variadic_func ( & llargument_tys, llreturn_ty)
610611 } else {
611- Type :: func ( & llargument_tys, & llreturn_ty)
612+ Type :: func ( & llargument_tys, llreturn_ty)
612613 }
613614 }
614615
@@ -629,7 +630,7 @@ impl<'a, 'tcx> FnTypeExt<'a, 'tcx> for FnType<'tcx, Ty<'tcx>> {
629630 }
630631 }
631632
632- fn apply_attrs_llfn ( & self , llfn : ValueRef ) {
633+ fn apply_attrs_llfn ( & self , llfn : & ' ll Value ) {
633634 let mut i = 0 ;
634635 let mut apply = |attrs : & ArgAttributes | {
635636 attrs. apply_llfn ( llvm:: AttributePlace :: Argument ( i) , llfn) ;
@@ -659,7 +660,7 @@ impl<'a, 'tcx> FnTypeExt<'a, 'tcx> for FnType<'tcx, Ty<'tcx>> {
659660 }
660661 }
661662
662- fn apply_attrs_callsite ( & self , bx : & Builder < ' a , ' tcx > , callsite : ValueRef ) {
663+ fn apply_attrs_callsite ( & self , bx : & Builder < ' a , ' ll , ' tcx > , callsite : & ' ll Value ) {
663664 let mut i = 0 ;
664665 let mut apply = |attrs : & ArgAttributes | {
665666 attrs. apply_callsite ( llvm:: AttributePlace :: Argument ( i) , callsite) ;
0 commit comments