Instructions
LLVM.Instruction
— TypeInstruction
An instruction in the LLVM IR.
Base.copy
— Methodcopy(inst::Instruction)
Create a copy of the given instruction.
LLVM.remove!
— Methodremove!(inst::Instruction)
Remove the given instruction from the containing basic block, but do not delete the object.
LLVM.erase!
— Methoderase!(inst::Instruction)
Remove the given instruction from the containing basic block and delete the object.
This function is unsafe because it does not check if the instruction is used elsewhere.
LLVM.parent
— Methodparent(inst::Instruction)
Get the basic block that contains the given instruction.
Creating instructions
LLVM.IRBuilder
— TypeIRBuilder
An instruction builder, which is used to build instructions within a basic block.
LLVM.IRBuilder
— MethodIRBuilder()
Create a new, unpositioned instruction builder.
This object needs to be disposed of using dispose
.
LLVM.dispose
— Methoddispose(builder::IRBuilder)
Dispose of an instruction builder.
LLVM.context
— Methodcontext(builder::IRBuilder)
Get the context associated with an instruction builder.
Base.position
— Functionposition(builder::IRBuilder)
Return the current position of the instruction builder.
LLVM.position!
— Methodposition!(builder::IRBuilder, inst::Instruction)
Position the instruction builder before the given instruction.
LLVM.position!
— Methodposition!(builder::IRBuilder, bb::BasicBlock)
Position the instruction builder at the end of the given basic block.
LLVM.position!
— Methodposition!(builder::IRBuilder)
Clear the current position of the instruction builder.
Base.insert!
— Methodinsert!(builder::IRBuilder, inst::Instruction, [name::String])
Insert an instruction into the current basic block at the current position, optionally giving it a name.
LLVM.debuglocation
— Functiondebuglocation(builder::IRBuilder)
Get the current debug location of the instruction builder, or nothing
if no location is set.
LLVM.debuglocation!
— Functiondebuglocation!(builder::IRBuilder)
Clear the current debug location of the instruction builder.
debuglocation!(builder::IRBuilder, loc)
Set the current debug location of the instruction builder to loc
, which can be a Metadata
or MetadataAsValue
.
debuglocation!(builder::IRBuilder, inst::Instruction)
Set the current debug location of the instruction builder to the location of the given instruction.
Comparison instructions
LLVM.predicate
— Functionpredicate(inst::ICmpInst)
predicate(inst::FCmpInst)
Get the comparison predicate of the given integer or floating-point comparison instruction.
Atomic instructions
LLVM.is_atomic
— Functionis_atomic(inst::Instruction)
Check if the given instruction is atomic. This includes atomic operations such as atomicrmw
or fence
, but also loads and stores that have been made atomic by setting an atomic ordering.
LLVM.ordering
— Functionordering(atomic_inst::Instruction)
Get the atomic ordering of the given atomic instruction.
LLVM.ordering!
— Functionordering!(inst::Instruction, ordering::LLVM.AtomicOrdering)
Set the atomic ordering of the given instruction.
LLVM.SyncScope
— TypeSyncScope
A synchronization scope for atomic operations.
LLVM.syncscope
— Functionsyncscope(inst::AtomicInst)
Get the synchronization scope of the given atomic instruction.
LLVM.syncscope!
— Functionsyncscope!(inst::AtomicInst, scope::SyncScope)
Set the synchronization scope of the given atomic instruction.
Call instructions
LLVM.callconv
— Methodcallconv(call_inst::Instruction)
Get the calling convention of the given callable instruction.
LLVM.callconv!
— Methodcallconv!(call_inst::Instruction, cc)
Set the calling convention of the given callable instruction.
LLVM.istailcall
— Functionistailcall(call_inst::Instruction)
Tests if this call site must be tail call optimized.
LLVM.tailcall!
— Functiontailcall!(call_inst::Instruction, is_tail::Bool)
Sets whether this call site must be tail call optimized.
LLVM.called_operand
— Functioncalled_operand(call_inst::Instruction)
Get the operand of a callable instruction that represents the called function.
LLVM.arguments
— Functionarguments(call_inst::Instruction)
Get the arguments of a callable instruction.
LLVM.called_type
— Functioncalled_type(call_inst::Instruction)
Get the type of the function being called by the given callable instruction.
Operand Bundles
LLVM.OperandBundle
— TypeOperandBundle
An operand bundle attached to a call site.
LLVM.operand_bundles
— Functionoperand_bundles(call_inst::Instruction)
Get the operand bundles attached to the given call instruction.
LLVM.tag
— Functiontag(bundle::OperandBundle)
Get the tag of the given operand bundle.
LLVM.inputs
— Functioninputs(bundle::OperandBundle)
Get an iterator over the inputs of the given operand bundle.
Terminator instructions
LLVM.isterminator
— Functionisterminator(inst::Instruction)
Check if the given instruction is a terminator instruction.
LLVM.isconditional
— Functionisconditional(br::BrInst)
Check if the given branch instruction is conditional.
LLVM.condition
— Functioncondition(br::BrInst)
Get the condition of the given branch instruction.
LLVM.condition!
— Functioncondition!(br::BrInst, cond::Value)
Set the condition of the given branch instruction.
LLVM.default_dest
— Functiondefault_dest(switch::SwitchInst)
Get the default destination of the given switch instruction.
LLVM.successors
— Methodsuccessors(term::Instruction)
Get an iterator over the successors of the given terminator instruction.
This is a mutable iterator, so you can modify the successors of the terminator by calling setindex!
.
Phi instructions
LLVM.incoming
— Functionincoming(phi::PhiInst)
Get an iterator over the incoming values of the given phi node.
This is a mutable iterator, so you can modify the incoming values of the phi node by calling push!
or append!
, passing a tuple of the incoming value and the originating basic block.
Floating Point instructions
LLVM.fast_math
— Functionfast_math(inst::Instruction)
Get the fast math flags on an instruction.
LLVM.fast_math!
— Functionfast_math!(inst::Instruction; [flag=...], [all=...])
Set the fast math flags on an instruction. If all
is true
, then all flags are set.
The following flags are supported:
nnan
: assume arguments and results are not NaNninf
: assume arguments and results are not Infnsz
: treat the sign of zero arguments and results as insignificantarcp
: allow use of reciprocal rather than perform divisioncontract
: allow contraction of operationsafn
: allow substitution of approximate calculations for functionsreassoc
: allow reassociation of operations
Alignment
LLVM.alignment
— Functionalignment(val::LLVM.GlobalValue)
Get the alignment of the global value.
alignment(val::Instruction)
Get the alignment of the instruction.
LLVM.alignment!
— Functionalignment!(val::LLVM.GlobalValue, bytes::Integer)
Set the alignment of the global value.
alignment!(val::Instruction, bytes::Integer)
Set the alignment of the instruction.