diff options
| author | Santiago Pastorino <spastorino@gmail.com> | 2019-02-22 05:24:03 +0100 |
|---|---|---|
| committer | Santiago Pastorino <spastorino@gmail.com> | 2019-03-01 05:02:00 +0100 |
| commit | 0f993d5a7abfe156a261d7a53f4297e8b05cc91f (patch) | |
| tree | 948dd422e29bed5d02b6f821840696c16753ecf5 /src/librustc_codegen_ssa | |
| parent | 1999a2288123173b2e487865c9a04386173025f7 (diff) | |
| download | rust-0f993d5a7abfe156a261d7a53f4297e8b05cc91f.tar.gz rust-0f993d5a7abfe156a261d7a53f4297e8b05cc91f.zip | |
Put Local, Static and Promoted as one Base variant of Place
Diffstat (limited to 'src/librustc_codegen_ssa')
| -rw-r--r-- | src/librustc_codegen_ssa/mir/analyze.rs | 5 | ||||
| -rw-r--r-- | src/librustc_codegen_ssa/mir/block.rs | 14 | ||||
| -rw-r--r-- | src/librustc_codegen_ssa/mir/operand.rs | 2 | ||||
| -rw-r--r-- | src/librustc_codegen_ssa/mir/place.rs | 12 | ||||
| -rw-r--r-- | src/librustc_codegen_ssa/mir/rvalue.rs | 2 | ||||
| -rw-r--r-- | src/librustc_codegen_ssa/mir/statement.rs | 2 |
6 files changed, 22 insertions, 15 deletions
diff --git a/src/librustc_codegen_ssa/mir/analyze.rs b/src/librustc_codegen_ssa/mir/analyze.rs index 9fe2e58bc20..facae9a9797 100644 --- a/src/librustc_codegen_ssa/mir/analyze.rs +++ b/src/librustc_codegen_ssa/mir/analyze.rs @@ -103,7 +103,7 @@ impl<'mir, 'a: 'mir, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> Visitor<'tcx> location: Location) { debug!("visit_assign(block={:?}, place={:?}, rvalue={:?})", block, place, rvalue); - if let mir::Place::Local(index) = *place { + if let mir::Place::Base(mir::PlaceBase::Local(index)) = *place { self.assign(index, location); if !self.fx.rvalue_creates_operand(rvalue) { self.not_ssa(index); @@ -245,7 +245,8 @@ impl<'mir, 'a: 'mir, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> Visitor<'tcx> } PlaceContext::MutatingUse(MutatingUseContext::Drop) => { - let ty = mir::Place::Local(local).ty(self.fx.mir, self.fx.cx.tcx()); + let ty = mir::Place::Base(mir::PlaceBase::Local(local)).ty(self.fx.mir, + self.fx.cx.tcx()); let ty = self.fx.monomorphize(&ty.to_ty(self.fx.cx.tcx())); // Only need the place if we're actually dropping it. diff --git a/src/librustc_codegen_ssa/mir/block.rs b/src/librustc_codegen_ssa/mir/block.rs index 627380ee38f..02086c7730c 100644 --- a/src/librustc_codegen_ssa/mir/block.rs +++ b/src/librustc_codegen_ssa/mir/block.rs @@ -249,7 +249,7 @@ impl<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { PassMode::Direct(_) | PassMode::Pair(..) => { let op = - self.codegen_consume(&mut bx, &mir::Place::Local(mir::RETURN_PLACE)); + self.codegen_consume(&mut bx, &mir::Place::RETURN_PLACE); if let Ref(llval, _, align) = op.val { bx.load(llval, align) } else { @@ -615,8 +615,12 @@ impl<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { // The shuffle array argument is usually not an explicit constant, // but specified directly in the code. This means it gets promoted // and we can then extract the value by evaluating the promoted. - mir::Operand::Copy(mir::Place::Promoted(box(index, ty))) | - mir::Operand::Move(mir::Place::Promoted(box(index, ty))) => { + mir::Operand::Copy( + mir::Place::Base(mir::PlaceBase::Promoted(box(index, ty))) + ) | + mir::Operand::Move( + mir::Place::Base(mir::PlaceBase::Promoted(box(index, ty))) + ) => { let param_env = ty::ParamEnv::reveal_all(); let cid = mir::interpret::GlobalId { instance: self.instance, @@ -1106,7 +1110,7 @@ impl<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { if fn_ret.is_ignore() { return ReturnDest::Nothing; } - let dest = if let mir::Place::Local(index) = *dest { + let dest = if let mir::Place::Base(mir::PlaceBase::Local(index)) = *dest { match self.locals[index] { LocalRef::Place(dest) => dest, LocalRef::UnsizedPlace(_) => bug!("return type must be sized"), @@ -1161,7 +1165,7 @@ impl<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { src: &mir::Operand<'tcx>, dst: &mir::Place<'tcx> ) { - if let mir::Place::Local(index) = *dst { + if let mir::Place::Base(mir::PlaceBase::Local(index)) = *dst { match self.locals[index] { LocalRef::Place(place) => self.codegen_transmute_into(bx, src, place), LocalRef::UnsizedPlace(_) => bug!("transmute must not involve unsized locals"), diff --git a/src/librustc_codegen_ssa/mir/operand.rs b/src/librustc_codegen_ssa/mir/operand.rs index 0e8cdc83b48..0a6549851f4 100644 --- a/src/librustc_codegen_ssa/mir/operand.rs +++ b/src/librustc_codegen_ssa/mir/operand.rs @@ -378,7 +378,7 @@ impl<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { // watch out for locals that do not have an // alloca; they are handled somewhat differently - if let mir::Place::Local(index) = *place { + if let mir::Place::Base(mir::PlaceBase::Local(index)) = *place { match self.locals[index] { LocalRef::Operand(Some(o)) => { return Some(o); diff --git a/src/librustc_codegen_ssa/mir/place.rs b/src/librustc_codegen_ssa/mir/place.rs index 1edcbfead2c..0408ccf039f 100644 --- a/src/librustc_codegen_ssa/mir/place.rs +++ b/src/librustc_codegen_ssa/mir/place.rs @@ -392,7 +392,7 @@ impl<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { let cx = self.cx; let tcx = self.cx.tcx(); - if let mir::Place::Local(index) = *place { + if let mir::Place::Base(mir::PlaceBase::Local(index)) = *place { match self.locals[index] { LocalRef::Place(place) => { return place; @@ -407,8 +407,8 @@ impl<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { } let result = match *place { - mir::Place::Local(_) => bug!(), // handled above - mir::Place::Promoted(box (index, ty)) => { + mir::Place::Base(mir::PlaceBase::Local(_)) => bug!(), // handled above + mir::Place::Base(mir::PlaceBase::Promoted(box (index, ty))) => { let param_env = ty::ParamEnv::reveal_all(); let cid = mir::interpret::GlobalId { instance: self.instance, @@ -435,7 +435,7 @@ impl<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { } } } - mir::Place::Static(box mir::Static { def_id, ty }) => { + mir::Place::Base(mir::PlaceBase::Static(box mir::Static { def_id, ty })) => { // NB: The layout of a static may be unsized as is the case when working // with a static that is an extern_type. let layout = cx.layout_of(self.monomorphize(&ty)); @@ -457,7 +457,9 @@ impl<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { cg_base.project_field(bx, field.index()) } mir::ProjectionElem::Index(index) => { - let index = &mir::Operand::Copy(mir::Place::Local(index)); + let index = &mir::Operand::Copy( + mir::Place::Base(mir::PlaceBase::Local(index)) + ); let index = self.codegen_operand(bx, index); let llindex = index.immediate(); cg_base.project_index(bx, llindex) diff --git a/src/librustc_codegen_ssa/mir/rvalue.rs b/src/librustc_codegen_ssa/mir/rvalue.rs index 25a7754d118..b0c667a965d 100644 --- a/src/librustc_codegen_ssa/mir/rvalue.rs +++ b/src/librustc_codegen_ssa/mir/rvalue.rs @@ -534,7 +534,7 @@ impl<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { ) -> Bx::Value { // ZST are passed as operands and require special handling // because codegen_place() panics if Local is operand. - if let mir::Place::Local(index) = *place { + if let mir::Place::Base(mir::PlaceBase::Local(index)) = *place { if let LocalRef::Operand(Some(op)) = self.locals[index] { if let ty::Array(_, n) = op.layout.ty.sty { let n = n.unwrap_usize(bx.cx().tcx()); diff --git a/src/librustc_codegen_ssa/mir/statement.rs b/src/librustc_codegen_ssa/mir/statement.rs index a1bd919c433..97729e8aeb3 100644 --- a/src/librustc_codegen_ssa/mir/statement.rs +++ b/src/librustc_codegen_ssa/mir/statement.rs @@ -17,7 +17,7 @@ impl<'a, 'tcx: 'a, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { self.set_debug_loc(&mut bx, statement.source_info); match statement.kind { mir::StatementKind::Assign(ref place, ref rvalue) => { - if let mir::Place::Local(index) = *place { + if let mir::Place::Base(mir::PlaceBase::Local(index)) = *place { match self.locals[index] { LocalRef::Place(cg_dest) => { self.codegen_rvalue(bx, cg_dest, rvalue) |
