@@ -41,7 +41,7 @@ use rustc::mir::traversal;
4141use self :: operand:: { OperandRef , OperandValue } ;
4242
4343/// Master context for translating MIR.
44- pub struct MirContext < ' a , ' tcx : ' a > {
44+ pub struct FunctionCx < ' a , ' tcx : ' a > {
4545 mir : & ' a mir:: Mir < ' tcx > ,
4646
4747 debug_context : debuginfo:: FunctionDebugContext ,
@@ -102,7 +102,7 @@ pub struct MirContext<'a, 'tcx:'a> {
102102 param_substs : & ' tcx Substs < ' tcx > ,
103103}
104104
105- impl < ' a , ' tcx > MirContext < ' a , ' tcx > {
105+ impl < ' a , ' tcx > FunctionCx < ' a , ' tcx > {
106106 pub fn monomorphize < T > ( & self , value : & T ) -> T
107107 where T : TransNormalize < ' tcx >
108108 {
@@ -224,7 +224,7 @@ pub fn trans_mir<'a, 'tcx: 'a>(
224224 let scopes = debuginfo:: create_mir_scopes ( cx, mir, & debug_context) ;
225225 let ( landing_pads, funclets) = create_funclets ( & bx, & cleanup_kinds, & block_bxs) ;
226226
227- let mut mircx = MirContext {
227+ let mut fx = FunctionCx {
228228 mir,
229229 llfn,
230230 fn_ty,
@@ -244,20 +244,20 @@ pub fn trans_mir<'a, 'tcx: 'a>(
244244 } ,
245245 } ;
246246
247- let memory_locals = analyze:: memory_locals ( & mircx ) ;
247+ let memory_locals = analyze:: memory_locals ( & fx ) ;
248248
249249 // Allocate variable and temp allocas
250- mircx . locals = {
251- let args = arg_local_refs ( & bx, & mircx , & mircx . scopes , & memory_locals) ;
250+ fx . locals = {
251+ let args = arg_local_refs ( & bx, & fx , & fx . scopes , & memory_locals) ;
252252
253253 let mut allocate_local = |local| {
254254 let decl = & mir. local_decls [ local] ;
255- let layout = bx. cx . layout_of ( mircx . monomorphize ( & decl. ty ) ) ;
255+ let layout = bx. cx . layout_of ( fx . monomorphize ( & decl. ty ) ) ;
256256 assert ! ( !layout. ty. has_erasable_regions( ) ) ;
257257
258258 if let Some ( name) = decl. name {
259259 // User variable
260- let debug_scope = mircx . scopes [ decl. source_info . scope ] ;
260+ let debug_scope = fx . scopes [ decl. source_info . scope ] ;
261261 let dbg = debug_scope. is_valid ( ) && bx. sess ( ) . opts . debuginfo == FullDebugInfo ;
262262
263263 if !memory_locals. contains ( local. index ( ) ) && !dbg {
@@ -268,15 +268,15 @@ pub fn trans_mir<'a, 'tcx: 'a>(
268268 debug ! ( "alloc: {:?} ({}) -> place" , local, name) ;
269269 let place = PlaceRef :: alloca ( & bx, layout, & name. as_str ( ) ) ;
270270 if dbg {
271- let ( scope, span) = mircx . debug_loc ( decl. source_info ) ;
272- declare_local ( & bx, & mircx . debug_context , name, layout. ty , scope,
271+ let ( scope, span) = fx . debug_loc ( decl. source_info ) ;
272+ declare_local ( & bx, & fx . debug_context , name, layout. ty , scope,
273273 VariableAccess :: DirectVariable { alloca : place. llval } ,
274274 VariableKind :: LocalVariable , span) ;
275275 }
276276 LocalRef :: Place ( place)
277277 } else {
278278 // Temporary or return place
279- if local == mir:: RETURN_PLACE && mircx . fn_ty . ret . is_indirect ( ) {
279+ if local == mir:: RETURN_PLACE && fx . fn_ty . ret . is_indirect ( ) {
280280 debug ! ( "alloc: {:?} (return place) -> place" , local) ;
281281 let llretptr = llvm:: get_param ( llfn, 0 ) ;
282282 LocalRef :: Place ( PlaceRef :: new_sized ( llretptr, layout, layout. align ) )
@@ -302,21 +302,21 @@ pub fn trans_mir<'a, 'tcx: 'a>(
302302
303303 // Branch to the START block, if it's not the entry block.
304304 if reentrant_start_block {
305- bx. br ( mircx . blocks [ mir:: START_BLOCK ] ) ;
305+ bx. br ( fx . blocks [ mir:: START_BLOCK ] ) ;
306306 }
307307
308308 // Up until here, IR instructions for this function have explicitly not been annotated with
309309 // source code location, so we don't step into call setup code. From here on, source location
310310 // emitting should be enabled.
311- debuginfo:: start_emitting_source_locations ( & mircx . debug_context ) ;
311+ debuginfo:: start_emitting_source_locations ( & fx . debug_context ) ;
312312
313313 let rpo = traversal:: reverse_postorder ( & mir) ;
314314 let mut visited = BitVector :: new ( mir. basic_blocks ( ) . len ( ) ) ;
315315
316316 // Translate the body of each block using reverse postorder
317317 for ( bb, _) in rpo {
318318 visited. insert ( bb. index ( ) ) ;
319- mircx . trans_block ( bb) ;
319+ fx . trans_block ( bb) ;
320320 }
321321
322322 // Remove blocks that haven't been visited, or have no
@@ -326,7 +326,7 @@ pub fn trans_mir<'a, 'tcx: 'a>(
326326 if !visited. contains ( bb. index ( ) ) {
327327 debug ! ( "trans_mir: block {:?} was not visited" , bb) ;
328328 unsafe {
329- llvm:: LLVMDeleteBasicBlock ( mircx . blocks [ bb] ) ;
329+ llvm:: LLVMDeleteBasicBlock ( fx . blocks [ bb] ) ;
330330 }
331331 }
332332 }
@@ -356,14 +356,14 @@ fn create_funclets<'a, 'tcx>(
356356/// argument's value. As arguments are places, these are always
357357/// indirect.
358358fn arg_local_refs < ' a , ' tcx > ( bx : & Builder < ' a , ' tcx > ,
359- mircx : & MirContext < ' a , ' tcx > ,
359+ fx : & FunctionCx < ' a , ' tcx > ,
360360 scopes : & IndexVec < mir:: VisibilityScope , debuginfo:: MirDebugScope > ,
361361 memory_locals : & BitVector )
362362 -> Vec < LocalRef < ' tcx > > {
363- let mir = mircx . mir ;
363+ let mir = fx . mir ;
364364 let tcx = bx. tcx ( ) ;
365365 let mut idx = 0 ;
366- let mut llarg_idx = mircx . fn_ty . ret . is_indirect ( ) as usize ;
366+ let mut llarg_idx = fx . fn_ty . ret . is_indirect ( ) as usize ;
367367
368368 // Get the argument scope, if it exists and if we need it.
369369 let arg_scope = scopes[ mir:: ARGUMENT_VISIBILITY_SCOPE ] ;
@@ -392,15 +392,15 @@ fn arg_local_refs<'a, 'tcx>(bx: &Builder<'a, 'tcx>,
392392 // to reconstruct it into a tuple local variable, from multiple
393393 // individual LLVM function arguments.
394394
395- let arg_ty = mircx . monomorphize ( & arg_decl. ty ) ;
395+ let arg_ty = fx . monomorphize ( & arg_decl. ty ) ;
396396 let tupled_arg_tys = match arg_ty. sty {
397397 ty:: TyTuple ( ref tys, _) => tys,
398398 _ => bug ! ( "spread argument isn't a tuple?!" )
399399 } ;
400400
401401 let place = PlaceRef :: alloca ( bx, bx. cx . layout_of ( arg_ty) , & name) ;
402402 for i in 0 ..tupled_arg_tys. len ( ) {
403- let arg = & mircx . fn_ty . args [ idx] ;
403+ let arg = & fx . fn_ty . args [ idx] ;
404404 idx += 1 ;
405405 arg. store_fn_arg ( bx, & mut llarg_idx, place. project_field ( bx, i) ) ;
406406 }
@@ -413,7 +413,7 @@ fn arg_local_refs<'a, 'tcx>(bx: &Builder<'a, 'tcx>,
413413 } ;
414414 declare_local (
415415 bx,
416- & mircx . debug_context ,
416+ & fx . debug_context ,
417417 arg_decl. name . unwrap_or ( keywords:: Invalid . name ( ) ) ,
418418 arg_ty, scope,
419419 variable_access,
@@ -425,7 +425,7 @@ fn arg_local_refs<'a, 'tcx>(bx: &Builder<'a, 'tcx>,
425425 return LocalRef :: Place ( place) ;
426426 }
427427
428- let arg = & mircx . fn_ty . args [ idx] ;
428+ let arg = & fx . fn_ty . args [ idx] ;
429429 idx += 1 ;
430430 if arg. pad . is_some ( ) {
431431 llarg_idx += 1 ;
@@ -499,7 +499,7 @@ fn arg_local_refs<'a, 'tcx>(bx: &Builder<'a, 'tcx>,
499499
500500 declare_local (
501501 bx,
502- & mircx . debug_context ,
502+ & fx . debug_context ,
503503 arg_decl. name . unwrap_or ( keywords:: Invalid . name ( ) ) ,
504504 arg. layout . ty ,
505505 scope,
@@ -568,7 +568,7 @@ fn arg_local_refs<'a, 'tcx>(bx: &Builder<'a, 'tcx>,
568568 } ;
569569 declare_local (
570570 bx,
571- & mircx . debug_context ,
571+ & fx . debug_context ,
572572 decl. debug_name ,
573573 ty,
574574 scope,
0 commit comments