From 89825f2ef5f76c680306378f139a88e2f45c0843 Mon Sep 17 00:00:00 2001 From: Denis Merigoux Date: Wed, 22 Aug 2018 18:57:31 +0200 Subject: [PATCH] Use associated types instead of type parameters inside the BuilderMethods trait --- src/librustc_codegen_llvm/base.rs | 16 +- src/librustc_codegen_llvm/builder.rs | 342 +++++++++++----------- src/librustc_codegen_llvm/mir/operand.rs | 9 +- src/librustc_codegen_llvm/traits.rs | 349 +++++++++++------------ 4 files changed, 355 insertions(+), 361 deletions(-) diff --git a/src/librustc_codegen_llvm/base.rs b/src/librustc_codegen_llvm/base.rs index 31a19439c84c..6c60f9d0ba07 100644 --- a/src/librustc_codegen_llvm/base.rs +++ b/src/librustc_codegen_llvm/base.rs @@ -76,7 +76,6 @@ use rustc_data_structures::sync::Lrc; use rustc_data_structures::indexed_vec::Idx; use traits::{IntPredicate, RealPredicate, BuilderMethods}; -use llvm::BasicBlock; use std::any::Any; use std::cmp; @@ -390,9 +389,8 @@ pub fn call_assume(bx: &Builder<'_, 'll, '_>, val: &'ll Value) { bx.call(assume_intrinsic, &[val], None); } -pub fn from_immediate<'a, 'll: 'a, 'tcx: 'll, - Builder: BuilderMethods<'a, 'll, 'tcx, Value, BasicBlock>>( - bx: &Builder, +pub fn from_immediate<'a, 'll: 'a, 'tcx: 'll>( + bx: &Builder<'_ ,'ll, '_, &'ll Value>, val: &'ll Value ) -> &'ll Value { if val_ty(val) == Type::i1(bx.cx()) { @@ -424,9 +422,8 @@ pub fn to_immediate_scalar( val } -pub fn call_memcpy<'a, 'll: 'a, 'tcx: 'll, - Builder: BuilderMethods<'a, 'll, 'tcx, Value, BasicBlock>>( - bx: &Builder, +pub fn call_memcpy<'a, 'll: 'a, 'tcx: 'll>( + bx: &Builder<'_ ,'ll, '_, &'ll Value>, dst: &'ll Value, dst_align: Align, src: &'ll Value, @@ -449,9 +446,8 @@ pub fn call_memcpy<'a, 'll: 'a, 'tcx: 'll, bx.memcpy(dst_ptr, dst_align.abi(), src_ptr, src_align.abi(), size, volatile); } -pub fn memcpy_ty<'a, 'll: 'a, 'tcx: 'll, - Builder: BuilderMethods<'a, 'll, 'tcx, Value, BasicBlock>>( - bx: &Builder, +pub fn memcpy_ty<'a, 'll: 'a, 'tcx: 'll>( + bx: &Builder<'_ ,'ll, '_, &'ll Value>, dst: &'ll Value, dst_align: Align, src: &'ll Value, diff --git a/src/librustc_codegen_llvm/builder.rs b/src/librustc_codegen_llvm/builder.rs index 583954cb8b0d..47c5315e0b59 100644 --- a/src/librustc_codegen_llvm/builder.rs +++ b/src/librustc_codegen_llvm/builder.rs @@ -9,11 +9,10 @@ // except according to those terms. use llvm::{AtomicRmwBinOp, AtomicOrdering, SynchronizationScope, AsmDialect}; -use llvm::{False, OperandBundleDef}; -use llvm::{self, BasicBlock}; +use llvm::{self, False, OperandBundleDef}; use common::*; -use type_::Type; -use value::Value; +use type_; +use value; use libc::{c_uint, c_char}; use rustc::ty::TyCtxt; use rustc::ty::layout::{Align, Size}; @@ -28,7 +27,7 @@ use std::ptr; // All Builders must have an llfn associated with them #[must_use] -pub struct Builder<'a, 'll: 'a, 'tcx: 'll, V: 'll = &'ll Value> { +pub struct Builder<'a, 'll: 'a, 'tcx: 'll, V: 'll = &'ll value::Value> { pub llbuilder: &'ll mut llvm::Builder<'ll>, pub cx: &'a CodegenCx<'ll, 'tcx, V>, } @@ -56,11 +55,14 @@ bitflags! { } } -impl BuilderMethods<'a, 'll, 'tcx, Value, BasicBlock> - for Builder<'a, 'll, 'tcx> { +impl BuilderMethods<'a, 'll, 'tcx> for Builder<'a, 'll, 'tcx> { + type Value = &'ll value::Value; + type BasicBlock = &'ll llvm::BasicBlock; + type Type = &'ll type_::Type; + fn new_block<'b>( cx: &'a CodegenCx<'ll, 'tcx>, - llfn: &'ll Value, + llfn: Self::Value, name: &'b str ) -> Self { let bx = Builder::with_cx(cx); @@ -99,13 +101,13 @@ impl BuilderMethods<'a, 'll, 'tcx, Value, BasicBlock> self.cx.tcx } - fn llfn(&self) -> &'ll Value { + fn llfn(&self) -> Self::Value { unsafe { llvm::LLVMGetBasicBlockParent(self.llbb()) } } - fn llbb(&self) -> &'ll BasicBlock { + fn llbb(&self) -> Self::BasicBlock { unsafe { llvm::LLVMGetInsertBlock(self.llbuilder) } @@ -124,20 +126,20 @@ impl BuilderMethods<'a, 'll, 'tcx, Value, BasicBlock> } } - fn set_value_name(&self, value: &'ll Value, name: &str) { + fn set_value_name(&self, value: Self::Value, name: &str) { let cname = SmallCStr::new(name); unsafe { llvm::LLVMSetValueName(value, cname.as_ptr()); } } - fn position_at_end(&self, llbb: &'ll BasicBlock) { + fn position_at_end(&self, llbb: Self::BasicBlock) { unsafe { llvm::LLVMPositionBuilderAtEnd(self.llbuilder, llbb); } } - fn position_at_start(&self, llbb: &'ll BasicBlock) { + fn position_at_start(&self, llbb: Self::BasicBlock) { unsafe { llvm::LLVMRustPositionBuilderAtStart(self.llbuilder, llbb); } @@ -150,14 +152,14 @@ impl BuilderMethods<'a, 'll, 'tcx, Value, BasicBlock> } } - fn ret(&self, v: &'ll Value) { + fn ret(&self, v: Self::Value) { self.count_insn("ret"); unsafe { llvm::LLVMBuildRet(self.llbuilder, v); } } - fn br(&self, dest: &'ll BasicBlock) { + fn br(&self, dest: Self::BasicBlock) { self.count_insn("br"); unsafe { llvm::LLVMBuildBr(self.llbuilder, dest); @@ -166,9 +168,9 @@ impl BuilderMethods<'a, 'll, 'tcx, Value, BasicBlock> fn cond_br( &self, - cond: &'ll Value, - then_llbb: &'ll BasicBlock, - else_llbb: &'ll BasicBlock, + cond: Self::Value, + then_llbb: Self::BasicBlock, + else_llbb: Self::BasicBlock, ) { self.count_insn("condbr"); unsafe { @@ -178,21 +180,21 @@ impl BuilderMethods<'a, 'll, 'tcx, Value, BasicBlock> fn switch( &self, - v: &'ll Value, - else_llbb: &'ll BasicBlock, + v: Self::Value, + else_llbb: Self::BasicBlock, num_cases: usize, - ) -> &'ll Value { + ) -> Self::Value { unsafe { llvm::LLVMBuildSwitch(self.llbuilder, v, else_llbb, num_cases as c_uint) } } fn invoke(&self, - llfn: &'ll Value, - args: &[&'ll Value], - then: &'ll BasicBlock, - catch: &'ll BasicBlock, - bundle: Option<&traits::OperandBundleDef<'ll, &'ll Value>>) -> &'ll Value { + llfn: Self::Value, + args: &[Self::Value], + then: Self::BasicBlock, + catch: Self::BasicBlock, + bundle: Option<&traits::OperandBundleDef<'ll, Self::Value>>) -> Self::Value { self.count_insn("invoke"); debug!("Invoke {:?} with args ({:?})", @@ -223,21 +225,21 @@ impl BuilderMethods<'a, 'll, 'tcx, Value, BasicBlock> } /* Arithmetic */ - fn add(&self, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value { + fn add(&self, lhs: Self::Value, rhs: Self::Value) -> Self::Value { self.count_insn("add"); unsafe { llvm::LLVMBuildAdd(self.llbuilder, lhs, rhs, noname()) } } - fn fadd(&self, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value { + fn fadd(&self, lhs: Self::Value, rhs: Self::Value) -> Self::Value { self.count_insn("fadd"); unsafe { llvm::LLVMBuildFAdd(self.llbuilder, lhs, rhs, noname()) } } - fn fadd_fast(&self, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value { + fn fadd_fast(&self, lhs: Self::Value, rhs: Self::Value) -> Self::Value { self.count_insn("fadd"); unsafe { let instr = llvm::LLVMBuildFAdd(self.llbuilder, lhs, rhs, noname()); @@ -246,21 +248,21 @@ impl BuilderMethods<'a, 'll, 'tcx, Value, BasicBlock> } } - fn sub(&self, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value { + fn sub(&self, lhs: Self::Value, rhs: Self::Value) -> Self::Value { self.count_insn("sub"); unsafe { llvm::LLVMBuildSub(self.llbuilder, lhs, rhs, noname()) } } - fn fsub(&self, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value { + fn fsub(&self, lhs: Self::Value, rhs: Self::Value) -> Self::Value { self.count_insn("fsub"); unsafe { llvm::LLVMBuildFSub(self.llbuilder, lhs, rhs, noname()) } } - fn fsub_fast(&self, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value { + fn fsub_fast(&self, lhs: Self::Value, rhs: Self::Value) -> Self::Value { self.count_insn("fsub"); unsafe { let instr = llvm::LLVMBuildFSub(self.llbuilder, lhs, rhs, noname()); @@ -269,21 +271,21 @@ impl BuilderMethods<'a, 'll, 'tcx, Value, BasicBlock> } } - fn mul(&self, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value { + fn mul(&self, lhs: Self::Value, rhs: Self::Value) -> Self::Value { self.count_insn("mul"); unsafe { llvm::LLVMBuildMul(self.llbuilder, lhs, rhs, noname()) } } - fn fmul(&self, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value { + fn fmul(&self, lhs: Self::Value, rhs: Self::Value) -> Self::Value { self.count_insn("fmul"); unsafe { llvm::LLVMBuildFMul(self.llbuilder, lhs, rhs, noname()) } } - fn fmul_fast(&self, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value { + fn fmul_fast(&self, lhs: Self::Value, rhs: Self::Value) -> Self::Value { self.count_insn("fmul"); unsafe { let instr = llvm::LLVMBuildFMul(self.llbuilder, lhs, rhs, noname()); @@ -293,42 +295,42 @@ impl BuilderMethods<'a, 'll, 'tcx, Value, BasicBlock> } - fn udiv(&self, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value { + fn udiv(&self, lhs: Self::Value, rhs: Self::Value) -> Self::Value { self.count_insn("udiv"); unsafe { llvm::LLVMBuildUDiv(self.llbuilder, lhs, rhs, noname()) } } - fn exactudiv(&self, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value { + fn exactudiv(&self, lhs: Self::Value, rhs: Self::Value) -> Self::Value { self.count_insn("exactudiv"); unsafe { llvm::LLVMBuildExactUDiv(self.llbuilder, lhs, rhs, noname()) } } - fn sdiv(&self, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value { + fn sdiv(&self, lhs: Self::Value, rhs: Self::Value) -> Self::Value { self.count_insn("sdiv"); unsafe { llvm::LLVMBuildSDiv(self.llbuilder, lhs, rhs, noname()) } } - fn exactsdiv(&self, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value { + fn exactsdiv(&self, lhs: Self::Value, rhs: Self::Value) -> Self::Value { self.count_insn("exactsdiv"); unsafe { llvm::LLVMBuildExactSDiv(self.llbuilder, lhs, rhs, noname()) } } - fn fdiv(&self, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value { + fn fdiv(&self, lhs: Self::Value, rhs: Self::Value) -> Self::Value { self.count_insn("fdiv"); unsafe { llvm::LLVMBuildFDiv(self.llbuilder, lhs, rhs, noname()) } } - fn fdiv_fast(&self, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value { + fn fdiv_fast(&self, lhs: Self::Value, rhs: Self::Value) -> Self::Value { self.count_insn("fdiv"); unsafe { let instr = llvm::LLVMBuildFDiv(self.llbuilder, lhs, rhs, noname()); @@ -337,28 +339,28 @@ impl BuilderMethods<'a, 'll, 'tcx, Value, BasicBlock> } } - fn urem(&self, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value { + fn urem(&self, lhs: Self::Value, rhs: Self::Value) -> Self::Value { self.count_insn("urem"); unsafe { llvm::LLVMBuildURem(self.llbuilder, lhs, rhs, noname()) } } - fn srem(&self, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value { + fn srem(&self, lhs: Self::Value, rhs: Self::Value) -> Self::Value { self.count_insn("srem"); unsafe { llvm::LLVMBuildSRem(self.llbuilder, lhs, rhs, noname()) } } - fn frem(&self, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value { + fn frem(&self, lhs: Self::Value, rhs: Self::Value) -> Self::Value { self.count_insn("frem"); unsafe { llvm::LLVMBuildFRem(self.llbuilder, lhs, rhs, noname()) } } - fn frem_fast(&self, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value { + fn frem_fast(&self, lhs: Self::Value, rhs: Self::Value) -> Self::Value { self.count_insn("frem"); unsafe { let instr = llvm::LLVMBuildFRem(self.llbuilder, lhs, rhs, noname()); @@ -367,70 +369,70 @@ impl BuilderMethods<'a, 'll, 'tcx, Value, BasicBlock> } } - fn shl(&self, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value { + fn shl(&self, lhs: Self::Value, rhs: Self::Value) -> Self::Value { self.count_insn("shl"); unsafe { llvm::LLVMBuildShl(self.llbuilder, lhs, rhs, noname()) } } - fn lshr(&self, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value { + fn lshr(&self, lhs: Self::Value, rhs: Self::Value) -> Self::Value { self.count_insn("lshr"); unsafe { llvm::LLVMBuildLShr(self.llbuilder, lhs, rhs, noname()) } } - fn ashr(&self, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value { + fn ashr(&self, lhs: Self::Value, rhs: Self::Value) -> Self::Value { self.count_insn("ashr"); unsafe { llvm::LLVMBuildAShr(self.llbuilder, lhs, rhs, noname()) } } - fn and(&self, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value { + fn and(&self, lhs: Self::Value, rhs: Self::Value) -> Self::Value { self.count_insn("and"); unsafe { llvm::LLVMBuildAnd(self.llbuilder, lhs, rhs, noname()) } } - fn or(&self, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value { + fn or(&self, lhs: Self::Value, rhs: Self::Value) -> Self::Value { self.count_insn("or"); unsafe { llvm::LLVMBuildOr(self.llbuilder, lhs, rhs, noname()) } } - fn xor(&self, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value { + fn xor(&self, lhs: Self::Value, rhs: Self::Value) -> Self::Value { self.count_insn("xor"); unsafe { llvm::LLVMBuildXor(self.llbuilder, lhs, rhs, noname()) } } - fn neg(&self, v: &'ll Value) -> &'ll Value { + fn neg(&self, v: Self::Value) -> Self::Value { self.count_insn("neg"); unsafe { llvm::LLVMBuildNeg(self.llbuilder, v, noname()) } } - fn fneg(&self, v: &'ll Value) -> &'ll Value { + fn fneg(&self, v: Self::Value) -> Self::Value { self.count_insn("fneg"); unsafe { llvm::LLVMBuildFNeg(self.llbuilder, v, noname()) } } - fn not(&self, v: &'ll Value) -> &'ll Value { + fn not(&self, v: Self::Value) -> Self::Value { self.count_insn("not"); unsafe { llvm::LLVMBuildNot(self.llbuilder, v, noname()) } } - fn alloca(&self, ty: &'ll Type, name: &str, align: Align) -> &'ll Value { + fn alloca(&self, ty: Self::Type, name: &str, align: Align) -> Self::Value { let bx = Builder::with_cx(self.cx); bx.position_at_start(unsafe { llvm::LLVMGetFirstBasicBlock(self.llfn()) @@ -438,7 +440,7 @@ impl BuilderMethods<'a, 'll, 'tcx, Value, BasicBlock> bx.dynamic_alloca(ty, name, align) } - fn dynamic_alloca(&self, ty: &'ll Type, name: &str, align: Align) -> &'ll Value { + fn dynamic_alloca(&self, ty: Self::Type, name: &str, align: Align) -> Self::Value { self.count_insn("alloca"); unsafe { let alloca = if name.is_empty() { @@ -454,10 +456,10 @@ impl BuilderMethods<'a, 'll, 'tcx, Value, BasicBlock> } fn array_alloca(&self, - ty: &'ll Type, - len: &'ll Value, + ty: Self::Type, + len: Self::Value, name: &str, - align: Align) -> &'ll Value { + align: Align) -> Self::Value { self.count_insn("alloca"); unsafe { let alloca = if name.is_empty() { @@ -472,7 +474,7 @@ impl BuilderMethods<'a, 'll, 'tcx, Value, BasicBlock> } } - fn load(&self, ptr: &'ll Value, align: Align) -> &'ll Value { + fn load(&self, ptr: Self::Value, align: Align) -> Self::Value { self.count_insn("load"); unsafe { let load = llvm::LLVMBuildLoad(self.llbuilder, ptr, noname()); @@ -481,7 +483,7 @@ impl BuilderMethods<'a, 'll, 'tcx, Value, BasicBlock> } } - fn volatile_load(&self, ptr: &'ll Value) -> &'ll Value { + fn volatile_load(&self, ptr: Self::Value) -> Self::Value { self.count_insn("load.volatile"); unsafe { let insn = llvm::LLVMBuildLoad(self.llbuilder, ptr, noname()); @@ -492,10 +494,10 @@ impl BuilderMethods<'a, 'll, 'tcx, Value, BasicBlock> fn atomic_load( &self, - ptr: &'ll Value, + ptr: Self::Value, order: traits::AtomicOrdering, size: Size, - ) -> &'ll Value { + ) -> Self::Value { self.count_insn("load.atomic"); unsafe { let load = llvm::LLVMRustBuildAtomicLoad( @@ -511,7 +513,7 @@ impl BuilderMethods<'a, 'll, 'tcx, Value, BasicBlock> } - fn range_metadata(&self, load: &'ll Value, range: Range) { + fn range_metadata(&self, load: Self::Value, range: Range) { if self.sess().target.target.arch == "amdgpu" { // amdgpu/LLVM does something weird and thinks a i64 value is // split into a v2i32, halving the bitwidth LLVM expects, @@ -534,24 +536,24 @@ impl BuilderMethods<'a, 'll, 'tcx, Value, BasicBlock> } } - fn nonnull_metadata(&self, load: &'ll Value) { + fn nonnull_metadata(&self, load: Self::Value) { unsafe { llvm::LLVMSetMetadata(load, llvm::MD_nonnull as c_uint, llvm::LLVMMDNodeInContext(self.cx.llcx, ptr::null(), 0)); } } - fn store(&self, val: &'ll Value, ptr: &'ll Value, align: Align) -> &'ll Value { + fn store(&self, val: Self::Value, ptr: Self::Value, align: Align) -> Self::Value { self.store_with_flags(val, ptr, align, MemFlags::empty()) } fn store_with_flags( &self, - val: &'ll Value, - ptr: &'ll Value, + val: Self::Value, + ptr: Self::Value, align: Align, flags: MemFlags, - ) -> &'ll Value { + ) -> Self::Value { debug!("Store {:?} -> {:?} ({:?})", val, ptr, flags); self.count_insn("store"); let ptr = self.check_store(val, ptr); @@ -579,7 +581,7 @@ impl BuilderMethods<'a, 'll, 'tcx, Value, BasicBlock> } } - fn atomic_store(&self, val: &'ll Value, ptr: &'ll Value, + fn atomic_store(&self, val: Self::Value, ptr: Self::Value, order: traits::AtomicOrdering, size: Size) { debug!("Store {:?} -> {:?}", val, ptr); self.count_insn("store.atomic"); @@ -596,7 +598,7 @@ impl BuilderMethods<'a, 'll, 'tcx, Value, BasicBlock> } } - fn gep(&self, ptr: &'ll Value, indices: &[&'ll Value]) -> &'ll Value { + fn gep(&self, ptr: Self::Value, indices: &[Self::Value]) -> Self::Value { self.count_insn("gep"); unsafe { llvm::LLVMBuildGEP(self.llbuilder, ptr, indices.as_ptr(), @@ -604,7 +606,7 @@ impl BuilderMethods<'a, 'll, 'tcx, Value, BasicBlock> } } - fn inbounds_gep(&self, ptr: &'ll Value, indices: &[&'ll Value]) -> &'ll Value { + fn inbounds_gep(&self, ptr: Self::Value, indices: &[Self::Value]) -> Self::Value { self.count_insn("inboundsgep"); unsafe { llvm::LLVMBuildInBoundsGEP( @@ -613,77 +615,77 @@ impl BuilderMethods<'a, 'll, 'tcx, Value, BasicBlock> } /* Casts */ - fn trunc(&self, val: &'ll Value, dest_ty: &'ll Type) -> &'ll Value { + fn trunc(&self, val: Self::Value, dest_ty: Self::Type) -> Self::Value { self.count_insn("trunc"); unsafe { llvm::LLVMBuildTrunc(self.llbuilder, val, dest_ty, noname()) } } - fn sext(&self, val: &'ll Value, dest_ty: &'ll Type) -> &'ll Value { + fn sext(&self, val: Self::Value, dest_ty: Self::Type) -> Self::Value { self.count_insn("sext"); unsafe { llvm::LLVMBuildSExt(self.llbuilder, val, dest_ty, noname()) } } - fn fptoui(&self, val: &'ll Value, dest_ty: &'ll Type) -> &'ll Value { + fn fptoui(&self, val: Self::Value, dest_ty: Self::Type) -> Self::Value { self.count_insn("fptoui"); unsafe { llvm::LLVMBuildFPToUI(self.llbuilder, val, dest_ty, noname()) } } - fn fptosi(&self, val: &'ll Value, dest_ty: &'ll Type) -> &'ll Value { + fn fptosi(&self, val: Self::Value, dest_ty: Self::Type) -> Self::Value { self.count_insn("fptosi"); unsafe { llvm::LLVMBuildFPToSI(self.llbuilder, val, dest_ty,noname()) } } - fn uitofp(&self, val: &'ll Value, dest_ty: &'ll Type) -> &'ll Value { + fn uitofp(&self, val: Self::Value, dest_ty: Self::Type) -> Self::Value { self.count_insn("uitofp"); unsafe { llvm::LLVMBuildUIToFP(self.llbuilder, val, dest_ty, noname()) } } - fn sitofp(&self, val: &'ll Value, dest_ty: &'ll Type) -> &'ll Value { + fn sitofp(&self, val: Self::Value, dest_ty: Self::Type) -> Self::Value { self.count_insn("sitofp"); unsafe { llvm::LLVMBuildSIToFP(self.llbuilder, val, dest_ty, noname()) } } - fn fptrunc(&self, val: &'ll Value, dest_ty: &'ll Type) -> &'ll Value { + fn fptrunc(&self, val: Self::Value, dest_ty: Self::Type) -> Self::Value { self.count_insn("fptrunc"); unsafe { llvm::LLVMBuildFPTrunc(self.llbuilder, val, dest_ty, noname()) } } - fn fpext(&self, val: &'ll Value, dest_ty: &'ll Type) -> &'ll Value { + fn fpext(&self, val: Self::Value, dest_ty: Self::Type) -> Self::Value { self.count_insn("fpext"); unsafe { llvm::LLVMBuildFPExt(self.llbuilder, val, dest_ty, noname()) } } - fn ptrtoint(&self, val: &'ll Value, dest_ty: &'ll Type) -> &'ll Value { + fn ptrtoint(&self, val: Self::Value, dest_ty: Self::Type) -> Self::Value { self.count_insn("ptrtoint"); unsafe { llvm::LLVMBuildPtrToInt(self.llbuilder, val, dest_ty, noname()) } } - fn inttoptr(&self, val: &'ll Value, dest_ty: &'ll Type) -> &'ll Value { + fn inttoptr(&self, val: Self::Value, dest_ty: Self::Type) -> Self::Value { self.count_insn("inttoptr"); unsafe { llvm::LLVMBuildIntToPtr(self.llbuilder, val, dest_ty, noname()) } } - fn bitcast(&self, val: &'ll Value, dest_ty: &'ll Type) -> &'ll Value { + fn bitcast(&self, val: Self::Value, dest_ty: Self::Type) -> Self::Value { self.count_insn("bitcast"); unsafe { llvm::LLVMBuildBitCast(self.llbuilder, val, dest_ty, noname()) @@ -691,14 +693,14 @@ impl BuilderMethods<'a, 'll, 'tcx, Value, BasicBlock> } - fn intcast(&self, val: &'ll Value, dest_ty: &'ll Type, is_signed: bool) -> &'ll Value { + fn intcast(&self, val: Self::Value, dest_ty: Self::Type, is_signed: bool) -> Self::Value { self.count_insn("intcast"); unsafe { llvm::LLVMRustBuildIntCast(self.llbuilder, val, dest_ty, is_signed) } } - fn pointercast(&self, val: &'ll Value, dest_ty: &'ll Type) -> &'ll Value { + fn pointercast(&self, val: Self::Value, dest_ty: Self::Type) -> Self::Value { self.count_insn("pointercast"); unsafe { llvm::LLVMBuildPointerCast(self.llbuilder, val, dest_ty, noname()) @@ -706,7 +708,7 @@ impl BuilderMethods<'a, 'll, 'tcx, Value, BasicBlock> } /* Comparisons */ - fn icmp(&self, op: traits::IntPredicate, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value { + fn icmp(&self, op: traits::IntPredicate, lhs: Self::Value, rhs: Self::Value) -> Self::Value { self.count_insn("icmp"); let op = llvm::IntPredicate::from_generic(op); unsafe { @@ -714,7 +716,7 @@ impl BuilderMethods<'a, 'll, 'tcx, Value, BasicBlock> } } - fn fcmp(&self, op: traits::RealPredicate, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value { + fn fcmp(&self, op: traits::RealPredicate, lhs: Self::Value, rhs: Self::Value) -> Self::Value { self.count_insn("fcmp"); unsafe { llvm::LLVMBuildFCmp(self.llbuilder, op as c_uint, lhs, rhs, noname()) @@ -722,14 +724,14 @@ impl BuilderMethods<'a, 'll, 'tcx, Value, BasicBlock> } /* Miscellaneous instructions */ - fn empty_phi(&self, ty: &'ll Type) -> &'ll Value { + fn empty_phi(&self, ty: Self::Type) -> Self::Value { self.count_insn("emptyphi"); unsafe { llvm::LLVMBuildPhi(self.llbuilder, ty, noname()) } } - fn phi(&self, ty: &'ll Type, vals: &[&'ll Value], bbs: &[&'ll BasicBlock]) -> &'ll Value { + fn phi(&self, ty: Self::Type, vals: &[Self::Value], bbs: &[Self::BasicBlock]) -> Self::Value { assert_eq!(vals.len(), bbs.len()); let phi = self.empty_phi(ty); self.count_insn("addincoming"); @@ -742,9 +744,9 @@ impl BuilderMethods<'a, 'll, 'tcx, Value, BasicBlock> } fn inline_asm_call(&self, asm: *const c_char, cons: *const c_char, - inputs: &[&'ll Value], output: &'ll Type, + inputs: &[Self::Value], output: Self::Type, volatile: bool, alignstack: bool, - dia: syntax::ast::AsmDialect) -> Option<&'ll Value> { + dia: syntax::ast::AsmDialect) -> Option { self.count_insn("inlineasm"); let volatile = if volatile { llvm::True } @@ -758,7 +760,7 @@ impl BuilderMethods<'a, 'll, 'tcx, Value, BasicBlock> }).collect::>(); debug!("Asm Output Type: {:?}", output); - let fty = Type::func(&argtys[..], output); + let fty = type_::Type::func(&argtys[..], output); unsafe { // Ask LLVM to verify that the constraints are well-formed. let constraints_ok = llvm::LLVMRustInlineAsmVerify(fty, cons); @@ -774,32 +776,32 @@ impl BuilderMethods<'a, 'll, 'tcx, Value, BasicBlock> } } - fn memcpy(&self, dst: &'ll Value, dst_align: u64, - src: &'ll Value, src_align: u64, - size: &'ll Value, is_volatile: bool) -> &'ll Value { + fn memcpy(&self, dst: Self::Value, dst_align: u64, + src: Self::Value, src_align: u64, + size: Self::Value, is_volatile: bool) -> Self::Value { unsafe { llvm::LLVMRustBuildMemCpy(self.llbuilder, dst, dst_align as c_uint, src, src_align as c_uint, size, is_volatile) } } - fn memmove(&self, dst: &'ll Value, dst_align: u64, - src: &'ll Value, src_align: u64, - size: &'ll Value, is_volatile: bool) -> &'ll Value { + fn memmove(&self, dst: Self::Value, dst_align: u64, + src: Self::Value, src_align: u64, + size: Self::Value, is_volatile: bool) -> Self::Value { unsafe { llvm::LLVMRustBuildMemMove(self.llbuilder, dst, dst_align as c_uint, src, src_align as c_uint, size, is_volatile) } } - fn minnum(&self, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value { + fn minnum(&self, lhs: Self::Value, rhs: Self::Value) -> Self::Value { self.count_insn("minnum"); unsafe { let instr = llvm::LLVMRustBuildMinNum(self.llbuilder, lhs, rhs); instr.expect("LLVMRustBuildMinNum is not available in LLVM version < 6.0") } } - fn maxnum(&self, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value { + fn maxnum(&self, lhs: Self::Value, rhs: Self::Value) -> Self::Value { self.count_insn("maxnum"); unsafe { let instr = llvm::LLVMRustBuildMaxNum(self.llbuilder, lhs, rhs); @@ -808,10 +810,10 @@ impl BuilderMethods<'a, 'll, 'tcx, Value, BasicBlock> } fn select( - &self, cond: &'ll Value, - then_val: &'ll Value, - else_val: &'ll Value, - ) -> &'ll Value { + &self, cond: Self::Value, + then_val: Self::Value, + else_val: Self::Value, + ) -> Self::Value { self.count_insn("select"); unsafe { llvm::LLVMBuildSelect(self.llbuilder, cond, then_val, else_val, noname()) @@ -819,14 +821,14 @@ impl BuilderMethods<'a, 'll, 'tcx, Value, BasicBlock> } #[allow(dead_code)] - fn va_arg(&self, list: &'ll Value, ty: &'ll Type) -> &'ll Value { + fn va_arg(&self, list: Self::Value, ty: Self::Type) -> Self::Value { self.count_insn("vaarg"); unsafe { llvm::LLVMBuildVAArg(self.llbuilder, list, ty, noname()) } } - fn extract_element(&self, vec: &'ll Value, idx: &'ll Value) -> &'ll Value { + fn extract_element(&self, vec: Self::Value, idx: Self::Value) -> Self::Value { self.count_insn("extractelement"); unsafe { llvm::LLVMBuildExtractElement(self.llbuilder, vec, idx, noname()) @@ -834,34 +836,34 @@ impl BuilderMethods<'a, 'll, 'tcx, Value, BasicBlock> } fn insert_element( - &self, vec: &'ll Value, - elt: &'ll Value, - idx: &'ll Value, - ) -> &'ll Value { + &self, vec: Self::Value, + elt: Self::Value, + idx: Self::Value, + ) -> Self::Value { self.count_insn("insertelement"); unsafe { llvm::LLVMBuildInsertElement(self.llbuilder, vec, elt, idx, noname()) } } - fn shuffle_vector(&self, v1: &'ll Value, v2: &'ll Value, mask: &'ll Value) -> &'ll Value { + fn shuffle_vector(&self, v1: Self::Value, v2: Self::Value, mask: Self::Value) -> Self::Value { self.count_insn("shufflevector"); unsafe { llvm::LLVMBuildShuffleVector(self.llbuilder, v1, v2, mask, noname()) } } - fn vector_splat(&self, num_elts: usize, elt: &'ll Value) -> &'ll Value { + fn vector_splat(&self, num_elts: usize, elt: Self::Value) -> Self::Value { unsafe { let elt_ty = val_ty(elt); - let undef = llvm::LLVMGetUndef(Type::vector(elt_ty, num_elts as u64)); + let undef = llvm::LLVMGetUndef(type_::Type::vector(elt_ty, num_elts as u64)); let vec = self.insert_element(undef, elt, C_i32(self.cx, 0)); - let vec_i32_ty = Type::vector(Type::i32(self.cx), num_elts as u64); + let vec_i32_ty = type_::Type::vector(type_::Type::i32(self.cx), num_elts as u64); self.shuffle_vector(vec, undef, C_null(vec_i32_ty)) } } - fn vector_reduce_fadd_fast(&self, acc: &'ll Value, src: &'ll Value) -> &'ll Value { + fn vector_reduce_fadd_fast(&self, acc: Self::Value, src: Self::Value) -> Self::Value { self.count_insn("vector.reduce.fadd_fast"); unsafe { // FIXME: add a non-fast math version once @@ -872,7 +874,7 @@ impl BuilderMethods<'a, 'll, 'tcx, Value, BasicBlock> instr } } - fn vector_reduce_fmul_fast(&self, acc: &'ll Value, src: &'ll Value) -> &'ll Value { + fn vector_reduce_fmul_fast(&self, acc: Self::Value, src: Self::Value) -> Self::Value { self.count_insn("vector.reduce.fmul_fast"); unsafe { // FIXME: add a non-fast math version once @@ -883,35 +885,35 @@ impl BuilderMethods<'a, 'll, 'tcx, Value, BasicBlock> instr } } - fn vector_reduce_add(&self, src: &'ll Value) -> &'ll Value { + fn vector_reduce_add(&self, src: Self::Value) -> Self::Value { self.count_insn("vector.reduce.add"); unsafe { llvm::LLVMRustBuildVectorReduceAdd(self.llbuilder, src) } } - fn vector_reduce_mul(&self, src: &'ll Value) -> &'ll Value { + fn vector_reduce_mul(&self, src: Self::Value) -> Self::Value { self.count_insn("vector.reduce.mul"); unsafe { llvm::LLVMRustBuildVectorReduceMul(self.llbuilder, src) } } - fn vector_reduce_and(&self, src: &'ll Value) -> &'ll Value { + fn vector_reduce_and(&self, src: Self::Value) -> Self::Value { self.count_insn("vector.reduce.and"); unsafe { llvm::LLVMRustBuildVectorReduceAnd(self.llbuilder, src) } } - fn vector_reduce_or(&self, src: &'ll Value) -> &'ll Value { + fn vector_reduce_or(&self, src: Self::Value) -> Self::Value { self.count_insn("vector.reduce.or"); unsafe { llvm::LLVMRustBuildVectorReduceOr(self.llbuilder, src) } } - fn vector_reduce_xor(&self, src: &'ll Value) -> &'ll Value { + fn vector_reduce_xor(&self, src: Self::Value) -> Self::Value { self.count_insn("vector.reduce.xor"); unsafe { llvm::LLVMRustBuildVectorReduceXor(self.llbuilder, src) } } - fn vector_reduce_fmin(&self, src: &'ll Value) -> &'ll Value { + fn vector_reduce_fmin(&self, src: Self::Value) -> Self::Value { self.count_insn("vector.reduce.fmin"); unsafe { llvm::LLVMRustBuildVectorReduceFMin(self.llbuilder, src, /*NoNaNs:*/ false) } } - fn vector_reduce_fmax(&self, src: &'ll Value) -> &'ll Value { + fn vector_reduce_fmax(&self, src: Self::Value) -> Self::Value { self.count_insn("vector.reduce.fmax"); unsafe { llvm::LLVMRustBuildVectorReduceFMax(self.llbuilder, src, /*NoNaNs:*/ false) } } - fn vector_reduce_fmin_fast(&self, src: &'ll Value) -> &'ll Value { + fn vector_reduce_fmin_fast(&self, src: Self::Value) -> Self::Value { self.count_insn("vector.reduce.fmin_fast"); unsafe { let instr = llvm::LLVMRustBuildVectorReduceFMin(self.llbuilder, src, /*NoNaNs:*/ true); @@ -919,7 +921,7 @@ impl BuilderMethods<'a, 'll, 'tcx, Value, BasicBlock> instr } } - fn vector_reduce_fmax_fast(&self, src: &'ll Value) -> &'ll Value { + fn vector_reduce_fmax_fast(&self, src: Self::Value) -> Self::Value { self.count_insn("vector.reduce.fmax_fast"); unsafe { let instr = llvm::LLVMRustBuildVectorReduceFMax(self.llbuilder, src, /*NoNaNs:*/ true); @@ -927,16 +929,16 @@ impl BuilderMethods<'a, 'll, 'tcx, Value, BasicBlock> instr } } - fn vector_reduce_min(&self, src: &'ll Value, is_signed: bool) -> &'ll Value { + fn vector_reduce_min(&self, src: Self::Value, is_signed: bool) -> Self::Value { self.count_insn("vector.reduce.min"); unsafe { llvm::LLVMRustBuildVectorReduceMin(self.llbuilder, src, is_signed) } } - fn vector_reduce_max(&self, src: &'ll Value, is_signed: bool) -> &'ll Value { + fn vector_reduce_max(&self, src: Self::Value, is_signed: bool) -> Self::Value { self.count_insn("vector.reduce.max"); unsafe { llvm::LLVMRustBuildVectorReduceMax(self.llbuilder, src, is_signed) } } - fn extract_value(&self, agg_val: &'ll Value, idx: u64) -> &'ll Value { + fn extract_value(&self, agg_val: Self::Value, idx: u64) -> Self::Value { self.count_insn("extractvalue"); assert_eq!(idx as c_uint as u64, idx); unsafe { @@ -944,8 +946,8 @@ impl BuilderMethods<'a, 'll, 'tcx, Value, BasicBlock> } } - fn insert_value(&self, agg_val: &'ll Value, elt: &'ll Value, - idx: u64) -> &'ll Value { + fn insert_value(&self, agg_val: Self::Value, elt: Self::Value, + idx: u64) -> Self::Value { self.count_insn("insertvalue"); assert_eq!(idx as c_uint as u64, idx); unsafe { @@ -954,8 +956,8 @@ impl BuilderMethods<'a, 'll, 'tcx, Value, BasicBlock> } } - fn landing_pad(&self, ty: &'ll Type, pers_fn: &'ll Value, - num_clauses: usize) -> &'ll Value { + fn landing_pad(&self, ty: Self::Type, pers_fn: Self::Value, + num_clauses: usize) -> Self::Value { self.count_insn("landingpad"); unsafe { llvm::LLVMBuildLandingPad(self.llbuilder, ty, pers_fn, @@ -963,20 +965,20 @@ impl BuilderMethods<'a, 'll, 'tcx, Value, BasicBlock> } } - fn add_clause(&self, landing_pad: &'ll Value, clause: &'ll Value) { + fn add_clause(&self, landing_pad: Self::Value, clause: Self::Value) { unsafe { llvm::LLVMAddClause(landing_pad, clause); } } - fn set_cleanup(&self, landing_pad: &'ll Value) { + fn set_cleanup(&self, landing_pad: Self::Value) { self.count_insn("setcleanup"); unsafe { llvm::LLVMSetCleanup(landing_pad, llvm::True); } } - fn resume(&self, exn: &'ll Value) -> &'ll Value { + fn resume(&self, exn: Self::Value) -> Self::Value { self.count_insn("resume"); unsafe { llvm::LLVMBuildResume(self.llbuilder, exn) @@ -984,8 +986,8 @@ impl BuilderMethods<'a, 'll, 'tcx, Value, BasicBlock> } fn cleanup_pad(&self, - parent: Option<&'ll Value>, - args: &[&'ll Value]) -> &'ll Value { + parent: Option, + args: &[Self::Value]) -> Self::Value { self.count_insn("cleanuppad"); let name = const_cstr!("cleanuppad"); let ret = unsafe { @@ -999,9 +1001,9 @@ impl BuilderMethods<'a, 'll, 'tcx, Value, BasicBlock> } fn cleanup_ret( - &self, cleanup: &'ll Value, - unwind: Option<&'ll BasicBlock>, - ) -> &'ll Value { + &self, cleanup: Self::Value, + unwind: Option, + ) -> Self::Value { self.count_insn("cleanupret"); let ret = unsafe { llvm::LLVMRustBuildCleanupRet(self.llbuilder, cleanup, unwind) @@ -1010,8 +1012,8 @@ impl BuilderMethods<'a, 'll, 'tcx, Value, BasicBlock> } fn catch_pad(&self, - parent: &'ll Value, - args: &[&'ll Value]) -> &'ll Value { + parent: Self::Value, + args: &[Self::Value]) -> Self::Value { self.count_insn("catchpad"); let name = const_cstr!("catchpad"); let ret = unsafe { @@ -1022,7 +1024,7 @@ impl BuilderMethods<'a, 'll, 'tcx, Value, BasicBlock> ret.expect("LLVM does not have support for catchpad") } - fn catch_ret(&self, pad: &'ll Value, unwind: &'ll BasicBlock) -> &'ll Value { + fn catch_ret(&self, pad: Self::Value, unwind: Self::BasicBlock) -> Self::Value { self.count_insn("catchret"); let ret = unsafe { llvm::LLVMRustBuildCatchRet(self.llbuilder, pad, unwind) @@ -1032,10 +1034,10 @@ impl BuilderMethods<'a, 'll, 'tcx, Value, BasicBlock> fn catch_switch( &self, - parent: Option<&'ll Value>, - unwind: Option<&'ll BasicBlock>, + parent: Option, + unwind: Option, num_handlers: usize, - ) -> &'ll Value { + ) -> Self::Value { self.count_insn("catchswitch"); let name = const_cstr!("catchswitch"); let ret = unsafe { @@ -1046,13 +1048,13 @@ impl BuilderMethods<'a, 'll, 'tcx, Value, BasicBlock> ret.expect("LLVM does not have support for catchswitch") } - fn add_handler(&self, catch_switch: &'ll Value, handler: &'ll BasicBlock) { + fn add_handler(&self, catch_switch: Self::Value, handler: Self::BasicBlock) { unsafe { llvm::LLVMRustAddHandler(catch_switch, handler); } } - fn set_personality_fn(&self, personality: &'ll Value) { + fn set_personality_fn(&self, personality: Self::Value) { unsafe { llvm::LLVMSetPersonalityFn(self.llfn(), personality); } @@ -1061,13 +1063,13 @@ impl BuilderMethods<'a, 'll, 'tcx, Value, BasicBlock> // Atomic Operations fn atomic_cmpxchg( &self, - dst: &'ll Value, - cmp: &'ll Value, - src: &'ll Value, + dst: Self::Value, + cmp: Self::Value, + src: Self::Value, order: traits::AtomicOrdering, failure_order: traits::AtomicOrdering, weak: bool, - ) -> &'ll Value { + ) -> Self::Value { let weak = if weak { llvm::True } else { llvm::False }; unsafe { llvm::LLVMRustBuildAtomicCmpXchg( @@ -1084,10 +1086,10 @@ impl BuilderMethods<'a, 'll, 'tcx, Value, BasicBlock> fn atomic_rmw( &self, op: traits::AtomicRmwBinOp, - dst: &'ll Value, - src: &'ll Value, + dst: Self::Value, + src: Self::Value, order: traits::AtomicOrdering, - ) -> &'ll Value { + ) -> Self::Value { unsafe { llvm::LLVMBuildAtomicRMW( self.llbuilder, @@ -1109,20 +1111,20 @@ impl BuilderMethods<'a, 'll, 'tcx, Value, BasicBlock> } } - fn add_case(&self, s: &'ll Value, on_val: &'ll Value, dest: &'ll BasicBlock) { + fn add_case(&self, s: Self::Value, on_val: Self::Value, dest: Self::BasicBlock) { unsafe { llvm::LLVMAddCase(s, on_val, dest) } } - fn add_incoming_to_phi(&self, phi: &'ll Value, val: &'ll Value, bb: &'ll BasicBlock) { + fn add_incoming_to_phi(&self, phi: Self::Value, val: Self::Value, bb: Self::BasicBlock) { self.count_insn("addincoming"); unsafe { llvm::LLVMAddIncoming(phi, &val, &bb, 1 as c_uint); } } - fn set_invariant_load(&self, load: &'ll Value) { + fn set_invariant_load(&self, load: Self::Value) { unsafe { llvm::LLVMSetMetadata(load, llvm::MD_invariant_load as c_uint, llvm::LLVMMDNodeInContext(self.cx.llcx, ptr::null(), 0)); @@ -1131,8 +1133,8 @@ impl BuilderMethods<'a, 'll, 'tcx, Value, BasicBlock> /// Returns the ptr value that should be used for storing `val`. fn check_store<'b>(&self, - val: &'ll Value, - ptr: &'ll Value) -> &'ll Value { + val: Self::Value, + ptr: Self::Value) -> Self::Value { let dest_ptr_ty = val_ty(ptr); let stored_ty = val_ty(val); let stored_ptr_ty = stored_ty.ptr_to(); @@ -1152,8 +1154,8 @@ impl BuilderMethods<'a, 'll, 'tcx, Value, BasicBlock> /// Returns the args that should be used for a call to `llfn`. fn check_call<'b>(&self, typ: &str, - llfn: &'ll Value, - args: &'b [&'ll Value]) -> Cow<'b, [&'ll Value]> { + llfn: Self::Value, + args: &'b [Self::Value]) -> Cow<'b, [Self::Value]> { let mut fn_ty = val_ty(llfn); // Strip off pointers while fn_ty.kind() == llvm::TypeKind::Pointer { @@ -1192,11 +1194,11 @@ impl BuilderMethods<'a, 'll, 'tcx, Value, BasicBlock> Cow::Owned(casted_args) } - fn lifetime_start(&self, ptr: &'ll Value, size: Size) { + fn lifetime_start(&self, ptr: Self::Value, size: Size) { self.call_lifetime_intrinsic("llvm.lifetime.start", ptr, size); } - fn lifetime_end(&self, ptr: &'ll Value, size: Size) { + fn lifetime_end(&self, ptr: Self::Value, size: Size) { self.call_lifetime_intrinsic("llvm.lifetime.end", ptr, size); } @@ -1208,7 +1210,7 @@ impl BuilderMethods<'a, 'll, 'tcx, Value, BasicBlock> /// /// If LLVM lifetime intrinsic support is disabled (i.e. optimizations /// off) or `ptr` is zero-sized, then no-op (does not call `emit`). - fn call_lifetime_intrinsic(&self, intrinsic: &str, ptr: &'ll Value, size: Size) { + fn call_lifetime_intrinsic(&self, intrinsic: &str, ptr: Self::Value, size: Size) { if self.cx.sess().opts.optimize == config::OptLevel::No { return; } @@ -1220,12 +1222,12 @@ impl BuilderMethods<'a, 'll, 'tcx, Value, BasicBlock> let lifetime_intrinsic = self.cx.get_intrinsic(intrinsic); - let ptr = self.pointercast(ptr, Type::i8p(self.cx)); + let ptr = self.pointercast(ptr, type_::Type::i8p(self.cx)); self.call(lifetime_intrinsic, &[C_u64(self.cx, size), ptr], None); } - fn call(&self, llfn: &'ll Value, args: &[&'ll Value], - bundle: Option<&traits::OperandBundleDef<'ll, &'ll Value>>) -> &'ll Value { + fn call(&self, llfn: Self::Value, args: &[Self::Value], + bundle: Option<&traits::OperandBundleDef<'ll, Self::Value>>) -> Self::Value { self.count_insn("call"); debug!("Call {:?} with args ({:?})", @@ -1247,14 +1249,14 @@ impl BuilderMethods<'a, 'll, 'tcx, Value, BasicBlock> } } - fn zext(&self, val: &'ll Value, dest_ty: &'ll Type) -> &'ll Value { + fn zext(&self, val: Self::Value, dest_ty: Self::Type) -> Self::Value { self.count_insn("zext"); unsafe { llvm::LLVMBuildZExt(self.llbuilder, val, dest_ty, noname()) } } - fn struct_gep(&self, ptr: &'ll Value, idx: u64) -> &'ll Value { + fn struct_gep(&self, ptr: Self::Value, idx: u64) -> Self::Value { self.count_insn("structgep"); assert_eq!(idx as c_uint as u64, idx); unsafe { diff --git a/src/librustc_codegen_llvm/mir/operand.rs b/src/librustc_codegen_llvm/mir/operand.rs index 2b4a9b400dce..b8505ba12813 100644 --- a/src/librustc_codegen_llvm/mir/operand.rs +++ b/src/librustc_codegen_llvm/mir/operand.rs @@ -22,7 +22,6 @@ use type_::Type; use glue; use traits::BuilderMethods; -use llvm::BasicBlock; use std::fmt; @@ -280,9 +279,7 @@ impl OperandValue<&'ll Value> { } } -impl<'a, 'll: 'a, 'tcx: 'll> OperandValue<&'ll Value> where - Builder<'a, 'll, 'tcx>: BuilderMethods<'a, 'll, 'tcx, Value, BasicBlock> -{ +impl<'a, 'll: 'a, 'tcx: 'll> OperandValue<&'ll Value> { pub fn nontemporal_store( self, bx: &Builder<'a, 'll, 'tcx>, @@ -291,9 +288,9 @@ impl<'a, 'll: 'a, 'tcx: 'll> OperandValue<&'ll Value> where self.store_with_flags(bx, dest, MemFlags::NONTEMPORAL); } - fn store_with_flags>( + fn store_with_flags( self, - bx: &Builder, + bx: &Builder<'a, 'll, 'tcx, &'ll Value>, dest: PlaceRef<'tcx, &'ll Value>, flags: MemFlags, ) { diff --git a/src/librustc_codegen_llvm/traits.rs b/src/librustc_codegen_llvm/traits.rs index 946d05415572..417c900b127a 100644 --- a/src/librustc_codegen_llvm/traits.rs +++ b/src/librustc_codegen_llvm/traits.rs @@ -9,7 +9,6 @@ // except according to those terms. use common::*; -use type_::Type; use libc::c_char; use rustc::ty::TyCtxt; use rustc::ty::layout::{Align, Size}; @@ -103,265 +102,265 @@ pub enum SynchronizationScope { } -pub trait BuilderMethods<'a, 'll :'a, 'tcx: 'll, - Value : ?Sized, - BasicBlock: ?Sized - > { +pub trait BuilderMethods<'a, 'll :'a, 'tcx: 'll> { + type Value; + type BasicBlock; + type Type; fn new_block<'b>( - cx: &'a CodegenCx<'ll, 'tcx>, - llfn: &'ll Value, + cx: &'a CodegenCx<'ll, 'tcx, Self::Value>, + llfn: Self::Value, name: &'b str ) -> Self; - fn with_cx(cx: &'a CodegenCx<'ll, 'tcx>) -> Self; + fn with_cx(cx: &'a CodegenCx<'ll, 'tcx, Self::Value>) -> Self; fn build_sibling_block<'b>(&self, name: &'b str) -> Self; fn sess(&self) -> &Session; - fn cx(&self) -> &'a CodegenCx<'ll, 'tcx>; + fn cx(&self) -> &'a CodegenCx<'ll, 'tcx, Self::Value>; fn tcx(&self) -> TyCtxt<'a, 'tcx, 'tcx>; - fn llfn(&self) -> &'ll Value; - fn llbb(&self) -> &'ll BasicBlock; + fn llfn(&self) -> Self::Value; + fn llbb(&self) -> Self::BasicBlock; fn count_insn(&self, category: &str); - fn set_value_name(&self, value: &'ll Value, name: &str); - fn position_at_end(&self, llbb: &'ll BasicBlock); - fn position_at_start(&self, llbb: &'ll BasicBlock); + fn set_value_name(&self, value: Self::Value, name: &str); + fn position_at_end(&self, llbb: Self::BasicBlock); + fn position_at_start(&self, llbb: Self::BasicBlock); fn ret_void(&self); - fn ret(&self, v: &'ll Value); - fn br(&self, dest: &'ll BasicBlock); + fn ret(&self, v: Self::Value); + fn br(&self, dest: Self::BasicBlock); fn cond_br( &self, - cond: &'ll Value, - then_llbb: &'ll BasicBlock, - else_llbb: &'ll BasicBlock, + cond: Self::Value, + then_llbb: Self::BasicBlock, + else_llbb: Self::BasicBlock, ); fn switch( &self, - v: &'ll Value, - else_llbb: &'ll BasicBlock, + v: Self::Value, + else_llbb: Self::BasicBlock, num_cases: usize, - ) -> &'ll Value; + ) -> Self::Value; fn invoke( &self, - llfn: &'ll Value, - args: &[&'ll Value], - then: &'ll BasicBlock, - catch: &'ll BasicBlock, - bundle: Option<&OperandBundleDef<'ll, &'ll Value>> - ) -> &'ll Value; + llfn: Self::Value, + args: &[Self::Value], + then: Self::BasicBlock, + catch: Self::BasicBlock, + bundle: Option<&OperandBundleDef<'ll, Self::Value>> + ) -> Self::Value; fn unreachable(&self); - fn add(&self, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value; - fn fadd(&self, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value; - fn fadd_fast(&self, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value; - fn sub(&self, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value; - fn fsub(&self, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value; - fn fsub_fast(&self, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value; - fn mul(&self, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value; - fn fmul(&self, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value; - fn fmul_fast(&self, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value; - fn udiv(&self, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value; - fn exactudiv(&self, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value; - fn sdiv(&self, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value; - fn exactsdiv(&self, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value; - fn fdiv(&self, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value; - fn fdiv_fast(&self, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value; - fn urem(&self, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value; - fn srem(&self, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value; - fn frem(&self, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value; - fn frem_fast(&self, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value; - fn shl(&self, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value; - fn lshr(&self, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value; - fn ashr(&self, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value; - fn and(&self, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value; - fn or(&self, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value; - fn xor(&self, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value; - fn neg(&self, v: &'ll Value) -> &'ll Value; - fn fneg(&self, v: &'ll Value) -> &'ll Value; - fn not(&self, v: &'ll Value) -> &'ll Value; + fn add(&self, lhs: Self::Value, rhs: Self::Value) -> Self::Value; + fn fadd(&self, lhs: Self::Value, rhs: Self::Value) -> Self::Value; + fn fadd_fast(&self, lhs: Self::Value, rhs: Self::Value) -> Self::Value; + fn sub(&self, lhs: Self::Value, rhs: Self::Value) -> Self::Value; + fn fsub(&self, lhs: Self::Value, rhs: Self::Value) -> Self::Value; + fn fsub_fast(&self, lhs: Self::Value, rhs: Self::Value) -> Self::Value; + fn mul(&self, lhs: Self::Value, rhs: Self::Value) -> Self::Value; + fn fmul(&self, lhs: Self::Value, rhs: Self::Value) -> Self::Value; + fn fmul_fast(&self, lhs: Self::Value, rhs: Self::Value) -> Self::Value; + fn udiv(&self, lhs: Self::Value, rhs: Self::Value) -> Self::Value; + fn exactudiv(&self, lhs: Self::Value, rhs: Self::Value) -> Self::Value; + fn sdiv(&self, lhs: Self::Value, rhs: Self::Value) -> Self::Value; + fn exactsdiv(&self, lhs: Self::Value, rhs: Self::Value) -> Self::Value; + fn fdiv(&self, lhs: Self::Value, rhs: Self::Value) -> Self::Value; + fn fdiv_fast(&self, lhs: Self::Value, rhs: Self::Value) -> Self::Value; + fn urem(&self, lhs: Self::Value, rhs: Self::Value) -> Self::Value; + fn srem(&self, lhs: Self::Value, rhs: Self::Value) -> Self::Value; + fn frem(&self, lhs: Self::Value, rhs: Self::Value) -> Self::Value; + fn frem_fast(&self, lhs: Self::Value, rhs: Self::Value) -> Self::Value; + fn shl(&self, lhs: Self::Value, rhs: Self::Value) -> Self::Value; + fn lshr(&self, lhs: Self::Value, rhs: Self::Value) -> Self::Value; + fn ashr(&self, lhs: Self::Value, rhs: Self::Value) -> Self::Value; + fn and(&self, lhs: Self::Value, rhs: Self::Value) -> Self::Value; + fn or(&self, lhs: Self::Value, rhs: Self::Value) -> Self::Value; + fn xor(&self, lhs: Self::Value, rhs: Self::Value) -> Self::Value; + fn neg(&self, v: Self::Value) -> Self::Value; + fn fneg(&self, v: Self::Value) -> Self::Value; + fn not(&self, v: Self::Value) -> Self::Value; - fn alloca(&self, ty: &'ll Type, name: &str, align: Align) -> &'ll Value; - fn dynamic_alloca(&self, ty: &'ll Type, name: &str, align: Align) -> &'ll Value; + fn alloca(&self, ty: Self::Type, name: &str, align: Align) -> Self::Value; + fn dynamic_alloca(&self, ty: Self::Type, name: &str, align: Align) -> Self::Value; fn array_alloca( &self, - ty: &'ll Type, - len: &'ll Value, + ty: Self::Type, + len: Self::Value, name: &str, align: Align - ) -> &'ll Value; + ) -> Self::Value; - fn load(&self, ptr: &'ll Value, align: Align) -> &'ll Value; - fn volatile_load(&self, ptr: &'ll Value) -> &'ll Value; - fn atomic_load(&self, ptr: &'ll Value, order: AtomicOrdering, size: Size) -> &'ll Value; + fn load(&self, ptr: Self::Value, align: Align) -> Self::Value; + fn volatile_load(&self, ptr: Self::Value) -> Self::Value; + fn atomic_load(&self, ptr: Self::Value, order: AtomicOrdering, size: Size) -> Self::Value; - fn range_metadata(&self, load: &'ll Value, range: Range); - fn nonnull_metadata(&self, load: &'ll Value); + fn range_metadata(&self, load: Self::Value, range: Range); + fn nonnull_metadata(&self, load: Self::Value); - fn store(&self, val: &'ll Value, ptr: &'ll Value, align: Align) -> &'ll Value; + fn store(&self, val: Self::Value, ptr: Self::Value, align: Align) -> Self::Value; fn store_with_flags( &self, - val: &'ll Value, - ptr: &'ll Value, + val: Self::Value, + ptr: Self::Value, align: Align, flags: MemFlags, - ) -> &'ll Value; + ) -> Self::Value; fn atomic_store( &self, - val: &'ll Value, - ptr: &'ll Value, + val: Self::Value, + ptr: Self::Value, order: AtomicOrdering, size: Size ); - fn gep(&self, ptr: &'ll Value, indices: &[&'ll Value]) -> &'ll Value; - fn inbounds_gep(&self, ptr: &'ll Value, indices: &[&'ll Value]) -> &'ll Value; - fn struct_gep(&self, ptr: &'ll Value, idx: u64) -> &'ll Value; + fn gep(&self, ptr: Self::Value, indices: &[Self::Value]) -> Self::Value; + fn inbounds_gep(&self, ptr: Self::Value, indices: &[Self::Value]) -> Self::Value; + fn struct_gep(&self, ptr: Self::Value, idx: u64) -> Self::Value; - fn trunc(&self, val: &'ll Value, dest_ty: &'ll Type) -> &'ll Value; - fn sext(&self, val: &'ll Value, dest_ty: &'ll Type) -> &'ll Value; - fn fptoui(&self, val: &'ll Value, dest_ty: &'ll Type) -> &'ll Value; - fn fptosi(&self, val: &'ll Value, dest_ty: &'ll Type) -> &'ll Value; - fn uitofp(&self, val: &'ll Value, dest_ty: &'ll Type) -> &'ll Value; - fn sitofp(&self, val: &'ll Value, dest_ty: &'ll Type) -> &'ll Value; - fn fptrunc(&self, val: &'ll Value, dest_ty: &'ll Type) -> &'ll Value; - fn fpext(&self, val: &'ll Value, dest_ty: &'ll Type) -> &'ll Value; - fn ptrtoint(&self, val: &'ll Value, dest_ty: &'ll Type) -> &'ll Value; - fn inttoptr(&self, val: &'ll Value, dest_ty: &'ll Type) -> &'ll Value; - fn bitcast(&self, val: &'ll Value, dest_ty: &'ll Type) -> &'ll Value; - fn intcast(&self, val: &'ll Value, dest_ty: &'ll Type, is_signed: bool) -> &'ll Value; - fn pointercast(&self, val: &'ll Value, dest_ty: &'ll Type) -> &'ll Value; + fn trunc(&self, val: Self::Value, dest_ty: Self::Type) -> Self::Value; + fn sext(&self, val: Self::Value, dest_ty: Self::Type) -> Self::Value; + fn fptoui(&self, val: Self::Value, dest_ty: Self::Type) -> Self::Value; + fn fptosi(&self, val: Self::Value, dest_ty: Self::Type) -> Self::Value; + fn uitofp(&self, val: Self::Value, dest_ty: Self::Type) -> Self::Value; + fn sitofp(&self, val: Self::Value, dest_ty: Self::Type) -> Self::Value; + fn fptrunc(&self, val: Self::Value, dest_ty: Self::Type) -> Self::Value; + fn fpext(&self, val: Self::Value, dest_ty: Self::Type) -> Self::Value; + fn ptrtoint(&self, val: Self::Value, dest_ty: Self::Type) -> Self::Value; + fn inttoptr(&self, val: Self::Value, dest_ty: Self::Type) -> Self::Value; + fn bitcast(&self, val: Self::Value, dest_ty: Self::Type) -> Self::Value; + fn intcast(&self, val: Self::Value, dest_ty: Self::Type, is_signed: bool) -> Self::Value; + fn pointercast(&self, val: Self::Value, dest_ty: Self::Type) -> Self::Value; - fn icmp(&self, op: IntPredicate, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value; - fn fcmp(&self, op: RealPredicate, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value; + fn icmp(&self, op: IntPredicate, lhs: Self::Value, rhs: Self::Value) -> Self::Value; + fn fcmp(&self, op: RealPredicate, lhs: Self::Value, rhs: Self::Value) -> Self::Value; - fn empty_phi(&self, ty: &'ll Type) -> &'ll Value; - fn phi(&self, ty: &'ll Type, vals: &[&'ll Value], bbs: &[&'ll BasicBlock]) -> &'ll Value; + fn empty_phi(&self, ty: Self::Type) -> Self::Value; + fn phi(&self, ty: Self::Type, vals: &[Self::Value], bbs: &[Self::BasicBlock]) -> Self::Value; fn inline_asm_call( &self, asm: *const c_char, cons: *const c_char, - inputs: &[&'ll Value], - output: &'ll Type, + inputs: &[Self::Value], + output: Self::Type, volatile: bool, alignstack: bool, dia: AsmDialect - ) -> Option<&'ll Value>; + ) -> Option; - fn memcpy(&self, dst: &'ll Value, dst_align: u64, - src: &'ll Value, src_align: u64, - size: &'ll Value, is_volatile: bool) -> &'ll Value; - fn memmove(&self, dst: &'ll Value, dst_align: u64, - src: &'ll Value, src_align: u64, - size: &'ll Value, is_volatile: bool) -> &'ll Value; + fn memcpy(&self, dst: Self::Value, dst_align: u64, + src: Self::Value, src_align: u64, + size: Self::Value, is_volatile: bool) -> Self::Value; + fn memmove(&self, dst: Self::Value, dst_align: u64, + src: Self::Value, src_align: u64, + size: Self::Value, is_volatile: bool) -> Self::Value; - fn minnum(&self, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value; - fn maxnum(&self, lhs: &'ll Value, rhs: &'ll Value) -> &'ll Value; + fn minnum(&self, lhs: Self::Value, rhs: Self::Value) -> Self::Value; + fn maxnum(&self, lhs: Self::Value, rhs: Self::Value) -> Self::Value; fn select( - &self, cond: &'ll Value, - then_val: &'ll Value, - else_val: &'ll Value, - ) -> &'ll Value; + &self, cond: Self::Value, + then_val: Self::Value, + else_val: Self::Value, + ) -> Self::Value; - fn va_arg(&self, list: &'ll Value, ty: &'ll Type) -> &'ll Value; - fn extract_element(&self, vec: &'ll Value, idx: &'ll Value) -> &'ll Value; + fn va_arg(&self, list: Self::Value, ty: Self::Type) -> Self::Value; + fn extract_element(&self, vec: Self::Value, idx: Self::Value) -> Self::Value; fn insert_element( - &self, vec: &'ll Value, - elt: &'ll Value, - idx: &'ll Value, - ) -> &'ll Value; - fn shuffle_vector(&self, v1: &'ll Value, v2: &'ll Value, mask: &'ll Value) -> &'ll Value; - fn vector_splat(&self, num_elts: usize, elt: &'ll Value) -> &'ll Value; - fn vector_reduce_fadd_fast(&self, acc: &'ll Value, src: &'ll Value) -> &'ll Value; - fn vector_reduce_fmul_fast(&self, acc: &'ll Value, src: &'ll Value) -> &'ll Value; - fn vector_reduce_add(&self, src: &'ll Value) -> &'ll Value; - fn vector_reduce_mul(&self, src: &'ll Value) -> &'ll Value; - fn vector_reduce_and(&self, src: &'ll Value) -> &'ll Value; - fn vector_reduce_or(&self, src: &'ll Value) -> &'ll Value; - fn vector_reduce_xor(&self, src: &'ll Value) -> &'ll Value; - fn vector_reduce_fmin(&self, src: &'ll Value) -> &'ll Value; - fn vector_reduce_fmax(&self, src: &'ll Value) -> &'ll Value; - fn vector_reduce_fmin_fast(&self, src: &'ll Value) -> &'ll Value; - fn vector_reduce_fmax_fast(&self, src: &'ll Value) -> &'ll Value; - fn vector_reduce_min(&self, src: &'ll Value, is_signed: bool) -> &'ll Value; - fn vector_reduce_max(&self, src: &'ll Value, is_signed: bool) -> &'ll Value; - fn extract_value(&self, agg_val: &'ll Value, idx: u64) -> &'ll Value; + &self, vec: Self::Value, + elt: Self::Value, + idx: Self::Value, + ) -> Self::Value; + fn shuffle_vector(&self, v1: Self::Value, v2: Self::Value, mask: Self::Value) -> Self::Value; + fn vector_splat(&self, num_elts: usize, elt: Self::Value) -> Self::Value; + fn vector_reduce_fadd_fast(&self, acc: Self::Value, src: Self::Value) -> Self::Value; + fn vector_reduce_fmul_fast(&self, acc: Self::Value, src: Self::Value) -> Self::Value; + fn vector_reduce_add(&self, src: Self::Value) -> Self::Value; + fn vector_reduce_mul(&self, src: Self::Value) -> Self::Value; + fn vector_reduce_and(&self, src: Self::Value) -> Self::Value; + fn vector_reduce_or(&self, src: Self::Value) -> Self::Value; + fn vector_reduce_xor(&self, src: Self::Value) -> Self::Value; + fn vector_reduce_fmin(&self, src: Self::Value) -> Self::Value; + fn vector_reduce_fmax(&self, src: Self::Value) -> Self::Value; + fn vector_reduce_fmin_fast(&self, src: Self::Value) -> Self::Value; + fn vector_reduce_fmax_fast(&self, src: Self::Value) -> Self::Value; + fn vector_reduce_min(&self, src: Self::Value, is_signed: bool) -> Self::Value; + fn vector_reduce_max(&self, src: Self::Value, is_signed: bool) -> Self::Value; + fn extract_value(&self, agg_val: Self::Value, idx: u64) -> Self::Value; fn insert_value( &self, - agg_val: &'ll Value, - elt: &'ll Value, + agg_val: Self::Value, + elt: Self::Value, idx: u64 - ) -> &'ll Value; + ) -> Self::Value; fn landing_pad( &self, - ty: &'ll Type, - pers_fn: &'ll Value, + ty: Self::Type, + pers_fn: Self::Value, num_clauses: usize - ) -> &'ll Value; - fn add_clause(&self, landing_pad: &'ll Value, clause: &'ll Value); - fn set_cleanup(&self, landing_pad: &'ll Value); - fn resume(&self, exn: &'ll Value) -> &'ll Value; + ) -> Self::Value; + fn add_clause(&self, landing_pad: Self::Value, clause: Self::Value); + fn set_cleanup(&self, landing_pad: Self::Value); + fn resume(&self, exn: Self::Value) -> Self::Value; fn cleanup_pad( &self, - parent: Option<&'ll Value>, - args: &[&'ll Value] - ) -> &'ll Value; + parent: Option, + args: &[Self::Value] + ) -> Self::Value; fn cleanup_ret( - &self, cleanup: &'ll Value, - unwind: Option<&'ll BasicBlock>, - ) -> &'ll Value; + &self, cleanup: Self::Value, + unwind: Option, + ) -> Self::Value; fn catch_pad( &self, - parent: &'ll Value, - args: &[&'ll Value] - ) -> &'ll Value; - fn catch_ret(&self, pad: &'ll Value, unwind: &'ll BasicBlock) -> &'ll Value; + parent: Self::Value, + args: &[Self::Value] + ) -> Self::Value; + fn catch_ret(&self, pad: Self::Value, unwind: Self::BasicBlock) -> Self::Value; fn catch_switch( &self, - parent: Option<&'ll Value>, - unwind: Option<&'ll BasicBlock>, + parent: Option, + unwind: Option, num_handlers: usize, - ) -> &'ll Value; - fn add_handler(&self, catch_switch: &'ll Value, handler: &'ll BasicBlock); - fn set_personality_fn(&self, personality: &'ll Value); + ) -> Self::Value; + fn add_handler(&self, catch_switch: Self::Value, handler: Self::BasicBlock); + fn set_personality_fn(&self, personality: Self::Value); fn atomic_cmpxchg( &self, - dst: &'ll Value, - cmp: &'ll Value, - src: &'ll Value, + dst: Self::Value, + cmp: Self::Value, + src: Self::Value, order: AtomicOrdering, failure_order: AtomicOrdering, weak: bool, - ) -> &'ll Value; + ) -> Self::Value; fn atomic_rmw( &self, op: AtomicRmwBinOp, - dst: &'ll Value, - src: &'ll Value, + dst: Self::Value, + src: Self::Value, order: AtomicOrdering, - ) -> &'ll Value; + ) -> Self::Value; fn atomic_fence(&self, order: AtomicOrdering, scope: SynchronizationScope); - fn add_case(&self, s: &'ll Value, on_val: &'ll Value, dest: &'ll BasicBlock); - fn add_incoming_to_phi(&self, phi: &'ll Value, val: &'ll Value, bb: &'ll BasicBlock); - fn set_invariant_load(&self, load: &'ll Value); + fn add_case(&self, s: Self::Value, on_val: Self::Value, dest: Self::BasicBlock); + fn add_incoming_to_phi(&self, phi: Self::Value, val: Self::Value, bb: Self::BasicBlock); + fn set_invariant_load(&self, load: Self::Value); fn check_store( &self, - val: &'ll Value, - ptr: &'ll Value - ) -> &'ll Value; + val: Self::Value, + ptr: Self::Value + ) -> Self::Value; fn check_call<'b>( &self, typ: &str, - llfn: &'ll Value, - args: &'b [&'ll Value] - ) -> Cow<'b, [&'ll Value]>; - fn lifetime_start(&self, ptr: &'ll Value, size: Size); - fn lifetime_end(&self, ptr: &'ll Value, size: Size); + llfn: Self::Value, + args: &'b [Self::Value] + ) -> Cow<'b, [Self::Value]> where [Self::Value] : ToOwned; + fn lifetime_start(&self, ptr: Self::Value, size: Size); + fn lifetime_end(&self, ptr: Self::Value, size: Size); - fn call_lifetime_intrinsic(&self, intrinsic: &str, ptr: &'ll Value, size: Size); + fn call_lifetime_intrinsic(&self, intrinsic: &str, ptr: Self::Value, size: Size); - fn call(&self, llfn: &'ll Value, args: &[&'ll Value], - bundle: Option<&OperandBundleDef<'ll, &'ll Value>>) -> &'ll Value; - fn zext(&self, val: &'ll Value, dest_ty: &'ll Type) -> &'ll Value; + fn call(&self, llfn: Self::Value, args: &[Self::Value], + bundle: Option<&OperandBundleDef<'ll, Self::Value>>) -> Self::Value; + fn zext(&self, val: Self::Value, dest_ty: Self::Type) -> Self::Value; }