codegen_place and related functions can take PlaceRef by value
This commit is contained in:
parent
10b19f6dee
commit
39d93b1ef8
5 changed files with 19 additions and 19 deletions
|
@ -264,7 +264,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
|||
}
|
||||
|
||||
PassMode::Direct(_) | PassMode::Pair(..) => {
|
||||
let op = self.codegen_consume(&mut bx, &mir::Place::return_place().as_ref());
|
||||
let op = self.codegen_consume(&mut bx, mir::Place::return_place().as_ref());
|
||||
if let Ref(llval, _, align) = op.val {
|
||||
bx.load(llval, align)
|
||||
} else {
|
||||
|
@ -319,7 +319,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
|||
return;
|
||||
}
|
||||
|
||||
let place = self.codegen_place(&mut bx, &location.as_ref());
|
||||
let place = self.codegen_place(&mut bx, location.as_ref());
|
||||
let (args1, args2);
|
||||
let mut args = if let Some(llextra) = place.llextra {
|
||||
args2 = [place.llval, llextra];
|
||||
|
@ -1111,7 +1111,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
|||
} else {
|
||||
self.codegen_place(
|
||||
bx,
|
||||
&mir::PlaceRef { local: &dest.local, projection: &dest.projection },
|
||||
mir::PlaceRef { local: &dest.local, projection: &dest.projection },
|
||||
)
|
||||
};
|
||||
if fn_ret.is_indirect() {
|
||||
|
@ -1137,7 +1137,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
|||
LocalRef::Place(place) => self.codegen_transmute_into(bx, src, place),
|
||||
LocalRef::UnsizedPlace(_) => bug!("transmute must not involve unsized locals"),
|
||||
LocalRef::Operand(None) => {
|
||||
let dst_layout = bx.layout_of(self.monomorphized_place_ty(&dst.as_ref()));
|
||||
let dst_layout = bx.layout_of(self.monomorphized_place_ty(dst.as_ref()));
|
||||
assert!(!dst_layout.ty.has_erasable_regions());
|
||||
let place = PlaceRef::alloca(bx, dst_layout);
|
||||
place.storage_live(bx);
|
||||
|
@ -1151,7 +1151,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
|||
}
|
||||
}
|
||||
} else {
|
||||
let dst = self.codegen_place(bx, &dst.as_ref());
|
||||
let dst = self.codegen_place(bx, dst.as_ref());
|
||||
self.codegen_transmute_into(bx, src, dst);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -369,7 +369,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
|||
fn maybe_codegen_consume_direct(
|
||||
&mut self,
|
||||
bx: &mut Bx,
|
||||
place_ref: &mir::PlaceRef<'_, 'tcx>,
|
||||
place_ref: mir::PlaceRef<'_, 'tcx>,
|
||||
) -> Option<OperandRef<'tcx, Bx::Value>> {
|
||||
debug!("maybe_codegen_consume_direct(place_ref={:?})", place_ref);
|
||||
|
||||
|
@ -413,7 +413,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
|||
pub fn codegen_consume(
|
||||
&mut self,
|
||||
bx: &mut Bx,
|
||||
place_ref: &mir::PlaceRef<'_, 'tcx>,
|
||||
place_ref: mir::PlaceRef<'_, 'tcx>,
|
||||
) -> OperandRef<'tcx, Bx::Value> {
|
||||
debug!("codegen_consume(place_ref={:?})", place_ref);
|
||||
|
||||
|
@ -444,7 +444,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
|||
|
||||
match *operand {
|
||||
mir::Operand::Copy(ref place) | mir::Operand::Move(ref place) => {
|
||||
self.codegen_consume(bx, &place.as_ref())
|
||||
self.codegen_consume(bx, place.as_ref())
|
||||
}
|
||||
|
||||
mir::Operand::Constant(ref constant) => {
|
||||
|
|
|
@ -408,14 +408,14 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
|||
pub fn codegen_place(
|
||||
&mut self,
|
||||
bx: &mut Bx,
|
||||
place_ref: &mir::PlaceRef<'_, 'tcx>,
|
||||
place_ref: mir::PlaceRef<'_, 'tcx>,
|
||||
) -> PlaceRef<'tcx, Bx::Value> {
|
||||
debug!("codegen_place(place_ref={:?})", place_ref);
|
||||
let cx = self.cx;
|
||||
let tcx = self.cx.tcx();
|
||||
|
||||
let result = match place_ref {
|
||||
mir::PlaceRef { local, projection: [] } => match self.locals[**local] {
|
||||
mir::PlaceRef { local, projection: [] } => match self.locals[*local] {
|
||||
LocalRef::Place(place) => {
|
||||
return place;
|
||||
}
|
||||
|
@ -428,13 +428,13 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
|||
},
|
||||
mir::PlaceRef { local, projection: [proj_base @ .., mir::ProjectionElem::Deref] } => {
|
||||
// Load the pointer from its location.
|
||||
self.codegen_consume(bx, &mir::PlaceRef { local, projection: proj_base })
|
||||
self.codegen_consume(bx, mir::PlaceRef { local, projection: proj_base })
|
||||
.deref(bx.cx())
|
||||
}
|
||||
mir::PlaceRef { local, projection: [proj_base @ .., elem] } => {
|
||||
// FIXME turn this recursion into iteration
|
||||
let cg_base =
|
||||
self.codegen_place(bx, &mir::PlaceRef { local, projection: proj_base });
|
||||
self.codegen_place(bx, mir::PlaceRef { local, projection: proj_base });
|
||||
|
||||
match elem {
|
||||
mir::ProjectionElem::Deref => bug!(),
|
||||
|
@ -497,7 +497,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
|||
result
|
||||
}
|
||||
|
||||
pub fn monomorphized_place_ty(&self, place_ref: &mir::PlaceRef<'_, 'tcx>) -> Ty<'tcx> {
|
||||
pub fn monomorphized_place_ty(&self, place_ref: mir::PlaceRef<'_, 'tcx>) -> Ty<'tcx> {
|
||||
let tcx = self.cx.tcx();
|
||||
let place_ty = mir::Place::ty_from(place_ref.local, place_ref.projection, *self.mir, tcx);
|
||||
self.monomorphize(&place_ty.ty)
|
||||
|
|
|
@ -467,7 +467,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
|||
mir::Rvalue::Discriminant(ref place) => {
|
||||
let discr_ty = rvalue.ty(*self.mir, bx.tcx());
|
||||
let discr = self
|
||||
.codegen_place(&mut bx, &place.as_ref())
|
||||
.codegen_place(&mut bx, place.as_ref())
|
||||
.codegen_get_discr(&mut bx, discr_ty);
|
||||
(
|
||||
bx,
|
||||
|
@ -541,7 +541,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
|||
}
|
||||
}
|
||||
// use common size calculation for non zero-sized types
|
||||
let cg_value = self.codegen_place(bx, &place.as_ref());
|
||||
let cg_value = self.codegen_place(bx, place.as_ref());
|
||||
cg_value.len(bx.cx())
|
||||
}
|
||||
|
||||
|
@ -552,7 +552,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
|||
place: &mir::Place<'tcx>,
|
||||
mk_ptr_ty: impl FnOnce(TyCtxt<'tcx>, Ty<'tcx>) -> Ty<'tcx>,
|
||||
) -> (Bx, OperandRef<'tcx, Bx::Value>) {
|
||||
let cg_place = self.codegen_place(&mut bx, &place.as_ref());
|
||||
let cg_place = self.codegen_place(&mut bx, place.as_ref());
|
||||
|
||||
let ty = cg_place.layout.ty;
|
||||
|
||||
|
|
|
@ -41,12 +41,12 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
|||
}
|
||||
}
|
||||
} else {
|
||||
let cg_dest = self.codegen_place(&mut bx, &place.as_ref());
|
||||
let cg_dest = self.codegen_place(&mut bx, place.as_ref());
|
||||
self.codegen_rvalue(bx, cg_dest, rvalue)
|
||||
}
|
||||
}
|
||||
mir::StatementKind::SetDiscriminant { box ref place, variant_index } => {
|
||||
self.codegen_place(&mut bx, &place.as_ref())
|
||||
self.codegen_place(&mut bx, place.as_ref())
|
||||
.codegen_set_discr(&mut bx, variant_index);
|
||||
bx
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
|||
let outputs = asm
|
||||
.outputs
|
||||
.iter()
|
||||
.map(|output| self.codegen_place(&mut bx, &output.as_ref()))
|
||||
.map(|output| self.codegen_place(&mut bx, output.as_ref()))
|
||||
.collect();
|
||||
|
||||
let input_vals = asm.inputs.iter().fold(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue