diff options
Diffstat (limited to 'src/librustc_trans')
| -rw-r--r-- | src/librustc_trans/abi.rs | 6 | ||||
| -rw-r--r-- | src/librustc_trans/asm.rs | 4 | ||||
| -rw-r--r-- | src/librustc_trans/base.rs | 6 | ||||
| -rw-r--r-- | src/librustc_trans/intrinsic.rs | 6 | ||||
| -rw-r--r-- | src/librustc_trans/mir/analyze.rs | 46 | ||||
| -rw-r--r-- | src/librustc_trans/mir/block.rs | 50 | ||||
| -rw-r--r-- | src/librustc_trans/mir/constant.rs | 36 | ||||
| -rw-r--r-- | src/librustc_trans/mir/lvalue.rs | 52 | ||||
| -rw-r--r-- | src/librustc_trans/mir/mod.rs | 28 | ||||
| -rw-r--r-- | src/librustc_trans/mir/operand.rs | 20 | ||||
| -rw-r--r-- | src/librustc_trans/mir/rvalue.rs | 14 | ||||
| -rw-r--r-- | src/librustc_trans/mir/statement.rs | 8 | ||||
| -rw-r--r-- | src/librustc_trans/type_of.rs | 2 |
13 files changed, 139 insertions, 139 deletions
diff --git a/src/librustc_trans/abi.rs b/src/librustc_trans/abi.rs index 1cd138d4ee6..9c23ffec6c0 100644 --- a/src/librustc_trans/abi.rs +++ b/src/librustc_trans/abi.rs @@ -30,7 +30,7 @@ use cabi_sparc64; use cabi_nvptx; use cabi_nvptx64; use cabi_hexagon; -use mir::lvalue::{Alignment, LvalueRef}; +use mir::lvalue::{Alignment, PlaceRef}; use mir::operand::OperandValue; use type_::Type; use type_of::{LayoutLlvmExt, PointerKind}; @@ -555,7 +555,7 @@ impl<'a, 'tcx> ArgType<'tcx> { /// lvalue for the original Rust type of this argument/return. /// Can be used for both storing formal arguments into Rust variables /// or results of call/invoke instructions into their destinations. - pub fn store(&self, bcx: &Builder<'a, 'tcx>, val: ValueRef, dst: LvalueRef<'tcx>) { + pub fn store(&self, bcx: &Builder<'a, 'tcx>, val: ValueRef, dst: PlaceRef<'tcx>) { if self.is_ignore() { return; } @@ -606,7 +606,7 @@ impl<'a, 'tcx> ArgType<'tcx> { } } - pub fn store_fn_arg(&self, bcx: &Builder<'a, 'tcx>, idx: &mut usize, dst: LvalueRef<'tcx>) { + pub fn store_fn_arg(&self, bcx: &Builder<'a, 'tcx>, idx: &mut usize, dst: PlaceRef<'tcx>) { if self.pad.is_some() { *idx += 1; } diff --git a/src/librustc_trans/asm.rs b/src/librustc_trans/asm.rs index 1959fd13ccb..5e6dfabc188 100644 --- a/src/librustc_trans/asm.rs +++ b/src/librustc_trans/asm.rs @@ -18,7 +18,7 @@ use builder::Builder; use rustc::hir; -use mir::lvalue::LvalueRef; +use mir::lvalue::PlaceRef; use mir::operand::OperandValue; use std::ffi::CString; @@ -29,7 +29,7 @@ use libc::{c_uint, c_char}; pub fn trans_inline_asm<'a, 'tcx>( bcx: &Builder<'a, 'tcx>, ia: &hir::InlineAsm, - outputs: Vec<LvalueRef<'tcx>>, + outputs: Vec<PlaceRef<'tcx>>, mut inputs: Vec<ValueRef> ) { let mut ext_constraints = vec![]; diff --git a/src/librustc_trans/base.rs b/src/librustc_trans/base.rs index 62738222a8c..ec9ed402ac6 100644 --- a/src/librustc_trans/base.rs +++ b/src/librustc_trans/base.rs @@ -50,7 +50,7 @@ use rustc::session::config::{self, NoDebugInfo}; use rustc::session::Session; use rustc_incremental; use allocator; -use mir::lvalue::LvalueRef; +use mir::lvalue::PlaceRef; use attributes; use builder::Builder; use callee; @@ -272,8 +272,8 @@ pub fn unsize_thin_ptr<'a, 'tcx>( /// Coerce `src`, which is a reference to a value of type `src_ty`, /// to a value of type `dst_ty` and store the result in `dst` pub fn coerce_unsized_into<'a, 'tcx>(bcx: &Builder<'a, 'tcx>, - src: LvalueRef<'tcx>, - dst: LvalueRef<'tcx>) { + src: PlaceRef<'tcx>, + dst: PlaceRef<'tcx>) { let src_ty = src.layout.ty; let dst_ty = dst.layout.ty; let coerce_ptr = || { diff --git a/src/librustc_trans/intrinsic.rs b/src/librustc_trans/intrinsic.rs index 997dd557353..cfa31260617 100644 --- a/src/librustc_trans/intrinsic.rs +++ b/src/librustc_trans/intrinsic.rs @@ -14,7 +14,7 @@ use intrinsics::{self, Intrinsic}; use llvm; use llvm::{ValueRef}; use abi::{Abi, FnType, PassMode}; -use mir::lvalue::{LvalueRef, Alignment}; +use mir::lvalue::{PlaceRef, Alignment}; use mir::operand::{OperandRef, OperandValue}; use base::*; use common::*; @@ -106,7 +106,7 @@ pub fn trans_intrinsic_call<'a, 'tcx>(bcx: &Builder<'a, 'tcx>, let name = &*tcx.item_name(def_id); let llret_ty = ccx.layout_of(ret_ty).llvm_type(ccx); - let result = LvalueRef::new_sized(llresult, fn_ty.ret.layout, Alignment::AbiAligned); + let result = PlaceRef::new_sized(llresult, fn_ty.ret.layout, Alignment::AbiAligned); let simple = get_simple_intrinsic(ccx, name); let llval = match name { @@ -625,7 +625,7 @@ pub fn trans_intrinsic_call<'a, 'tcx>(bcx: &Builder<'a, 'tcx>, OperandValue::Ref(ptr, align) => (ptr, align), _ => bug!() }; - let arg = LvalueRef::new_sized(ptr, arg.layout, align); + let arg = PlaceRef::new_sized(ptr, arg.layout, align); (0..contents.len()).map(|i| { arg.project_field(bcx, i).load(bcx).immediate() }).collect() diff --git a/src/librustc_trans/mir/analyze.rs b/src/librustc_trans/mir/analyze.rs index 77f607e5514..6feb056a83c 100644 --- a/src/librustc_trans/mir/analyze.rs +++ b/src/librustc_trans/mir/analyze.rs @@ -15,7 +15,7 @@ use rustc_data_structures::bitvec::BitVector; use rustc_data_structures::indexed_vec::{Idx, IndexVec}; use rustc::middle::const_val::ConstVal; use rustc::mir::{self, Location, TerminatorKind, Literal}; -use rustc::mir::visit::{Visitor, LvalueContext}; +use rustc::mir::visit::{Visitor, PlaceContext}; use rustc::mir::traversal; use rustc::ty; use rustc::ty::layout::LayoutOf; @@ -88,18 +88,18 @@ impl<'mir, 'a, 'tcx> LocalAnalyzer<'mir, 'a, 'tcx> { impl<'mir, 'a, 'tcx> Visitor<'tcx> for LocalAnalyzer<'mir, 'a, 'tcx> { fn visit_assign(&mut self, block: mir::BasicBlock, - lvalue: &mir::Lvalue<'tcx>, + lvalue: &mir::Place<'tcx>, rvalue: &mir::Rvalue<'tcx>, location: Location) { debug!("visit_assign(block={:?}, lvalue={:?}, rvalue={:?})", block, lvalue, rvalue); - if let mir::Lvalue::Local(index) = *lvalue { + if let mir::Place::Local(index) = *lvalue { self.mark_assigned(index); if !self.cx.rvalue_creates_operand(rvalue) { self.mark_as_lvalue(index); } } else { - self.visit_lvalue(lvalue, LvalueContext::Store, location); + self.visit_lvalue(lvalue, PlaceContext::Store, location); } self.visit_rvalue(rvalue, location); @@ -122,7 +122,7 @@ impl<'mir, 'a, 'tcx> Visitor<'tcx> for LocalAnalyzer<'mir, 'a, 'tcx> { // is not guaranteed to be statically dominated by the // definition of x, so x must always be in an alloca. if let mir::Operand::Move(ref lvalue) = args[0] { - self.visit_lvalue(lvalue, LvalueContext::Drop, location); + self.visit_lvalue(lvalue, PlaceContext::Drop, location); } } _ => {} @@ -132,16 +132,16 @@ impl<'mir, 'a, 'tcx> Visitor<'tcx> for LocalAnalyzer<'mir, 'a, 'tcx> { } fn visit_lvalue(&mut self, - lvalue: &mir::Lvalue<'tcx>, - context: LvalueContext<'tcx>, + lvalue: &mir::Place<'tcx>, + context: PlaceContext<'tcx>, location: Location) { debug!("visit_lvalue(lvalue={:?}, context={:?})", lvalue, context); let ccx = self.cx.ccx; - if let mir::Lvalue::Projection(ref proj) = *lvalue { + if let mir::Place::Projection(ref proj) = *lvalue { // Allow uses of projections that are ZSTs or from scalar fields. let is_consume = match context { - LvalueContext::Copy | LvalueContext::Move => true, + PlaceContext::Copy | PlaceContext::Move => true, _ => false }; if is_consume { @@ -169,7 +169,7 @@ impl<'mir, 'a, 'tcx> Visitor<'tcx> for LocalAnalyzer<'mir, 'a, 'tcx> { // A deref projection only reads the pointer, never needs the lvalue. if let mir::ProjectionElem::Deref = proj.elem { - return self.visit_lvalue(&proj.base, LvalueContext::Copy, location); + return self.visit_lvalue(&proj.base, PlaceContext::Copy, location); } } @@ -178,28 +178,28 @@ impl<'mir, 'a, 'tcx> Visitor<'tcx> for LocalAnalyzer<'mir, 'a, 'tcx> { fn visit_local(&mut self, &index: &mir::Local, - context: LvalueContext<'tcx>, + context: PlaceContext<'tcx>, _: Location) { match context { - LvalueContext::Call => { + PlaceContext::Call => { self.mark_assigned(index); } - LvalueContext::StorageLive | - LvalueContext::StorageDead | - LvalueContext::Validate | - LvalueContext::Copy | - LvalueContext::Move => {} + PlaceContext::StorageLive | + PlaceContext::StorageDead | + PlaceContext::Validate | + PlaceContext::Copy | + PlaceContext::Move => {} - LvalueContext::Inspect | - LvalueContext::Store | - LvalueContext::Borrow { .. } | - LvalueContext::Projection(..) => { + PlaceContext::Inspect | + PlaceContext::Store | + PlaceContext::Borrow { .. } | + PlaceContext::Projection(..) => { self.mark_as_lvalue(index); } - LvalueContext::Drop => { - let ty = mir::Lvalue::Local(index).ty(self.cx.mir, self.cx.ccx.tcx()); + PlaceContext::Drop => { + let ty = mir::Place::Local(index).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. diff --git a/src/librustc_trans/mir/block.rs b/src/librustc_trans/mir/block.rs index 61811a62c66..94a8df0a35b 100644 --- a/src/librustc_trans/mir/block.rs +++ b/src/librustc_trans/mir/block.rs @@ -31,7 +31,7 @@ use syntax_pos::Pos; use super::{MirContext, LocalRef}; use super::constant::Const; -use super::lvalue::{Alignment, LvalueRef}; +use super::lvalue::{Alignment, PlaceRef}; use super::operand::OperandRef; use super::operand::OperandValue::{Pair, Ref, Immediate}; @@ -214,7 +214,7 @@ impl<'a, 'tcx> MirContext<'a, 'tcx> { } PassMode::Direct(_) | PassMode::Pair(..) => { - let op = self.trans_consume(&bcx, &mir::Lvalue::Local(mir::RETURN_POINTER)); + let op = self.trans_consume(&bcx, &mir::Place::Local(mir::RETURN_POINTER)); if let Ref(llval, align) = op.val { bcx.load(llval, align.non_abi()) } else { @@ -226,7 +226,7 @@ impl<'a, 'tcx> MirContext<'a, 'tcx> { let op = match self.locals[mir::RETURN_POINTER] { LocalRef::Operand(Some(op)) => op, LocalRef::Operand(None) => bug!("use of return before def"), - LocalRef::Lvalue(tr_lvalue) => { + LocalRef::Place(tr_lvalue) => { OperandRef { val: Ref(tr_lvalue.llval, tr_lvalue.alignment), layout: tr_lvalue.layout @@ -235,7 +235,7 @@ impl<'a, 'tcx> MirContext<'a, 'tcx> { }; let llslot = match op.val { Immediate(_) | Pair(..) => { - let scratch = LvalueRef::alloca(&bcx, self.fn_ty.ret.layout, "ret"); + let scratch = PlaceRef::alloca(&bcx, self.fn_ty.ret.layout, "ret"); op.val.store(&bcx, scratch); scratch.llval } @@ -577,7 +577,7 @@ impl<'a, 'tcx> MirContext<'a, 'tcx> { match (arg, op.val) { (&mir::Operand::Copy(_), Ref(..)) | (&mir::Operand::Constant(_), Ref(..)) => { - let tmp = LvalueRef::alloca(&bcx, op.layout, "const"); + let tmp = PlaceRef::alloca(&bcx, op.layout, "const"); op.val.store(&bcx, tmp); op.val = Ref(tmp.llval, tmp.alignment); } @@ -637,7 +637,7 @@ impl<'a, 'tcx> MirContext<'a, 'tcx> { Immediate(_) | Pair(..) => { match arg.mode { PassMode::Indirect(_) | PassMode::Cast(_) => { - let scratch = LvalueRef::alloca(bcx, arg.layout, "arg"); + let scratch = PlaceRef::alloca(bcx, arg.layout, "arg"); op.val.store(bcx, scratch); (scratch.llval, Alignment::AbiAligned, true) } @@ -651,7 +651,7 @@ impl<'a, 'tcx> MirContext<'a, 'tcx> { // think that ATM (Rust 1.16) we only pass temporaries, but we shouldn't // have scary latent bugs around. - let scratch = LvalueRef::alloca(bcx, arg.layout, "arg"); + let scratch = PlaceRef::alloca(bcx, arg.layout, "arg"); base::memcpy_ty(bcx, scratch.llval, llval, op.layout, align.non_abi()); (scratch.llval, Alignment::AbiAligned, true) } @@ -665,7 +665,7 @@ impl<'a, 'tcx> MirContext<'a, 'tcx> { (align | Alignment::Packed(arg.layout.align)) .non_abi()); } else { - // We can't use `LvalueRef::load` here because the argument + // We can't use `PlaceRef::load` here because the argument // may have a type we don't treat as immediate, but the ABI // used for this call is passing it by-value. In that case, // the load would just produce `OperandValue::Ref` instead @@ -693,7 +693,7 @@ impl<'a, 'tcx> MirContext<'a, 'tcx> { // Handle both by-ref and immediate tuples. if let Ref(llval, align) = tuple.val { - let tuple_ptr = LvalueRef::new_sized(llval, tuple.layout, align); + let tuple_ptr = PlaceRef::new_sized(llval, tuple.layout, align); for i in 0..tuple.layout.fields.count() { let field_ptr = tuple_ptr.project_field(bcx, i); self.trans_argument(bcx, field_ptr.load(bcx), llargs, &args[i]); @@ -707,7 +707,7 @@ impl<'a, 'tcx> MirContext<'a, 'tcx> { } } - fn get_personality_slot(&mut self, bcx: &Builder<'a, 'tcx>) -> LvalueRef<'tcx> { + fn get_personality_slot(&mut self, bcx: &Builder<'a, 'tcx>) -> PlaceRef<'tcx> { let ccx = bcx.ccx; if let Some(slot) = self.personality_slot { slot @@ -716,7 +716,7 @@ impl<'a, 'tcx> MirContext<'a, 'tcx> { ccx.tcx().mk_mut_ptr(ccx.tcx().types.u8), ccx.tcx().types.i32 ], false)); - let slot = LvalueRef::alloca(bcx, layout, "personalityslot"); + let slot = PlaceRef::alloca(bcx, layout, "personalityslot"); self.personality_slot = Some(slot); slot } @@ -781,23 +781,23 @@ impl<'a, 'tcx> MirContext<'a, 'tcx> { } fn make_return_dest(&mut self, bcx: &Builder<'a, 'tcx>, - dest: &mir::Lvalue<'tcx>, fn_ret: &ArgType<'tcx>, + dest: &mir::Place<'tcx>, fn_ret: &ArgType<'tcx>, llargs: &mut Vec<ValueRef>, is_intrinsic: bool) -> ReturnDest<'tcx> { // If the return is ignored, we can just return a do-nothing ReturnDest if fn_ret.is_ignore() { return ReturnDest::Nothing; } - let dest = if let mir::Lvalue::Local(index) = *dest { + let dest = if let mir::Place::Local(index) = *dest { match self.locals[index] { - LocalRef::Lvalue(dest) => dest, + LocalRef::Place(dest) => dest, LocalRef::Operand(None) => { // Handle temporary lvalues, specifically Operand ones, as // they don't have allocas return if fn_ret.is_indirect() { // Odd, but possible, case, we have an operand temporary, // but the calling convention has an indirect return. - let tmp = LvalueRef::alloca(bcx, fn_ret.layout, "tmp_ret"); + let tmp = PlaceRef::alloca(bcx, fn_ret.layout, "tmp_ret"); tmp.storage_live(bcx); llargs.push(tmp.llval); ReturnDest::IndirectOperand(tmp, index) @@ -805,7 +805,7 @@ impl<'a, 'tcx> MirContext<'a, 'tcx> { // Currently, intrinsics always need a location to store // the result. so we create a temporary alloca for the // result - let tmp = LvalueRef::alloca(bcx, fn_ret.layout, "tmp_ret"); + let tmp = PlaceRef::alloca(bcx, fn_ret.layout, "tmp_ret"); tmp.storage_live(bcx); ReturnDest::IndirectOperand(tmp, index) } else { @@ -842,14 +842,14 @@ impl<'a, 'tcx> MirContext<'a, 'tcx> { fn trans_transmute(&mut self, bcx: &Builder<'a, 'tcx>, src: &mir::Operand<'tcx>, - dst: &mir::Lvalue<'tcx>) { - if let mir::Lvalue::Local(index) = *dst { + dst: &mir::Place<'tcx>) { + if let mir::Place::Local(index) = *dst { match self.locals[index] { - LocalRef::Lvalue(lvalue) => self.trans_transmute_into(bcx, src, lvalue), + LocalRef::Place(lvalue) => self.trans_transmute_into(bcx, src, lvalue), LocalRef::Operand(None) => { let dst_layout = bcx.ccx.layout_of(self.monomorphized_lvalue_ty(dst)); assert!(!dst_layout.ty.has_erasable_regions()); - let lvalue = LvalueRef::alloca(bcx, dst_layout, "transmute_temp"); + let lvalue = PlaceRef::alloca(bcx, dst_layout, "transmute_temp"); lvalue.storage_live(bcx); self.trans_transmute_into(bcx, src, lvalue); let op = lvalue.load(bcx); @@ -869,13 +869,13 @@ impl<'a, 'tcx> MirContext<'a, 'tcx> { fn trans_transmute_into(&mut self, bcx: &Builder<'a, 'tcx>, src: &mir::Operand<'tcx>, - dst: LvalueRef<'tcx>) { + dst: PlaceRef<'tcx>) { let src = self.trans_operand(bcx, src); let llty = src.layout.llvm_type(bcx.ccx); let cast_ptr = bcx.pointercast(dst.llval, llty.ptr_to()); let align = src.layout.align.min(dst.layout.align); src.val.store(bcx, - LvalueRef::new_sized(cast_ptr, src.layout, Alignment::Packed(align))); + PlaceRef::new_sized(cast_ptr, src.layout, Alignment::Packed(align))); } @@ -898,7 +898,7 @@ impl<'a, 'tcx> MirContext<'a, 'tcx> { DirectOperand(index) => { // If there is a cast, we have to store and reload. let op = if let PassMode::Cast(_) = ret_ty.mode { - let tmp = LvalueRef::alloca(bcx, ret_ty.layout, "tmp_ret"); + let tmp = PlaceRef::alloca(bcx, ret_ty.layout, "tmp_ret"); tmp.storage_live(bcx); ret_ty.store(bcx, llval, tmp); let op = tmp.load(bcx); @@ -917,9 +917,9 @@ enum ReturnDest<'tcx> { // Do nothing, the return value is indirect or ignored Nothing, // Store the return value to the pointer - Store(LvalueRef<'tcx>), + Store(PlaceRef<'tcx>), // Stores an indirect return value to an operand local lvalue - IndirectOperand(LvalueRef<'tcx>, mir::Local), + IndirectOperand(PlaceRef<'tcx>, mir::Local), // Stores a direct return value to an operand local lvalue DirectOperand(mir::Local) } diff --git a/src/librustc_trans/mir/constant.rs b/src/librustc_trans/mir/constant.rs index e38af774a51..75fb95ed6e8 100644 --- a/src/librustc_trans/mir/constant.rs +++ b/src/librustc_trans/mir/constant.rs @@ -16,7 +16,7 @@ use rustc::hir::def_id::DefId; use rustc::infer::TransNormalize; use rustc::traits; use rustc::mir; -use rustc::mir::tcx::LvalueTy; +use rustc::mir::tcx::PlaceTy; use rustc::ty::{self, Ty, TyCtxt, TypeFoldable}; use rustc::ty::layout::{self, LayoutOf, Size}; use rustc::ty::cast::{CastTy, IntTy}; @@ -156,8 +156,8 @@ impl<'a, 'tcx> Const<'tcx> { self.get_pair(ccx) } - fn as_lvalue(&self) -> ConstLvalue<'tcx> { - ConstLvalue { + fn as_lvalue(&self) -> ConstPlace<'tcx> { + ConstPlace { base: Base::Value(self.llval), llextra: ptr::null_mut(), ty: self.ty @@ -212,13 +212,13 @@ enum Base { /// An lvalue as seen from a constant. #[derive(Copy, Clone)] -struct ConstLvalue<'tcx> { +struct ConstPlace<'tcx> { base: Base, llextra: ValueRef, ty: Ty<'tcx> } -impl<'tcx> ConstLvalue<'tcx> { +impl<'tcx> ConstPlace<'tcx> { fn to_const(&self, span: Span) -> Const<'tcx> { match self.base { Base::Value(val) => Const::new(val, self.ty), @@ -242,7 +242,7 @@ impl<'tcx> ConstLvalue<'tcx> { assert!(self.llextra != ptr::null_mut()); self.llextra } - _ => bug!("unexpected type `{}` in ConstLvalue::len", self.ty) + _ => bug!("unexpected type `{}` in ConstPlace::len", self.ty) } } } @@ -427,38 +427,38 @@ impl<'a, 'tcx> MirConstContext<'a, 'tcx> { } fn store(&mut self, - dest: &mir::Lvalue<'tcx>, + dest: &mir::Place<'tcx>, value: Result<Const<'tcx>, ConstEvalErr<'tcx>>, span: Span) { - if let mir::Lvalue::Local(index) = *dest { + if let mir::Place::Local(index) = *dest { self.locals[index] = Some(value); } else { span_bug!(span, "assignment to {:?} in constant", dest); } } - fn const_lvalue(&self, lvalue: &mir::Lvalue<'tcx>, span: Span) - -> Result<ConstLvalue<'tcx>, ConstEvalErr<'tcx>> { + fn const_lvalue(&self, lvalue: &mir::Place<'tcx>, span: Span) + -> Result<ConstPlace<'tcx>, ConstEvalErr<'tcx>> { let tcx = self.ccx.tcx(); - if let mir::Lvalue::Local(index) = *lvalue { + if let mir::Place::Local(index) = *lvalue { return self.locals[index].clone().unwrap_or_else(|| { span_bug!(span, "{:?} not initialized", lvalue) }).map(|v| v.as_lvalue()); } let lvalue = match *lvalue { - mir::Lvalue::Local(_) => bug!(), // handled above - mir::Lvalue::Static(box mir::Static { def_id, ty }) => { - ConstLvalue { + mir::Place::Local(_) => bug!(), // handled above + mir::Place::Static(box mir::Static { def_id, ty }) => { + ConstPlace { base: Base::Static(consts::get_static(self.ccx, def_id)), llextra: ptr::null_mut(), ty: self.monomorphize(&ty), } } - mir::Lvalue::Projection(ref projection) => { + mir::Place::Projection(ref projection) => { let tr_base = self.const_lvalue(&projection.base, span)?; - let projected_ty = LvalueTy::Ty { ty: tr_base.ty } + let projected_ty = PlaceTy::Ty { ty: tr_base.ty } .projection_ty(tcx, &projection.elem); let base = tr_base.to_const(span); let projected_ty = self.monomorphize(&projected_ty).to_ty(tcx); @@ -505,7 +505,7 @@ impl<'a, 'tcx> MirConstContext<'a, 'tcx> { (Base::Value(llprojected), llextra) } mir::ProjectionElem::Index(index) => { - let index = &mir::Operand::Copy(mir::Lvalue::Local(index)); + let index = &mir::Operand::Copy(mir::Place::Local(index)); let llindex = self.const_operand(index, span)?.llval; let iv = if let Some(iv) = common::const_to_opt_u128(llindex, false) { @@ -526,7 +526,7 @@ impl<'a, 'tcx> MirConstContext<'a, 'tcx> { } _ => span_bug!(span, "{:?} in constant", projection.elem) }; - ConstLvalue { + ConstPlace { base: projected, llextra, ty: projected_ty diff --git a/src/librustc_trans/mir/lvalue.rs b/src/librustc_trans/mir/lvalue.rs index b7470e470bc..88689540f95 100644 --- a/src/librustc_trans/mir/lvalue.rs +++ b/src/librustc_trans/mir/lvalue.rs @@ -12,7 +12,7 @@ use llvm::{self, ValueRef}; use rustc::ty::{self, Ty}; use rustc::ty::layout::{self, Align, TyLayout, LayoutOf}; use rustc::mir; -use rustc::mir::tcx::LvalueTy; +use rustc::mir::tcx::PlaceTy; use rustc_data_structures::indexed_vec::Idx; use base; use builder::Builder; @@ -73,7 +73,7 @@ impl Alignment { } #[derive(Copy, Clone, Debug)] -pub struct LvalueRef<'tcx> { +pub struct PlaceRef<'tcx> { /// Pointer to the contents of the lvalue pub llval: ValueRef, @@ -87,12 +87,12 @@ pub struct LvalueRef<'tcx> { pub alignment: Alignment, } -impl<'a, 'tcx> LvalueRef<'tcx> { +impl<'a, 'tcx> PlaceRef<'tcx> { pub fn new_sized(llval: ValueRef, layout: TyLayout<'tcx>, alignment: Alignment) - -> LvalueRef<'tcx> { - LvalueRef { + -> PlaceRef<'tcx> { + PlaceRef { llval, llextra: ptr::null_mut(), layout, @@ -101,7 +101,7 @@ impl<'a, 'tcx> LvalueRef<'tcx> { } pub fn alloca(bcx: &Builder<'a, 'tcx>, layout: TyLayout<'tcx>, name: &str) - -> LvalueRef<'tcx> { + -> PlaceRef<'tcx> { debug!("alloca({:?}: {:?})", name, layout); let tmp = bcx.alloca(layout.llvm_type(bcx.ccx), name, layout.align); Self::new_sized(tmp, layout, Alignment::AbiAligned) @@ -117,7 +117,7 @@ impl<'a, 'tcx> LvalueRef<'tcx> { C_usize(ccx, count) } } else { - bug!("unexpected layout `{:#?}` in LvalueRef::len", self.layout) + bug!("unexpected layout `{:#?}` in PlaceRef::len", self.layout) } } @@ -126,7 +126,7 @@ impl<'a, 'tcx> LvalueRef<'tcx> { } pub fn load(&self, bcx: &Builder<'a, 'tcx>) -> OperandRef<'tcx> { - debug!("LvalueRef::load: {:?}", self); + debug!("PlaceRef::load: {:?}", self); assert!(!self.has_extra()); @@ -202,7 +202,7 @@ impl<'a, 'tcx> LvalueRef<'tcx> { } /// Access a field, at a point when the value's case is known. - pub fn project_field(self, bcx: &Builder<'a, 'tcx>, ix: usize) -> LvalueRef<'tcx> { + pub fn project_field(self, bcx: &Builder<'a, 'tcx>, ix: usize) -> PlaceRef<'tcx> { let ccx = bcx.ccx; let field = self.layout.field(ccx, ix); let offset = self.layout.fields.offset(ix); @@ -219,7 +219,7 @@ impl<'a, 'tcx> LvalueRef<'tcx> { } else { bcx.struct_gep(self.llval, self.layout.llvm_field_index(ix)) }; - LvalueRef { + PlaceRef { // HACK(eddyb) have to bitcast pointers until LLVM removes pointee types. llval: bcx.pointercast(llval, field.llvm_type(ccx).ptr_to()), llextra: if ccx.shared().type_has_metadata(field.ty) { @@ -295,7 +295,7 @@ impl<'a, 'tcx> LvalueRef<'tcx> { let ll_fty = field.llvm_type(ccx); debug!("struct_field_ptr: Field type is {:?}", ll_fty); - LvalueRef { + PlaceRef { llval: bcx.pointercast(byte_ptr, ll_fty.ptr_to()), llextra: self.llextra, layout: field, @@ -413,8 +413,8 @@ impl<'a, 'tcx> LvalueRef<'tcx> { } pub fn project_index(&self, bcx: &Builder<'a, 'tcx>, llindex: ValueRef) - -> LvalueRef<'tcx> { - LvalueRef { + -> PlaceRef<'tcx> { + PlaceRef { llval: bcx.inbounds_gep(self.llval, &[C_usize(bcx.ccx, 0), llindex]), llextra: ptr::null_mut(), layout: self.layout.field(bcx.ccx, 0), @@ -423,7 +423,7 @@ impl<'a, 'tcx> LvalueRef<'tcx> { } pub fn project_downcast(&self, bcx: &Builder<'a, 'tcx>, variant_index: usize) - -> LvalueRef<'tcx> { + -> PlaceRef<'tcx> { let mut downcast = *self; downcast.layout = self.layout.for_variant(bcx.ccx, variant_index); @@ -446,16 +446,16 @@ impl<'a, 'tcx> LvalueRef<'tcx> { impl<'a, 'tcx> MirContext<'a, 'tcx> { pub fn trans_lvalue(&mut self, bcx: &Builder<'a, 'tcx>, - lvalue: &mir::Lvalue<'tcx>) - -> LvalueRef<'tcx> { + lvalue: &mir::Place<'tcx>) + -> PlaceRef<'tcx> { debug!("trans_lvalue(lvalue={:?})", lvalue); let ccx = bcx.ccx; let tcx = ccx.tcx(); - if let mir::Lvalue::Local(index) = *lvalue { + if let mir::Place::Local(index) = *lvalue { match self.locals[index] { - LocalRef::Lvalue(lvalue) => { + LocalRef::Place(lvalue) => { return lvalue; } LocalRef::Operand(..) => { @@ -465,20 +465,20 @@ impl<'a, 'tcx> MirContext<'a, 'tcx> { } let result = match *lvalue { - mir::Lvalue::Local(_) => bug!(), // handled above - mir::Lvalue::Static(box mir::Static { def_id, ty }) => { - LvalueRef::new_sized(consts::get_static(ccx, def_id), + mir::Place::Local(_) => bug!(), // handled above + mir::Place::Static(box mir::Static { def_id, ty }) => { + PlaceRef::new_sized(consts::get_static(ccx, def_id), ccx.layout_of(self.monomorphize(&ty)), Alignment::AbiAligned) }, - mir::Lvalue::Projection(box mir::Projection { + mir::Place::Projection(box mir::Projection { ref base, elem: mir::ProjectionElem::Deref }) => { // Load the pointer from its location. self.trans_consume(bcx, base).deref(bcx.ccx) } - mir::Lvalue::Projection(ref projection) => { + mir::Place::Projection(ref projection) => { let tr_base = self.trans_lvalue(bcx, &projection.base); match projection.elem { @@ -487,7 +487,7 @@ impl<'a, 'tcx> MirContext<'a, 'tcx> { tr_base.project_field(bcx, field.index()) } mir::ProjectionElem::Index(index) => { - let index = &mir::Operand::Copy(mir::Lvalue::Local(index)); + let index = &mir::Operand::Copy(mir::Place::Local(index)); let index = self.trans_operand(bcx, index); let llindex = index.immediate(); tr_base.project_index(bcx, llindex) @@ -509,7 +509,7 @@ impl<'a, 'tcx> MirContext<'a, 'tcx> { mir::ProjectionElem::Subslice { from, to } => { let mut subslice = tr_base.project_index(bcx, C_usize(bcx.ccx, from as u64)); - let projected_ty = LvalueTy::Ty { ty: tr_base.layout.ty } + let projected_ty = PlaceTy::Ty { ty: tr_base.layout.ty } .projection_ty(tcx, &projection.elem).to_ty(bcx.tcx()); subslice.layout = bcx.ccx.layout_of(self.monomorphize(&projected_ty)); @@ -536,7 +536,7 @@ impl<'a, 'tcx> MirContext<'a, 'tcx> { result } - pub fn monomorphized_lvalue_ty(&self, lvalue: &mir::Lvalue<'tcx>) -> Ty<'tcx> { + pub fn monomorphized_lvalue_ty(&self, lvalue: &mir::Place<'tcx>) -> Ty<'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 7f3a430c418..de57b0239e1 100644 --- a/src/librustc_trans/mir/mod.rs +++ b/src/librustc_trans/mir/mod.rs @@ -35,7 +35,7 @@ use rustc_data_structures::indexed_vec::{IndexVec, Idx}; pub use self::constant::trans_static_initializer; use self::analyze::CleanupKind; -use self::lvalue::{Alignment, LvalueRef}; +use self::lvalue::{Alignment, PlaceRef}; use rustc::mir::traversal; use self::operand::{OperandRef, OperandValue}; @@ -59,7 +59,7 @@ pub struct MirContext<'a, 'tcx:'a> { /// don't really care about it very much. Anyway, this value /// contains an alloca into which the personality is stored and /// then later loaded when generating the DIVERGE_BLOCK. - personality_slot: Option<LvalueRef<'tcx>>, + personality_slot: Option<PlaceRef<'tcx>>, /// A `Block` for each MIR `BasicBlock` blocks: IndexVec<mir::BasicBlock, BasicBlockRef>, @@ -79,7 +79,7 @@ pub struct MirContext<'a, 'tcx:'a> { unreachable_block: Option<BasicBlockRef>, /// The location where each MIR arg/var/tmp/ret is stored. This is - /// usually an `LvalueRef` representing an alloca, but not always: + /// usually an `PlaceRef` representing an alloca, but not always: /// sometimes we can skip the alloca and just store the value /// directly using an `OperandRef`, which makes for tighter LLVM /// IR. The conditions for using an `OperandRef` are as follows: @@ -171,7 +171,7 @@ impl<'a, 'tcx> MirContext<'a, 'tcx> { } enum LocalRef<'tcx> { - Lvalue(LvalueRef<'tcx>), + Place(PlaceRef<'tcx>), Operand(Option<OperandRef<'tcx>>), } @@ -266,25 +266,25 @@ pub fn trans_mir<'a, 'tcx: 'a>( } debug!("alloc: {:?} ({}) -> lvalue", local, name); - let lvalue = LvalueRef::alloca(&bcx, layout, &name.as_str()); + let lvalue = PlaceRef::alloca(&bcx, layout, &name.as_str()); if dbg { let (scope, span) = mircx.debug_loc(decl.source_info); declare_local(&bcx, &mircx.debug_context, name, layout.ty, scope, VariableAccess::DirectVariable { alloca: lvalue.llval }, VariableKind::LocalVariable, span); } - LocalRef::Lvalue(lvalue) + LocalRef::Place(lvalue) } else { // Temporary or return pointer if local == mir::RETURN_POINTER && mircx.fn_ty.ret.is_indirect() { debug!("alloc: {:?} (return pointer) -> lvalue", local); let llretptr = llvm::get_param(llfn, 0); - LocalRef::Lvalue(LvalueRef::new_sized(llretptr, + LocalRef::Place(PlaceRef::new_sized(llretptr, layout, Alignment::AbiAligned)) } else if lvalue_locals.contains(local.index()) { debug!("alloc: {:?} -> lvalue", local); - LocalRef::Lvalue(LvalueRef::alloca(&bcx, layout, &format!("{:?}", local))) + LocalRef::Place(PlaceRef::alloca(&bcx, layout, &format!("{:?}", local))) } else { // If this is an immediate local, we do not create an // alloca in advance. Instead we wait until we see the @@ -400,7 +400,7 @@ fn arg_local_refs<'a, 'tcx>(bcx: &Builder<'a, 'tcx>, _ => bug!("spread argument isn't a tuple?!") }; - let lvalue = LvalueRef::alloca(bcx, bcx.ccx.layout_of(arg_ty), &name); + let lvalue = PlaceRef::alloca(bcx, bcx.ccx.layout_of(arg_ty), &name); for i in 0..tupled_arg_tys.len() { let arg = &mircx.fn_ty.args[idx]; idx += 1; @@ -424,7 +424,7 @@ fn arg_local_refs<'a, 'tcx>(bcx: &Builder<'a, 'tcx>, ); }); - return LocalRef::Lvalue(lvalue); + return LocalRef::Place(lvalue); } let arg = &mircx.fn_ty.args[idx]; @@ -474,9 +474,9 @@ fn arg_local_refs<'a, 'tcx>(bcx: &Builder<'a, 'tcx>, let llarg = llvm::get_param(bcx.llfn(), llarg_idx as c_uint); bcx.set_value_name(llarg, &name); llarg_idx += 1; - LvalueRef::new_sized(llarg, arg.layout, Alignment::AbiAligned) + PlaceRef::new_sized(llarg, arg.layout, Alignment::AbiAligned) } else { - let tmp = LvalueRef::alloca(bcx, arg.layout, &name); + let tmp = PlaceRef::alloca(bcx, arg.layout, &name); arg.store_fn_arg(bcx, &mut llarg_idx, tmp); tmp }; @@ -532,7 +532,7 @@ fn arg_local_refs<'a, 'tcx>(bcx: &Builder<'a, 'tcx>, // doesn't actually strip the offset when splitting the closure // environment into its components so it ends up out of bounds. let env_ptr = if !env_ref { - let alloc = LvalueRef::alloca(bcx, + let alloc = PlaceRef::alloca(bcx, bcx.ccx.layout_of(tcx.mk_mut_ptr(arg.layout.ty)), "__debuginfo_env_ptr"); bcx.store(lvalue.llval, alloc.llval, None); @@ -580,7 +580,7 @@ fn arg_local_refs<'a, 'tcx>(bcx: &Builder<'a, 'tcx>, ); } }); - LocalRef::Lvalue(lvalue) + LocalRef::Place(lvalue) }).collect() } diff --git a/src/librustc_trans/mir/operand.rs b/src/librustc_trans/mir/operand.rs index 21770c1d792..876b5e74779 100644 --- a/src/librustc_trans/mir/operand.rs +++ b/src/librustc_trans/mir/operand.rs @@ -25,7 +25,7 @@ use std::fmt; use std::ptr; use super::{MirContext, LocalRef}; -use super::lvalue::{Alignment, LvalueRef}; +use super::lvalue::{Alignment, PlaceRef}; /// The representation of a Rust value. The enum variant is in fact /// uniquely determined by the value's type, but is kept as a @@ -99,7 +99,7 @@ impl<'a, 'tcx> OperandRef<'tcx> { } } - pub fn deref(self, ccx: &CrateContext<'a, 'tcx>) -> LvalueRef<'tcx> { + pub fn deref(self, ccx: &CrateContext<'a, 'tcx>) -> PlaceRef<'tcx> { let projected_ty = self.layout.ty.builtin_deref(true, ty::NoPreference) .unwrap_or_else(|| bug!("deref of non-pointer {:?}", self)).ty; let (llptr, llextra) = match self.val { @@ -107,7 +107,7 @@ impl<'a, 'tcx> OperandRef<'tcx> { OperandValue::Pair(llptr, llextra) => (llptr, llextra), OperandValue::Ref(..) => bug!("Deref of by-Ref operand {:?}", self) }; - LvalueRef { + PlaceRef { llval: llptr, llextra, layout: ccx.layout_of(projected_ty), @@ -212,7 +212,7 @@ impl<'a, 'tcx> OperandRef<'tcx> { } impl<'a, 'tcx> OperandValue { - pub fn store(self, bcx: &Builder<'a, 'tcx>, dest: LvalueRef<'tcx>) { + pub fn store(self, bcx: &Builder<'a, 'tcx>, dest: PlaceRef<'tcx>) { debug!("OperandRef::store: operand={:?}, dest={:?}", self, dest); // Avoid generating stores of zero-sized values, because the only way to have a zero-sized // value is through `undef`, and store itself is useless. @@ -243,14 +243,14 @@ impl<'a, 'tcx> OperandValue { impl<'a, 'tcx> MirContext<'a, 'tcx> { fn maybe_trans_consume_direct(&mut self, bcx: &Builder<'a, 'tcx>, - lvalue: &mir::Lvalue<'tcx>) + lvalue: &mir::Place<'tcx>) -> Option<OperandRef<'tcx>> { debug!("maybe_trans_consume_direct(lvalue={:?})", lvalue); // watch out for locals that do not have an // alloca; they are handled somewhat differently - if let mir::Lvalue::Local(index) = *lvalue { + if let mir::Place::Local(index) = *lvalue { match self.locals[index] { LocalRef::Operand(Some(o)) => { return Some(o); @@ -258,14 +258,14 @@ impl<'a, 'tcx> MirContext<'a, 'tcx> { LocalRef::Operand(None) => { bug!("use of {:?} before def", lvalue); } - LocalRef::Lvalue(..) => { + LocalRef::Place(..) => { // use path below } } } // Moves out of scalar and scalar pair fields are trivial. - if let &mir::Lvalue::Projection(ref proj) = lvalue { + if let &mir::Place::Projection(ref proj) = lvalue { if let mir::ProjectionElem::Field(ref f, _) = proj.elem { if let Some(o) = self.maybe_trans_consume_direct(bcx, &proj.base) { return Some(o.extract_field(bcx, f.index())); @@ -278,7 +278,7 @@ impl<'a, 'tcx> MirContext<'a, 'tcx> { pub fn trans_consume(&mut self, bcx: &Builder<'a, 'tcx>, - lvalue: &mir::Lvalue<'tcx>) + lvalue: &mir::Place<'tcx>) -> OperandRef<'tcx> { debug!("trans_consume(lvalue={:?})", lvalue); @@ -318,7 +318,7 @@ impl<'a, 'tcx> MirContext<'a, 'tcx> { let operand = val.to_operand(bcx.ccx); if let OperandValue::Ref(ptr, align) = operand.val { // If this is a OperandValue::Ref to an immediate constant, load it. - LvalueRef::new_sized(ptr, operand.layout, align).load(bcx) + PlaceRef::new_sized(ptr, operand.layout, align).load(bcx) } else { operand } diff --git a/src/librustc_trans/mir/rvalue.rs b/src/librustc_trans/mir/rvalue.rs index 4781425f491..431c34eb9e6 100644 --- a/src/librustc_trans/mir/rvalue.rs +++ b/src/librustc_trans/mir/rvalue.rs @@ -32,12 +32,12 @@ use value::Value; use super::{MirContext, LocalRef}; use super::constant::const_scalar_checked_binop; use super::operand::{OperandRef, OperandValue}; -use super::lvalue::LvalueRef; +use super::lvalue::PlaceRef; impl<'a, 'tcx> MirContext<'a, 'tcx> { pub fn trans_rvalue(&mut self, bcx: Builder<'a, 'tcx>, - dest: LvalueRef<'tcx>, + dest: PlaceRef<'tcx>, rvalue: &mir::Rvalue<'tcx>) -> Builder<'a, 'tcx> { @@ -79,14 +79,14 @@ impl<'a, 'tcx> MirContext<'a, 'tcx> { // index into the struct, and this case isn't // important enough for it. debug!("trans_rvalue: creating ugly alloca"); - let scratch = LvalueRef::alloca(&bcx, operand.layout, "__unsize_temp"); + let scratch = PlaceRef::alloca(&bcx, operand.layout, "__unsize_temp"); scratch.storage_live(&bcx); operand.val.store(&bcx, scratch); base::coerce_unsized_into(&bcx, scratch, dest); scratch.storage_dead(&bcx); } OperandValue::Ref(llref, align) => { - let source = LvalueRef::new_sized(llref, operand.layout, align); + let source = PlaceRef::new_sized(llref, operand.layout, align); base::coerce_unsized_into(&bcx, source, dest); } } @@ -139,7 +139,7 @@ impl<'a, 'tcx> MirContext<'a, 'tcx> { header_bcx.cond_br(keep_going, body_bcx.llbb(), next_bcx.llbb()); tr_elem.val.store(&body_bcx, - LvalueRef::new_sized(current, tr_elem.layout, dest.alignment)); + PlaceRef::new_sized(current, tr_elem.layout, dest.alignment)); let next = body_bcx.inbounds_gep(current, &[C_usize(bcx.ccx, 1)]); body_bcx.br(header_bcx.llbb()); @@ -486,11 +486,11 @@ impl<'a, 'tcx> MirContext<'a, 'tcx> { fn evaluate_array_len(&mut self, bcx: &Builder<'a, 'tcx>, - lvalue: &mir::Lvalue<'tcx>) -> ValueRef + lvalue: &mir::Place<'tcx>) -> ValueRef { // ZST are passed as operands and require special handling // because trans_lvalue() panics if Local is operand. - if let mir::Lvalue::Local(index) = *lvalue { + if let mir::Place::Local(index) = *lvalue { if let LocalRef::Operand(Some(op)) = self.locals[index] { if let ty::TyArray(_, n) = op.layout.ty.sty { let n = n.val.to_const_int().unwrap().to_u64().unwrap(); diff --git a/src/librustc_trans/mir/statement.rs b/src/librustc_trans/mir/statement.rs index 607ecd887fa..20843db2e64 100644 --- a/src/librustc_trans/mir/statement.rs +++ b/src/librustc_trans/mir/statement.rs @@ -26,9 +26,9 @@ impl<'a, 'tcx> MirContext<'a, 'tcx> { self.set_debug_loc(&bcx, statement.source_info); match statement.kind { mir::StatementKind::Assign(ref lvalue, ref rvalue) => { - if let mir::Lvalue::Local(index) = *lvalue { + if let mir::Place::Local(index) = *lvalue { match self.locals[index] { - LocalRef::Lvalue(tr_dest) => { + LocalRef::Place(tr_dest) => { self.trans_rvalue(bcx, tr_dest, rvalue) } LocalRef::Operand(None) => { @@ -59,13 +59,13 @@ impl<'a, 'tcx> MirContext<'a, 'tcx> { bcx } mir::StatementKind::StorageLive(local) => { - if let LocalRef::Lvalue(tr_lval) = self.locals[local] { + if let LocalRef::Place(tr_lval) = self.locals[local] { tr_lval.storage_live(&bcx); } bcx } mir::StatementKind::StorageDead(local) => { - if let LocalRef::Lvalue(tr_lval) = self.locals[local] { + if let LocalRef::Place(tr_lval) = self.locals[local] { tr_lval.storage_dead(&bcx); } bcx diff --git a/src/librustc_trans/type_of.rs b/src/librustc_trans/type_of.rs index 42e45b3a36f..9ee4e7d4922 100644 --- a/src/librustc_trans/type_of.rs +++ b/src/librustc_trans/type_of.rs @@ -227,7 +227,7 @@ impl<'tcx> LayoutLlvmExt<'tcx> for TyLayout<'tcx> { } /// Get the LLVM type corresponding to a Rust type, i.e. `rustc::ty::Ty`. - /// The pointee type of the pointer in `LvalueRef` is always this type. + /// The pointee type of the pointer in `PlaceRef` is always this type. /// For sized types, it is also the right LLVM type for an `alloca` /// containing a value of that type, and most immediates (except `bool`). /// Unsized types, however, are represented by a "minimal unit", e.g. |
