8
8
// option. This file may not be copied, modified, or distributed
9
9
// except according to those terms.
10
10
11
- use llvm:: { self , ValueRef , AttributePlace } ;
11
+ use llvm:: { self , AttributePlace } ;
12
12
use base;
13
13
use builder:: { Builder , MemFlags } ;
14
14
use common:: { ty_fn_sig, C_usize } ;
@@ -17,6 +17,7 @@ use mir::place::PlaceRef;
17
17
use mir:: operand:: OperandValue ;
18
18
use type_:: Type ;
19
19
use type_of:: { LayoutLlvmExt , PointerKind } ;
20
+ use value:: Value ;
20
21
21
22
use rustc_target:: abi:: { LayoutOf , Size , TyLayout } ;
22
23
use rustc:: ty:: { self , Ty } ;
@@ -46,12 +47,12 @@ impl ArgAttributeExt for ArgAttribute {
46
47
}
47
48
48
49
pub 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 ) ;
51
52
}
52
53
53
54
impl ArgAttributesExt for ArgAttributes {
54
- fn apply_llfn ( & self , idx : AttributePlace , llfn : ValueRef ) {
55
+ fn apply_llfn ( & self , idx : AttributePlace , llfn : & Value ) {
55
56
let mut regular = self . regular ;
56
57
unsafe {
57
58
let deref = self . pointee_size . bytes ( ) ;
@@ -76,7 +77,7 @@ impl ArgAttributesExt for ArgAttributes {
76
77
}
77
78
}
78
79
79
- fn apply_callsite ( & self , idx : AttributePlace , callsite : ValueRef ) {
80
+ fn apply_callsite ( & self , idx : AttributePlace , callsite : & Value ) {
80
81
let mut regular = self . regular ;
81
82
unsafe {
82
83
let deref = self . pointee_size . bytes ( ) ;
@@ -103,11 +104,11 @@ impl ArgAttributesExt for ArgAttributes {
103
104
}
104
105
105
106
pub trait LlvmType {
106
- fn llvm_type ( & self , cx : & CodegenCx ) -> Type ;
107
+ fn llvm_type ( & self , cx : & CodegenCx < ' ll , ' _ > ) -> & ' ll Type ;
107
108
}
108
109
109
110
impl LlvmType for Reg {
110
- fn llvm_type ( & self , cx : & CodegenCx ) -> Type {
111
+ fn llvm_type ( & self , cx : & CodegenCx < ' ll , ' _ > ) -> & ' ll Type {
111
112
match self . kind {
112
113
RegKind :: Integer => Type :: ix ( cx, self . size . bits ( ) ) ,
113
114
RegKind :: Float => {
@@ -118,14 +119,14 @@ impl LlvmType for Reg {
118
119
}
119
120
}
120
121
RegKind :: Vector => {
121
- Type :: vector ( & Type :: i8 ( cx) , self . size . bytes ( ) )
122
+ Type :: vector ( Type :: i8 ( cx) , self . size . bytes ( ) )
122
123
}
123
124
}
124
125
}
125
126
}
126
127
127
128
impl LlvmType for CastTarget {
128
- fn llvm_type ( & self , cx : & CodegenCx ) -> Type {
129
+ fn llvm_type ( & self , cx : & CodegenCx < ' ll , ' _ > ) -> & ' ll Type {
129
130
let rest_ll_unit = self . rest . unit . llvm_type ( cx) ;
130
131
let ( rest_count, rem_bytes) = if self . rest . unit . size . bytes ( ) == 0 {
131
132
( 0 , 0 )
@@ -142,7 +143,7 @@ impl LlvmType for CastTarget {
142
143
143
144
// Simplify to array when all chunks are the same size and type
144
145
if rem_bytes == 0 {
145
- return Type :: array ( & rest_ll_unit, rest_count) ;
146
+ return Type :: array ( rest_ll_unit, rest_count) ;
146
147
}
147
148
}
148
149
@@ -164,24 +165,24 @@ impl LlvmType for CastTarget {
164
165
}
165
166
}
166
167
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 > ) ;
171
172
}
172
173
173
- impl < ' a , ' tcx > ArgTypeExt < ' a , ' tcx > for ArgType < ' tcx , Ty < ' tcx > > {
174
+ impl ArgTypeExt < ' ll , ' tcx > for ArgType < ' tcx , Ty < ' tcx > > {
174
175
/// Get the LLVM type for a place of the original Rust type of
175
176
/// 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 {
177
178
self . layout . llvm_type ( cx)
178
179
}
179
180
180
181
/// Store a direct/indirect value described by this ArgType into a
181
182
/// place for the original Rust type of this argument/return.
182
183
/// Can be used for both storing formal arguments into Rust variables
183
184
/// 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 > ) {
185
186
if self . is_ignore ( ) {
186
187
return ;
187
188
}
@@ -234,7 +235,7 @@ impl<'a, 'tcx> ArgTypeExt<'a, 'tcx> for ArgType<'tcx, Ty<'tcx>> {
234
235
}
235
236
}
236
237
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 > ) {
238
239
let mut next = || {
239
240
let val = llvm:: get_param ( bx. llfn ( ) , * idx as c_uint ) ;
240
241
* idx += 1 ;
@@ -252,48 +253,48 @@ impl<'a, 'tcx> ArgTypeExt<'a, 'tcx> for ArgType<'tcx, Ty<'tcx>> {
252
253
}
253
254
}
254
255
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 > )
257
258
-> Self ;
258
- fn new ( cx : & CodegenCx < ' a , ' tcx > ,
259
+ fn new ( cx : & CodegenCx < ' ll , ' tcx > ,
259
260
sig : ty:: FnSig < ' tcx > ,
260
261
extra_args : & [ Ty < ' tcx > ] ) -> Self ;
261
- fn new_vtable ( cx : & CodegenCx < ' a , ' tcx > ,
262
+ fn new_vtable ( cx : & CodegenCx < ' ll , ' tcx > ,
262
263
sig : ty:: FnSig < ' tcx > ,
263
264
extra_args : & [ Ty < ' tcx > ] ) -> Self ;
264
265
fn new_internal (
265
- cx : & CodegenCx < ' a , ' tcx > ,
266
+ cx : & CodegenCx < ' ll , ' tcx > ,
266
267
sig : ty:: FnSig < ' tcx > ,
267
268
extra_args : & [ Ty < ' tcx > ] ,
268
269
mk_arg_type : impl Fn ( Ty < ' tcx > , Option < usize > ) -> ArgType < ' tcx , Ty < ' tcx > > ,
269
270
) -> Self ;
270
271
fn adjust_for_abi ( & mut self ,
271
- cx : & CodegenCx < ' a , ' tcx > ,
272
+ cx : & CodegenCx < ' ll , ' tcx > ,
272
273
abi : Abi ) ;
273
- fn llvm_type ( & self , cx : & CodegenCx < ' a , ' tcx > ) -> Type ;
274
+ fn llvm_type ( & self , cx : & CodegenCx < ' ll , ' tcx > ) -> & ' ll Type ;
274
275
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 ) ;
277
278
}
278
279
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 > )
281
282
-> Self {
282
283
let fn_ty = instance. ty ( cx. tcx ) ;
283
284
let sig = ty_fn_sig ( cx, fn_ty) ;
284
285
let sig = cx. tcx . normalize_erasing_late_bound_regions ( ty:: ParamEnv :: reveal_all ( ) , & sig) ;
285
286
FnType :: new ( cx, sig, & [ ] )
286
287
}
287
288
288
- fn new ( cx : & CodegenCx < ' a , ' tcx > ,
289
+ fn new ( cx : & CodegenCx < ' ll , ' tcx > ,
289
290
sig : ty:: FnSig < ' tcx > ,
290
291
extra_args : & [ Ty < ' tcx > ] ) -> Self {
291
292
FnType :: new_internal ( cx, sig, extra_args, |ty, _| {
292
293
ArgType :: new ( cx. layout_of ( ty) )
293
294
} )
294
295
}
295
296
296
- fn new_vtable ( cx : & CodegenCx < ' a , ' tcx > ,
297
+ fn new_vtable ( cx : & CodegenCx < ' ll , ' tcx > ,
297
298
sig : ty:: FnSig < ' tcx > ,
298
299
extra_args : & [ Ty < ' tcx > ] ) -> Self {
299
300
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>> {
316
317
}
317
318
318
319
fn new_internal (
319
- cx : & CodegenCx < ' a , ' tcx > ,
320
+ cx : & CodegenCx < ' ll , ' tcx > ,
320
321
sig : ty:: FnSig < ' tcx > ,
321
322
extra_args : & [ Ty < ' tcx > ] ,
322
323
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>> {
497
498
}
498
499
499
500
fn adjust_for_abi ( & mut self ,
500
- cx : & CodegenCx < ' a , ' tcx > ,
501
+ cx : & CodegenCx < ' ll , ' tcx > ,
501
502
abi : Abi ) {
502
503
if abi == Abi :: Unadjusted { return }
503
504
@@ -564,7 +565,7 @@ impl<'a, 'tcx> FnTypeExt<'a, 'tcx> for FnType<'tcx, Ty<'tcx>> {
564
565
}
565
566
}
566
567
567
- fn llvm_type ( & self , cx : & CodegenCx < ' a , ' tcx > ) -> Type {
568
+ fn llvm_type ( & self , cx : & CodegenCx < ' ll , ' tcx > ) -> & ' ll Type {
568
569
let args_capacity: usize = self . args . iter ( ) . map ( |arg|
569
570
if arg. pad . is_some ( ) { 1 } else { 0 } +
570
571
if let PassMode :: Pair ( _, _) = arg. mode { 2 } else { 1 }
@@ -606,9 +607,9 @@ impl<'a, 'tcx> FnTypeExt<'a, 'tcx> for FnType<'tcx, Ty<'tcx>> {
606
607
}
607
608
608
609
if self . variadic {
609
- Type :: variadic_func ( & llargument_tys, & llreturn_ty)
610
+ Type :: variadic_func ( & llargument_tys, llreturn_ty)
610
611
} else {
611
- Type :: func ( & llargument_tys, & llreturn_ty)
612
+ Type :: func ( & llargument_tys, llreturn_ty)
612
613
}
613
614
}
614
615
@@ -629,7 +630,7 @@ impl<'a, 'tcx> FnTypeExt<'a, 'tcx> for FnType<'tcx, Ty<'tcx>> {
629
630
}
630
631
}
631
632
632
- fn apply_attrs_llfn ( & self , llfn : ValueRef ) {
633
+ fn apply_attrs_llfn ( & self , llfn : & ' ll Value ) {
633
634
let mut i = 0 ;
634
635
let mut apply = |attrs : & ArgAttributes | {
635
636
attrs. apply_llfn ( llvm:: AttributePlace :: Argument ( i) , llfn) ;
@@ -659,7 +660,7 @@ impl<'a, 'tcx> FnTypeExt<'a, 'tcx> for FnType<'tcx, Ty<'tcx>> {
659
660
}
660
661
}
661
662
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 ) {
663
664
let mut i = 0 ;
664
665
let mut apply = |attrs : & ArgAttributes | {
665
666
attrs. apply_callsite ( llvm:: AttributePlace :: Argument ( i) , callsite) ;
0 commit comments