@@ -14,9 +14,7 @@ use rustc::mir::repr as mir;
14
14
use rustc:: mir:: tcx:: LvalueTy ;
15
15
use trans:: adt;
16
16
use trans:: base;
17
- use trans:: build;
18
- use trans:: common:: { self , Block } ;
19
- use trans:: debuginfo:: DebugLoc ;
17
+ use trans:: common:: { self , BlockAndBuilder } ;
20
18
use trans:: machine;
21
19
use trans:: type_of;
22
20
use llvm;
@@ -43,20 +41,20 @@ impl<'tcx> LvalueRef<'tcx> {
43
41
LvalueRef { llval : llval, llextra : ptr:: null_mut ( ) , ty : lvalue_ty }
44
42
}
45
43
46
- pub fn alloca < ' bcx > ( bcx : Block < ' bcx , ' tcx > ,
44
+ pub fn alloca < ' bcx > ( bcx : & BlockAndBuilder < ' bcx , ' tcx > ,
47
45
ty : Ty < ' tcx > ,
48
46
name : & str )
49
47
-> LvalueRef < ' tcx >
50
48
{
51
49
assert ! ( !ty. has_erasable_regions( ) ) ;
52
- let lltemp = base:: alloc_ty ( bcx, ty, name) ;
50
+ let lltemp = bcx . with_block ( |bcx| base:: alloc_ty ( bcx, ty, name) ) ;
53
51
LvalueRef :: new_sized ( lltemp, LvalueTy :: from_ty ( ty) )
54
52
}
55
53
}
56
54
57
55
impl < ' bcx , ' tcx > MirContext < ' bcx , ' tcx > {
58
56
pub fn lvalue_len ( & mut self ,
59
- bcx : Block < ' bcx , ' tcx > ,
57
+ bcx : & BlockAndBuilder < ' bcx , ' tcx > ,
60
58
lvalue : LvalueRef < ' tcx > )
61
59
-> ValueRef {
62
60
match lvalue. ty . to_ty ( bcx. tcx ( ) ) . sty {
@@ -70,13 +68,13 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
70
68
}
71
69
72
70
pub fn trans_lvalue ( & mut self ,
73
- bcx : Block < ' bcx , ' tcx > ,
71
+ bcx : & BlockAndBuilder < ' bcx , ' tcx > ,
74
72
lvalue : & mir:: Lvalue < ' tcx > )
75
73
-> LvalueRef < ' tcx > {
76
74
debug ! ( "trans_lvalue(lvalue={:?})" , lvalue) ;
77
75
78
- let fcx = bcx. fcx ;
79
- let ccx = fcx . ccx ;
76
+ let fcx = bcx. fcx ( ) ;
77
+ let ccx = bcx . ccx ( ) ;
80
78
let tcx = bcx. tcx ( ) ;
81
79
match * lvalue {
82
80
mir:: Lvalue :: Var ( index) => self . vars [ index as usize ] ,
@@ -97,7 +95,9 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
97
95
let fn_return_ty = bcx. monomorphize ( & self . mir . return_ty ) ;
98
96
let return_ty = fn_return_ty. unwrap ( ) ;
99
97
let llval = if !common:: return_type_is_void ( bcx. ccx ( ) , return_ty) {
100
- fcx. get_ret_slot ( bcx, fn_return_ty, "" )
98
+ bcx. with_block ( |bcx| {
99
+ fcx. get_ret_slot ( bcx, fn_return_ty, "" )
100
+ } )
101
101
} else {
102
102
// This is a void return; that is, there’s no place to store the value and
103
103
// there cannot really be one (or storing into it doesn’t make sense, anyway).
@@ -117,12 +117,14 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
117
117
let ( llprojected, llextra) = match projection. elem {
118
118
mir:: ProjectionElem :: Deref => {
119
119
let base_ty = tr_base. ty . to_ty ( tcx) ;
120
- if common:: type_is_sized ( tcx, projected_ty. to_ty ( tcx) ) {
121
- ( base:: load_ty ( bcx, tr_base. llval , base_ty) ,
122
- ptr:: null_mut ( ) )
123
- } else {
124
- base:: load_fat_ptr ( bcx, tr_base. llval , base_ty)
125
- }
120
+ bcx. with_block ( |bcx| {
121
+ if common:: type_is_sized ( tcx, projected_ty. to_ty ( tcx) ) {
122
+ ( base:: load_ty ( bcx, tr_base. llval , base_ty) ,
123
+ ptr:: null_mut ( ) )
124
+ } else {
125
+ base:: load_fat_ptr ( bcx, tr_base. llval , base_ty)
126
+ }
127
+ } )
126
128
}
127
129
mir:: ProjectionElem :: Field ( ref field) => {
128
130
let base_ty = tr_base. ty . to_ty ( tcx) ;
@@ -138,18 +140,21 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
138
140
} else {
139
141
adt:: MaybeSizedValue :: unsized_ ( tr_base. llval , tr_base. llextra )
140
142
} ;
141
- ( adt:: trans_field_ptr ( bcx, & base_repr, base, Disr ( discr) , field. index ( ) ) ,
142
- if is_sized {
143
- ptr:: null_mut ( )
144
- } else {
145
- tr_base. llextra
146
- } )
143
+ let llprojected = bcx. with_block ( |bcx| {
144
+ adt:: trans_field_ptr ( bcx, & base_repr, base, Disr ( discr) , field. index ( ) )
145
+ } ) ;
146
+ let llextra = if is_sized {
147
+ ptr:: null_mut ( )
148
+ } else {
149
+ tr_base. llextra
150
+ } ;
151
+ ( llprojected, llextra)
147
152
}
148
153
mir:: ProjectionElem :: Index ( ref index) => {
149
154
let index = self . trans_operand ( bcx, index) ;
150
155
let llindex = self . prepare_index ( bcx, index. immediate ( ) ) ;
151
156
let zero = common:: C_uint ( bcx. ccx ( ) , 0u64 ) ;
152
- ( build :: InBoundsGEP ( bcx, tr_base. llval , & [ zero, llindex] ) ,
157
+ ( bcx. inbounds_gep ( tr_base. llval , & [ zero, llindex] ) ,
153
158
ptr:: null_mut ( ) )
154
159
}
155
160
mir:: ProjectionElem :: ConstantIndex { offset,
@@ -158,18 +163,18 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
158
163
let lloffset = common:: C_u32 ( bcx. ccx ( ) , offset) ;
159
164
let llindex = self . prepare_index ( bcx, lloffset) ;
160
165
let zero = common:: C_uint ( bcx. ccx ( ) , 0u64 ) ;
161
- ( build :: InBoundsGEP ( bcx, tr_base. llval , & [ zero, llindex] ) ,
166
+ ( bcx. inbounds_gep ( tr_base. llval , & [ zero, llindex] ) ,
162
167
ptr:: null_mut ( ) )
163
168
}
164
169
mir:: ProjectionElem :: ConstantIndex { offset,
165
170
from_end : true ,
166
171
min_length : _ } => {
167
172
let lloffset = common:: C_u32 ( bcx. ccx ( ) , offset) ;
168
173
let lllen = self . lvalue_len ( bcx, tr_base) ;
169
- let llindex = build :: Sub ( bcx, lllen, lloffset, DebugLoc :: None ) ;
174
+ let llindex = bcx. sub ( lllen, lloffset) ;
170
175
let llindex = self . prepare_index ( bcx, llindex) ;
171
176
let zero = common:: C_uint ( bcx. ccx ( ) , 0u64 ) ;
172
- ( build :: InBoundsGEP ( bcx, tr_base. llval , & [ zero, llindex] ) ,
177
+ ( bcx. inbounds_gep ( tr_base. llval , & [ zero, llindex] ) ,
173
178
ptr:: null_mut ( ) )
174
179
}
175
180
mir:: ProjectionElem :: Downcast ( ..) => {
@@ -190,17 +195,17 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
190
195
///
191
196
/// nmatsakis: is this still necessary? Not sure.
192
197
fn prepare_index ( & mut self ,
193
- bcx : Block < ' bcx , ' tcx > ,
198
+ bcx : & BlockAndBuilder < ' bcx , ' tcx > ,
194
199
llindex : ValueRef )
195
200
-> ValueRef
196
201
{
197
202
let ccx = bcx. ccx ( ) ;
198
203
let index_size = machine:: llbitsize_of_real ( bcx. ccx ( ) , common:: val_ty ( llindex) ) ;
199
204
let int_size = machine:: llbitsize_of_real ( bcx. ccx ( ) , ccx. int_type ( ) ) ;
200
205
if index_size < int_size {
201
- build :: ZExt ( bcx, llindex, ccx. int_type ( ) )
206
+ bcx. zext ( llindex, ccx. int_type ( ) )
202
207
} else if index_size > int_size {
203
- build :: Trunc ( bcx, llindex, ccx. int_type ( ) )
208
+ bcx. trunc ( llindex, ccx. int_type ( ) )
204
209
} else {
205
210
llindex
206
211
}
0 commit comments