@@ -31,16 +31,16 @@ use super::place::PlaceRef;
3131/// uniquely determined by the value's type, but is kept as a
3232/// safety check.
3333#[ derive( Copy , Clone , Debug ) ]
34- pub enum OperandValue < ' ll > {
34+ pub enum OperandValue < V > {
3535 /// A reference to the actual operand. The data is guaranteed
3636 /// to be valid for the operand's lifetime.
3737 /// The second value, if any, is the extra data (vtable or length)
3838 /// which indicates that it refers to an unsized rvalue.
39- Ref ( & ' ll Value , Option < & ' ll Value > , Align ) ,
39+ Ref ( V , Option < V > , Align ) ,
4040 /// A single LLVM value.
41- Immediate ( & ' ll Value ) ,
41+ Immediate ( V ) ,
4242 /// A pair of immediate LLVM values. Used by fat pointers too.
43- Pair ( & ' ll Value , & ' ll Value )
43+ Pair ( V , V )
4444}
4545
4646/// An `OperandRef` is an "SSA" reference to a Rust value, along with
@@ -52,23 +52,23 @@ pub enum OperandValue<'ll> {
5252/// directly is sure to cause problems -- use `OperandRef::store`
5353/// instead.
5454#[ derive( Copy , Clone ) ]
55- pub struct OperandRef < ' ll , ' tcx > {
55+ pub struct OperandRef < ' tcx , V > {
5656 // The value.
57- pub val : OperandValue < ' ll > ,
57+ pub val : OperandValue < V > ,
5858
5959 // The layout of value, based on its Rust type.
6060 pub layout : TyLayout < ' tcx > ,
6161}
6262
63- impl fmt:: Debug for OperandRef < ' ll , ' tcx > {
63+ impl fmt:: Debug for OperandRef < ' tcx , & ' ll Value > {
6464 fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
6565 write ! ( f, "OperandRef({:?} @ {:?})" , self . val, self . layout)
6666 }
6767}
6868
69- impl OperandRef < ' ll , ' tcx > {
69+ impl OperandRef < ' tcx , & ' ll Value > {
7070 pub fn new_zst ( cx : & CodegenCx < ' ll , ' tcx > ,
71- layout : TyLayout < ' tcx > ) -> OperandRef < ' ll , ' tcx > {
71+ layout : TyLayout < ' tcx > ) -> OperandRef < ' tcx , & ' ll Value > {
7272 assert ! ( layout. is_zst( ) ) ;
7373 OperandRef {
7474 val : OperandValue :: Immediate ( C_undef ( layout. immediate_llvm_type ( cx) ) ) ,
@@ -78,7 +78,7 @@ impl OperandRef<'ll, 'tcx> {
7878
7979 pub fn from_const ( bx : & Builder < ' a , ' ll , ' tcx > ,
8080 val : & ' tcx ty:: Const < ' tcx > )
81- -> Result < OperandRef < ' ll , ' tcx > , ErrorHandled > {
81+ -> Result < OperandRef < ' tcx , & ' ll Value > , ErrorHandled > {
8282 let layout = bx. cx . layout_of ( val. ty ) ;
8383
8484 if layout. is_zst ( ) {
@@ -140,7 +140,7 @@ impl OperandRef<'ll, 'tcx> {
140140 }
141141 }
142142
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 > {
144144 let projected_ty = self . layout . ty . builtin_deref ( true )
145145 . unwrap_or_else ( || bug ! ( "deref of non-pointer {:?}" , self ) ) . ty ;
146146 let ( llptr, llextra) = match self . val {
@@ -178,7 +178,7 @@ impl OperandRef<'ll, 'tcx> {
178178 pub fn from_immediate_or_packed_pair ( bx : & Builder < ' a , ' ll , ' tcx > ,
179179 llval : & ' ll Value ,
180180 layout : TyLayout < ' tcx > )
181- -> OperandRef < ' ll , ' tcx > {
181+ -> OperandRef < ' tcx , & ' ll Value > {
182182 let val = if let layout:: Abi :: ScalarPair ( ref a, ref b) = layout. abi {
183183 debug ! ( "Operand::from_immediate_or_packed_pair: unpacking {:?} @ {:?}" ,
184184 llval, layout) ;
@@ -193,7 +193,11 @@ impl OperandRef<'ll, 'tcx> {
193193 OperandRef { val, layout }
194194 }
195195
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 > {
197201 let field = self . layout . field ( bx. cx , i) ;
198202 let offset = self . layout . fields . offset ( i) ;
199203
@@ -251,27 +255,31 @@ impl OperandRef<'ll, 'tcx> {
251255 }
252256}
253257
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 > ) {
256260 self . store_with_flags ( bx, dest, MemFlags :: empty ( ) ) ;
257261 }
258262
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 > ) {
260264 self . store_with_flags ( bx, dest, MemFlags :: VOLATILE ) ;
261265 }
262266
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+ ) {
264272 self . store_with_flags ( bx, dest, MemFlags :: VOLATILE | MemFlags :: UNALIGNED ) ;
265273 }
266274
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 > ) {
268276 self . store_with_flags ( bx, dest, MemFlags :: NONTEMPORAL ) ;
269277 }
270278
271279 fn store_with_flags (
272280 self ,
273281 bx : & Builder < ' a , ' ll , ' tcx > ,
274- dest : PlaceRef < ' ll , ' tcx > ,
282+ dest : PlaceRef < ' tcx , & ' ll Value > ,
275283 flags : MemFlags ,
276284 ) {
277285 debug ! ( "OperandRef::store: operand={:?}, dest={:?}" , self , dest) ;
@@ -302,7 +310,11 @@ impl OperandValue<'ll> {
302310 }
303311 }
304312
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+ ) {
306318 debug ! ( "OperandRef::store_unsized: operand={:?}, indirect_dest={:?}" , self , indirect_dest) ;
307319 let flags = MemFlags :: empty ( ) ;
308320
@@ -336,7 +348,7 @@ impl FunctionCx<'a, 'll, 'tcx> {
336348 fn maybe_codegen_consume_direct ( & mut self ,
337349 bx : & Builder < ' a , ' ll , ' tcx > ,
338350 place : & mir:: Place < ' tcx > )
339- -> Option < OperandRef < ' ll , ' tcx > >
351+ -> Option < OperandRef < ' tcx , & ' ll Value > >
340352 {
341353 debug ! ( "maybe_codegen_consume_direct(place={:?})" , place) ;
342354
@@ -384,7 +396,7 @@ impl FunctionCx<'a, 'll, 'tcx> {
384396 pub fn codegen_consume ( & mut self ,
385397 bx : & Builder < ' a , ' ll , ' tcx > ,
386398 place : & mir:: Place < ' tcx > )
387- -> OperandRef < ' ll , ' tcx >
399+ -> OperandRef < ' tcx , & ' ll Value >
388400 {
389401 debug ! ( "codegen_consume(place={:?})" , place) ;
390402
@@ -408,7 +420,7 @@ impl FunctionCx<'a, 'll, 'tcx> {
408420 pub fn codegen_operand ( & mut self ,
409421 bx : & Builder < ' a , ' ll , ' tcx > ,
410422 operand : & mir:: Operand < ' tcx > )
411- -> OperandRef < ' ll , ' tcx >
423+ -> OperandRef < ' tcx , & ' ll Value >
412424 {
413425 debug ! ( "codegen_operand(operand={:?})" , operand) ;
414426
0 commit comments