@@ -14,9 +14,7 @@ use rustc::mir::repr as mir;
1414use rustc:: mir:: tcx:: LvalueTy ;
1515use trans:: adt;
1616use trans:: base;
17- use trans:: build;
18- use trans:: common:: { self , Block } ;
19- use trans:: debuginfo:: DebugLoc ;
17+ use trans:: common:: { self , BlockAndBuilder } ;
2018use trans:: machine;
2119use trans:: type_of;
2220use llvm;
@@ -43,20 +41,20 @@ impl<'tcx> LvalueRef<'tcx> {
4341 LvalueRef { llval : llval, llextra : ptr:: null_mut ( ) , ty : lvalue_ty }
4442 }
4543
46- pub fn alloca < ' bcx > ( bcx : Block < ' bcx , ' tcx > ,
44+ pub fn alloca < ' bcx > ( bcx : & BlockAndBuilder < ' bcx , ' tcx > ,
4745 ty : Ty < ' tcx > ,
4846 name : & str )
4947 -> LvalueRef < ' tcx >
5048 {
5149 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) ) ;
5351 LvalueRef :: new_sized ( lltemp, LvalueTy :: from_ty ( ty) )
5452 }
5553}
5654
5755impl < ' bcx , ' tcx > MirContext < ' bcx , ' tcx > {
5856 pub fn lvalue_len ( & mut self ,
59- bcx : Block < ' bcx , ' tcx > ,
57+ bcx : & BlockAndBuilder < ' bcx , ' tcx > ,
6058 lvalue : LvalueRef < ' tcx > )
6159 -> ValueRef {
6260 match lvalue. ty . to_ty ( bcx. tcx ( ) ) . sty {
@@ -70,13 +68,13 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
7068 }
7169
7270 pub fn trans_lvalue ( & mut self ,
73- bcx : Block < ' bcx , ' tcx > ,
71+ bcx : & BlockAndBuilder < ' bcx , ' tcx > ,
7472 lvalue : & mir:: Lvalue < ' tcx > )
7573 -> LvalueRef < ' tcx > {
7674 debug ! ( "trans_lvalue(lvalue={:?})" , lvalue) ;
7775
78- let fcx = bcx. fcx ;
79- let ccx = fcx . ccx ;
76+ let fcx = bcx. fcx ( ) ;
77+ let ccx = bcx . ccx ( ) ;
8078 let tcx = bcx. tcx ( ) ;
8179 match * lvalue {
8280 mir:: Lvalue :: Var ( index) => self . vars [ index as usize ] ,
@@ -97,7 +95,9 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
9795 let fn_return_ty = bcx. monomorphize ( & self . mir . return_ty ) ;
9896 let return_ty = fn_return_ty. unwrap ( ) ;
9997 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+ } )
101101 } else {
102102 // This is a void return; that is, there’s no place to store the value and
103103 // there cannot really be one (or storing into it doesn’t make sense, anyway).
@@ -117,12 +117,14 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
117117 let ( llprojected, llextra) = match projection. elem {
118118 mir:: ProjectionElem :: Deref => {
119119 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+ } )
126128 }
127129 mir:: ProjectionElem :: Field ( ref field) => {
128130 let base_ty = tr_base. ty . to_ty ( tcx) ;
@@ -138,18 +140,21 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
138140 } else {
139141 adt:: MaybeSizedValue :: unsized_ ( tr_base. llval , tr_base. llextra )
140142 } ;
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)
147152 }
148153 mir:: ProjectionElem :: Index ( ref index) => {
149154 let index = self . trans_operand ( bcx, index) ;
150155 let llindex = self . prepare_index ( bcx, index. immediate ( ) ) ;
151156 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] ) ,
153158 ptr:: null_mut ( ) )
154159 }
155160 mir:: ProjectionElem :: ConstantIndex { offset,
@@ -158,18 +163,18 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
158163 let lloffset = common:: C_u32 ( bcx. ccx ( ) , offset) ;
159164 let llindex = self . prepare_index ( bcx, lloffset) ;
160165 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] ) ,
162167 ptr:: null_mut ( ) )
163168 }
164169 mir:: ProjectionElem :: ConstantIndex { offset,
165170 from_end : true ,
166171 min_length : _ } => {
167172 let lloffset = common:: C_u32 ( bcx. ccx ( ) , offset) ;
168173 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) ;
170175 let llindex = self . prepare_index ( bcx, llindex) ;
171176 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] ) ,
173178 ptr:: null_mut ( ) )
174179 }
175180 mir:: ProjectionElem :: Downcast ( ..) => {
@@ -190,17 +195,17 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
190195 ///
191196 /// nmatsakis: is this still necessary? Not sure.
192197 fn prepare_index ( & mut self ,
193- bcx : Block < ' bcx , ' tcx > ,
198+ bcx : & BlockAndBuilder < ' bcx , ' tcx > ,
194199 llindex : ValueRef )
195200 -> ValueRef
196201 {
197202 let ccx = bcx. ccx ( ) ;
198203 let index_size = machine:: llbitsize_of_real ( bcx. ccx ( ) , common:: val_ty ( llindex) ) ;
199204 let int_size = machine:: llbitsize_of_real ( bcx. ccx ( ) , ccx. int_type ( ) ) ;
200205 if index_size < int_size {
201- build :: ZExt ( bcx, llindex, ccx. int_type ( ) )
206+ bcx. zext ( llindex, ccx. int_type ( ) )
202207 } else if index_size > int_size {
203- build :: Trunc ( bcx, llindex, ccx. int_type ( ) )
208+ bcx. trunc ( llindex, ccx. int_type ( ) )
204209 } else {
205210 llindex
206211 }
0 commit comments