BasicBlock
public struct BasicBlock : IRValue
A BasicBlock
represents a basic block in an LLVM IR program. A basic
block contains a sequence of instructions, a pointer to its parent block and
its follower block, and an optional label that gives the basic block an
entry in the symbol table.
A basic block can be thought of as a sequence of instructions, and indeed
its member instructions may be iterated over with a for-in
loop.
The first basic block in a function is special in two ways: it is immediately executed on entrance to the function, and it is not allowed to have predecessor basic blocks (i.e. there can not be any branches to the entry block of a function). Because the block can have no predecessors, it also cannot have any PHI nodes.
-
Creates a
BasicBlock
from anLLVMBasicBlockRef
object.Declaration
Swift
public init(llvm: LLVMBasicBlockRef)
-
Retrieves the underlying LLVM value object.
Declaration
Swift
public func asLLVM() -> LLVMValueRef
-
Retrieves the name of this basic block.
Declaration
Swift
public var name: String { get }
-
Returns the first instruction in the basic block, if it exists.
Declaration
Swift
public var firstInstruction: Instruction? { get }
-
Returns the first instruction in the basic block, if it exists.
Declaration
Swift
public var lastInstruction: Instruction? { get }
-
Returns the terminator instruction if this basic block is well formed or
nil
if it is not well formed.Declaration
Swift
public var terminator: TerminatorInstruction? { get }
-
Returns the parent function of this basic block, if it exists.
Declaration
Swift
public var parent: Function? { get }
-
Returns the basic block following this basic block, if it exists.
Declaration
Swift
public func next() -> BasicBlock?
-
Returns the basic block before this basic block, if it exists.
Declaration
Swift
public func previous() -> BasicBlock?
-
Returns a sequence of the Instructions that make up this basic block.
Declaration
Swift
public var instructions: AnySequence<Instruction> { get }
-
Removes this basic block from a function but keeps it alive.
Note
To ensure correct removal of the block, you must invalidate any references to it and its child instructions. The block must also have no successor blocks that make reference to it.Declaration
Swift
public func removeFromParent()
-
Moves this basic block before the given basic block.
Declaration
Swift
public func moveBefore(_ block: BasicBlock)
-
Moves this basic block after the given basic block.
Declaration
Swift
public func moveAfter(_ block: BasicBlock)