]> git.lizzy.rs Git - rust.git/commitdiff
Change *.fcx.ccx to *.ccx
authorMark Simulacrum <mark.simulacrum@gmail.com>
Tue, 20 Dec 2016 00:48:41 +0000 (17:48 -0700)
committerMark Simulacrum <mark.simulacrum@gmail.com>
Wed, 21 Dec 2016 03:04:43 +0000 (20:04 -0700)
src/librustc_trans/base.rs
src/librustc_trans/cleanup.rs
src/librustc_trans/common.rs
src/librustc_trans/glue.rs
src/librustc_trans/mir/analyze.rs
src/librustc_trans/mir/block.rs
src/librustc_trans/mir/lvalue.rs
src/librustc_trans/mir/mod.rs

index 9697f2604349bbf9ad5d6b9a124d20c2e5ee1902..3f5cbd68042480a9c35b794fc41a4844ca2dac48 100644 (file)
@@ -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);
             }
index 4eb786d63941bd0e8b8b92d94563318ce8e42974..67dc347f21fedb09f0c0765dc4f3aeafa4accdaa 100644 (file)
@@ -175,9 +175,7 @@ fn get_landing_pad<'a>(fcx: &FunctionContext<'a, 'tcx>, drop_val: &DropValue<'tc
             // 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);
index 81aba269a8b3b407605654a270f6da69f99be022..f022aa50184c798cbbff968b881a278739298a5e 100644 (file)
@@ -421,17 +421,14 @@ pub fn at_start<F, R>(&self, f: F) -> R
         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 {
index ea34dbbeeb4268dda35a421bd5039bfcd41a8e6d..c9690ee0d1b972edcf7a4ad4be0d29189b323b7a 100644 (file)
@@ -474,7 +474,7 @@ fn iter_variant<'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 iter_variant<'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 iter_variant<'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 iter_variant<'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 iter_variant<'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 iter_variant<'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"),
                 }
             }
         },
index 3f94af825539487fb25afc0de462c8bb83920c6e..8df24da7135887e4ecdea99dfcf1467ce2d7bc5b 100644 (file)
@@ -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 @@ fn visit_terminator_kind(&mut self,
                     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 @@ fn visit_lvalue(&mut self,
         // 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 @@ fn visit_lvalue(&mut self,
                 }
 
                 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);
                     }
                 }
index 3d3796aeebffc46f16298c63e5dc81d78a91a72e..b4e9d301039b9e172d4821c39f8aa648f4cae4fa 100644 (file)
@@ -838,7 +838,7 @@ fn landing_pad_to(&mut self, target_bb: mir::BasicBlock) -> BasicBlockRef {
             return block;
         }
 
-        if base::wants_msvc_seh(self.fcx.ccx.sess()) {
+        if base::wants_msvc_seh(self.ccx.sess()) {
             return self.blocks[target_bb];
         }
 
index 980c6e678c525b74cc9c4e4ca473cd9195899a46..0cd7f007c5df92dda45b67fee48d100b808ac524 100644 (file)
@@ -140,7 +140,7 @@ pub fn trans_lvalue(&mut self,
                             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 @@ fn prepare_index(&mut self,
     }
 
     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))
     }
index 93caa565817e4e7a5660d787794e19191099392c..04e8802cf4e95550cef4a86b0e7ca64c52a31f4a 100644 (file)
@@ -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 @@ pub fn debug_loc(&mut self, source_info: mir::SourceInfo) -> (DIScope, Span) {
         // (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 @@ fn scope_metadata_for_loc(&self, scope_id: mir::VisibilityScope, pos: BytePos)
         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,