@@ -10,7 +10,7 @@ use crate::traits::*;
1010use rustc:: ty:: { self , Ty , adjustment:: { PointerCast } , Instance } ;
1111use rustc:: ty:: cast:: { CastTy , IntTy } ;
1212use rustc:: ty:: layout:: { self , LayoutOf , HasTyCtxt } ;
13- use rustc:: mir:: { self , Body } ;
13+ use rustc:: mir;
1414use rustc:: middle:: lang_items:: ExchangeMallocFnLangItem ;
1515use rustc_apfloat:: { ieee, Float , Status , Round } ;
1616use syntax:: symbol:: sym;
@@ -21,7 +21,6 @@ use std::{u128, i128};
2121impl < ' a , ' b , ' tcx , Bx : BuilderMethods < ' a , ' tcx > > FunctionCx < ' a , ' b , ' tcx , Bx > {
2222 pub fn codegen_rvalue (
2323 & mut self ,
24- mir : & Body < ' tcx > ,
2524 mut bx : Bx ,
2625 dest : PlaceRef < ' tcx , Bx :: Value > ,
2726 rvalue : & mir:: Rvalue < ' tcx >
@@ -31,7 +30,7 @@ impl<'a, 'b, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'b, 'tcx, Bx> {
3130
3231 match * rvalue {
3332 mir:: Rvalue :: Use ( ref operand) => {
34- let cg_operand = self . codegen_operand ( mir , & mut bx, operand) ;
33+ let cg_operand = self . codegen_operand ( & mut bx, operand) ;
3534 // FIXME: consider not copying constants through stack. (Fixable by codegen'ing
3635 // constants into `OperandValue::Ref`; why don’t we do that yet if we don’t?)
3736 cg_operand. val . store ( & mut bx, dest) ;
@@ -44,7 +43,7 @@ impl<'a, 'b, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'b, 'tcx, Bx> {
4443 if bx. cx ( ) . is_backend_scalar_pair ( dest. layout ) {
4544 // Into-coerce of a thin pointer to a fat pointer -- just
4645 // use the operand path.
47- let ( mut bx, temp) = self . codegen_rvalue_operand ( mir , bx, rvalue) ;
46+ let ( mut bx, temp) = self . codegen_rvalue_operand ( bx, rvalue) ;
4847 temp. val . store ( & mut bx, dest) ;
4948 return bx;
5049 }
@@ -53,7 +52,7 @@ impl<'a, 'b, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'b, 'tcx, Bx> {
5352 // this to be eliminated by MIR building, but
5453 // `CoerceUnsized` can be passed by a where-clause,
5554 // so the (generic) MIR may not be able to expand it.
56- let operand = self . codegen_operand ( mir , & mut bx, source) ;
55+ let operand = self . codegen_operand ( & mut bx, source) ;
5756 match operand. val {
5857 OperandValue :: Pair ( ..) |
5958 OperandValue :: Immediate ( _) => {
@@ -82,7 +81,7 @@ impl<'a, 'b, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'b, 'tcx, Bx> {
8281 }
8382
8483 mir:: Rvalue :: Repeat ( ref elem, count) => {
85- let cg_elem = self . codegen_operand ( mir , & mut bx, elem) ;
84+ let cg_elem = self . codegen_operand ( & mut bx, elem) ;
8685
8786 // Do not generate the loop for zero-sized elements or empty arrays.
8887 if dest. layout . is_zst ( ) {
@@ -125,7 +124,7 @@ impl<'a, 'b, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'b, 'tcx, Bx> {
125124 _ => ( dest, None )
126125 } ;
127126 for ( i, operand) in operands. iter ( ) . enumerate ( ) {
128- let op = self . codegen_operand ( mir , & mut bx, operand) ;
127+ let op = self . codegen_operand ( & mut bx, operand) ;
129128 // Do not generate stores and GEPis for zero-sized fields.
130129 if !op. layout . is_zst ( ) {
131130 let field_index = active_field_index. unwrap_or ( i) ;
@@ -137,8 +136,8 @@ impl<'a, 'b, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'b, 'tcx, Bx> {
137136 }
138137
139138 _ => {
140- assert ! ( self . rvalue_creates_operand( rvalue, DUMMY_SP , mir ) ) ;
141- let ( mut bx, temp) = self . codegen_rvalue_operand ( mir , bx, rvalue) ;
139+ assert ! ( self . rvalue_creates_operand( rvalue, DUMMY_SP ) ) ;
140+ let ( mut bx, temp) = self . codegen_rvalue_operand ( bx, rvalue) ;
142141 temp. val . store ( & mut bx, dest) ;
143142 bx
144143 }
@@ -147,7 +146,6 @@ impl<'a, 'b, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'b, 'tcx, Bx> {
147146
148147 pub fn codegen_rvalue_unsized (
149148 & mut self ,
150- mir : & Body < ' tcx > ,
151149 mut bx : Bx ,
152150 indirect_dest : PlaceRef < ' tcx , Bx :: Value > ,
153151 rvalue : & mir:: Rvalue < ' tcx > ,
@@ -157,7 +155,7 @@ impl<'a, 'b, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'b, 'tcx, Bx> {
157155
158156 match * rvalue {
159157 mir:: Rvalue :: Use ( ref operand) => {
160- let cg_operand = self . codegen_operand ( mir , & mut bx, operand) ;
158+ let cg_operand = self . codegen_operand ( & mut bx, operand) ;
161159 cg_operand. val . store_unsized ( & mut bx, indirect_dest) ;
162160 bx
163161 }
@@ -168,19 +166,18 @@ impl<'a, 'b, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'b, 'tcx, Bx> {
168166
169167 pub fn codegen_rvalue_operand (
170168 & mut self ,
171- mir : & Body < ' tcx > ,
172169 mut bx : Bx ,
173170 rvalue : & mir:: Rvalue < ' tcx >
174171 ) -> ( Bx , OperandRef < ' tcx , Bx :: Value > ) {
175172 assert ! (
176- self . rvalue_creates_operand( rvalue, DUMMY_SP , mir ) ,
173+ self . rvalue_creates_operand( rvalue, DUMMY_SP ) ,
177174 "cannot codegen {:?} to operand" ,
178175 rvalue,
179176 ) ;
180177
181178 match * rvalue {
182179 mir:: Rvalue :: Cast ( ref kind, ref source, mir_cast_ty) => {
183- let operand = self . codegen_operand ( mir , & mut bx, source) ;
180+ let operand = self . codegen_operand ( & mut bx, source) ;
184181 debug ! ( "cast operand is {:?}" , operand) ;
185182 let cast = bx. cx ( ) . layout_of ( self . monomorphize ( & mir_cast_ty) ) ;
186183
@@ -373,7 +370,7 @@ impl<'a, 'b, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'b, 'tcx, Bx> {
373370 }
374371
375372 mir:: Rvalue :: Ref ( _, bk, ref place) => {
376- let cg_place = self . codegen_place ( mir , & mut bx, & place. as_ref ( ) ) ;
373+ let cg_place = self . codegen_place ( & mut bx, & place. as_ref ( ) ) ;
377374
378375 let ty = cg_place. layout . ty ;
379376
@@ -394,7 +391,7 @@ impl<'a, 'b, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'b, 'tcx, Bx> {
394391 }
395392
396393 mir:: Rvalue :: Len ( ref place) => {
397- let size = self . evaluate_array_len ( mir , & mut bx, place) ;
394+ let size = self . evaluate_array_len ( & mut bx, place) ;
398395 let operand = OperandRef {
399396 val : OperandValue :: Immediate ( size) ,
400397 layout : bx. cx ( ) . layout_of ( bx. tcx ( ) . types . usize ) ,
@@ -403,8 +400,8 @@ impl<'a, 'b, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'b, 'tcx, Bx> {
403400 }
404401
405402 mir:: Rvalue :: BinaryOp ( op, ref lhs, ref rhs) => {
406- let lhs = self . codegen_operand ( mir , & mut bx, lhs) ;
407- let rhs = self . codegen_operand ( mir , & mut bx, rhs) ;
403+ let lhs = self . codegen_operand ( & mut bx, lhs) ;
404+ let rhs = self . codegen_operand ( & mut bx, rhs) ;
408405 let llresult = match ( lhs. val , rhs. val ) {
409406 ( OperandValue :: Pair ( lhs_addr, lhs_extra) ,
410407 OperandValue :: Pair ( rhs_addr, rhs_extra) ) => {
@@ -429,8 +426,8 @@ impl<'a, 'b, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'b, 'tcx, Bx> {
429426 ( bx, operand)
430427 }
431428 mir:: Rvalue :: CheckedBinaryOp ( op, ref lhs, ref rhs) => {
432- let lhs = self . codegen_operand ( mir , & mut bx, lhs) ;
433- let rhs = self . codegen_operand ( mir , & mut bx, rhs) ;
429+ let lhs = self . codegen_operand ( & mut bx, lhs) ;
430+ let rhs = self . codegen_operand ( & mut bx, rhs) ;
434431 let result = self . codegen_scalar_checked_binop ( & mut bx, op,
435432 lhs. immediate ( ) , rhs. immediate ( ) ,
436433 lhs. layout . ty ) ;
@@ -445,7 +442,7 @@ impl<'a, 'b, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'b, 'tcx, Bx> {
445442 }
446443
447444 mir:: Rvalue :: UnaryOp ( op, ref operand) => {
448- let operand = self . codegen_operand ( mir , & mut bx, operand) ;
445+ let operand = self . codegen_operand ( & mut bx, operand) ;
449446 let lloperand = operand. immediate ( ) ;
450447 let is_float = operand. layout . ty . is_floating_point ( ) ;
451448 let llval = match op {
@@ -463,8 +460,8 @@ impl<'a, 'b, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'b, 'tcx, Bx> {
463460 }
464461
465462 mir:: Rvalue :: Discriminant ( ref place) => {
466- let discr_ty = rvalue. ty ( mir, bx. tcx ( ) ) ;
467- let discr = self . codegen_place ( mir , & mut bx, & place. as_ref ( ) )
463+ let discr_ty = rvalue. ty ( self . mir , bx. tcx ( ) ) ;
464+ let discr = self . codegen_place ( & mut bx, & place. as_ref ( ) )
468465 . codegen_get_discr ( & mut bx, discr_ty) ;
469466 ( bx, OperandRef {
470467 val : OperandValue :: Immediate ( discr) ,
@@ -509,14 +506,14 @@ impl<'a, 'b, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'b, 'tcx, Bx> {
509506 ( bx, operand)
510507 }
511508 mir:: Rvalue :: Use ( ref operand) => {
512- let operand = self . codegen_operand ( mir , & mut bx, operand) ;
509+ let operand = self . codegen_operand ( & mut bx, operand) ;
513510 ( bx, operand)
514511 }
515512 mir:: Rvalue :: Repeat ( ..) |
516513 mir:: Rvalue :: Aggregate ( ..) => {
517514 // According to `rvalue_creates_operand`, only ZST
518515 // aggregate rvalues are allowed to be operands.
519- let ty = rvalue. ty ( mir, self . cx . tcx ( ) ) ;
516+ let ty = rvalue. ty ( self . mir , self . cx . tcx ( ) ) ;
520517 let operand = OperandRef :: new_zst (
521518 & mut bx,
522519 self . cx . layout_of ( self . monomorphize ( & ty) ) ,
@@ -528,7 +525,6 @@ impl<'a, 'b, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'b, 'tcx, Bx> {
528525
529526 fn evaluate_array_len (
530527 & mut self ,
531- mir : & Body < ' tcx > ,
532528 bx : & mut Bx ,
533529 place : & mir:: Place < ' tcx > ,
534530 ) -> Bx :: Value {
@@ -543,7 +539,7 @@ impl<'a, 'b, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'b, 'tcx, Bx> {
543539 }
544540 }
545541 // use common size calculation for non zero-sized types
546- let cg_value = self . codegen_place ( mir , bx, & place. as_ref ( ) ) ;
542+ let cg_value = self . codegen_place ( bx, & place. as_ref ( ) ) ;
547543 cg_value. len ( bx. cx ( ) )
548544 }
549545
@@ -704,7 +700,6 @@ impl<'a, 'b, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'b, 'tcx, Bx> {
704700 & self ,
705701 rvalue : & mir:: Rvalue < ' tcx > ,
706702 span : Span ,
707- mir : & Body < ' tcx >
708703 ) -> bool {
709704 match * rvalue {
710705 mir:: Rvalue :: Ref ( ..) |
@@ -719,7 +714,7 @@ impl<'a, 'b, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'b, 'tcx, Bx> {
719714 true ,
720715 mir:: Rvalue :: Repeat ( ..) |
721716 mir:: Rvalue :: Aggregate ( ..) => {
722- let ty = rvalue. ty ( mir, self . cx . tcx ( ) ) ;
717+ let ty = rvalue. ty ( self . mir , self . cx . tcx ( ) ) ;
723718 let ty = self . monomorphize ( & ty) ;
724719 self . cx . spanned_layout_of ( ty, span) . is_zst ( )
725720 }
0 commit comments