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 an LLVMBasicBlockRef object.

    Declaration

    Swift

    public init(llvm: LLVMBasicBlockRef)
  • Retrieves the underlying LLVM value object.

    Declaration

    Swift

    public func asLLVM() -> LLVMValueRef
  • Returns the first instruction in the basic block, if it exists.

    Declaration

    Swift

    public var firstInstruction: Instruction?
  • Returns the first instruction in the basic block, if it exists.

    Declaration

    Swift

    public var lastInstruction: Instruction?
  • Returns the parent function of this basic block, if it exists.

    Declaration

    Swift

    public var parent: Function?
  • Returns the basic block following this basic block, if it exists.

    Declaration

    Swift

    public func next() -> BasicBlock?
  • Returns a sequence of the Instructions that make up this basic block.

    Declaration

    Swift

    public var instructions: AnySequence<Instruction>
  • Deletes the basic block from its containing function. - note: This does not remove breaks to this block from the function. Ensure you have removed all insructions that reference this basic block before deleting it.

    Declaration

    Swift

    public func delete()
  • Removes this basic block from a function but keeps it alive.

    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)
  • An Address represents a function-relative address of a basic block for use with the indirectbr instruction.

    See more

    Declaration

    Swift

    public struct Address: IRValue