Remove to_addr and to_addr_maybe_unsized
This commit is contained in:
parent
696053e69f
commit
8f5ef6172c
@ -611,7 +611,8 @@ pub fn codegen_drop<'tcx>(fx: &mut FunctionCx<'_, 'tcx, impl Backend>, drop_plac
|
||||
let drop_fn_ty = drop_fn.ty(fx.tcx);
|
||||
match ty.kind {
|
||||
ty::Dynamic(..) => {
|
||||
let (ptr, vtable) = drop_place.to_addr_maybe_unsized(fx);
|
||||
let (ptr, vtable) = drop_place.to_ptr_maybe_unsized(fx);
|
||||
let ptr = ptr.get_addr(fx);
|
||||
let drop_fn = crate::vtable::drop_fn_of_obj(fx, vtable.unwrap());
|
||||
|
||||
let fn_sig = fx.tcx.normalize_erasing_late_bound_regions(
|
||||
|
@ -119,7 +119,7 @@ pub fn adjust_arg_for_abi<'tcx>(
|
||||
let (a, b) = arg.load_scalar_pair(fx);
|
||||
Pair(a, b)
|
||||
}
|
||||
PassMode::ByRef => Single(arg.force_stack(fx)),
|
||||
PassMode::ByRef => Single(arg.force_stack(fx).get_addr(fx)),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -58,7 +58,7 @@ pub fn codegen_with_call_return_arg<'tcx, B: Backend, T>(
|
||||
let return_ptr = match output_pass_mode {
|
||||
PassMode::NoPass => None,
|
||||
PassMode::ByRef => match ret_place {
|
||||
Some(ret_place) => Some(ret_place.to_addr(fx)),
|
||||
Some(ret_place) => Some(ret_place.to_ptr(fx).get_addr(fx)),
|
||||
None => Some(fx.bcx.ins().iconst(fx.pointer_type, 43)),
|
||||
},
|
||||
PassMode::ByVal(_) | PassMode::ByValPair(_, _) => None,
|
||||
|
@ -598,7 +598,7 @@ pub fn codegen_intrinsic_call<'tcx>(
|
||||
|
||||
transmute, <src_ty, dst_ty> (c from) {
|
||||
assert_eq!(from.layout().ty, src_ty);
|
||||
let addr = Pointer::new(from.force_stack(fx));
|
||||
let addr = from.force_stack(fx);
|
||||
let dst_layout = fx.layout_of(dst_ty);
|
||||
ret.write_cvalue(fx, CValue::by_ref(addr, dst_layout))
|
||||
};
|
||||
@ -633,7 +633,7 @@ pub fn codegen_intrinsic_call<'tcx>(
|
||||
fx.bcx.def_var(mir_var(var), val);
|
||||
}
|
||||
_ => {
|
||||
let addr = ret.to_addr(fx);
|
||||
let addr = ret.to_ptr(fx).get_addr(fx);
|
||||
let layout = ret.layout();
|
||||
fx.bcx.emit_small_memset(fx.module.target_config(), addr, 0, layout.size.bytes(), 1);
|
||||
}
|
||||
|
@ -88,14 +88,14 @@ impl<'tcx> CValue<'tcx> {
|
||||
self.1
|
||||
}
|
||||
|
||||
pub fn force_stack<'a>(self, fx: &mut FunctionCx<'_, 'tcx, impl Backend>) -> Value {
|
||||
pub fn force_stack<'a>(self, fx: &mut FunctionCx<'_, 'tcx, impl Backend>) -> Pointer {
|
||||
let layout = self.1;
|
||||
match self.0 {
|
||||
CValueInner::ByRef(ptr) => ptr.get_addr(fx),
|
||||
CValueInner::ByRef(ptr) => ptr,
|
||||
CValueInner::ByVal(_) | CValueInner::ByValPair(_, _) => {
|
||||
let cplace = CPlace::new_stack_slot(fx, layout.ty);
|
||||
cplace.write_cvalue(fx, self);
|
||||
cplace.to_addr(fx)
|
||||
cplace.to_ptr(fx)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -331,10 +331,6 @@ impl<'tcx> CPlace<'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn to_addr(self, fx: &mut FunctionCx<'_, 'tcx, impl Backend>) -> Value {
|
||||
self.to_ptr(fx).get_addr(fx)
|
||||
}
|
||||
|
||||
pub fn to_ptr_maybe_unsized(
|
||||
self,
|
||||
fx: &mut FunctionCx<'_, 'tcx, impl Backend>,
|
||||
@ -355,14 +351,6 @@ impl<'tcx> CPlace<'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn to_addr_maybe_unsized(
|
||||
self,
|
||||
fx: &mut FunctionCx<'_, 'tcx, impl Backend>,
|
||||
) -> (Value, Option<Value>) {
|
||||
let (ptr, extra) = self.to_ptr_maybe_unsized(fx);
|
||||
(ptr.get_addr(fx), extra)
|
||||
}
|
||||
|
||||
pub fn write_cvalue(self, fx: &mut FunctionCx<'_, 'tcx, impl Backend>, from: CValue<'tcx>) {
|
||||
use rustc::hir::Mutability::*;
|
||||
|
||||
@ -533,15 +521,15 @@ impl<'tcx> CPlace<'tcx> {
|
||||
|
||||
pub fn write_place_ref(self, fx: &mut FunctionCx<'_, 'tcx, impl Backend>, dest: CPlace<'tcx>) {
|
||||
if has_ptr_meta(fx.tcx, self.layout().ty) {
|
||||
let (value, extra) = self.to_addr_maybe_unsized(fx);
|
||||
let (ptr, extra) = self.to_ptr_maybe_unsized(fx);
|
||||
let ptr = CValue::by_val_pair(
|
||||
value,
|
||||
ptr.get_addr(fx),
|
||||
extra.expect("unsized type without metadata"),
|
||||
dest.layout(),
|
||||
);
|
||||
dest.write_cvalue(fx, ptr);
|
||||
} else {
|
||||
let ptr = CValue::by_val(self.to_addr(fx), dest.layout());
|
||||
let ptr = CValue::by_val(self.to_ptr(fx).get_addr(fx), dest.layout());
|
||||
dest.write_cvalue(fx, ptr);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user