Instruction

public struct Instruction : IRValue

An Instruction represents an instruction residing in a basic block.

  • Creates an Intruction from an LLVMValueRef object.

    Declaration

    Swift

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

    Declaration

    Swift

    public func asLLVM() -> LLVMValueRef
  • Retrieves the opcode associated with this Instruction.

    Declaration

    Swift

    public var opCode: OpCode { get }
  • Obtain the instruction that occurs before this one, if it exists.

    Declaration

    Swift

    public func previous() -> Instruction?
  • Obtain the instruction that occurs after this one, if it exists.

    Declaration

    Swift

    public func next() -> Instruction?
  • Retrieves the parent basic block that contains this instruction, if it exists.

    Declaration

    Swift

    public var parentBlock: BasicBlock? { get }
  • Retrieves the first use of this instruction.

    Declaration

    Swift

    public var firstUse: Use? { get }
  • Retrieves the sequence of instructions that use the value from this instruction.

    Declaration

    Swift

    public var uses: AnySequence<Use> { get }
  • Removes this instruction from a basic block but keeps it alive.

    Note

    To ensure correct removal of the instruction, you must invalidate any references to its result values, if any.

    Declaration

    Swift

    public func removeFromParent()
  • Create a copy of ‘this’ instruction that is identical in all ways except the following:

    • The instruction has no parent
    • The instruction has no name

    Declaration

    Swift

    public func clone() -> Instruction
  • Retrieves all metadata entries attached to this instruction.

    Declaration

    Swift

    public var metadata: AttachedMetadata { get }
  • Sets a metadata attachment, erasing the existing metadata attachment if it already exists for the given kind.

    Declaration

    Swift

    public func addMetadata(_ metadata: IRMetadata, kind: AttachedMetadata.PinnedKind)

    Parameters

    metadata

    The metadata to attach to this global value.

    kind

    The kind of metadata to attach.

  • Sets a metadata attachment, erasing the existing metadata attachment if it already exists for the given kind.

    Declaration

    Swift

    public func addMetadata(_ metadata: IRMetadata, kind: UInt32)

    Parameters

    metadata

    The metadata to attach to this global value.

    kind

    The kind of metadata to attach.