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