Add load/store helpers that take PlaceValue
This commit is contained in:
parent
3596098823
commit
d0ae76848a
6 changed files with 18 additions and 11 deletions
|
@ -264,7 +264,7 @@ impl<'ll, 'tcx> IntrinsicCallMethods<'tcx> for Builder<'_, 'll, 'tcx> {
|
||||||
llvm::LLVMSetAlignment(load, align);
|
llvm::LLVMSetAlignment(load, align);
|
||||||
}
|
}
|
||||||
if !result.layout.is_zst() {
|
if !result.layout.is_zst() {
|
||||||
self.store(load, result.val.llval, result.val.align);
|
self.store_to_place(load, result.val);
|
||||||
}
|
}
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
|
@ -456,7 +456,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
||||||
PassMode::Direct(_) | PassMode::Pair(..) => {
|
PassMode::Direct(_) | PassMode::Pair(..) => {
|
||||||
let op = self.codegen_consume(bx, mir::Place::return_place().as_ref());
|
let op = self.codegen_consume(bx, mir::Place::return_place().as_ref());
|
||||||
if let Ref(place_val) = op.val {
|
if let Ref(place_val) = op.val {
|
||||||
bx.load(bx.backend_type(op.layout), place_val.llval, place_val.align)
|
bx.load_from_place(bx.backend_type(op.layout), place_val)
|
||||||
} else {
|
} else {
|
||||||
op.immediate_or_packed_pair(bx)
|
op.immediate_or_packed_pair(bx)
|
||||||
}
|
}
|
||||||
|
|
|
@ -420,7 +420,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
||||||
bx.set_var_name(alloca.val.llval, &(var.name.to_string() + ".dbg.spill"));
|
bx.set_var_name(alloca.val.llval, &(var.name.to_string() + ".dbg.spill"));
|
||||||
|
|
||||||
// Write the pointer to the variable
|
// Write the pointer to the variable
|
||||||
bx.store(place.val.llval, alloca.val.llval, alloca.val.align);
|
bx.store_to_place(place.val.llval, alloca.val);
|
||||||
|
|
||||||
// Point the debug info to `*alloca` for the current variable
|
// Point the debug info to `*alloca` for the current variable
|
||||||
bx.dbg_var_addr(
|
bx.dbg_var_addr(
|
||||||
|
|
|
@ -387,9 +387,9 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
||||||
let success = bx.from_immediate(success);
|
let success = bx.from_immediate(success);
|
||||||
|
|
||||||
let dest = result.project_field(bx, 0);
|
let dest = result.project_field(bx, 0);
|
||||||
bx.store(val, dest.val.llval, dest.val.align);
|
bx.store_to_place(val, dest.val);
|
||||||
let dest = result.project_field(bx, 1);
|
let dest = result.project_field(bx, 1);
|
||||||
bx.store(success, dest.val.llval, dest.val.align);
|
bx.store_to_place(success, dest.val);
|
||||||
} else {
|
} else {
|
||||||
invalid_monomorphization(ty);
|
invalid_monomorphization(ty);
|
||||||
}
|
}
|
||||||
|
@ -511,7 +511,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
||||||
|
|
||||||
if !fn_abi.ret.is_ignore() {
|
if !fn_abi.ret.is_ignore() {
|
||||||
if let PassMode::Cast { .. } = &fn_abi.ret.mode {
|
if let PassMode::Cast { .. } = &fn_abi.ret.mode {
|
||||||
bx.store(llval, result.val.llval, result.val.align);
|
bx.store_to_place(llval, result.val);
|
||||||
} else {
|
} else {
|
||||||
OperandRef::from_immediate_or_packed_pair(bx, llval, result.layout)
|
OperandRef::from_immediate_or_packed_pair(bx, llval, result.layout)
|
||||||
.val
|
.val
|
||||||
|
|
|
@ -343,10 +343,9 @@ impl<'a, 'tcx, V: CodegenObject> PlaceRef<'tcx, V> {
|
||||||
let ptr = self.project_field(bx, tag_field);
|
let ptr = self.project_field(bx, tag_field);
|
||||||
let to =
|
let to =
|
||||||
self.layout.ty.discriminant_for_variant(bx.tcx(), variant_index).unwrap().val;
|
self.layout.ty.discriminant_for_variant(bx.tcx(), variant_index).unwrap().val;
|
||||||
bx.store(
|
bx.store_to_place(
|
||||||
bx.cx().const_uint_big(bx.cx().backend_type(ptr.layout), to),
|
bx.cx().const_uint_big(bx.cx().backend_type(ptr.layout), to),
|
||||||
ptr.val.llval,
|
ptr.val,
|
||||||
ptr.val.align,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
Variants::Multiple {
|
Variants::Multiple {
|
||||||
|
|
|
@ -12,7 +12,7 @@ use crate::common::{
|
||||||
AtomicOrdering, AtomicRmwBinOp, IntPredicate, RealPredicate, SynchronizationScope, TypeKind,
|
AtomicOrdering, AtomicRmwBinOp, IntPredicate, RealPredicate, SynchronizationScope, TypeKind,
|
||||||
};
|
};
|
||||||
use crate::mir::operand::{OperandRef, OperandValue};
|
use crate::mir::operand::{OperandRef, OperandValue};
|
||||||
use crate::mir::place::PlaceRef;
|
use crate::mir::place::{PlaceRef, PlaceValue};
|
||||||
use crate::MemFlags;
|
use crate::MemFlags;
|
||||||
|
|
||||||
use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrs;
|
use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrs;
|
||||||
|
@ -156,6 +156,10 @@ pub trait BuilderMethods<'a, 'tcx>:
|
||||||
order: AtomicOrdering,
|
order: AtomicOrdering,
|
||||||
size: Size,
|
size: Size,
|
||||||
) -> Self::Value;
|
) -> Self::Value;
|
||||||
|
fn load_from_place(&mut self, ty: Self::Type, place: PlaceValue<Self::Value>) -> Self::Value {
|
||||||
|
debug_assert_eq!(place.llextra, None);
|
||||||
|
self.load(ty, place.llval, place.align)
|
||||||
|
}
|
||||||
fn load_operand(&mut self, place: PlaceRef<'tcx, Self::Value>)
|
fn load_operand(&mut self, place: PlaceRef<'tcx, Self::Value>)
|
||||||
-> OperandRef<'tcx, Self::Value>;
|
-> OperandRef<'tcx, Self::Value>;
|
||||||
|
|
||||||
|
@ -171,6 +175,10 @@ pub trait BuilderMethods<'a, 'tcx>:
|
||||||
fn nonnull_metadata(&mut self, load: Self::Value);
|
fn nonnull_metadata(&mut self, load: Self::Value);
|
||||||
|
|
||||||
fn store(&mut self, val: Self::Value, ptr: Self::Value, align: Align) -> Self::Value;
|
fn store(&mut self, val: Self::Value, ptr: Self::Value, align: Align) -> Self::Value;
|
||||||
|
fn store_to_place(&mut self, val: Self::Value, place: PlaceValue<Self::Value>) -> Self::Value {
|
||||||
|
debug_assert_eq!(place.llextra, None);
|
||||||
|
self.store(val, place.llval, place.align)
|
||||||
|
}
|
||||||
fn store_with_flags(
|
fn store_with_flags(
|
||||||
&mut self,
|
&mut self,
|
||||||
val: Self::Value,
|
val: Self::Value,
|
||||||
|
@ -296,7 +304,7 @@ pub trait BuilderMethods<'a, 'tcx>:
|
||||||
if flags.contains(MemFlags::NONTEMPORAL) {
|
if flags.contains(MemFlags::NONTEMPORAL) {
|
||||||
// HACK(nox): This is inefficient but there is no nontemporal memcpy.
|
// HACK(nox): This is inefficient but there is no nontemporal memcpy.
|
||||||
let ty = self.backend_type(dst.layout);
|
let ty = self.backend_type(dst.layout);
|
||||||
let val = self.load(ty, src.val.llval, src.val.align);
|
let val = self.load_from_place(ty, src.val);
|
||||||
self.store_with_flags(val, dst.val.llval, dst.val.align, flags);
|
self.store_with_flags(val, dst.val.llval, dst.val.align, flags);
|
||||||
} else if self.sess().opts.optimize == OptLevel::No && self.is_backend_immediate(dst.layout)
|
} else if self.sess().opts.optimize == OptLevel::No && self.is_backend_immediate(dst.layout)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue