Function
public class Function: IRGlobal
A Function represents a named function body in LLVM IR source. Functions
in LLVM IR encapsulate a list of parameters and a sequence of basic blocks
and provide a way to append to that sequence to build out its body.
-
Accesses the calling convention for this function.
Declaration
Swift
public var callingConvention: CallingConvention -
Retrieves the entry block of this function.
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.
Declaration
Swift
public var entryBlock: BasicBlock? -
Retrieves the first basic block in this function’s body.
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.
Declaration
Swift
public var firstBlock: BasicBlock? -
Retrieves the last basic block in this function’s body.
Declaration
Swift
public var lastBlock: BasicBlock? -
Retrieves the sequence of basic blocks that make up this function’s body.
Declaration
Swift
public var basicBlocks: AnySequence<BasicBlock> -
Computes the address of the specified basic block in this function.
Taking the address of the entry block is illegal.
This value only has defined behavior when used as an operand to the
indirectbrinstruction, or for comparisons against null. Pointer equality tests between labels addresses results in undefined behavior. Though, again, comparison against null is ok, and no label is equal to the null pointer. This may be passed around as an opaque pointer sized value as long as the bits are not inspected. This allowsptrtointand arithmetic to be performed on these values so long as the original value is reconstituted before the indirectbr instruction.Finally, some targets may provide defined semantics when using the value as the operand to an inline assembly, but that is target specific.
Declaration
Swift
public func address(of block: BasicBlock) -> BasicBlock.Address?Parameters
blockThe basic block to compute the address of.
Return Value
An IRValue representing the address of the given basic block in this function, else nil if the address cannot be computed or the basic block does not reside in this function.
-
Retrieves the previous function in the module, if there is one.
Declaration
Swift
public func previous() -> Function? -
Retrieves the next function in the module, if there is one.
Declaration
Swift
public func next() -> Function? -
Retrieves a parameter at the given index, if it exists.
Declaration
Swift
public func parameter(at index: Int) -> Parameter?Parameters
indexThe index of the parameter to retrieve.
Return Value
The parameter at the specified index if it exists, else nil.
-
Retrieves a parameter at the first index, if it exists.
Declaration
Swift
public var firstParameter: Parameter? -
Retrieves a parameter at the last index, if it exists.
Declaration
Swift
public var lastParameter: Parameter? -
Retrieves the list of all parameters for this function, in order.
Declaration
Swift
public var parameters: [IRValue] -
Appends the named basic block to the body of this function.
Declaration
Swift
public func appendBasicBlock(named name: String, in context: Context? = nil) -> BasicBlockParameters
nameThe name associated with this basic block.
contextAn optional context into which the basic block can be inserted into. If no context is provided, the block is inserted into the global context.
-
Deletes the function from its containing module. - note: This does not remove calls to this function from the module. Ensure you have removed all insructions that reference this function before deleting it.
Declaration
Swift
public func delete() -
Retrieves the underlying LLVM value object.
Declaration
Swift
public func asLLVM() -> LLVMValueRef
Function Class Reference