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);
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);
}
// 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);
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 {
}
}
- 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
}
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));
}
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
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
// 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);
}
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"),
}
}
},
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
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.
// 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;
}
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);
}
}
return block;
}
- if base::wants_msvc_seh(self.fcx.ccx.sess()) {
+ if base::wants_msvc_seh(self.ccx.sess()) {
return self.blocks[target_bb];
}
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 {
}
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))
}
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
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) {
// (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 {
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
}
let mut mircx = MirContext {
mir: mir,
fcx: fcx,
+ ccx: fcx.ccx,
llpersonalityslot: None,
blocks: block_bcxs,
unreachable_block: None,