diff options
| author | Mark Simulacrum <mark.simulacrum@gmail.com> | 2016-12-19 17:48:41 -0700 |
|---|---|---|
| committer | Mark Simulacrum <mark.simulacrum@gmail.com> | 2016-12-20 20:04:43 -0700 |
| commit | 6fac0a1a84891ccf38f0cfbaf7b93e1c64578bfb (patch) | |
| tree | 7e9e5290a6d294ce227ce07c67c572e2cefdf9c4 | |
| parent | 15c9e5e35bc3a9675c476ae10eb656df2c2c14ed (diff) | |
Change *.fcx.ccx to *.ccx
| -rw-r--r-- | src/librustc_trans/base.rs | 4 | ||||
| -rw-r--r-- | src/librustc_trans/cleanup.rs | 4 | ||||
| -rw-r--r-- | src/librustc_trans/common.rs | 7 | ||||
| -rw-r--r-- | src/librustc_trans/glue.rs | 16 | ||||
| -rw-r--r-- | src/librustc_trans/mir/analyze.rs | 22 | ||||
| -rw-r--r-- | src/librustc_trans/mir/block.rs | 2 | ||||
| -rw-r--r-- | src/librustc_trans/mir/lvalue.rs | 4 | ||||
| -rw-r--r-- | src/librustc_trans/mir/mod.rs | 16 |
8 files changed, 34 insertions, 41 deletions
diff --git a/src/librustc_trans/base.rs b/src/librustc_trans/base.rs index 9697f260434..3f5cbd68042 100644 --- a/src/librustc_trans/base.rs +++ b/src/librustc_trans/base.rs @@ -424,7 +424,7 @@ pub fn load_ty<'a, 'tcx>(b: &Builder<'a, 'tcx>, ptr: ValueRef, t: Ty<'tcx>) -> V pub fn store_ty<'a, 'tcx>(cx: &BlockAndBuilder<'a, 'tcx>, v: ValueRef, dst: ValueRef, t: Ty<'tcx>) { debug!("store_ty: {:?} : {:?} <- {:?}", Value(dst), t, Value(v)); - if common::type_is_fat_ptr(cx.ccx(), t) { + if common::type_is_fat_ptr(cx.ccx, t) { let lladdr = cx.extract_value(v, abi::FAT_PTR_ADDR); let llextra = cx.extract_value(v, abi::FAT_PTR_EXTRA); store_fat_ptr(cx, lladdr, llextra, dst, t); @@ -656,7 +656,7 @@ pub fn trans_ctor_shim<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, if let Some(cast_ty) = fcx.fn_ty.ret.cast { let load = bcx.load(bcx.pointercast(dest, cast_ty.ptr_to())); - let llalign = llalign_of_min(fcx.ccx, fcx.fn_ty.ret.ty); + let llalign = llalign_of_min(ccx, fcx.fn_ty.ret.ty); unsafe { llvm::LLVMSetAlignment(load, llalign); } diff --git a/src/librustc_trans/cleanup.rs b/src/librustc_trans/cleanup.rs index 4eb786d6394..67dc347f21f 100644 --- a/src/librustc_trans/cleanup.rs +++ b/src/librustc_trans/cleanup.rs @@ -175,9 +175,7 @@ impl<'tcx> CleanupScope<'tcx> { // The landing pad return type (the type being propagated). Not sure // what this represents but it's determined by the personality // function and this is what the EH proposal example uses. - let llretty = Type::struct_(fcx.ccx, - &[Type::i8p(fcx.ccx), Type::i32(fcx.ccx)], - false); + let llretty = Type::struct_(fcx.ccx, &[Type::i8p(fcx.ccx), Type::i32(fcx.ccx)], false); // The only landing pad clause will be 'cleanup' let llretval = pad_bcx.landing_pad(llretty, llpersonality, 1, pad_bcx.fcx().llfn); diff --git a/src/librustc_trans/common.rs b/src/librustc_trans/common.rs index 81aba269a8b..f022aa50184 100644 --- a/src/librustc_trans/common.rs +++ b/src/librustc_trans/common.rs @@ -421,17 +421,14 @@ impl<'a, 'tcx> BlockAndBuilder<'a, 'tcx> { r } - pub fn ccx(&self) -> &'a CrateContext<'a, 'tcx> { - self.fcx.ccx - } pub fn fcx(&self) -> &'a FunctionContext<'a, 'tcx> { self.fcx } pub fn tcx(&self) -> TyCtxt<'a, 'tcx, 'tcx> { - self.fcx.ccx.tcx() + self.ccx.tcx() } pub fn sess(&self) -> &'a Session { - self.fcx.ccx.sess() + self.ccx.sess() } pub fn llbb(&self) -> BasicBlockRef { diff --git a/src/librustc_trans/glue.rs b/src/librustc_trans/glue.rs index ea34dbbeeb4..c9690ee0d1b 100644 --- a/src/librustc_trans/glue.rs +++ b/src/librustc_trans/glue.rs @@ -474,7 +474,7 @@ fn drop_structural_ty<'a, 'tcx>(cx: BlockAndBuilder<'a, 'tcx>, } } - let value = if cx.ccx().shared().type_is_sized(t) { + let value = if cx.ccx.shared().type_is_sized(t) { adt::MaybeSizedValue::sized(av) } else { // FIXME(#36457) -- we should pass unsized values as two arguments @@ -493,7 +493,7 @@ fn drop_structural_ty<'a, 'tcx>(cx: BlockAndBuilder<'a, 'tcx>, } ty::TyArray(_, n) => { let base = get_dataptr(&cx, value.value); - let len = C_uint(cx.ccx(), n); + let len = C_uint(cx.ccx, n); let unit_ty = t.sequence_element_type(cx.tcx()); cx = tvec::slice_for_each(&cx, base, unit_ty, len, |bb, vv| drop_ty(bb, vv, unit_ty)); } @@ -514,7 +514,7 @@ fn drop_structural_ty<'a, 'tcx>(cx: BlockAndBuilder<'a, 'tcx>, for (i, &Field(_, field_ty)) in fields.iter().enumerate() { let llfld_a = adt::trans_field_ptr(&cx, t, value, Disr::from(discr), i); - let val = if cx.ccx().shared().type_is_sized(field_ty) { + let val = if cx.ccx.shared().type_is_sized(field_ty) { llfld_a } else { // FIXME(#36457) -- we should pass unsized values as two arguments @@ -530,8 +530,6 @@ fn drop_structural_ty<'a, 'tcx>(cx: BlockAndBuilder<'a, 'tcx>, bug!("Union in `glue::drop_structural_ty`"); } AdtKind::Enum => { - let fcx = cx.fcx(); - let ccx = fcx.ccx; let n_variants = adt.variants.len(); // NB: we must hit the discriminant first so that structural @@ -562,15 +560,15 @@ fn drop_structural_ty<'a, 'tcx>(cx: BlockAndBuilder<'a, 'tcx>, // from the outer function, and any other use case will only // call this for an already-valid enum in which case the `ret // void` will never be hit. - let ret_void_cx = fcx.build_new_block("enum-iter-ret-void"); + let ret_void_cx = cx.fcx().build_new_block("enum-iter-ret-void"); ret_void_cx.ret_void(); let llswitch = cx.switch(lldiscrim_a, ret_void_cx.llbb(), n_variants); - let next_cx = fcx.build_new_block("enum-iter-next"); + let next_cx = cx.fcx().build_new_block("enum-iter-next"); for variant in &adt.variants { let variant_cx_name = format!("enum-iter-variant-{}", &variant.disr_val.to_string()); - let variant_cx = fcx.build_new_block(&variant_cx_name); + let variant_cx = cx.fcx().build_new_block(&variant_cx_name); let case_val = adt::trans_case(&cx, t, Disr::from(variant.disr_val)); variant_cx.add_case(llswitch, case_val, variant_cx.llbb()); iter_variant(&variant_cx, t, value, variant, substs); @@ -578,7 +576,7 @@ fn drop_structural_ty<'a, 'tcx>(cx: BlockAndBuilder<'a, 'tcx>, } cx = next_cx; } - _ => ccx.sess().unimpl("value from adt::trans_switch in drop_structural_ty"), + _ => cx.ccx.sess().unimpl("value from adt::trans_switch in drop_structural_ty"), } } }, diff --git a/src/librustc_trans/mir/analyze.rs b/src/librustc_trans/mir/analyze.rs index 3f94af82553..8df24da7135 100644 --- a/src/librustc_trans/mir/analyze.rs +++ b/src/librustc_trans/mir/analyze.rs @@ -33,13 +33,13 @@ pub fn lvalue_locals<'a, 'tcx>(mircx: &MirContext<'a, 'tcx>) -> BitVector { ty.is_unique() || ty.is_region_ptr() || ty.is_simd() || - common::type_is_zero_size(mircx.fcx.ccx, ty) + common::type_is_zero_size(mircx.ccx, ty) { // These sorts of types are immediates that we can store // in an ValueRef without an alloca. - assert!(common::type_is_immediate(mircx.fcx.ccx, ty) || - common::type_is_fat_ptr(mircx.fcx.ccx, ty)); - } else if common::type_is_imm_pair(mircx.fcx.ccx, ty) { + assert!(common::type_is_immediate(mircx.ccx, ty) || + common::type_is_fat_ptr(mircx.ccx, ty)); + } else if common::type_is_imm_pair(mircx.ccx, ty) { // We allow pairs and uses of any of their 2 fields. } else { // These sorts of types require an alloca. Note that @@ -112,7 +112,7 @@ impl<'mir, 'a, 'tcx> Visitor<'tcx> for LocalAnalyzer<'mir, 'a, 'tcx> { literal: mir::Literal::Item { def_id, .. }, .. }), ref args, .. - } if Some(def_id) == self.cx.fcx.ccx.tcx().lang_items.box_free_fn() => { + } if Some(def_id) == self.cx.ccx.tcx().lang_items.box_free_fn() => { // box_free(x) shares with `drop x` the property that it // is not guaranteed to be statically dominated by the // definition of x, so x must always be in an alloca. @@ -135,10 +135,10 @@ impl<'mir, 'a, 'tcx> Visitor<'tcx> for LocalAnalyzer<'mir, 'a, 'tcx> { // Allow uses of projections of immediate pair fields. if let mir::Lvalue::Projection(ref proj) = *lvalue { if let mir::Lvalue::Local(_) = proj.base { - let ty = proj.base.ty(self.cx.mir, self.cx.fcx.ccx.tcx()); + let ty = proj.base.ty(self.cx.mir, self.cx.ccx.tcx()); - let ty = self.cx.monomorphize(&ty.to_ty(self.cx.fcx.ccx.tcx())); - if common::type_is_imm_pair(self.cx.fcx.ccx, ty) { + let ty = self.cx.monomorphize(&ty.to_ty(self.cx.ccx.tcx())); + if common::type_is_imm_pair(self.cx.ccx, ty) { if let mir::ProjectionElem::Field(..) = proj.elem { if let LvalueContext::Consume = context { return; @@ -166,11 +166,11 @@ impl<'mir, 'a, 'tcx> Visitor<'tcx> for LocalAnalyzer<'mir, 'a, 'tcx> { } LvalueContext::Drop => { - let ty = lvalue.ty(self.cx.mir, self.cx.fcx.ccx.tcx()); - let ty = self.cx.monomorphize(&ty.to_ty(self.cx.fcx.ccx.tcx())); + let ty = lvalue.ty(self.cx.mir, self.cx.ccx.tcx()); + let ty = self.cx.monomorphize(&ty.to_ty(self.cx.ccx.tcx())); // Only need the lvalue if we're actually dropping it. - if self.cx.fcx.ccx.shared().type_needs_drop(ty) { + if self.cx.ccx.shared().type_needs_drop(ty) { self.mark_as_lvalue(index); } } diff --git a/src/librustc_trans/mir/block.rs b/src/librustc_trans/mir/block.rs index 3d3796aeebf..b4e9d301039 100644 --- a/src/librustc_trans/mir/block.rs +++ b/src/librustc_trans/mir/block.rs @@ -838,7 +838,7 @@ impl<'a, 'tcx> MirContext<'a, 'tcx> { return block; } - if base::wants_msvc_seh(self.fcx.ccx.sess()) { + if base::wants_msvc_seh(self.ccx.sess()) { return self.blocks[target_bb]; } diff --git a/src/librustc_trans/mir/lvalue.rs b/src/librustc_trans/mir/lvalue.rs index 980c6e678c5..0cd7f007c5d 100644 --- a/src/librustc_trans/mir/lvalue.rs +++ b/src/librustc_trans/mir/lvalue.rs @@ -140,7 +140,7 @@ impl<'a, 'tcx> MirContext<'a, 'tcx> { LvalueTy::Downcast { adt_def: _, substs: _, variant_index: v } => v, }; let discr = discr as u64; - let is_sized = self.fcx.ccx.shared().type_is_sized(projected_ty.to_ty(tcx)); + let is_sized = self.ccx.shared().type_is_sized(projected_ty.to_ty(tcx)); let base = if is_sized { adt::MaybeSizedValue::sized(tr_base.llval) } else { @@ -272,7 +272,7 @@ impl<'a, 'tcx> MirContext<'a, 'tcx> { } pub fn monomorphized_lvalue_ty(&self, lvalue: &mir::Lvalue<'tcx>) -> Ty<'tcx> { - let tcx = self.fcx.ccx.tcx(); + let tcx = self.ccx.tcx(); let lvalue_ty = lvalue.ty(&self.mir, tcx); self.monomorphize(&lvalue_ty.to_ty(tcx)) } diff --git a/src/librustc_trans/mir/mod.rs b/src/librustc_trans/mir/mod.rs index 93caa565817..04e8802cf4e 100644 --- a/src/librustc_trans/mir/mod.rs +++ b/src/librustc_trans/mir/mod.rs @@ -48,9 +48,10 @@ pub struct MirContext<'a, 'tcx:'a> { debug_context: debuginfo::FunctionDebugContext, - /// Function context fcx: &'a common::FunctionContext<'a, 'tcx>, + ccx: &'a CrateContext<'a, 'tcx>, + /// When unwinding is initiated, we have to store this personality /// value somewhere so that we can load it and re-use it in the /// resume instruction. The personality is (afaik) some kind of @@ -100,7 +101,7 @@ pub struct MirContext<'a, 'tcx:'a> { impl<'a, 'tcx> MirContext<'a, 'tcx> { pub fn monomorphize<T>(&self, value: &T) -> T where T: TransNormalize<'tcx> { - monomorphize::apply_param_substs(self.fcx.ccx.shared(), self.param_substs, value) + monomorphize::apply_param_substs(self.ccx.shared(), self.param_substs, value) } pub fn set_debug_loc(&mut self, bcx: &BlockAndBuilder, source_info: mir::SourceInfo) { @@ -123,12 +124,12 @@ impl<'a, 'tcx> MirContext<'a, 'tcx> { // (unless the crate is being compiled with `-Z debug-macros`). if source_info.span.expn_id == NO_EXPANSION || source_info.span.expn_id == COMMAND_LINE_EXPN || - self.fcx.ccx.sess().opts.debugging_opts.debug_macros { + self.ccx.sess().opts.debugging_opts.debug_macros { let scope = self.scope_metadata_for_loc(source_info.scope, source_info.span.lo); (scope, source_info.span) } else { - let cm = self.fcx.ccx.sess().codemap(); + let cm = self.ccx.sess().codemap(); // Walk up the macro expansion chain until we reach a non-expanded span. let mut span = source_info.span; while span.expn_id != NO_EXPANSION && span.expn_id != COMMAND_LINE_EXPN { @@ -154,10 +155,8 @@ impl<'a, 'tcx> MirContext<'a, 'tcx> { let scope_metadata = self.scopes[scope_id].scope_metadata; if pos < self.scopes[scope_id].file_start_pos || pos >= self.scopes[scope_id].file_end_pos { - let cm = self.fcx.ccx.sess().codemap(); - debuginfo::extend_scope_to_file(self.fcx.ccx, - scope_metadata, - &cm.lookup_char_pos(pos).file) + let cm = self.ccx.sess().codemap(); + debuginfo::extend_scope_to_file(self.ccx, scope_metadata, &cm.lookup_char_pos(pos).file) } else { scope_metadata } @@ -225,6 +224,7 @@ pub fn trans_mir<'a, 'tcx: 'a>( let mut mircx = MirContext { mir: mir, fcx: fcx, + ccx: fcx.ccx, llpersonalityslot: None, blocks: block_bcxs, unreachable_block: None, |
