Use get_dataptr() and get_meta() where appropriate
This commit is contained in:
parent
d80ff126bf
commit
110a34cd84
@ -188,7 +188,6 @@ pub use self::TransBindingMode::*;
|
||||
use self::Opt::*;
|
||||
use self::FailureHandler::*;
|
||||
|
||||
use back::abi;
|
||||
use llvm::{ValueRef, BasicBlockRef};
|
||||
use middle::check_match::StaticInliner;
|
||||
use middle::check_match;
|
||||
@ -730,9 +729,8 @@ fn bind_subslice_pat(bcx: Block,
|
||||
let slice_ty = bcx.tcx().mk_imm_ref(bcx.tcx().mk_region(ty::ReStatic),
|
||||
bcx.tcx().mk_slice(unit_ty));
|
||||
let scratch = rvalue_scratch_datum(bcx, slice_ty, "");
|
||||
Store(bcx, slice_begin,
|
||||
GEPi(bcx, scratch.val, &[0, abi::FAT_PTR_ADDR]));
|
||||
Store(bcx, slice_len, GEPi(bcx, scratch.val, &[0, abi::FAT_PTR_EXTRA]));
|
||||
Store(bcx, slice_begin, expr::get_dataptr(bcx, scratch.val));
|
||||
Store(bcx, slice_len, expr::get_meta(bcx, scratch.val));
|
||||
scratch.val
|
||||
}
|
||||
|
||||
@ -909,14 +907,14 @@ fn compare_values<'blk, 'tcx>(cx: Block<'blk, 'tcx>,
|
||||
let ty_str_slice = cx.tcx().mk_static_str();
|
||||
|
||||
let rhs_str = alloc_ty(cx, ty_str_slice, "rhs_str");
|
||||
Store(cx, GEPi(cx, rhs, &[0, 0]), expr::get_dataptr(cx, rhs_str));
|
||||
Store(cx, expr::get_dataptr(cx, rhs), expr::get_dataptr(cx, rhs_str));
|
||||
Store(cx, C_uint(cx.ccx(), pat_len), expr::get_meta(cx, rhs_str));
|
||||
|
||||
let lhs_str;
|
||||
if val_ty(lhs) == val_ty(rhs) {
|
||||
// Both the discriminant and the pattern are thin pointers
|
||||
lhs_str = alloc_ty(cx, ty_str_slice, "lhs_str");
|
||||
Store(cx, GEPi(cx, lhs, &[0, 0]), expr::get_dataptr(cx, lhs_str));
|
||||
Store(cx, expr::get_dataptr(cx, lhs), expr::get_dataptr(cx, lhs_str));
|
||||
Store(cx, C_uint(cx.ccx(), pat_len), expr::get_meta(cx, lhs_str));
|
||||
}
|
||||
else {
|
||||
|
@ -403,8 +403,8 @@ pub fn iter_structural_ty<'blk, 'tcx, F>(cx: Block<'blk, 'tcx>,
|
||||
let (data_ptr, info) = if common::type_is_sized(cx.tcx(), t) {
|
||||
(av, None)
|
||||
} else {
|
||||
let data = GEPi(cx, av, &[0, abi::FAT_PTR_ADDR]);
|
||||
let info = GEPi(cx, av, &[0, abi::FAT_PTR_EXTRA]);
|
||||
let data = expr::get_dataptr(cx, av);
|
||||
let info = expr::get_meta(cx, av);
|
||||
(Load(cx, data), Some(Load(cx, info)))
|
||||
};
|
||||
|
||||
@ -420,8 +420,8 @@ pub fn iter_structural_ty<'blk, 'tcx, F>(cx: Block<'blk, 'tcx>,
|
||||
llfld_a
|
||||
} else {
|
||||
let scratch = datum::rvalue_scratch_datum(cx, field_ty, "__fat_ptr_iter");
|
||||
Store(cx, llfld_a, GEPi(cx, scratch.val, &[0, abi::FAT_PTR_ADDR]));
|
||||
Store(cx, info.unwrap(), GEPi(cx, scratch.val, &[0, abi::FAT_PTR_EXTRA]));
|
||||
Store(cx, llfld_a, expr::get_dataptr(cx, scratch.val));
|
||||
Store(cx, info.unwrap(), expr::get_meta(cx, scratch.val));
|
||||
scratch.val
|
||||
};
|
||||
cx = f(cx, val, field_ty);
|
||||
|
@ -13,7 +13,6 @@
|
||||
// Code relating to drop glue.
|
||||
|
||||
|
||||
use back::abi;
|
||||
use back::link::*;
|
||||
use llvm;
|
||||
use llvm::{ValueRef, get_param};
|
||||
@ -524,14 +523,14 @@ fn make_drop_glue<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, v0: ValueRef, g: DropGlueK
|
||||
// a safe-guard, assert TyBox not used with TyContents.
|
||||
assert!(!skip_dtor);
|
||||
if !type_is_sized(bcx.tcx(), content_ty) {
|
||||
let llval = GEPi(bcx, v0, &[0, abi::FAT_PTR_ADDR]);
|
||||
let llval = expr::get_dataptr(bcx, v0);
|
||||
let llbox = Load(bcx, llval);
|
||||
let llbox_as_usize = PtrToInt(bcx, llbox, Type::int(bcx.ccx()));
|
||||
let drop_flag_not_dropped_already =
|
||||
ICmp(bcx, llvm::IntNE, llbox_as_usize, dropped_pattern, DebugLoc::None);
|
||||
with_cond(bcx, drop_flag_not_dropped_already, |bcx| {
|
||||
let bcx = drop_ty(bcx, v0, content_ty, DebugLoc::None);
|
||||
let info = GEPi(bcx, v0, &[0, abi::FAT_PTR_EXTRA]);
|
||||
let info = expr::get_meta(bcx, v0);
|
||||
let info = Load(bcx, info);
|
||||
let (llsize, llalign) = size_and_align_of_dst(bcx, content_ty, info);
|
||||
|
||||
@ -590,8 +589,8 @@ fn make_drop_glue<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, v0: ValueRef, g: DropGlueK
|
||||
// versus without calling Drop::drop. Assert caller is
|
||||
// okay with always calling the Drop impl, if any.
|
||||
assert!(!skip_dtor);
|
||||
let data_ptr = GEPi(bcx, v0, &[0, abi::FAT_PTR_ADDR]);
|
||||
let vtable_ptr = Load(bcx, GEPi(bcx, v0, &[0, abi::FAT_PTR_EXTRA]));
|
||||
let data_ptr = expr::get_dataptr(bcx, v0);
|
||||
let vtable_ptr = Load(bcx, expr::get_meta(bcx, v0));
|
||||
let dtor = Load(bcx, vtable_ptr);
|
||||
Call(bcx,
|
||||
dtor,
|
||||
|
@ -9,7 +9,6 @@
|
||||
// except according to those terms.
|
||||
|
||||
use arena::TypedArena;
|
||||
use back::abi;
|
||||
use back::link;
|
||||
use llvm::{ValueRef, get_params};
|
||||
use middle::subst::{Subst, Substs};
|
||||
@ -445,8 +444,8 @@ fn trans_trait_callee<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
self_datum.val
|
||||
};
|
||||
|
||||
let llself = Load(bcx, GEPi(bcx, llval, &[0, abi::FAT_PTR_ADDR]));
|
||||
let llvtable = Load(bcx, GEPi(bcx, llval, &[0, abi::FAT_PTR_EXTRA]));
|
||||
let llself = Load(bcx, expr::get_dataptr(bcx, llval));
|
||||
let llvtable = Load(bcx, expr::get_meta(bcx, llval));
|
||||
trans_trait_callee_from_llval(bcx, opaque_fn_ty, vtable_index, llself, llvtable)
|
||||
}
|
||||
|
||||
|
@ -10,7 +10,6 @@
|
||||
|
||||
#![allow(non_camel_case_types)]
|
||||
|
||||
use back::abi;
|
||||
use llvm;
|
||||
use llvm::ValueRef;
|
||||
use trans::base::*;
|
||||
@ -147,8 +146,8 @@ pub fn trans_lit_str<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
let llbytes = C_uint(bcx.ccx(), bytes);
|
||||
let llcstr = C_cstr(bcx.ccx(), str_lit, false);
|
||||
let llcstr = consts::ptrcast(llcstr, Type::i8p(bcx.ccx()));
|
||||
Store(bcx, llcstr, GEPi(bcx, lldest, &[0, abi::FAT_PTR_ADDR]));
|
||||
Store(bcx, llbytes, GEPi(bcx, lldest, &[0, abi::FAT_PTR_EXTRA]));
|
||||
Store(bcx, llcstr, expr::get_dataptr(bcx, lldest));
|
||||
Store(bcx, llbytes, expr::get_meta(bcx, lldest));
|
||||
bcx
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user