From 110a34cd84585b9f8853331bd6df9f6dc9989220 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Steinbrink?= Date: Mon, 24 Aug 2015 22:05:20 +0200 Subject: [PATCH] Use get_dataptr() and get_meta() where appropriate --- src/librustc_trans/trans/_match.rs | 10 ++++------ src/librustc_trans/trans/base.rs | 8 ++++---- src/librustc_trans/trans/glue.rs | 9 ++++----- src/librustc_trans/trans/meth.rs | 5 ++--- src/librustc_trans/trans/tvec.rs | 5 ++--- 5 files changed, 16 insertions(+), 21 deletions(-) diff --git a/src/librustc_trans/trans/_match.rs b/src/librustc_trans/trans/_match.rs index bd3e077aa55..dc96aa40f47 100644 --- a/src/librustc_trans/trans/_match.rs +++ b/src/librustc_trans/trans/_match.rs @@ -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 { diff --git a/src/librustc_trans/trans/base.rs b/src/librustc_trans/trans/base.rs index 0f53255197e..955a777bbbe 100644 --- a/src/librustc_trans/trans/base.rs +++ b/src/librustc_trans/trans/base.rs @@ -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); diff --git a/src/librustc_trans/trans/glue.rs b/src/librustc_trans/trans/glue.rs index d049d51d085..5083829005b 100644 --- a/src/librustc_trans/trans/glue.rs +++ b/src/librustc_trans/trans/glue.rs @@ -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, diff --git a/src/librustc_trans/trans/meth.rs b/src/librustc_trans/trans/meth.rs index 3fafd6e7d01..a86ef17a166 100644 --- a/src/librustc_trans/trans/meth.rs +++ b/src/librustc_trans/trans/meth.rs @@ -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) } diff --git a/src/librustc_trans/trans/tvec.rs b/src/librustc_trans/trans/tvec.rs index 397c9c74835..57e7cc4b02e 100644 --- a/src/librustc_trans/trans/tvec.rs +++ b/src/librustc_trans/trans/tvec.rs @@ -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 } }