use llvm::{AtomicRmwBinOp, AtomicOrdering, SynchronizationScope, AsmDialect};
use llvm::{Opcode, IntPredicate, RealPredicate, False, OperandBundleDef};
-use llvm::{self, BasicBlockRef};
+use llvm::{self, BasicBlock};
use common::*;
use type_::Type;
use value::Value;
}
}
- pub fn llbb(&self) -> BasicBlockRef {
+ pub fn llbb(&self) -> &'ll BasicBlock {
unsafe {
llvm::LLVMGetInsertBlock(self.llbuilder)
}
}
}
- pub fn position_at_end(&self, llbb: BasicBlockRef) {
+ pub fn position_at_end(&self, llbb: &'ll BasicBlock) {
unsafe {
llvm::LLVMPositionBuilderAtEnd(self.llbuilder, llbb);
}
}
- pub fn position_at_start(&self, llbb: BasicBlockRef) {
+ pub fn position_at_start(&self, llbb: &'ll BasicBlock) {
unsafe {
llvm::LLVMRustPositionBuilderAtStart(self.llbuilder, llbb);
}
}
}
- pub fn br(&self, dest: BasicBlockRef) {
+ pub fn br(&self, dest: &'ll BasicBlock) {
self.count_insn("br");
unsafe {
llvm::LLVMBuildBr(self.llbuilder, dest);
}
}
- pub fn cond_br(&self, cond: &'ll Value, then_llbb: BasicBlockRef, else_llbb: BasicBlockRef) {
+ pub fn cond_br(&self, cond: &'ll Value, then_llbb: &'ll BasicBlock, else_llbb: &'ll BasicBlock) {
self.count_insn("condbr");
unsafe {
llvm::LLVMBuildCondBr(self.llbuilder, cond, then_llbb, else_llbb);
}
}
- pub fn switch(&self, v: &'ll Value, else_llbb: BasicBlockRef, num_cases: usize) -> &'ll Value {
+ pub fn switch(&self, v: &'ll Value, else_llbb: &'ll BasicBlock, num_cases: usize) -> &'ll Value {
unsafe {
llvm::LLVMBuildSwitch(self.llbuilder, v, else_llbb, num_cases as c_uint)
}
pub fn invoke(&self,
llfn: &'ll Value,
args: &[&'ll Value],
- then: BasicBlockRef,
- catch: BasicBlockRef,
+ then: &'ll BasicBlock,
+ catch: &'ll BasicBlock,
bundle: Option<&OperandBundleDef>) -> &'ll Value {
self.count_insn("invoke");
}
}
- pub fn phi(&self, ty: &'ll Type, vals: &[&'ll Value], bbs: &[BasicBlockRef]) -> &'ll Value {
+ pub fn phi(&self, ty: &'ll Type, vals: &[&'ll Value], bbs: &[&'ll BasicBlock]) -> &'ll Value {
assert_eq!(vals.len(), bbs.len());
let phi = self.empty_phi(ty);
self.count_insn("addincoming");
ret.expect("LLVM does not have support for cleanuppad")
}
- pub fn cleanup_ret(&self, cleanup: &'ll Value,
- unwind: Option<BasicBlockRef>) -> &'ll Value {
+ pub fn cleanup_ret(
+ &self, cleanup: &'ll Value,
+ unwind: Option<&'ll BasicBlock>,
+ ) -> &'ll Value {
self.count_insn("cleanupret");
- let unwind = unwind.and_then(NonNull::new);
let ret = unsafe {
llvm::LLVMRustBuildCleanupRet(self.llbuilder, cleanup, unwind)
};
ret.expect("LLVM does not have support for catchpad")
}
- pub fn catch_ret(&self, pad: &'ll Value, unwind: BasicBlockRef) -> &'ll Value {
+ pub fn catch_ret(&self, pad: &'ll Value, unwind: &'ll BasicBlock) -> &'ll Value {
self.count_insn("catchret");
let ret = unsafe {
llvm::LLVMRustBuildCatchRet(self.llbuilder, pad, unwind)
pub fn catch_switch(
&self,
parent: Option<&'ll Value>,
- unwind: Option<BasicBlockRef>,
+ unwind: Option<&'ll BasicBlock>,
num_handlers: usize,
) -> &'ll Value {
self.count_insn("catchswitch");
- let unwind = unwind.and_then(NonNull::new);
let name = CString::new("catchswitch").unwrap();
let ret = unsafe {
llvm::LLVMRustBuildCatchSwitch(self.llbuilder, parent, unwind,
ret.expect("LLVM does not have support for catchswitch")
}
- pub fn add_handler(&self, catch_switch: &'ll Value, handler: BasicBlockRef) {
+ pub fn add_handler(&self, catch_switch: &'ll Value, handler: &'ll BasicBlock) {
unsafe {
llvm::LLVMRustAddHandler(catch_switch, handler);
}
}
}
- pub fn add_case(&self, s: &'ll Value, on_val: &'ll Value, dest: BasicBlockRef) {
+ pub fn add_case(&self, s: &'ll Value, on_val: &'ll Value, dest: &'ll BasicBlock) {
unsafe {
llvm::LLVMAddCase(s, on_val, dest)
}
}
- pub fn add_incoming_to_phi(&self, phi: &'ll Value, val: &'ll Value, bb: BasicBlockRef) {
+ pub fn add_incoming_to_phi(&self, phi: &'ll Value, val: &'ll Value, bb: &'ll BasicBlock) {
self.count_insn("addincoming");
unsafe {
llvm::LLVMAddIncoming(phi, &val, &bb, 1 as c_uint);
extern { pub type Value; }
extern { pub type Metadata; }
extern { pub type BasicBlock; }
-pub type BasicBlockRef = *mut BasicBlock;
extern { pub type Builder; }
extern { pub type MemoryBuffer; }
pub type MemoryBufferRef = *mut MemoryBuffer;
pub fn LLVMGetParam(Fn: &Value, Index: c_uint) -> &Value;
// Operations on basic blocks
- pub fn LLVMBasicBlockAsValue(BB: BasicBlockRef) -> &'a Value;
- pub fn LLVMGetBasicBlockParent(BB: BasicBlockRef) -> &'a Value;
+ pub fn LLVMBasicBlockAsValue(BB: &BasicBlock) -> &Value;
+ pub fn LLVMGetBasicBlockParent(BB: &BasicBlock) -> &Value;
pub fn LLVMAppendBasicBlockInContext(C: &'a Context,
Fn: &'a Value,
Name: *const c_char)
- -> BasicBlockRef;
- pub fn LLVMDeleteBasicBlock(BB: BasicBlockRef);
+ -> &'a BasicBlock;
+ pub fn LLVMDeleteBasicBlock(BB: &BasicBlock);
// Operations on instructions
- pub fn LLVMGetInstructionParent(Inst: &Value) -> BasicBlockRef;
- pub fn LLVMGetFirstBasicBlock(Fn: &Value) -> BasicBlockRef;
- pub fn LLVMGetFirstInstruction(BB: BasicBlockRef) -> &'a Value;
+ pub fn LLVMGetInstructionParent(Inst: &Value) -> &BasicBlock;
+ pub fn LLVMGetFirstBasicBlock(Fn: &Value) -> &BasicBlock;
+ pub fn LLVMGetFirstInstruction(BB: &BasicBlock) -> &'a Value;
pub fn LLVMInstructionEraseFromParent(Inst: &Value);
// Operations on call sites
// Operations on phi nodes
pub fn LLVMAddIncoming(PhiNode: &'a Value,
IncomingValues: *const &'a Value,
- IncomingBlocks: *const BasicBlockRef,
+ IncomingBlocks: *const &'a BasicBlock,
Count: c_uint);
// Instruction builders
pub fn LLVMCreateBuilderInContext(C: &Context) -> &Builder;
- pub fn LLVMPositionBuilder(Builder: &'a Builder, Block: BasicBlockRef, Instr: &'a Value);
+ pub fn LLVMPositionBuilder(Builder: &'a Builder, Block: &'a BasicBlock, Instr: &'a Value);
pub fn LLVMPositionBuilderBefore(Builder: &'a Builder, Instr: &'a Value);
- pub fn LLVMPositionBuilderAtEnd(Builder: &Builder, Block: BasicBlockRef);
- pub fn LLVMGetInsertBlock(Builder: &Builder) -> BasicBlockRef;
+ pub fn LLVMPositionBuilderAtEnd(Builder: &'a Builder, Block: &'a BasicBlock);
+ pub fn LLVMGetInsertBlock(Builder: &Builder) -> &BasicBlock;
pub fn LLVMDisposeBuilder(Builder: &Builder);
// Metadata
pub fn LLVMBuildRetVoid(B: &Builder) -> &Value;
pub fn LLVMBuildRet(B: &'a Builder, V: &'a Value) -> &'a Value;
pub fn LLVMBuildAggregateRet(B: &'a Builder, RetVals: *const &'a Value, N: c_uint) -> &'a Value;
- pub fn LLVMBuildBr(B: &Builder, Dest: BasicBlockRef) -> &Value;
+ pub fn LLVMBuildBr(B: &'a Builder, Dest: &'a BasicBlock) -> &'a Value;
pub fn LLVMBuildCondBr(B: &'a Builder,
If: &'a Value,
- Then: BasicBlockRef,
- Else: BasicBlockRef)
+ Then: &'a BasicBlock,
+ Else: &'a BasicBlock)
-> &'a Value;
pub fn LLVMBuildSwitch(B: &'a Builder,
V: &'a Value,
- Else: BasicBlockRef,
+ Else: &'a BasicBlock,
NumCases: c_uint)
-> &'a Value;
pub fn LLVMBuildIndirectBr(B: &'a Builder, Addr: &'a Value, NumDests: c_uint) -> &'a Value;
Fn: &'a Value,
Args: *const &'a Value,
NumArgs: c_uint,
- Then: BasicBlockRef,
- Catch: BasicBlockRef,
+ Then: &'a BasicBlock,
+ Catch: &'a BasicBlock,
Bundle: Option<NonNull<OperandBundleDef>>,
Name: *const c_char)
-> &'a Value;
-> Option<&'a Value>;
pub fn LLVMRustBuildCleanupRet(B: &'a Builder,
CleanupPad: &'a Value,
- UnwindBB: Option<NonNull<BasicBlock>>)
+ UnwindBB: Option<&'a BasicBlock>)
-> Option<&'a Value>;
pub fn LLVMRustBuildCatchPad(B: &'a Builder,
ParentPad: &'a Value,
Args: *const &'a Value,
Name: *const c_char)
-> Option<&'a Value>;
- pub fn LLVMRustBuildCatchRet(B: &'a Builder, Pad: &'a Value, BB: BasicBlockRef) -> Option<&'a Value>;
+ pub fn LLVMRustBuildCatchRet(B: &'a Builder, Pad: &'a Value, BB: &'a BasicBlock) -> Option<&'a Value>;
pub fn LLVMRustBuildCatchSwitch(Builder: &'a Builder,
ParentPad: Option<&'a Value>,
- BB: Option<NonNull<BasicBlock>>,
+ BB: Option<&'a BasicBlock>,
NumHandlers: c_uint,
Name: *const c_char)
-> Option<&'a Value>;
- pub fn LLVMRustAddHandler(CatchSwitch: &Value, Handler: BasicBlockRef);
+ pub fn LLVMRustAddHandler(CatchSwitch: &'a Value, Handler: &'a BasicBlock);
pub fn LLVMSetPersonalityFn(Func: &'a Value, Pers: &'a Value);
// Add a case to the switch instruction
- pub fn LLVMAddCase(Switch: &'a Value, OnVal: &'a Value, Dest: BasicBlockRef);
+ pub fn LLVMAddCase(Switch: &'a Value, OnVal: &'a Value, Dest: &'a BasicBlock);
// Add a clause to the landing pad instruction
pub fn LLVMAddClause(LandingPad: &'a Value, ClauseVal: &'a Value);
AddrOps: *const i64,
AddrOpsCount: c_uint,
DL: &'a Value,
- InsertAtEnd: BasicBlockRef)
+ InsertAtEnd: &'a BasicBlock)
-> &'a Value;
pub fn LLVMRustDIBuilderCreateEnumerator(Builder: &DIBuilder,
-> OperandBundleDefRef;
pub fn LLVMRustFreeOperandBundleDef(Bundle: OperandBundleDefRef);
- pub fn LLVMRustPositionBuilderAtStart(B: &Builder, BB: BasicBlockRef);
+ pub fn LLVMRustPositionBuilderAtStart(B: &'a Builder, BB: &'a BasicBlock);
pub fn LLVMRustSetComdat(M: &'a Module, V: &'a Value, Name: *const c_char);
pub fn LLVMRustUnsetComdat(V: &Value);
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-use llvm::{self, BasicBlockRef};
+use llvm::{self, BasicBlock};
use rustc::middle::lang_items;
use rustc::ty::{self, Ty, TypeFoldable};
use rustc::ty::layout::{self, LayoutOf};
/// Return the landingpad wrapper around the given basic block
///
/// No-op in MSVC SEH scheme.
- fn landing_pad_to(&mut self, target_bb: mir::BasicBlock) -> BasicBlockRef {
+ fn landing_pad_to(&mut self, target_bb: mir::BasicBlock) -> &'ll BasicBlock {
if let Some(block) = self.landing_pads[target_bb] {
return block;
}
landing_pad
}
- fn landing_pad_uncached(&mut self, target_bb: BasicBlockRef) -> BasicBlockRef {
+ fn landing_pad_uncached(&mut self, target_bb: &'ll BasicBlock) -> &'ll BasicBlock {
if base::wants_msvc_seh(self.cx.sess()) {
span_bug!(self.mir.span, "landing pad was not inserted?")
}
Type::struct_(cx, &[Type::i8p(cx), Type::i32(cx)], false)
}
- fn unreachable_block(&mut self) -> BasicBlockRef {
+ fn unreachable_block(&mut self) -> &'ll BasicBlock {
self.unreachable_block.unwrap_or_else(|| {
let bl = self.new_block("unreachable");
bl.unreachable();
use common::{C_i32, C_null};
use libc::c_uint;
-use llvm::{self, BasicBlockRef};
+use llvm::{self, BasicBlock};
use llvm::debuginfo::DIScope;
use rustc::ty::{self, Ty, TypeFoldable, UpvarSubsts};
use rustc::ty::layout::{LayoutOf, TyLayout};
personality_slot: Option<PlaceRef<'ll, 'tcx>>,
/// A `Block` for each MIR `BasicBlock`
- blocks: IndexVec<mir::BasicBlock, BasicBlockRef>,
+ blocks: IndexVec<mir::BasicBlock, &'ll BasicBlock>,
/// The funclet status of each basic block
cleanup_kinds: IndexVec<mir::BasicBlock, analyze::CleanupKind>,
/// This stores the landing-pad block for a given BB, computed lazily on GNU
/// and eagerly on MSVC.
- landing_pads: IndexVec<mir::BasicBlock, Option<BasicBlockRef>>,
+ landing_pads: IndexVec<mir::BasicBlock, Option<&'ll BasicBlock>>,
/// Cached unreachable block
- unreachable_block: Option<BasicBlockRef>,
+ unreachable_block: Option<&'ll BasicBlock>,
/// The location where each MIR arg/var/tmp/ret is stored. This is
/// usually an `PlaceRef` representing an alloca, but not always:
// Allocate a `Block` for every basic block, except
// the start block, if nothing loops back to it.
let reentrant_start_block = !mir.predecessors_for(mir::START_BLOCK).is_empty();
- let block_bxs: IndexVec<mir::BasicBlock, BasicBlockRef> =
+ let block_bxs: IndexVec<mir::BasicBlock, &'ll BasicBlock> =
mir.basic_blocks().indices().map(|bb| {
if bb == mir::START_BLOCK && !reentrant_start_block {
bx.llbb()
mir: &'a Mir<'tcx>,
bx: &Builder<'a, 'll, 'tcx>,
cleanup_kinds: &IndexVec<mir::BasicBlock, CleanupKind>,
- block_bxs: &IndexVec<mir::BasicBlock, BasicBlockRef>)
- -> (IndexVec<mir::BasicBlock, Option<BasicBlockRef>>,
+ block_bxs: &IndexVec<mir::BasicBlock, &'ll BasicBlock>)
+ -> (IndexVec<mir::BasicBlock, Option<&'ll BasicBlock>>,
IndexVec<mir::BasicBlock, Option<Funclet<'ll>>>)
{
block_bxs.iter_enumerated().zip(cleanup_kinds).map(|((bb, &llbb), cleanup_kind)| {