@@ -31,16 +31,16 @@ use super::place::PlaceRef;
31
31
/// uniquely determined by the value's type, but is kept as a
32
32
/// safety check.
33
33
#[ derive( Copy , Clone , Debug ) ]
34
- pub enum OperandValue < ' ll > {
34
+ pub enum OperandValue < V > {
35
35
/// A reference to the actual operand. The data is guaranteed
36
36
/// to be valid for the operand's lifetime.
37
37
/// The second value, if any, is the extra data (vtable or length)
38
38
/// which indicates that it refers to an unsized rvalue.
39
- Ref ( & ' ll Value , Option < & ' ll Value > , Align ) ,
39
+ Ref ( V , Option < V > , Align ) ,
40
40
/// A single LLVM value.
41
- Immediate ( & ' ll Value ) ,
41
+ Immediate ( V ) ,
42
42
/// A pair of immediate LLVM values. Used by fat pointers too.
43
- Pair ( & ' ll Value , & ' ll Value )
43
+ Pair ( V , V )
44
44
}
45
45
46
46
/// An `OperandRef` is an "SSA" reference to a Rust value, along with
@@ -52,23 +52,23 @@ pub enum OperandValue<'ll> {
52
52
/// directly is sure to cause problems -- use `OperandRef::store`
53
53
/// instead.
54
54
#[ derive( Copy , Clone ) ]
55
- pub struct OperandRef < ' ll , ' tcx > {
55
+ pub struct OperandRef < ' tcx , V > {
56
56
// The value.
57
- pub val : OperandValue < ' ll > ,
57
+ pub val : OperandValue < V > ,
58
58
59
59
// The layout of value, based on its Rust type.
60
60
pub layout : TyLayout < ' tcx > ,
61
61
}
62
62
63
- impl fmt:: Debug for OperandRef < ' ll , ' tcx > {
63
+ impl fmt:: Debug for OperandRef < ' tcx , & ' ll Value > {
64
64
fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
65
65
write ! ( f, "OperandRef({:?} @ {:?})" , self . val, self . layout)
66
66
}
67
67
}
68
68
69
- impl OperandRef < ' ll , ' tcx > {
69
+ impl OperandRef < ' tcx , & ' ll Value > {
70
70
pub fn new_zst ( cx : & CodegenCx < ' ll , ' tcx > ,
71
- layout : TyLayout < ' tcx > ) -> OperandRef < ' ll , ' tcx > {
71
+ layout : TyLayout < ' tcx > ) -> OperandRef < ' tcx , & ' ll Value > {
72
72
assert ! ( layout. is_zst( ) ) ;
73
73
OperandRef {
74
74
val : OperandValue :: Immediate ( C_undef ( layout. immediate_llvm_type ( cx) ) ) ,
@@ -78,7 +78,7 @@ impl OperandRef<'ll, 'tcx> {
78
78
79
79
pub fn from_const ( bx : & Builder < ' a , ' ll , ' tcx > ,
80
80
val : & ' tcx ty:: Const < ' tcx > )
81
- -> Result < OperandRef < ' ll , ' tcx > , ErrorHandled > {
81
+ -> Result < OperandRef < ' tcx , & ' ll Value > , ErrorHandled > {
82
82
let layout = bx. cx . layout_of ( val. ty ) ;
83
83
84
84
if layout. is_zst ( ) {
@@ -140,7 +140,7 @@ impl OperandRef<'ll, 'tcx> {
140
140
}
141
141
}
142
142
143
- pub fn deref ( self , cx : & CodegenCx < ' ll , ' tcx > ) -> PlaceRef < ' ll , ' tcx > {
143
+ pub fn deref ( self , cx : & CodegenCx < ' ll , ' tcx > ) -> PlaceRef < ' tcx , & ' ll Value > {
144
144
let projected_ty = self . layout . ty . builtin_deref ( true )
145
145
. unwrap_or_else ( || bug ! ( "deref of non-pointer {:?}" , self ) ) . ty ;
146
146
let ( llptr, llextra) = match self . val {
@@ -178,7 +178,7 @@ impl OperandRef<'ll, 'tcx> {
178
178
pub fn from_immediate_or_packed_pair ( bx : & Builder < ' a , ' ll , ' tcx > ,
179
179
llval : & ' ll Value ,
180
180
layout : TyLayout < ' tcx > )
181
- -> OperandRef < ' ll , ' tcx > {
181
+ -> OperandRef < ' tcx , & ' ll Value > {
182
182
let val = if let layout:: Abi :: ScalarPair ( ref a, ref b) = layout. abi {
183
183
debug ! ( "Operand::from_immediate_or_packed_pair: unpacking {:?} @ {:?}" ,
184
184
llval, layout) ;
@@ -193,7 +193,11 @@ impl OperandRef<'ll, 'tcx> {
193
193
OperandRef { val, layout }
194
194
}
195
195
196
- pub fn extract_field ( & self , bx : & Builder < ' a , ' ll , ' tcx > , i : usize ) -> OperandRef < ' ll , ' tcx > {
196
+ pub fn extract_field (
197
+ & self ,
198
+ bx : & Builder < ' a , ' ll , ' tcx > ,
199
+ i : usize ,
200
+ ) -> OperandRef < ' tcx , & ' ll Value > {
197
201
let field = self . layout . field ( bx. cx , i) ;
198
202
let offset = self . layout . fields . offset ( i) ;
199
203
@@ -251,27 +255,31 @@ impl OperandRef<'ll, 'tcx> {
251
255
}
252
256
}
253
257
254
- impl OperandValue < ' ll > {
255
- pub fn store ( self , bx : & Builder < ' a , ' ll , ' tcx > , dest : PlaceRef < ' ll , ' tcx > ) {
258
+ impl OperandValue < & ' ll Value > {
259
+ pub fn store ( self , bx : & Builder < ' a , ' ll , ' tcx > , dest : PlaceRef < ' tcx , & ' ll Value > ) {
256
260
self . store_with_flags ( bx, dest, MemFlags :: empty ( ) ) ;
257
261
}
258
262
259
- pub fn volatile_store ( self , bx : & Builder < ' a , ' ll , ' tcx > , dest : PlaceRef < ' ll , ' tcx > ) {
263
+ pub fn volatile_store ( self , bx : & Builder < ' a , ' ll , ' tcx > , dest : PlaceRef < ' tcx , & ' ll Value > ) {
260
264
self . store_with_flags ( bx, dest, MemFlags :: VOLATILE ) ;
261
265
}
262
266
263
- pub fn unaligned_volatile_store ( self , bx : & Builder < ' a , ' ll , ' tcx > , dest : PlaceRef < ' ll , ' tcx > ) {
267
+ pub fn unaligned_volatile_store (
268
+ self ,
269
+ bx : & Builder < ' a , ' ll , ' tcx > ,
270
+ dest : PlaceRef < ' tcx , & ' ll Value > ,
271
+ ) {
264
272
self . store_with_flags ( bx, dest, MemFlags :: VOLATILE | MemFlags :: UNALIGNED ) ;
265
273
}
266
274
267
- pub fn nontemporal_store ( self , bx : & Builder < ' a , ' ll , ' tcx > , dest : PlaceRef < ' ll , ' tcx > ) {
275
+ pub fn nontemporal_store ( self , bx : & Builder < ' a , ' ll , ' tcx > , dest : PlaceRef < ' tcx , & ' ll Value > ) {
268
276
self . store_with_flags ( bx, dest, MemFlags :: NONTEMPORAL ) ;
269
277
}
270
278
271
279
fn store_with_flags (
272
280
self ,
273
281
bx : & Builder < ' a , ' ll , ' tcx > ,
274
- dest : PlaceRef < ' ll , ' tcx > ,
282
+ dest : PlaceRef < ' tcx , & ' ll Value > ,
275
283
flags : MemFlags ,
276
284
) {
277
285
debug ! ( "OperandRef::store: operand={:?}, dest={:?}" , self , dest) ;
@@ -302,7 +310,11 @@ impl OperandValue<'ll> {
302
310
}
303
311
}
304
312
305
- pub fn store_unsized ( self , bx : & Builder < ' a , ' ll , ' tcx > , indirect_dest : PlaceRef < ' ll , ' tcx > ) {
313
+ pub fn store_unsized (
314
+ self ,
315
+ bx : & Builder < ' a , ' ll , ' tcx > ,
316
+ indirect_dest : PlaceRef < ' tcx , & ' ll Value > ,
317
+ ) {
306
318
debug ! ( "OperandRef::store_unsized: operand={:?}, indirect_dest={:?}" , self , indirect_dest) ;
307
319
let flags = MemFlags :: empty ( ) ;
308
320
@@ -336,7 +348,7 @@ impl FunctionCx<'a, 'll, 'tcx> {
336
348
fn maybe_codegen_consume_direct ( & mut self ,
337
349
bx : & Builder < ' a , ' ll , ' tcx > ,
338
350
place : & mir:: Place < ' tcx > )
339
- -> Option < OperandRef < ' ll , ' tcx > >
351
+ -> Option < OperandRef < ' tcx , & ' ll Value > >
340
352
{
341
353
debug ! ( "maybe_codegen_consume_direct(place={:?})" , place) ;
342
354
@@ -384,7 +396,7 @@ impl FunctionCx<'a, 'll, 'tcx> {
384
396
pub fn codegen_consume ( & mut self ,
385
397
bx : & Builder < ' a , ' ll , ' tcx > ,
386
398
place : & mir:: Place < ' tcx > )
387
- -> OperandRef < ' ll , ' tcx >
399
+ -> OperandRef < ' tcx , & ' ll Value >
388
400
{
389
401
debug ! ( "codegen_consume(place={:?})" , place) ;
390
402
@@ -408,7 +420,7 @@ impl FunctionCx<'a, 'll, 'tcx> {
408
420
pub fn codegen_operand ( & mut self ,
409
421
bx : & Builder < ' a , ' ll , ' tcx > ,
410
422
operand : & mir:: Operand < ' tcx > )
411
- -> OperandRef < ' ll , ' tcx >
423
+ -> OperandRef < ' tcx , & ' ll Value >
412
424
{
413
425
debug ! ( "codegen_operand(operand={:?})" , operand) ;
414
426
0 commit comments