@@ -10,7 +10,7 @@ use crate::traits::*;
10
10
use rustc:: ty:: { self , Ty , adjustment:: { PointerCast } , Instance } ;
11
11
use rustc:: ty:: cast:: { CastTy , IntTy } ;
12
12
use rustc:: ty:: layout:: { self , LayoutOf , HasTyCtxt } ;
13
- use rustc:: mir:: { self , Body } ;
13
+ use rustc:: mir;
14
14
use rustc:: middle:: lang_items:: ExchangeMallocFnLangItem ;
15
15
use rustc_apfloat:: { ieee, Float , Status , Round } ;
16
16
use syntax:: symbol:: sym;
@@ -21,7 +21,6 @@ use std::{u128, i128};
21
21
impl < ' a , ' b , ' tcx , Bx : BuilderMethods < ' a , ' tcx > > FunctionCx < ' a , ' b , ' tcx , Bx > {
22
22
pub fn codegen_rvalue (
23
23
& mut self ,
24
- mir : & Body < ' tcx > ,
25
24
mut bx : Bx ,
26
25
dest : PlaceRef < ' tcx , Bx :: Value > ,
27
26
rvalue : & mir:: Rvalue < ' tcx >
@@ -31,7 +30,7 @@ impl<'a, 'b, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'b, 'tcx, Bx> {
31
30
32
31
match * rvalue {
33
32
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) ;
35
34
// FIXME: consider not copying constants through stack. (Fixable by codegen'ing
36
35
// constants into `OperandValue::Ref`; why don’t we do that yet if we don’t?)
37
36
cg_operand. val . store ( & mut bx, dest) ;
@@ -44,7 +43,7 @@ impl<'a, 'b, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'b, 'tcx, Bx> {
44
43
if bx. cx ( ) . is_backend_scalar_pair ( dest. layout ) {
45
44
// Into-coerce of a thin pointer to a fat pointer -- just
46
45
// 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) ;
48
47
temp. val . store ( & mut bx, dest) ;
49
48
return bx;
50
49
}
@@ -53,7 +52,7 @@ impl<'a, 'b, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'b, 'tcx, Bx> {
53
52
// this to be eliminated by MIR building, but
54
53
// `CoerceUnsized` can be passed by a where-clause,
55
54
// 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) ;
57
56
match operand. val {
58
57
OperandValue :: Pair ( ..) |
59
58
OperandValue :: Immediate ( _) => {
@@ -82,7 +81,7 @@ impl<'a, 'b, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'b, 'tcx, Bx> {
82
81
}
83
82
84
83
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) ;
86
85
87
86
// Do not generate the loop for zero-sized elements or empty arrays.
88
87
if dest. layout . is_zst ( ) {
@@ -125,7 +124,7 @@ impl<'a, 'b, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'b, 'tcx, Bx> {
125
124
_ => ( dest, None )
126
125
} ;
127
126
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) ;
129
128
// Do not generate stores and GEPis for zero-sized fields.
130
129
if !op. layout . is_zst ( ) {
131
130
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> {
137
136
}
138
137
139
138
_ => {
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) ;
142
141
temp. val . store ( & mut bx, dest) ;
143
142
bx
144
143
}
@@ -147,7 +146,6 @@ impl<'a, 'b, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'b, 'tcx, Bx> {
147
146
148
147
pub fn codegen_rvalue_unsized (
149
148
& mut self ,
150
- mir : & Body < ' tcx > ,
151
149
mut bx : Bx ,
152
150
indirect_dest : PlaceRef < ' tcx , Bx :: Value > ,
153
151
rvalue : & mir:: Rvalue < ' tcx > ,
@@ -157,7 +155,7 @@ impl<'a, 'b, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'b, 'tcx, Bx> {
157
155
158
156
match * rvalue {
159
157
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) ;
161
159
cg_operand. val . store_unsized ( & mut bx, indirect_dest) ;
162
160
bx
163
161
}
@@ -168,19 +166,18 @@ impl<'a, 'b, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'b, 'tcx, Bx> {
168
166
169
167
pub fn codegen_rvalue_operand (
170
168
& mut self ,
171
- mir : & Body < ' tcx > ,
172
169
mut bx : Bx ,
173
170
rvalue : & mir:: Rvalue < ' tcx >
174
171
) -> ( Bx , OperandRef < ' tcx , Bx :: Value > ) {
175
172
assert ! (
176
- self . rvalue_creates_operand( rvalue, DUMMY_SP , mir ) ,
173
+ self . rvalue_creates_operand( rvalue, DUMMY_SP ) ,
177
174
"cannot codegen {:?} to operand" ,
178
175
rvalue,
179
176
) ;
180
177
181
178
match * rvalue {
182
179
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) ;
184
181
debug ! ( "cast operand is {:?}" , operand) ;
185
182
let cast = bx. cx ( ) . layout_of ( self . monomorphize ( & mir_cast_ty) ) ;
186
183
@@ -373,7 +370,7 @@ impl<'a, 'b, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'b, 'tcx, Bx> {
373
370
}
374
371
375
372
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 ( ) ) ;
377
374
378
375
let ty = cg_place. layout . ty ;
379
376
@@ -394,7 +391,7 @@ impl<'a, 'b, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'b, 'tcx, Bx> {
394
391
}
395
392
396
393
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) ;
398
395
let operand = OperandRef {
399
396
val : OperandValue :: Immediate ( size) ,
400
397
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> {
403
400
}
404
401
405
402
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) ;
408
405
let llresult = match ( lhs. val , rhs. val ) {
409
406
( OperandValue :: Pair ( lhs_addr, lhs_extra) ,
410
407
OperandValue :: Pair ( rhs_addr, rhs_extra) ) => {
@@ -429,8 +426,8 @@ impl<'a, 'b, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'b, 'tcx, Bx> {
429
426
( bx, operand)
430
427
}
431
428
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) ;
434
431
let result = self . codegen_scalar_checked_binop ( & mut bx, op,
435
432
lhs. immediate ( ) , rhs. immediate ( ) ,
436
433
lhs. layout . ty ) ;
@@ -445,7 +442,7 @@ impl<'a, 'b, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'b, 'tcx, Bx> {
445
442
}
446
443
447
444
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) ;
449
446
let lloperand = operand. immediate ( ) ;
450
447
let is_float = operand. layout . ty . is_floating_point ( ) ;
451
448
let llval = match op {
@@ -463,8 +460,8 @@ impl<'a, 'b, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'b, 'tcx, Bx> {
463
460
}
464
461
465
462
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 ( ) )
468
465
. codegen_get_discr ( & mut bx, discr_ty) ;
469
466
( bx, OperandRef {
470
467
val : OperandValue :: Immediate ( discr) ,
@@ -509,14 +506,14 @@ impl<'a, 'b, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'b, 'tcx, Bx> {
509
506
( bx, operand)
510
507
}
511
508
mir:: Rvalue :: Use ( ref operand) => {
512
- let operand = self . codegen_operand ( mir , & mut bx, operand) ;
509
+ let operand = self . codegen_operand ( & mut bx, operand) ;
513
510
( bx, operand)
514
511
}
515
512
mir:: Rvalue :: Repeat ( ..) |
516
513
mir:: Rvalue :: Aggregate ( ..) => {
517
514
// According to `rvalue_creates_operand`, only ZST
518
515
// 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 ( ) ) ;
520
517
let operand = OperandRef :: new_zst (
521
518
& mut bx,
522
519
self . cx . layout_of ( self . monomorphize ( & ty) ) ,
@@ -528,7 +525,6 @@ impl<'a, 'b, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'b, 'tcx, Bx> {
528
525
529
526
fn evaluate_array_len (
530
527
& mut self ,
531
- mir : & Body < ' tcx > ,
532
528
bx : & mut Bx ,
533
529
place : & mir:: Place < ' tcx > ,
534
530
) -> Bx :: Value {
@@ -543,7 +539,7 @@ impl<'a, 'b, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'b, 'tcx, Bx> {
543
539
}
544
540
}
545
541
// 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 ( ) ) ;
547
543
cg_value. len ( bx. cx ( ) )
548
544
}
549
545
@@ -704,7 +700,6 @@ impl<'a, 'b, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'b, 'tcx, Bx> {
704
700
& self ,
705
701
rvalue : & mir:: Rvalue < ' tcx > ,
706
702
span : Span ,
707
- mir : & Body < ' tcx >
708
703
) -> bool {
709
704
match * rvalue {
710
705
mir:: Rvalue :: Ref ( ..) |
@@ -719,7 +714,7 @@ impl<'a, 'b, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'b, 'tcx, Bx> {
719
714
true ,
720
715
mir:: Rvalue :: Repeat ( ..) |
721
716
mir:: Rvalue :: Aggregate ( ..) => {
722
- let ty = rvalue. ty ( mir, self . cx . tcx ( ) ) ;
717
+ let ty = rvalue. ty ( self . mir , self . cx . tcx ( ) ) ;
723
718
let ty = self . monomorphize ( & ty) ;
724
719
self . cx . spanned_layout_of ( ty, span) . is_zst ( )
725
720
}
0 commit comments