@@ -41,7 +41,7 @@ use rustc::mir::traversal;
41
41
use self :: operand:: { OperandRef , OperandValue } ;
42
42
43
43
/// Master context for translating MIR.
44
- pub struct MirContext < ' a , ' tcx : ' a > {
44
+ pub struct FunctionCx < ' a , ' tcx : ' a > {
45
45
mir : & ' a mir:: Mir < ' tcx > ,
46
46
47
47
debug_context : debuginfo:: FunctionDebugContext ,
@@ -102,7 +102,7 @@ pub struct MirContext<'a, 'tcx:'a> {
102
102
param_substs : & ' tcx Substs < ' tcx > ,
103
103
}
104
104
105
- impl < ' a , ' tcx > MirContext < ' a , ' tcx > {
105
+ impl < ' a , ' tcx > FunctionCx < ' a , ' tcx > {
106
106
pub fn monomorphize < T > ( & self , value : & T ) -> T
107
107
where T : TransNormalize < ' tcx >
108
108
{
@@ -224,7 +224,7 @@ pub fn trans_mir<'a, 'tcx: 'a>(
224
224
let scopes = debuginfo:: create_mir_scopes ( cx, mir, & debug_context) ;
225
225
let ( landing_pads, funclets) = create_funclets ( & bx, & cleanup_kinds, & block_bxs) ;
226
226
227
- let mut mircx = MirContext {
227
+ let mut fx = FunctionCx {
228
228
mir,
229
229
llfn,
230
230
fn_ty,
@@ -244,20 +244,20 @@ pub fn trans_mir<'a, 'tcx: 'a>(
244
244
} ,
245
245
} ;
246
246
247
- let memory_locals = analyze:: memory_locals ( & mircx ) ;
247
+ let memory_locals = analyze:: memory_locals ( & fx ) ;
248
248
249
249
// 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) ;
252
252
253
253
let mut allocate_local = |local| {
254
254
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 ) ) ;
256
256
assert ! ( !layout. ty. has_erasable_regions( ) ) ;
257
257
258
258
if let Some ( name) = decl. name {
259
259
// User variable
260
- let debug_scope = mircx . scopes [ decl. source_info . scope ] ;
260
+ let debug_scope = fx . scopes [ decl. source_info . scope ] ;
261
261
let dbg = debug_scope. is_valid ( ) && bx. sess ( ) . opts . debuginfo == FullDebugInfo ;
262
262
263
263
if !memory_locals. contains ( local. index ( ) ) && !dbg {
@@ -268,15 +268,15 @@ pub fn trans_mir<'a, 'tcx: 'a>(
268
268
debug ! ( "alloc: {:?} ({}) -> place" , local, name) ;
269
269
let place = PlaceRef :: alloca ( & bx, layout, & name. as_str ( ) ) ;
270
270
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,
273
273
VariableAccess :: DirectVariable { alloca : place. llval } ,
274
274
VariableKind :: LocalVariable , span) ;
275
275
}
276
276
LocalRef :: Place ( place)
277
277
} else {
278
278
// 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 ( ) {
280
280
debug ! ( "alloc: {:?} (return place) -> place" , local) ;
281
281
let llretptr = llvm:: get_param ( llfn, 0 ) ;
282
282
LocalRef :: Place ( PlaceRef :: new_sized ( llretptr, layout, layout. align ) )
@@ -302,21 +302,21 @@ pub fn trans_mir<'a, 'tcx: 'a>(
302
302
303
303
// Branch to the START block, if it's not the entry block.
304
304
if reentrant_start_block {
305
- bx. br ( mircx . blocks [ mir:: START_BLOCK ] ) ;
305
+ bx. br ( fx . blocks [ mir:: START_BLOCK ] ) ;
306
306
}
307
307
308
308
// Up until here, IR instructions for this function have explicitly not been annotated with
309
309
// source code location, so we don't step into call setup code. From here on, source location
310
310
// emitting should be enabled.
311
- debuginfo:: start_emitting_source_locations ( & mircx . debug_context ) ;
311
+ debuginfo:: start_emitting_source_locations ( & fx . debug_context ) ;
312
312
313
313
let rpo = traversal:: reverse_postorder ( & mir) ;
314
314
let mut visited = BitVector :: new ( mir. basic_blocks ( ) . len ( ) ) ;
315
315
316
316
// Translate the body of each block using reverse postorder
317
317
for ( bb, _) in rpo {
318
318
visited. insert ( bb. index ( ) ) ;
319
- mircx . trans_block ( bb) ;
319
+ fx . trans_block ( bb) ;
320
320
}
321
321
322
322
// Remove blocks that haven't been visited, or have no
@@ -326,7 +326,7 @@ pub fn trans_mir<'a, 'tcx: 'a>(
326
326
if !visited. contains ( bb. index ( ) ) {
327
327
debug ! ( "trans_mir: block {:?} was not visited" , bb) ;
328
328
unsafe {
329
- llvm:: LLVMDeleteBasicBlock ( mircx . blocks [ bb] ) ;
329
+ llvm:: LLVMDeleteBasicBlock ( fx . blocks [ bb] ) ;
330
330
}
331
331
}
332
332
}
@@ -356,14 +356,14 @@ fn create_funclets<'a, 'tcx>(
356
356
/// argument's value. As arguments are places, these are always
357
357
/// indirect.
358
358
fn arg_local_refs < ' a , ' tcx > ( bx : & Builder < ' a , ' tcx > ,
359
- mircx : & MirContext < ' a , ' tcx > ,
359
+ fx : & FunctionCx < ' a , ' tcx > ,
360
360
scopes : & IndexVec < mir:: VisibilityScope , debuginfo:: MirDebugScope > ,
361
361
memory_locals : & BitVector )
362
362
-> Vec < LocalRef < ' tcx > > {
363
- let mir = mircx . mir ;
363
+ let mir = fx . mir ;
364
364
let tcx = bx. tcx ( ) ;
365
365
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 ;
367
367
368
368
// Get the argument scope, if it exists and if we need it.
369
369
let arg_scope = scopes[ mir:: ARGUMENT_VISIBILITY_SCOPE ] ;
@@ -392,15 +392,15 @@ fn arg_local_refs<'a, 'tcx>(bx: &Builder<'a, 'tcx>,
392
392
// to reconstruct it into a tuple local variable, from multiple
393
393
// individual LLVM function arguments.
394
394
395
- let arg_ty = mircx . monomorphize ( & arg_decl. ty ) ;
395
+ let arg_ty = fx . monomorphize ( & arg_decl. ty ) ;
396
396
let tupled_arg_tys = match arg_ty. sty {
397
397
ty:: TyTuple ( ref tys, _) => tys,
398
398
_ => bug ! ( "spread argument isn't a tuple?!" )
399
399
} ;
400
400
401
401
let place = PlaceRef :: alloca ( bx, bx. cx . layout_of ( arg_ty) , & name) ;
402
402
for i in 0 ..tupled_arg_tys. len ( ) {
403
- let arg = & mircx . fn_ty . args [ idx] ;
403
+ let arg = & fx . fn_ty . args [ idx] ;
404
404
idx += 1 ;
405
405
arg. store_fn_arg ( bx, & mut llarg_idx, place. project_field ( bx, i) ) ;
406
406
}
@@ -413,7 +413,7 @@ fn arg_local_refs<'a, 'tcx>(bx: &Builder<'a, 'tcx>,
413
413
} ;
414
414
declare_local (
415
415
bx,
416
- & mircx . debug_context ,
416
+ & fx . debug_context ,
417
417
arg_decl. name . unwrap_or ( keywords:: Invalid . name ( ) ) ,
418
418
arg_ty, scope,
419
419
variable_access,
@@ -425,7 +425,7 @@ fn arg_local_refs<'a, 'tcx>(bx: &Builder<'a, 'tcx>,
425
425
return LocalRef :: Place ( place) ;
426
426
}
427
427
428
- let arg = & mircx . fn_ty . args [ idx] ;
428
+ let arg = & fx . fn_ty . args [ idx] ;
429
429
idx += 1 ;
430
430
if arg. pad . is_some ( ) {
431
431
llarg_idx += 1 ;
@@ -499,7 +499,7 @@ fn arg_local_refs<'a, 'tcx>(bx: &Builder<'a, 'tcx>,
499
499
500
500
declare_local (
501
501
bx,
502
- & mircx . debug_context ,
502
+ & fx . debug_context ,
503
503
arg_decl. name . unwrap_or ( keywords:: Invalid . name ( ) ) ,
504
504
arg. layout . ty ,
505
505
scope,
@@ -568,7 +568,7 @@ fn arg_local_refs<'a, 'tcx>(bx: &Builder<'a, 'tcx>,
568
568
} ;
569
569
declare_local (
570
570
bx,
571
- & mircx . debug_context ,
571
+ & fx . debug_context ,
572
572
decl. debug_name ,
573
573
ty,
574
574
scope,
0 commit comments