llvm: github.com/llir/llvm/ir Index | Examples | Files | Directories

package ir

import "github.com/llir/llvm/ir"

Package ir declares the types used to represent LLVM IR modules.

Code:

// This example produces LLVM IR code equivalent to the following C code,
// which implements a pseudo-random number generator.
//
//    int abs(int x);
//
//    int seed = 0;
//
//    // ref: https://en.wikipedia.org/wiki/Linear_congruential_generator
//    //    a = 0x15A4E35
//    //    c = 1
//    int rand(void) {
//       seed = seed*0x15A4E35 + 1;
//       return abs(seed);
//    }

// Create convenience types and constants.
i32 := types.I32
zero := constant.NewInt(i32, 0)
a := constant.NewInt(i32, 0x15A4E35) // multiplier of the PRNG.
c := constant.NewInt(i32, 1)         // increment of the PRNG.

// Create a new LLVM IR module.
m := ir.NewModule()

// Create an external function declaration and append it to the module.
//
//    int abs(int x);
abs := m.NewFunc("abs", i32, ir.NewParam("x", i32))

// Create a global variable definition and append it to the module.
//
//    int seed = 0;
seed := m.NewGlobalDef("seed", zero)

// Create a function definition and append it to the module.
//
//    int rand(void) { ... }
rand := m.NewFunc("rand", i32)

// Create an unnamed entry basic block and append it to the `rand` function.
entry := rand.NewBlock("")

// Create instructions and append them to the entry basic block.
tmp1 := entry.NewLoad(types.I32, seed)
tmp2 := entry.NewMul(tmp1, a)
tmp3 := entry.NewAdd(tmp2, c)
entry.NewStore(tmp3, seed)
tmp4 := entry.NewCall(abs, tmp3)
entry.NewRet(tmp4)

// Print the LLVM IR assembly of the module.
fmt.Println(m)

Output:

@seed = global i32 0

declare i32 @abs(i32 %x)

define i32 @rand() {
0:
	%1 = load i32, i32* @seed
	%2 = mul i32 %1, 22695477
	%3 = add i32 %2, 1
	store i32 %3, i32* @seed
	%4 = call i32 @abs(i32 %3)
	ret i32 %4
}

Code:

// Parse LLVM IR assembly file.
m, err := asm.ParseFile("testdata/eval.ll")
if err != nil {
    panic(err)
}
// Produce callgraph of module.
callgraph := genCallgraph(m)
// Output callgraph in Graphviz DOT format.
fmt.Println(callgraph)

Output:

digraph {
	"@add"
	"@sub"
	"@f"
	"@f" -> "@printf"
	"@main"
	"@main" -> "@add"
	"@main" -> "@sub"
	"@main" -> "@f"
	"@printf"
}

Code:

// This example program parses testdata/eval.ll, evaluates the return value of
// the @main function and prints the result to standard output. The result
// should be 42.
package main

import (
    "fmt"
    "log"

    "github.com/llir/llvm/asm"
    "github.com/llir/llvm/ir"
    "github.com/llir/llvm/ir/constant"
    "github.com/llir/llvm/ir/types"
    "github.com/llir/llvm/ir/value"
)

func main() {
    // Parse the LLVM IR assembly file `eval.ll`.
    m, err := asm.ParseFile("testdata/eval.ll")
    if err != nil {
        log.Fatalf("%+v", err)
    }
    // Evalute and print the return value of the `@main` function.
    for _, f := range m.Funcs {
        if f.Name() == "main" {
            e := newEvaluator(f)
            fmt.Println("result:", e.eval())
            break
        }
    }

}

// evaluator is a function evaluator.
type evaluator struct {
    // Function being evaluated.
    f   *ir.Func
    // Function arguments.
    args []value.Value
}

// newEvaluator returns a new function evaluator, for evaluating the result of
// invoking f with args.
func newEvaluator(f *ir.Func, args ...value.Value) *evaluator {
    return &evaluator{f: f, args: args}
}

// eval evalutes f and returns the corresponding 32-bit integer.
func (e *evaluator) eval() uint32 {
    f := e.f
    if !types.Equal(f.Sig.RetType, types.I32) {
        panic(fmt.Errorf("support for function return type %s not yet implemented", f.Sig.RetType))
    }
    for _, block := range f.Blocks {
        switch term := block.Term.(type) {
        case *ir.TermRet:
            // Note: support for functions with more than one ret terminator not
            // yet implemented.
            if term.X != nil {
                // The result of the first return value of a function is evaluated.
                return e.evalValue(term.X)
            }
        }
    }
    panic(fmt.Errorf("unable to locate ret terminator in function %q", f.Ident()))
}

// evalInst evaluates inst and returns the corresponding 32-bit integer.
func (e *evaluator) evalInst(inst ir.Instruction) uint32 {
    switch inst := inst.(type) {
    // Binary instructions.
    case *ir.InstAdd:
        return e.evalValue(inst.X) + e.evalValue(inst.Y)
    case *ir.InstSub:
        return e.evalValue(inst.X) - e.evalValue(inst.Y)
    case *ir.InstMul:
        return e.evalValue(inst.X) * e.evalValue(inst.Y)
    case *ir.InstUDiv:
        return e.evalValue(inst.X) / e.evalValue(inst.Y)
    case *ir.InstSDiv:
        return e.evalValue(inst.X) / e.evalValue(inst.Y)
    case *ir.InstURem:
        return e.evalValue(inst.X) % e.evalValue(inst.Y)
    case *ir.InstSRem:
        return e.evalValue(inst.X) % e.evalValue(inst.Y)
    // Bitwise instructions.
    case *ir.InstShl:
        return e.evalValue(inst.X) << e.evalValue(inst.Y)
    case *ir.InstLShr:
        return e.evalValue(inst.X) >> e.evalValue(inst.Y)
    case *ir.InstAShr:
        x, y := e.evalValue(inst.X), e.evalValue(inst.Y)
        result := x >> y
        // sign extend.
        if x&0x80000000 != 0 {
            result = signExt(result)
        }
        return result
    case *ir.InstAnd:
        return e.evalValue(inst.X) & e.evalValue(inst.Y)
    case *ir.InstOr:
        return e.evalValue(inst.X) | e.evalValue(inst.Y)
    case *ir.InstXor:
        return e.evalValue(inst.X) ^ e.evalValue(inst.Y)
    // Other instructions.
    case *ir.InstCall:
        callee, ok := inst.Callee.(*ir.Func)
        if !ok {
            panic(fmt.Errorf("support for callee type %T not yet implemented", inst.Callee))
        }
        ee := newEvaluator(callee, inst.Args...)
        return ee.eval()
    default:
        panic(fmt.Errorf("support for instruction type %T not yet implemented", inst))
    }
}

// evalValue evalutes v and returns the corresponding 32-bit integer.
func (e *evaluator) evalValue(v value.Value) uint32 {
    switch v := v.(type) {
    case ir.Instruction:
        return e.evalInst(v)
    case *constant.Int:
        return uint32(v.X.Int64())
    case *ir.Param:
        f := e.f
        for i, param := range f.Params {
            if v.Ident() == param.Ident() {
                return e.evalValue(e.args[i])
            }
        }
        panic(fmt.Errorf("unable to locate paramater %q of function %q", v.Ident(), f.Ident()))
    default:
        panic(fmt.Errorf("support for value type %T not yet implemented", v))
    }
}

// signExt sign extends x.
func signExt(x uint32) uint32 {
    for i := uint32(31); i >= 0; i-- {
        mask := uint32(1 << i)
        if x&mask != 0 {
            break
        }
        x |= mask
    }
    return x
}

Code:

// This example produces LLVM IR code equivalent to the following C code:
//
//    int main() {
//       int a = 32;
//       int b = 16;
//       return a + b;
//    }
//
// Read: https://blog.felixangell.com/an-introduction-to-llvm-in-go for inspiration.

// Create convenience types.
i32 := types.I32

// Create a new LLVM IR module.
m := ir.NewModule()
// int main() { ... }
main := m.NewFunc("main", i32)

// Create an unnamed entry basic block and append it to the `main` function.
entry := main.NewBlock("")
// Create instructions and append them to the entry basic block.

// %a = alloca i32
a := entry.NewAlloca(i32)
a.SetName("a")

// %b = alloca i32
b := entry.NewAlloca(i32)
b.SetName("b")

// store i32 32, i32* %a
entry.NewStore(constant.NewInt(i32, 32), a)

// store i32 16, i32* %b
entry.NewStore(constant.NewInt(i32, 16), b)

// %1 = load i32, i32* %a
tmpA := entry.NewLoad(types.I32, a)

// %2 = load i32, i32* %b
tmpB := entry.NewLoad(types.I32, b)

// %3 = add nsw i32 %1, %2
tmpC := entry.NewAdd(tmpA, tmpB)

// ret i32 %3
entry.NewRet(tmpC)

// Print the LLVM IR assembly of the module.
fmt.Println(m)

Output:

define i32 @main() {
0:
	%a = alloca i32
	%b = alloca i32
	store i32 32, i32* %a
	store i32 16, i32* %b
	%1 = load i32, i32* %a
	%2 = load i32, i32* %b
	%3 = add i32 %1, %2
	ret i32 %3
}

Index

Examples

Package Files

alias.go block.go block_aggregate.go block_binary.go block_bitwise.go block_conversion.go block_memory.go block_other.go block_term.go block_unary.go block_vector.go func.go func_block.go global.go helper.go ifunc.go inline_asm.go inst_aggregate.go inst_binary.go inst_bitwise.go inst_conversion.go inst_memory.go inst_other.go inst_unary.go inst_vector.go instruction.go ir.go module.go module_alias.go module_func.go module_global.go module_ifunc.go module_type.go sumtype.go terminator.go

type Alias Uses

type Alias struct {
    // Alias name (without '@' prefix).
    GlobalIdent
    // Aliasee.
    Aliasee constant.Constant

    // Pointer type of aliasee.
    Typ *types.PointerType
    // (optional) Linkage; zero value if not present.
    Linkage enum.Linkage
    // (optional) Preemption; zero value if not present.
    Preemption enum.Preemption
    // (optional) Visibility; zero value if not present.
    Visibility enum.Visibility
    // (optional) DLL storage class; zero value if not present.
    DLLStorageClass enum.DLLStorageClass
    // (optional) Thread local storage model; zero value if not present.
    TLSModel enum.TLSModel
    // (optional) Unnamed address; zero value if not present.
    UnnamedAddr enum.UnnamedAddr
    // (optional) Partition name; empty if not present.
    Partition string
}

Alias is an alias of a global identifier or constant expression.

func NewAlias Uses

func NewAlias(name string, aliasee constant.Constant) *Alias

NewAlias returns a new alias based on the given alias name and aliasee.

func (*Alias) IsConstant Uses

func (*Alias) IsConstant()

IsConstant ensures that only constants can be assigned to the constant.Constant interface.

func (*Alias) LLString Uses

func (a *Alias) LLString() string

LLString returns the LLVM syntax representation of the alias definition.

Name=GlobalIdent '=' (ExternLinkage | Linkageopt) Preemptionopt Visibilityopt DLLStorageClassopt ThreadLocalopt UnnamedAddropt IndirectSymbolKind ContentType=Type ',' IndirectSymbol Partitions=(',' Partition)*

func (*Alias) String Uses

func (a *Alias) String() string

String returns the LLVM syntax representation of the alias as a type-value pair.

func (*Alias) Type Uses

func (a *Alias) Type() types.Type

Type returns the type of the alias.

type Align Uses

type Align uint64

Align is a memory alignment attribute.

func (Align) IsFuncAttribute Uses

func (Align) IsFuncAttribute()

IsFuncAttribute ensures that only function attributes can be assigned to the ir.FuncAttribute interface.

func (Align) IsParamAttribute Uses

func (Align) IsParamAttribute()

IsParamAttribute ensures that only parameter attributes can be assigned to the ir.ParamAttribute interface.

func (Align) IsReturnAttribute Uses

func (Align) IsReturnAttribute()

IsReturnAttribute ensures that only return attributes can be assigned to the ir.ReturnAttribute interface.

func (Align) String Uses

func (align Align) String() string

String returns the string representation of the alignment attribute.

type AlignStack Uses

type AlignStack uint64

AlignStack is a stack alignment attribute.

func (AlignStack) IsFuncAttribute Uses

func (AlignStack) IsFuncAttribute()

IsFuncAttribute ensures that only function attributes can be assigned to the ir.FuncAttribute interface.

func (AlignStack) String Uses

func (align AlignStack) String() string

String returns the string representation of the stack alignment attribute.

type AllocSize Uses

type AllocSize struct {
    // Element size parameter index.
    ElemSizeIndex int
    // Number of elements parameter index; -1 if not present.
    NElemsIndex int
}

AllocSize is an attribute for functions like malloc. If the second parameter is omitted, NElemsIndex will be -1.

func (AllocSize) IsFuncAttribute Uses

func (AllocSize) IsFuncAttribute()

IsFuncAttribute ensures that only function attributes can be assigned to the ir.FuncAttribute interface.

func (AllocSize) String Uses

func (a AllocSize) String() string

String returns the string representation of the allocsize attribute.

type Arg Uses

type Arg struct {
    // Argument value.
    value.Value
    // (optional) Parameter attributes.
    Attrs []ParamAttribute
}

Arg is a function argument with optional parameter attributes.

func NewArg Uses

func NewArg(x value.Value, attrs ...ParamAttribute) *Arg

NewArg returns a new function argument based on the given value and parameter attributes.

func (*Arg) String Uses

func (arg *Arg) String() string

String returns a string representation of the function argument.

type AttrGroupDef Uses

type AttrGroupDef struct {
    // Attribute group ID (without '#' prefix).
    ID  int64
    // Function attributes.
    FuncAttrs []FuncAttribute
}

AttrGroupDef is an attribute group definition.

func (*AttrGroupDef) IsFuncAttribute Uses

func (*AttrGroupDef) IsFuncAttribute()

IsFuncAttribute ensures that only function attributes can be assigned to the ir.FuncAttribute interface.

func (*AttrGroupDef) LLString Uses

func (a *AttrGroupDef) LLString() string

LLString returns the LLVM syntax representation of the attribute group definition.

'attributes' ID=AttrGroupID '=' '{' FuncAttrs=FuncAttribute* '}'

func (*AttrGroupDef) String Uses

func (a *AttrGroupDef) String() string

String returns the string representation of the attribute group definition.

type AttrPair Uses

type AttrPair struct {
    Key   string
    Value string
}

AttrPair is an attribute key-value pair (used in function, parameter and return attributes).

func (AttrPair) IsFuncAttribute Uses

func (AttrPair) IsFuncAttribute()

IsFuncAttribute ensures that only function attributes can be assigned to the ir.FuncAttribute interface.

func (AttrPair) IsParamAttribute Uses

func (AttrPair) IsParamAttribute()

IsParamAttribute ensures that only parameter attributes can be assigned to the ir.ParamAttribute interface.

func (AttrPair) IsReturnAttribute Uses

func (AttrPair) IsReturnAttribute()

IsReturnAttribute ensures that only return attributes can be assigned to the ir.ReturnAttribute interface.

func (AttrPair) String Uses

func (a AttrPair) String() string

String returns the string representation of the attribute key-value pair.

type AttrString Uses

type AttrString string

AttrString is an attribute string (used in function, parameter and return attributes).

func (AttrString) IsFuncAttribute Uses

func (AttrString) IsFuncAttribute()

IsFuncAttribute ensures that only function attributes can be assigned to the ir.FuncAttribute interface.

func (AttrString) IsParamAttribute Uses

func (AttrString) IsParamAttribute()

IsParamAttribute ensures that only parameter attributes can be assigned to the ir.ParamAttribute interface.

func (AttrString) IsReturnAttribute Uses

func (AttrString) IsReturnAttribute()

IsReturnAttribute ensures that only return attributes can be assigned to the ir.ReturnAttribute interface.

func (AttrString) String Uses

func (a AttrString) String() string

String returns the string representation of the attribute string.

type Block Uses

type Block struct {
    // Name of local variable associated with the basic block.
    LocalIdent
    // Instructions of the basic block.
    Insts []Instruction
    // Terminator of the basic block.
    Term Terminator

    // Parent function; field set by ir.Func.NewBlock.
    Parent *Func `json:"-"`
}

Block is an LLVM IR basic block; a sequence of non-branching instructions terminated by a control flow instruction (e.g. br or ret).

func NewBlock Uses

func NewBlock(name string) *Block

NewBlock returns a new basic block based on the given label name. An empty label name indicates an unnamed basic block.

func (*Block) LLString Uses

func (block *Block) LLString() string

LLString returns the LLVM syntax representation of the basic block definition.

Name=LabelIdentopt Insts=Instruction* Term=Terminator

func (*Block) NewAShr Uses

func (block *Block) NewAShr(x, y value.Value) *InstAShr

NewAShr appends a new ashr instruction to the basic block based on the given operands.

func (*Block) NewAdd Uses

func (block *Block) NewAdd(x, y value.Value) *InstAdd

NewAdd appends a new add instruction to the basic block based on the given operands.

func (*Block) NewAddrSpaceCast Uses

func (block *Block) NewAddrSpaceCast(from value.Value, to types.Type) *InstAddrSpaceCast

NewAddrSpaceCast appends a new addrspacecast instruction to the basic block based on the given source value and target type.

func (*Block) NewAlloca Uses

func (block *Block) NewAlloca(elemType types.Type) *InstAlloca

NewAlloca appends a new alloca instruction to the basic block based on the given element type.

func (*Block) NewAnd Uses

func (block *Block) NewAnd(x, y value.Value) *InstAnd

NewAnd appends a new and instruction to the basic block based on the given operands.

func (*Block) NewAtomicRMW Uses

func (block *Block) NewAtomicRMW(op enum.AtomicOp, dst, x value.Value, ordering enum.AtomicOrdering) *InstAtomicRMW

NewAtomicRMW appends a new atomicrmw instruction to the basic block based on the given atomic operation, destination address, operand and atomic ordering.

func (*Block) NewBitCast Uses

func (block *Block) NewBitCast(from value.Value, to types.Type) *InstBitCast

NewBitCast appends a new bitcast instruction to the basic block based on the given source value and target type.

func (*Block) NewBr Uses

func (block *Block) NewBr(target *Block) *TermBr

NewBr sets the terminator of the basic block to a new unconditional br terminator based on the given target basic block.

func (*Block) NewCall Uses

func (block *Block) NewCall(callee value.Value, args ...value.Value) *InstCall

NewCall appends a new call instruction to the basic block based on the given callee and function arguments.

TODO: specify the set of underlying types of callee.

func (*Block) NewCallBr Uses

func (block *Block) NewCallBr(callee value.Value, args []value.Value, normalRetTarget *Block, otherRetTargets ...*Block) *TermCallBr

NewCallBr sets the terminator of the basic block to a new callbr terminator based on the given callee, function arguments and control flow return points for normal and exceptional execution.

TODO: specify the set of underlying types of callee.

func (*Block) NewCatchPad Uses

func (block *Block) NewCatchPad(catchSwitch *TermCatchSwitch, args ...value.Value) *InstCatchPad

NewCatchPad appends a new catchpad instruction to the basic block based on the given parent catchswitch terminator and exception arguments.

func (*Block) NewCatchRet Uses

func (block *Block) NewCatchRet(catchPad *InstCatchPad, target *Block) *TermCatchRet

NewCatchRet sets the terminator of the basic block to a new catchret terminator based on the given exit catchpad and target basic block.

func (*Block) NewCatchSwitch Uses

func (block *Block) NewCatchSwitch(parentPad ExceptionPad, handlers []*Block, defaultUnwindTarget *Block) *TermCatchSwitch

NewCatchSwitch sets the terminator of the basic block to a new catchswitch terminator based on the given parent exception pad, exception handlers and optional default unwind target. If defaultUnwindTarget is nil, catchswitch unwinds to caller function.

func (*Block) NewCleanupPad Uses

func (block *Block) NewCleanupPad(parentPad ExceptionPad, args ...value.Value) *InstCleanupPad

NewCleanupPad appends a new cleanuppad instruction to the basic block based on the given parent exception pad and exception arguments.

func (*Block) NewCleanupRet Uses

func (block *Block) NewCleanupRet(cleanupPad *InstCleanupPad, unwindTarget *Block) *TermCleanupRet

NewCleanupRet sets the terminator of the basic block to a new cleanupret terminator based on the given exit cleanuppad and optional unwind target. If unwindTarget is nil, cleanupret unwinds to caller function.

func (*Block) NewCmpXchg Uses

func (block *Block) NewCmpXchg(ptr, cmp, new value.Value, successOrdering, failureOrdering enum.AtomicOrdering) *InstCmpXchg

NewCmpXchg appends a new cmpxchg instruction to the basic block based on the given address, value to compare against, new value to store, and atomic orderings for success and failure.

func (*Block) NewCondBr Uses

func (block *Block) NewCondBr(cond value.Value, targetTrue, targetFalse *Block) *TermCondBr

NewCondBr sets the terminator of the basic block to a new conditional br terminator based on the given branching condition and conditional target basic blocks.

func (*Block) NewExtractElement Uses

func (block *Block) NewExtractElement(x, index value.Value) *InstExtractElement

NewExtractElement appends a new extractelement instruction to the basic block based on the given vector and element index.

func (*Block) NewExtractValue Uses

func (block *Block) NewExtractValue(x value.Value, indices ...uint64) *InstExtractValue

NewExtractValue appends a new extractvalue instruction to the basic block based on the given aggregate value and indicies.

func (*Block) NewFAdd Uses

func (block *Block) NewFAdd(x, y value.Value) *InstFAdd

NewFAdd appends a new fadd instruction to the basic block based on the given operands.

func (*Block) NewFCmp Uses

func (block *Block) NewFCmp(pred enum.FPred, x, y value.Value) *InstFCmp

NewFCmp appends a new fcmp instruction to the basic block based on the given floating-point comparison predicate and floating-point scalar or vector operands.

func (*Block) NewFDiv Uses

func (block *Block) NewFDiv(x, y value.Value) *InstFDiv

NewFDiv appends a new fdiv instruction to the basic block based on the given operands.

func (*Block) NewFMul Uses

func (block *Block) NewFMul(x, y value.Value) *InstFMul

NewFMul appends a new fmul instruction to the basic block based on the given operands.

func (*Block) NewFNeg Uses

func (block *Block) NewFNeg(x value.Value) *InstFNeg

NewFNeg appends a new fneg instruction to the basic block based on the given operand.

func (*Block) NewFPExt Uses

func (block *Block) NewFPExt(from value.Value, to types.Type) *InstFPExt

NewFPExt appends a new fpext instruction to the basic block based on the given source value and target type.

func (*Block) NewFPToSI Uses

func (block *Block) NewFPToSI(from value.Value, to types.Type) *InstFPToSI

NewFPToSI appends a new fptosi instruction to the basic block based on the given source value and target type.

func (*Block) NewFPToUI Uses

func (block *Block) NewFPToUI(from value.Value, to types.Type) *InstFPToUI

NewFPToUI appends a new fptoui instruction to the basic block based on the given source value and target type.

func (*Block) NewFPTrunc Uses

func (block *Block) NewFPTrunc(from value.Value, to types.Type) *InstFPTrunc

NewFPTrunc appends a new fptrunc instruction to the basic block based on the given source value and target type.

func (*Block) NewFRem Uses

func (block *Block) NewFRem(x, y value.Value) *InstFRem

NewFRem appends a new frem instruction to the basic block based on the given operands.

func (*Block) NewFSub Uses

func (block *Block) NewFSub(x, y value.Value) *InstFSub

NewFSub appends a new fsub instruction to the basic block based on the given operands.

func (*Block) NewFence Uses

func (block *Block) NewFence(ordering enum.AtomicOrdering) *InstFence

NewFence appends a new fence instruction to the basic block based on the given atomic ordering.

func (*Block) NewGetElementPtr Uses

func (block *Block) NewGetElementPtr(elemType types.Type, src value.Value, indices ...value.Value) *InstGetElementPtr

NewGetElementPtr appends a new getelementptr instruction to the basic block based on the given element type, source address and element indices.

func (*Block) NewICmp Uses

func (block *Block) NewICmp(pred enum.IPred, x, y value.Value) *InstICmp

NewICmp appends a new icmp instruction to the basic block based on the given integer comparison predicate and integer scalar or vector operands.

func (*Block) NewIndirectBr Uses

func (block *Block) NewIndirectBr(addr constant.Constant, validTargets ...*Block) *TermIndirectBr

NewIndirectBr sets the terminator of the basic block to a new indirectbr terminator based on the given target address (derived from a blockaddress constant) and set of valid target basic blocks.

func (*Block) NewInsertElement Uses

func (block *Block) NewInsertElement(x, elem, index value.Value) *InstInsertElement

NewInsertElement appends a new insertelement instruction to the basic block based on the given vector, element and element index.

func (*Block) NewInsertValue Uses

func (block *Block) NewInsertValue(x, elem value.Value, indices ...uint64) *InstInsertValue

NewInsertValue appends a new insertvalue instruction to the basic block based on the given aggregate value, element and indicies.

func (*Block) NewIntToPtr Uses

func (block *Block) NewIntToPtr(from value.Value, to types.Type) *InstIntToPtr

NewIntToPtr appends a new inttoptr instruction to the basic block based on the given source value and target type.

func (*Block) NewInvoke Uses

func (block *Block) NewInvoke(invokee value.Value, args []value.Value, normalRetTarget, exceptionRetTarget *Block) *TermInvoke

NewInvoke sets the terminator of the basic block to a new invoke terminator based on the given invokee, function arguments and control flow return points for normal and exceptional execution.

TODO: specify the set of underlying types of invokee.

func (*Block) NewLShr Uses

func (block *Block) NewLShr(x, y value.Value) *InstLShr

NewLShr appends a new lshr instruction to the basic block based on the given operands.

func (*Block) NewLandingPad Uses

func (block *Block) NewLandingPad(resultType types.Type, clauses ...*Clause) *InstLandingPad

NewLandingPad appends a new landingpad instruction to the basic block based on the given result type and filter/catch clauses.

func (*Block) NewLoad Uses

func (block *Block) NewLoad(elemType types.Type, src value.Value) *InstLoad

NewLoad appends a new load instruction to the basic block based on the given element type and source address.

func (*Block) NewMul Uses

func (block *Block) NewMul(x, y value.Value) *InstMul

NewMul appends a new mul instruction to the basic block based on the given operands.

func (*Block) NewOr Uses

func (block *Block) NewOr(x, y value.Value) *InstOr

NewOr appends a new or instruction to the basic block based on the given operands.

func (*Block) NewPhi Uses

func (block *Block) NewPhi(incs ...*Incoming) *InstPhi

NewPhi appends a new phi instruction to the basic block based on the given incoming values.

func (*Block) NewPtrToInt Uses

func (block *Block) NewPtrToInt(from value.Value, to types.Type) *InstPtrToInt

NewPtrToInt appends a new ptrtoint instruction to the basic block based on the given source value and target type.

func (*Block) NewResume Uses

func (block *Block) NewResume(x value.Value) *TermResume

NewResume sets the terminator of the basic block to a new resume terminator based on the given exception argument to propagate.

func (*Block) NewRet Uses

func (block *Block) NewRet(x value.Value) *TermRet

NewRet sets the terminator of the basic block to a new ret terminator based on the given return value. A nil return value indicates a void return.

func (*Block) NewSDiv Uses

func (block *Block) NewSDiv(x, y value.Value) *InstSDiv

NewSDiv appends a new sdiv instruction to the basic block based on the given operands.

func (*Block) NewSExt Uses

func (block *Block) NewSExt(from value.Value, to types.Type) *InstSExt

NewSExt appends a new sext instruction to the basic block based on the given source value and target type.

func (*Block) NewSIToFP Uses

func (block *Block) NewSIToFP(from value.Value, to types.Type) *InstSIToFP

NewSIToFP appends a new sitofp instruction to the basic block based on the given source value and target type.

func (*Block) NewSRem Uses

func (block *Block) NewSRem(x, y value.Value) *InstSRem

NewSRem appends a new srem instruction to the basic block based on the given operands.

func (*Block) NewSelect Uses

func (block *Block) NewSelect(cond, valueTrue, valueFalse value.Value) *InstSelect

NewSelect appends a new select instruction to the basic block based on the given selection condition and true and false condition values.

func (*Block) NewShl Uses

func (block *Block) NewShl(x, y value.Value) *InstShl

NewShl appends a new shl instruction to the basic block based on the given operands.

func (*Block) NewShuffleVector Uses

func (block *Block) NewShuffleVector(x, y, mask value.Value) *InstShuffleVector

NewShuffleVector appends a new shufflevector instruction to the basic block based on the given vectors and shuffle mask.

func (*Block) NewStore Uses

func (block *Block) NewStore(src, dst value.Value) *InstStore

NewStore appends a new store instruction to the basic block based on the given source value and destination address.

func (*Block) NewSub Uses

func (block *Block) NewSub(x, y value.Value) *InstSub

NewSub appends a new sub instruction to the basic block based on the given operands.

func (*Block) NewSwitch Uses

func (block *Block) NewSwitch(x value.Value, targetDefault *Block, cases ...*Case) *TermSwitch

NewSwitch sets the terminator of the basic block to a new switch terminator based on the given control variable, default target basic block and switch cases.

func (*Block) NewTrunc Uses

func (block *Block) NewTrunc(from value.Value, to types.Type) *InstTrunc

NewTrunc appends a new trunc instruction to the basic block based on the given source value and target type.

func (*Block) NewUDiv Uses

func (block *Block) NewUDiv(x, y value.Value) *InstUDiv

NewUDiv appends a new udiv instruction to the basic block based on the given operands.

func (*Block) NewUIToFP Uses

func (block *Block) NewUIToFP(from value.Value, to types.Type) *InstUIToFP

NewUIToFP appends a new uitofp instruction to the basic block based on the given source value and target type.

func (*Block) NewURem Uses

func (block *Block) NewURem(x, y value.Value) *InstURem

NewURem appends a new urem instruction to the basic block based on the given operands.

func (*Block) NewUnreachable Uses

func (block *Block) NewUnreachable() *TermUnreachable

NewUnreachable sets the terminator of the basic block to a new unreachable terminator.

func (*Block) NewVAArg Uses

func (block *Block) NewVAArg(vaList value.Value, argType types.Type) *InstVAArg

NewVAArg appends a new va_arg instruction to the basic block based on the given variable argument list and argument type.

func (*Block) NewXor Uses

func (block *Block) NewXor(x, y value.Value) *InstXor

NewXor appends a new xor instruction to the basic block based on the given operands.

func (*Block) NewZExt Uses

func (block *Block) NewZExt(from value.Value, to types.Type) *InstZExt

NewZExt appends a new zext instruction to the basic block based on the given source value and target type.

func (*Block) String Uses

func (block *Block) String() string

String returns the LLVM syntax representation of the basic block as a type-value pair.

func (*Block) Type Uses

func (block *Block) Type() types.Type

Type returns the type of the basic block.

type Byval Uses

type Byval struct {
    // (optional) Parameter type.
    Typ types.Type
}

Byval is a byval parameter attribute.

func (Byval) IsParamAttribute Uses

func (Byval) IsParamAttribute()

IsParamAttribute ensures that only parameter attributes can be assigned to the ir.ParamAttribute interface.

func (Byval) String Uses

func (b Byval) String() string

String returns the string representation of the byval parameter attribute.

type Case Uses

type Case struct {
    // Case comparand.
    X   value.Value // constant.Constant (integer constant or integer constant expression)
    // Case target branch.
    Target value.Value // *ir.Block
}

Case is a switch case.

func NewCase Uses

func NewCase(x constant.Constant, target *Block) *Case

NewCase returns a new switch case based on the given case comparand and target basic block.

func (*Case) String Uses

func (c *Case) String() string

String returns the string representation of the switch case.

type Clause Uses

type Clause struct {
    // Clause type (catch or filter).
    Type enum.ClauseType
    // Operand.
    X   value.Value
}

Clause is a landingpad catch or filter clause.

func NewClause Uses

func NewClause(clauseType enum.ClauseType, x value.Value) *Clause

NewClause returns a new landingpad clause based on the given clause type and operand.

func (*Clause) String Uses

func (clause *Clause) String() string

String returns the string representation of the landingpad clause.

type ComdatDef Uses

type ComdatDef struct {
    // Comdat name (without '$' prefix).
    Name string
    // Comdat kind.
    Kind enum.SelectionKind
}

ComdatDef is a comdat definition top-level entity.

func (*ComdatDef) LLString Uses

func (c *ComdatDef) LLString() string

LLString returns the LLVM syntax representation of the Comdat definition.

Name=ComdatName '=' 'comdat' Kind=SelectionKind

func (*ComdatDef) String Uses

func (c *ComdatDef) String() string

String returns the string representation of the Comdat definition.

type Dereferenceable Uses

type Dereferenceable struct {
    // Number of bytes known to be dereferenceable.
    N   uint64
    // (optional) Either dereferenceable or null if set.
    DerefOrNull bool
}

Dereferenceable is a dereferenceable memory attribute.

func (Dereferenceable) IsParamAttribute Uses

func (Dereferenceable) IsParamAttribute()

IsParamAttribute ensures that only parameter attributes can be assigned to the ir.ParamAttribute interface.

func (Dereferenceable) IsReturnAttribute Uses

func (Dereferenceable) IsReturnAttribute()

IsReturnAttribute ensures that only return attributes can be assigned to the ir.ReturnAttribute interface.

func (Dereferenceable) String Uses

func (d Dereferenceable) String() string

String returns the string representation of the dereferenceable memory attribute.

type ExceptionPad Uses

type ExceptionPad interface {
    value.Value
}

ExceptionPad is an exception pad or the none token.

An ExceptionPad has one of the following underlying types.

*ir.InstCatchPad
*ir.InstCleanupPad
*constant.NoneToken

type Func Uses

type Func struct {
    // Function name (without '@' prefix).
    GlobalIdent
    // Function signature.
    Sig *types.FuncType
    // Function parameters.
    Params []*Param
    // Basic blocks.
    Blocks []*Block // nil if declaration.

    // Pointer type to function, including an optional address space. If Typ is
    // nil, the first invocation of Type stores a pointer type with Sig as
    // element.
    Typ *types.PointerType
    // (optional) Linkage.
    Linkage enum.Linkage
    // (optional) Preemption; zero value if not present.
    Preemption enum.Preemption
    // (optional) Visibility; zero value if not present.
    Visibility enum.Visibility
    // (optional) DLL storage class; zero value if not present.
    DLLStorageClass enum.DLLStorageClass
    // (optional) Calling convention; zero value if not present.
    CallingConv enum.CallingConv
    // (optional) Return attributes.
    ReturnAttrs []ReturnAttribute
    // (optional) Unnamed address.
    UnnamedAddr enum.UnnamedAddr
    // (optional) Address space; zero if not present.
    AddrSpace types.AddrSpace
    // (optional) Function attributes.
    FuncAttrs []FuncAttribute
    // (optional) Section name; empty if not present.
    Section string
    // (optional) Partition name; empty if not present.
    Partition string
    // (optional) Comdat; nil if not present.
    Comdat *ComdatDef
    // (optional) Alignment; zero if not present.
    Align Align
    // (optional) Garbage collection; empty if not present.
    GC  string
    // (optional) Prefix; nil if not present.
    Prefix constant.Constant
    // (optional) Prologue; nil if not present.
    Prologue constant.Constant
    // (optional) Personality; nil if not present.
    Personality constant.Constant
    // (optional) Use list orders.
    UseListOrders []*UseListOrder
    // (optional) Metadata.
    Metadata

    // Parent module; field set by ir.Module.NewFunc.
    Parent *Module `json:"-"`
    // contains filtered or unexported fields
}

Func is an LLVM IR function. The body of a function definition consists of a set of basic blocks, interconnected by terminator control flow instructions.

func NewFunc Uses

func NewFunc(name string, retType types.Type, params ...*Param) *Func

NewFunc returns a new function based on the given function name, return type and function parameters.

func (*Func) AssignIDs Uses

func (f *Func) AssignIDs() error

AssignIDs assigns IDs to unnamed local variables.

func (*Func) IsConstant Uses

func (*Func) IsConstant()

IsConstant ensures that only constants can be assigned to the constant.Constant interface.

func (*Func) LLString Uses

func (f *Func) LLString() string

LLString returns the LLVM syntax representation of the function definition or declaration.

Function declaration.

'declare' Metadata=MetadataAttachment* Header=FuncHeader

Function definition.

'define' Header=FuncHeader Metadata=MetadataAttachment* Body=FuncBody

func (*Func) NewBlock Uses

func (f *Func) NewBlock(name string) *Block

NewBlock appends a new basic block to the function based on the given label name. An empty label name indicates an unnamed basic block.

The Parent field of the block is set to f.

func (*Func) String Uses

func (f *Func) String() string

String returns the LLVM syntax representation of the function as a type-value pair.

func (*Func) Type Uses

func (f *Func) Type() types.Type

Type returns the type of the function.

type FuncAttribute Uses

type FuncAttribute interface {
    fmt.Stringer
    // IsFuncAttribute ensures that only function attributes can be assigned to
    // the ir.FuncAttribute interface.
    IsFuncAttribute()
}

FuncAttribute is a function attribute.

A FuncAttribute has one of the following underlying types.

ir.AttrString
ir.AttrPair
*ir.AttrGroupDef
ir.Align
ir.AlignStack
ir.AllocSize
enum.FuncAttr

type Global Uses

type Global struct {
    // Global variable name (without '@' prefix).
    GlobalIdent
    // Immutability of global variable (constant or global).
    Immutable bool
    // Content type.
    ContentType types.Type
    // Initial value; or nil if declaration.
    Init constant.Constant

    // Pointer type to global variable, including an optional address space. If
    // Typ is nil, the first invocation of Type stores a pointer type with
    // ContentType as element.
    Typ *types.PointerType
    // (optional) Linkage; zero value if not present.
    Linkage enum.Linkage
    // (optional) Preemption; zero value if not present.
    Preemption enum.Preemption
    // (optional) Visibility; zero value if not present.
    Visibility enum.Visibility
    // (optional) DLL storage class; zero value if not present.
    DLLStorageClass enum.DLLStorageClass
    // (optional) Thread local storage model; zero value if not present.
    TLSModel enum.TLSModel
    // (optional) Unnamed address; zero value if not present.
    UnnamedAddr enum.UnnamedAddr
    // (optional) Address space; zero if not present.
    AddrSpace types.AddrSpace
    // (optional) Externally initialized; false if not present.
    ExternallyInitialized bool
    // (optional) Section name; empty if not present.
    Section string
    // (optional) Partition name; empty if not present.
    Partition string
    // (optional) Comdat; nil if not present.
    Comdat *ComdatDef
    // (optional) Alignment; zero if not present.
    Align Align
    // (optional) Function attributes.
    FuncAttrs []FuncAttribute
    // (optional) Metadata.
    Metadata
}

Global is a global variable declaration or definition.

func NewGlobal Uses

func NewGlobal(name string, contentType types.Type) *Global

NewGlobal returns a new global variable declaration based on the given global variable name and content type.

func NewGlobalDef Uses

func NewGlobalDef(name string, init constant.Constant) *Global

NewGlobalDef returns a new global variable definition based on the given global variable name and initial value.

func (*Global) IsConstant Uses

func (*Global) IsConstant()

IsConstant ensures that only constants can be assigned to the constant.Constant interface.

func (*Global) LLString Uses

func (g *Global) LLString() string

LLString returns the LLVM syntax representation of the global variable definition or declaration.

Global declaration.

Name=GlobalIdent '=' Linkage=ExternLinkage Preemptionopt Visibilityopt DLLStorageClassopt ThreadLocalopt UnnamedAddropt AddrSpaceopt ExternallyInitializedopt Immutable ContentType=Type (',' Section)? (',' Partition)? (',' Comdat)? (',' Align)? Metadata=(',' MetadataAttachment)+? FuncAttrs=FuncAttribute+?

Global definition.

Name=GlobalIdent '=' Linkage=Linkageopt Preemptionopt Visibilityopt DLLStorageClassopt ThreadLocalopt UnnamedAddropt AddrSpaceopt ExternallyInitializedopt Immutable ContentType=Type Init=Constant (',' Section)? (',' Partition)? (',' Comdat)? (',' Align)? Metadata=(',' MetadataAttachment)+? FuncAttrs=FuncAttribute+?

func (*Global) String Uses

func (g *Global) String() string

String returns the LLVM syntax representation of the global variable as a type-value pair.

func (*Global) Type Uses

func (g *Global) Type() types.Type

Type returns the type of the global variable.

type GlobalIdent Uses

type GlobalIdent struct {
    GlobalName string
    GlobalID   int64
}

GlobalIdent is a global identifier.

func (GlobalIdent) ID Uses

func (i GlobalIdent) ID() int64

ID returns the ID of the global identifier.

func (GlobalIdent) Ident Uses

func (i GlobalIdent) Ident() string

Ident returns the identifier associated with the global identifier.

func (GlobalIdent) IsUnnamed Uses

func (i GlobalIdent) IsUnnamed() bool

IsUnnamed reports whether the global identifier is unnamed.

func (GlobalIdent) Name Uses

func (i GlobalIdent) Name() string

Name returns the name of the global identifier.

If unnamed, the global ID is returned. To distinguish numeric names from unnamed IDs, numeric names are quoted.

func (*GlobalIdent) SetID Uses

func (i *GlobalIdent) SetID(id int64)

SetID sets the ID of the global identifier.

func (*GlobalIdent) SetName Uses

func (i *GlobalIdent) SetName(name string)

SetName sets the name of the global identifier.

type IFunc Uses

type IFunc struct {
    // IFunc name (without '@' prefix).
    GlobalIdent
    // Resolver.
    Resolver constant.Constant

    // Pointer type of resolver.
    Typ *types.PointerType
    // (optional) Linkage; zero value if not present.
    Linkage enum.Linkage
    // (optional) Preemption; zero value if not present.
    Preemption enum.Preemption
    // (optional) Visibility; zero value if not present.
    Visibility enum.Visibility
    // (optional) DLL storage class; zero value if not present.
    DLLStorageClass enum.DLLStorageClass
    // (optional) Thread local storage model; zero value if not present.
    TLSModel enum.TLSModel
    // (optional) Unnamed address; zero value if not present.
    UnnamedAddr enum.UnnamedAddr
    // (optional) Partition name; empty if not present.
    Partition string
}

IFunc is an indirect function (a special kind of function alias).

func NewIFunc Uses

func NewIFunc(name string, resolver constant.Constant) *IFunc

NewIFunc returns a new indirect function based on the given IFunc name and resolver.

func (*IFunc) IsConstant Uses

func (*IFunc) IsConstant()

IsConstant ensures that only constants can be assigned to the constant.Constant interface.

func (*IFunc) LLString Uses

func (i *IFunc) LLString() string

LLString returns the LLVM syntax representation of the IFunc definition.

Name=GlobalIdent '=' (ExternLinkage | Linkageopt) Preemptionopt Visibilityopt DLLStorageClassopt ThreadLocalopt UnnamedAddropt IndirectSymbolKind ContentType=Type ',' IndirectSymbol Partitions=(',' Partition)*

func (*IFunc) String Uses

func (i *IFunc) String() string

String returns the LLVM syntax representation of the IFunc as a type-value pair.

func (*IFunc) Type Uses

func (i *IFunc) Type() types.Type

Type returns the type of the IFunc.

type Incoming Uses

type Incoming struct {
    // Incoming value.
    X   value.Value
    // Predecessor basic block of the incoming value.
    Pred value.Value // *ir.Block
}

Incoming is an incoming value of a phi instruction.

func NewIncoming Uses

func NewIncoming(x value.Value, pred *Block) *Incoming

NewIncoming returns a new incoming value based on the given value and predecessor basic block.

func (*Incoming) String Uses

func (inc *Incoming) String() string

String returns the string representation of the incoming value.

type InlineAsm Uses

type InlineAsm struct {
    // Assembly instructions.
    Asm string
    // Constraints.
    Constraint string

    // Type of result produced by the inline assembler expression.
    Typ types.Type
    // (optional) Side effect.
    SideEffect bool
    // (optional) Stack alignment.
    AlignStack bool
    // (optional) Intel dialect.
    IntelDialect bool
}

InlineAsm is an inline assembler expression.

func NewInlineAsm Uses

func NewInlineAsm(typ types.Type, asm, constraint string) *InlineAsm

NewInlineAsm returns a new inline assembler expression based on the given type, assembly instructions and constraints.

func (*InlineAsm) Ident Uses

func (asm *InlineAsm) Ident() string

Ident returns the identifier associated with the inline assembler expression.

func (*InlineAsm) String Uses

func (asm *InlineAsm) String() string

String returns the LLVM syntax representation of the inline assembler expression as a type-value pair.

func (*InlineAsm) Type Uses

func (asm *InlineAsm) Type() types.Type

Type returns the type of the inline assembler expression.

type InstAShr Uses

type InstAShr struct {
    // Name of local variable associated with the result.
    LocalIdent
    // Operands.
    X, Y value.Value // integer scalars or vectors

    // Type of result produced by the instruction.
    Typ types.Type
    // (optional) Exact.
    Exact bool
    // (optional) Metadata.
    Metadata
}

InstAShr is an LLVM IR ashr instruction.

func NewAShr Uses

func NewAShr(x, y value.Value) *InstAShr

NewAShr returns a new ashr instruction based on the given operands.

func (*InstAShr) LLString Uses

func (inst *InstAShr) LLString() string

LLString returns the LLVM syntax representation of the instruction.

'ashr' Exactopt X=TypeValue ',' Y=Value Metadata=(',' MetadataAttachment)+?

func (*InstAShr) String Uses

func (inst *InstAShr) String() string

String returns the LLVM syntax representation of the instruction as a type-value pair.

func (*InstAShr) Type Uses

func (inst *InstAShr) Type() types.Type

Type returns the type of the instruction.

type InstAdd Uses

type InstAdd struct {
    // Name of local variable associated with the result.
    LocalIdent
    // Operands.
    X, Y value.Value // integer scalar or integer vector

    // Type of result produced by the instruction.
    Typ types.Type
    // (optional) Overflow flags.
    OverflowFlags []enum.OverflowFlag
    // (optional) Metadata.
    Metadata
}

InstAdd is an LLVM IR add instruction.

func NewAdd Uses

func NewAdd(x, y value.Value) *InstAdd

NewAdd returns a new add instruction based on the given operands.

func (*InstAdd) LLString Uses

func (inst *InstAdd) LLString() string

LLString returns the LLVM syntax representation of the instruction.

'add' OverflowFlags=OverflowFlag* X=TypeValue ',' Y=Value Metadata=(',' MetadataAttachment)+?

func (*InstAdd) String Uses

func (inst *InstAdd) String() string

String returns the LLVM syntax representation of the instruction as a type-value pair.

func (*InstAdd) Type Uses

func (inst *InstAdd) Type() types.Type

Type returns the type of the instruction.

type InstAddrSpaceCast Uses

type InstAddrSpaceCast struct {
    // Name of local variable associated with the result.
    LocalIdent
    // Value before conversion.
    From value.Value
    // Type after conversion.
    To  types.Type

    // (optional) Metadata.
    Metadata
}

InstAddrSpaceCast is an LLVM IR addrspacecast instruction.

func NewAddrSpaceCast Uses

func NewAddrSpaceCast(from value.Value, to types.Type) *InstAddrSpaceCast

NewAddrSpaceCast returns a new addrspacecast instruction based on the given source value and target type.

func (*InstAddrSpaceCast) LLString Uses

func (inst *InstAddrSpaceCast) LLString() string

LLString returns the LLVM syntax representation of the instruction.

'addrspacecast' From=TypeValue 'to' To=Type Metadata=(',' MetadataAttachment)+?

func (*InstAddrSpaceCast) String Uses

func (inst *InstAddrSpaceCast) String() string

String returns the LLVM syntax representation of the instruction as a type-value pair.

func (*InstAddrSpaceCast) Type Uses

func (inst *InstAddrSpaceCast) Type() types.Type

Type returns the type of the instruction.

type InstAlloca Uses

type InstAlloca struct {
    // Name of local variable associated with the result.
    LocalIdent
    // Element type.
    ElemType types.Type
    // (optional) Number of elements; nil if not present.
    NElems value.Value

    // Type of result produced by the instruction, including an optional address
    // space.
    Typ *types.PointerType
    // (optional) In-alloca.
    InAlloca bool
    // (optional) Swift error.
    SwiftError bool
    // (optional) Alignment; zero if not present.
    Align Align
    // (optional) Address space; zero if not present.
    AddrSpace types.AddrSpace
    // (optional) Metadata.
    Metadata
}

InstAlloca is an LLVM IR alloca instruction.

func NewAlloca Uses

func NewAlloca(elemType types.Type) *InstAlloca

NewAlloca returns a new alloca instruction based on the given element type.

func (*InstAlloca) LLString Uses

func (inst *InstAlloca) LLString() string

LLString returns the LLVM syntax representation of the instruction.

'alloca' InAllocaopt SwiftErroropt ElemType=Type NElems=(',' TypeValue)? (',' Align)? (',' AddrSpace)? Metadata=(',' MetadataAttachment)+?

func (*InstAlloca) String Uses

func (inst *InstAlloca) String() string

String returns the LLVM syntax representation of the instruction as a type-value pair.

func (*InstAlloca) Type Uses

func (inst *InstAlloca) Type() types.Type

Type returns the type of the instruction.

type InstAnd Uses

type InstAnd struct {
    // Name of local variable associated with the result.
    LocalIdent
    // Operands.
    X, Y value.Value // integer scalars or vectors

    // Type of result produced by the instruction.
    Typ types.Type
    // (optional) Metadata.
    Metadata
}

InstAnd is an LLVM IR and instruction.

func NewAnd Uses

func NewAnd(x, y value.Value) *InstAnd

NewAnd returns a new and instruction based on the given operands.

func (*InstAnd) LLString Uses

func (inst *InstAnd) LLString() string

LLString returns the LLVM syntax representation of the instruction.

'and' X=TypeValue ',' Y=Value Metadata=(',' MetadataAttachment)+?

func (*InstAnd) String Uses

func (inst *InstAnd) String() string

String returns the LLVM syntax representation of the instruction as a type-value pair.

func (*InstAnd) Type Uses

func (inst *InstAnd) Type() types.Type

Type returns the type of the instruction.

type InstAtomicRMW Uses

type InstAtomicRMW struct {
    // Name of local variable associated with the result.
    LocalIdent
    // Atomic operation.
    Op  enum.AtomicOp
    // Destination address.
    Dst value.Value
    // Operand.
    X   value.Value
    // Atomic memory ordering constraints.
    Ordering enum.AtomicOrdering

    // Type of result produced by the instruction.
    Typ types.Type
    // (optional) Volatile.
    Volatile bool
    // (optional) Sync scope; empty if not present.
    SyncScope string
    // (optional) Metadata.
    Metadata
}

InstAtomicRMW is an LLVM IR atomicrmw instruction.

func NewAtomicRMW Uses

func NewAtomicRMW(op enum.AtomicOp, dst, x value.Value, ordering enum.AtomicOrdering) *InstAtomicRMW

NewAtomicRMW returns a new atomicrmw instruction based on the given atomic operation, destination address, operand and atomic ordering.

func (*InstAtomicRMW) LLString Uses

func (inst *InstAtomicRMW) LLString() string

LLString returns the LLVM syntax representation of the instruction.

'atomicrmw' Volatileopt Op=AtomicOp Dst=TypeValue ',' X=TypeValue SyncScopeopt Ordering=AtomicOrdering Metadata=(',' MetadataAttachment)+?

func (*InstAtomicRMW) String Uses

func (inst *InstAtomicRMW) String() string

String returns the LLVM syntax representation of the instruction as a type-value pair.

func (*InstAtomicRMW) Type Uses

func (inst *InstAtomicRMW) Type() types.Type

Type returns the type of the instruction.

type InstBitCast Uses

type InstBitCast struct {
    // Name of local variable associated with the result.
    LocalIdent
    // Value before conversion.
    From value.Value
    // Type after conversion.
    To  types.Type

    // (optional) Metadata.
    Metadata
}

InstBitCast is an LLVM IR bitcast instruction.

func NewBitCast Uses

func NewBitCast(from value.Value, to types.Type) *InstBitCast

NewBitCast returns a new bitcast instruction based on the given source value and target type.

func (*InstBitCast) LLString Uses

func (inst *InstBitCast) LLString() string

LLString returns the LLVM syntax representation of the instruction.

'bitcast' From=TypeValue 'to' To=Type Metadata=(',' MetadataAttachment)+?

func (*InstBitCast) String Uses

func (inst *InstBitCast) String() string

String returns the LLVM syntax representation of the instruction as a type-value pair.

func (*InstBitCast) Type Uses

func (inst *InstBitCast) Type() types.Type

Type returns the type of the instruction.

type InstCall Uses

type InstCall struct {
    // Name of local variable associated with the result.
    LocalIdent
    // Callee.
    // TODO: specify the set of underlying types of Callee.
    Callee value.Value
    // Function arguments.
    //
    // Arg has one of the following underlying types:
    //    value.Value
    //    *ir.Arg
    //    TODO: add metadata value?
    Args []value.Value

    // Type of result produced by the instruction.
    Typ types.Type
    // (optional) Tail; zero if not present.
    Tail enum.Tail
    // (optional) Fast math flags.
    FastMathFlags []enum.FastMathFlag
    // (optional) Calling convention; zero if not present.
    CallingConv enum.CallingConv
    // (optional) Return attributes.
    ReturnAttrs []ReturnAttribute
    // (optional) Address space; zero if not present.
    AddrSpace types.AddrSpace
    // (optional) Function attributes.
    FuncAttrs []FuncAttribute
    // (optional) Operand bundles.
    OperandBundles []*OperandBundle
    // (optional) Metadata.
    Metadata
}

InstCall is an LLVM IR call instruction.

func NewCall Uses

func NewCall(callee value.Value, args ...value.Value) *InstCall

NewCall returns a new call instruction based on the given callee and function arguments.

TODO: specify the set of underlying types of callee.

func (*InstCall) LLString Uses

func (inst *InstCall) LLString() string

LLString returns the LLVM syntax representation of the instruction.

Tailopt 'call' FastMathFlags=FastMathFlag* CallingConvopt ReturnAttrs=ReturnAttribute* AddrSpaceopt Typ=Type Callee=Value '(' Args ')' FuncAttrs=FuncAttribute* OperandBundles=('[' (OperandBundle separator ',')+ ']')? Metadata=(',' MetadataAttachment)+?

func (*InstCall) Sig Uses

func (inst *InstCall) Sig() *types.FuncType

Sig returns the function signature of the callee.

func (*InstCall) String Uses

func (inst *InstCall) String() string

String returns the LLVM syntax representation of the instruction as a type-value pair.

func (*InstCall) Type Uses

func (inst *InstCall) Type() types.Type

Type returns the type of the instruction.

type InstCatchPad Uses

type InstCatchPad struct {
    // Name of local variable associated with the result.
    LocalIdent
    // Parent catchswitch terminator.
    CatchSwitch value.Value // *ir.TermCatchSwitch
    // Exception arguments.
    //
    // Arg has one of the following underlying types:
    //    value.Value
    //    TODO: add metadata value?
    Args []value.Value

    // (optional) Metadata.
    Metadata
}

InstCatchPad is an LLVM IR catchpad instruction.

func NewCatchPad Uses

func NewCatchPad(catchSwitch *TermCatchSwitch, args ...value.Value) *InstCatchPad

NewCatchPad returns a new catchpad instruction based on the given parent catchswitch terminator and exception arguments.

func (*InstCatchPad) LLString Uses

func (inst *InstCatchPad) LLString() string

LLString returns the LLVM syntax representation of the instruction.

'catchpad' 'within' CatchSwitch=LocalIdent '[' Args=(ExceptionArg separator ',')* ']' Metadata=(',' MetadataAttachment)+?

func (*InstCatchPad) String Uses

func (inst *InstCatchPad) String() string

String returns the LLVM syntax representation of the instruction as a type-value pair.

func (*InstCatchPad) Type Uses

func (inst *InstCatchPad) Type() types.Type

Type returns the type of the instruction.

type InstCleanupPad Uses

type InstCleanupPad struct {
    // Name of local variable associated with the result.
    LocalIdent
    // Parent exception pad.
    ParentPad value.Value // ir.ExceptionPad
    // Exception arguments.
    //
    // Arg has one of the following underlying types:
    //    value.Value
    //    TODO: add metadata value?
    Args []value.Value

    // (optional) Metadata.
    Metadata
}

InstCleanupPad is an LLVM IR cleanuppad instruction.

func NewCleanupPad Uses

func NewCleanupPad(parentPad ExceptionPad, args ...value.Value) *InstCleanupPad

NewCleanupPad returns a new cleanuppad instruction based on the given parent exception pad and exception arguments.

func (*InstCleanupPad) LLString Uses

func (inst *InstCleanupPad) LLString() string

LLString returns the LLVM syntax representation of the instruction.

'cleanuppad' 'within' ParentPad=ExceptionPad '[' Args=(ExceptionArg separator ',')* ']' Metadata=(',' MetadataAttachment)+?

func (*InstCleanupPad) String Uses

func (inst *InstCleanupPad) String() string

String returns the LLVM syntax representation of the instruction as a type-value pair.

func (*InstCleanupPad) Type Uses

func (inst *InstCleanupPad) Type() types.Type

Type returns the type of the instruction.

type InstCmpXchg Uses

type InstCmpXchg struct {
    // Name of local variable associated with the result.
    LocalIdent
    // Address to read from, compare against and store to.
    Ptr value.Value
    // Value to compare against.
    Cmp value.Value
    // New value to store.
    New value.Value
    // Atomic memory ordering constraints on success.
    SuccessOrdering enum.AtomicOrdering
    // Atomic memory ordering constraints on failure.
    FailureOrdering enum.AtomicOrdering

    // Type of result produced by the instruction; the first field of the struct
    // holds the old value, and the second field indicates success.
    Typ *types.StructType
    // (optional) Weak.
    Weak bool
    // (optional) Volatile.
    Volatile bool
    // (optional) Sync scope; empty if not present.
    SyncScope string
    // (optional) Metadata.
    Metadata
}

InstCmpXchg is an LLVM IR cmpxchg instruction.

func NewCmpXchg Uses

func NewCmpXchg(ptr, cmp, new value.Value, successOrdering, failureOrdering enum.AtomicOrdering) *InstCmpXchg

NewCmpXchg returns a new cmpxchg instruction based on the given address, value to compare against, new value to store, and atomic orderings for success and failure.

func (*InstCmpXchg) LLString Uses

func (inst *InstCmpXchg) LLString() string

LLString returns the LLVM syntax representation of the instruction.

'cmpxchg' Weakopt Volatileopt Ptr=TypeValue ',' Cmp=TypeValue ',' New=TypeValue SyncScopeopt SuccessOrdering=AtomicOrdering FailureOrdering=AtomicOrdering Metadata=(',' MetadataAttachment)+?

func (*InstCmpXchg) String Uses

func (inst *InstCmpXchg) String() string

String returns the LLVM syntax representation of the instruction as a type-value pair.

func (*InstCmpXchg) Type Uses

func (inst *InstCmpXchg) Type() types.Type

Type returns the type of the instruction. The result type is a struct type with two fields, the first field has the type of the old value and the second field has boolean type.

type InstExtractElement Uses

type InstExtractElement struct {
    // Name of local variable associated with the result.
    LocalIdent
    // Vector.
    X   value.Value
    // Element index.
    Index value.Value

    // Type of result produced by the instruction.
    Typ types.Type
    // (optional) Metadata.
    Metadata
}

InstExtractElement is an LLVM IR extractelement instruction.

func NewExtractElement Uses

func NewExtractElement(x, index value.Value) *InstExtractElement

NewExtractElement returns a new extractelement instruction based on the given vector and element index.

func (*InstExtractElement) LLString Uses

func (inst *InstExtractElement) LLString() string

LLString returns the LLVM syntax representation of the instruction.

'extractelement' X=TypeValue ',' Index=TypeValue Metadata=(',' MetadataAttachment)+?

func (*InstExtractElement) String Uses

func (inst *InstExtractElement) String() string

String returns the LLVM syntax representation of the instruction as a type-value pair.

func (*InstExtractElement) Type Uses

func (inst *InstExtractElement) Type() types.Type

Type returns the type of the instruction.

type InstExtractValue Uses

type InstExtractValue struct {
    // Name of local variable associated with the result.
    LocalIdent
    // Aggregate value.
    X   value.Value // array or struct
    // Element indices.
    Indices []uint64

    // Type of result produced by the instruction.
    Typ types.Type
    // (optional) Metadata.
    Metadata
}

InstExtractValue is an LLVM IR extractvalue instruction.

func NewExtractValue Uses

func NewExtractValue(x value.Value, indices ...uint64) *InstExtractValue

NewExtractValue returns a new extractvalue instruction based on the given aggregate value and indicies.

func (*InstExtractValue) LLString Uses

func (inst *InstExtractValue) LLString() string

LLString returns the LLVM syntax representation of the instruction.

'extractvalue' X=TypeValue Indices=(',' UintLit)+ Metadata=(',' MetadataAttachment)+?

func (*InstExtractValue) String Uses

func (inst *InstExtractValue) String() string

String returns the LLVM syntax representation of the instruction as a type-value pair.

func (*InstExtractValue) Type Uses

func (inst *InstExtractValue) Type() types.Type

Type returns the type of the instruction.

type InstFAdd Uses

type InstFAdd struct {
    // Name of local variable associated with the result.
    LocalIdent
    // Operands.
    X, Y value.Value // floating-point scalar or floating-point vector

    // Type of result produced by the instruction.
    Typ types.Type
    // (optional) Fast math flags.
    FastMathFlags []enum.FastMathFlag
    // (optional) Metadata.
    Metadata
}

InstFAdd is an LLVM IR fadd instruction.

func NewFAdd Uses

func NewFAdd(x, y value.Value) *InstFAdd

NewFAdd returns a new fadd instruction based on the given operands.

func (*InstFAdd) LLString Uses

func (inst *InstFAdd) LLString() string

LLString returns the LLVM syntax representation of the instruction.

'fadd' FastMathFlags=FastMathFlag* X=TypeValue ',' Y=Value Metadata=(',' MetadataAttachment)+?

func (*InstFAdd) String Uses

func (inst *InstFAdd) String() string

String returns the LLVM syntax representation of the instruction as a type-value pair.

func (*InstFAdd) Type Uses

func (inst *InstFAdd) Type() types.Type

Type returns the type of the instruction.

type InstFCmp Uses

type InstFCmp struct {
    // Name of local variable associated with the result.
    LocalIdent
    // Floating-point comparison predicate.
    Pred enum.FPred
    // Floating-point scalar or vector operands.
    X, Y value.Value // floating-point scalar or floating-point vector

    // Type of result produced by the instruction.
    Typ types.Type // boolean or boolean vector
    // (optional) Fast math flags.
    FastMathFlags []enum.FastMathFlag
    // (optional) Metadata.
    Metadata
}

InstFCmp is an LLVM IR fcmp instruction.

func NewFCmp Uses

func NewFCmp(pred enum.FPred, x, y value.Value) *InstFCmp

NewFCmp returns a new fcmp instruction based on the given floating-point comparison predicate and floating-point scalar or vector operands.

func (*InstFCmp) LLString Uses

func (inst *InstFCmp) LLString() string

LLString returns the LLVM syntax representation of the instruction.

'fcmp' FastMathFlags=FastMathFlag* Pred=FPred X=TypeValue ',' Y=Value Metadata=(',' MetadataAttachment)+?

func (*InstFCmp) String Uses

func (inst *InstFCmp) String() string

String returns the LLVM syntax representation of the instruction as a type-value pair.

func (*InstFCmp) Type Uses

func (inst *InstFCmp) Type() types.Type

Type returns the type of the instruction. The result type is either boolean type or vector of booleans type.

type InstFDiv Uses

type InstFDiv struct {
    // Name of local variable associated with the result.
    LocalIdent
    // Operands.
    X, Y value.Value // floating-point scalar or floating-point vector

    // Type of result produced by the instruction.
    Typ types.Type
    // (optional) Fast math flags.
    FastMathFlags []enum.FastMathFlag
    // (optional) Metadata.
    Metadata
}

InstFDiv is an LLVM IR fdiv instruction.

func NewFDiv Uses

func NewFDiv(x, y value.Value) *InstFDiv

NewFDiv returns a new fdiv instruction based on the given operands.

func (*InstFDiv) LLString Uses

func (inst *InstFDiv) LLString() string

LLString returns the LLVM syntax representation of the instruction.

'fdiv' FastMathFlags=FastMathFlag* X=TypeValue ',' Y=Value Metadata=(',' MetadataAttachment)+?

func (*InstFDiv) String Uses

func (inst *InstFDiv) String() string

String returns the LLVM syntax representation of the instruction as a type-value pair.

func (*InstFDiv) Type Uses

func (inst *InstFDiv) Type() types.Type

Type returns the type of the instruction.

type InstFMul Uses

type InstFMul struct {
    // Name of local variable associated with the result.
    LocalIdent
    // Operands.
    X, Y value.Value // floating-point scalar or floating-point vector

    // Type of result produced by the instruction.
    Typ types.Type
    // (optional) Fast math flags.
    FastMathFlags []enum.FastMathFlag
    // (optional) Metadata.
    Metadata
}

InstFMul is an LLVM IR fmul instruction.

func NewFMul Uses

func NewFMul(x, y value.Value) *InstFMul

NewFMul returns a new fmul instruction based on the given operands.

func (*InstFMul) LLString Uses

func (inst *InstFMul) LLString() string

LLString returns the LLVM syntax representation of the instruction.

'fmul' FastMathFlags=FastMathFlag* X=TypeValue ',' Y=Value Metadata=(',' MetadataAttachment)+?

func (*InstFMul) String Uses

func (inst *InstFMul) String() string

String returns the LLVM syntax representation of the instruction as a type-value pair.

func (*InstFMul) Type Uses

func (inst *InstFMul) Type() types.Type

Type returns the type of the instruction.

type InstFNeg Uses

type InstFNeg struct {
    // Name of local variable associated with the result.
    LocalIdent
    // Operand.
    X   value.Value // floating-point scalar or floating-point vector

    // Type of result produced by the instruction.
    Typ types.Type
    // (optional) Fast math flags.
    FastMathFlags []enum.FastMathFlag
    // (optional) Metadata.
    Metadata
}

InstFNeg is an LLVM IR fneg instruction.

func NewFNeg Uses

func NewFNeg(x value.Value) *InstFNeg

NewFNeg returns a new fneg instruction based on the given operand.

func (*InstFNeg) LLString Uses

func (inst *InstFNeg) LLString() string

LLString returns the LLVM syntax representation of the instruction.

'fneg' FastMathFlags=FastMathFlag* X=TypeValue Metadata=(',' MetadataAttachment)+?

func (*InstFNeg) String Uses

func (inst *InstFNeg) String() string

String returns the LLVM syntax representation of the instruction as a type-value pair.

func (*InstFNeg) Type Uses

func (inst *InstFNeg) Type() types.Type

Type returns the type of the instruction.

type InstFPExt Uses

type InstFPExt struct {
    // Name of local variable associated with the result.
    LocalIdent
    // Value before conversion.
    From value.Value
    // Type after conversion.
    To  types.Type

    // (optional) Metadata.
    Metadata
}

InstFPExt is an LLVM IR fpext instruction.

func NewFPExt Uses

func NewFPExt(from value.Value, to types.Type) *InstFPExt

NewFPExt returns a new fpext instruction based on the given source value and target type.

func (*InstFPExt) LLString Uses

func (inst *InstFPExt) LLString() string

LLString returns the LLVM syntax representation of the instruction.

'fpext' From=TypeValue 'to' To=Type Metadata=(',' MetadataAttachment)+?

func (*InstFPExt) String Uses

func (inst *InstFPExt) String() string

String returns the LLVM syntax representation of the instruction as a type-value pair.

func (*InstFPExt) Type Uses

func (inst *InstFPExt) Type() types.Type

Type returns the type of the instruction.

type InstFPToSI Uses

type InstFPToSI struct {
    // Name of local variable associated with the result.
    LocalIdent
    // Value before conversion.
    From value.Value
    // Type after conversion.
    To  types.Type

    // (optional) Metadata.
    Metadata
}

InstFPToSI is an LLVM IR fptosi instruction.

func NewFPToSI Uses

func NewFPToSI(from value.Value, to types.Type) *InstFPToSI

NewFPToSI returns a new fptosi instruction based on the given source value and target type.

func (*InstFPToSI) LLString Uses

func (inst *InstFPToSI) LLString() string

LLString returns the LLVM syntax representation of the instruction.

'fptosi' From=TypeValue 'to' To=Type Metadata=(',' MetadataAttachment)+?

func (*InstFPToSI) String Uses

func (inst *InstFPToSI) String() string

String returns the LLVM syntax representation of the instruction as a type-value pair.

func (*InstFPToSI) Type Uses

func (inst *InstFPToSI) Type() types.Type

Type returns the type of the instruction.

type InstFPToUI Uses

type InstFPToUI struct {
    // Name of local variable associated with the result.
    LocalIdent
    // Value before conversion.
    From value.Value
    // Type after conversion.
    To  types.Type

    // (optional) Metadata.
    Metadata
}

InstFPToUI is an LLVM IR fptoui instruction.

func NewFPToUI Uses

func NewFPToUI(from value.Value, to types.Type) *InstFPToUI

NewFPToUI returns a new fptoui instruction based on the given source value and target type.

func (*InstFPToUI) LLString Uses

func (inst *InstFPToUI) LLString() string

LLString returns the LLVM syntax representation of the instruction.

'fptoui' From=TypeValue 'to' To=Type Metadata=(',' MetadataAttachment)+?

func (*InstFPToUI) String Uses

func (inst *InstFPToUI) String() string

String returns the LLVM syntax representation of the instruction as a type-value pair.

func (*InstFPToUI) Type Uses

func (inst *InstFPToUI) Type() types.Type

Type returns the type of the instruction.

type InstFPTrunc Uses

type InstFPTrunc struct {
    // Name of local variable associated with the result.
    LocalIdent
    // Value before conversion.
    From value.Value
    // Type after conversion.
    To  types.Type

    // (optional) Metadata.
    Metadata
}

InstFPTrunc is an LLVM IR fptrunc instruction.

func NewFPTrunc Uses

func NewFPTrunc(from value.Value, to types.Type) *InstFPTrunc

NewFPTrunc returns a new fptrunc instruction based on the given source value and target type.

func (*InstFPTrunc) LLString Uses

func (inst *InstFPTrunc) LLString() string

LLString returns the LLVM syntax representation of the instruction.

'fptrunc' From=TypeValue 'to' To=Type Metadata=(',' MetadataAttachment)+?

func (*InstFPTrunc) String Uses

func (inst *InstFPTrunc) String() string

String returns the LLVM syntax representation of the instruction as a type-value pair.

func (*InstFPTrunc) Type Uses

func (inst *InstFPTrunc) Type() types.Type

Type returns the type of the instruction.

type InstFRem Uses

type InstFRem struct {
    // Name of local variable associated with the result.
    LocalIdent
    // Operands.
    X, Y value.Value // floating-point scalar or floating-point vector

    // Type of result produced by the instruction.
    Typ types.Type
    // (optional) Fast math flags.
    FastMathFlags []enum.FastMathFlag
    // (optional) Metadata.
    Metadata
}

InstFRem is an LLVM IR frem instruction.

func NewFRem Uses

func NewFRem(x, y value.Value) *InstFRem

NewFRem returns a new frem instruction based on the given operands.

func (*InstFRem) LLString Uses

func (inst *InstFRem) LLString() string

LLString returns the LLVM syntax representation of the instruction.

'frem' FastMathFlags=FastMathFlag* X=TypeValue ',' Y=Value Metadata=(',' MetadataAttachment)+?

func (*InstFRem) String Uses

func (inst *InstFRem) String() string

String returns the LLVM syntax representation of the instruction as a type-value pair.

func (*InstFRem) Type Uses

func (inst *InstFRem) Type() types.Type

Type returns the type of the instruction.

type InstFSub Uses

type InstFSub struct {
    // Name of local variable associated with the result.
    LocalIdent
    // Operands.
    X, Y value.Value // floating-point scalar or floating-point vector

    // Type of result produced by the instruction.
    Typ types.Type
    // (optional) Fast math flags.
    FastMathFlags []enum.FastMathFlag
    // (optional) Metadata.
    Metadata
}

InstFSub is an LLVM IR fsub instruction.

func NewFSub Uses

func NewFSub(x, y value.Value) *InstFSub

NewFSub returns a new fsub instruction based on the given operands.

func (*InstFSub) LLString Uses

func (inst *InstFSub) LLString() string

LLString returns the LLVM syntax representation of the instruction.

'fsub' FastMathFlags=FastMathFlag* X=TypeValue ',' Y=Value Metadata=(',' MetadataAttachment)+?

func (*InstFSub) String Uses

func (inst *InstFSub) String() string

String returns the LLVM syntax representation of the instruction as a type-value pair.

func (*InstFSub) Type Uses

func (inst *InstFSub) Type() types.Type

Type returns the type of the instruction.

type InstFence Uses

type InstFence struct {
    // Atomic memory ordering constraints.
    Ordering enum.AtomicOrdering

    // (optional) Sync scope; empty if not present.
    SyncScope string
    // (optional) Metadata.
    Metadata
}

InstFence is an LLVM IR fence instruction.

func NewFence Uses

func NewFence(ordering enum.AtomicOrdering) *InstFence

NewFence returns a new fence instruction based on the given atomic ordering.

func (*InstFence) LLString Uses

func (inst *InstFence) LLString() string

LLString returns the LLVM syntax representation of the instruction.

'fence' SyncScopeopt Ordering=AtomicOrdering Metadata=(',' MetadataAttachment)+?

type InstFreeze Uses

type InstFreeze struct {
    // Name of local variable associated with the result.
    LocalIdent
    // Operand.
    X   value.Value

    // Type of result produced by the instruction.
    Typ types.Type
    // (optional) Metadata.
    Metadata
}

InstFreeze is an LLVM IR freeze instruction.

func NewInstFreeze Uses

func NewInstFreeze(x value.Value) *InstFreeze

NewInstFreeze returns a new freeze instruction based on the given operand.

func (*InstFreeze) LLString Uses

func (inst *InstFreeze) LLString() string

LLString returns the LLVM syntax representation of the instruction.

'freeze' Type Value

func (*InstFreeze) String Uses

func (inst *InstFreeze) String() string

String returns the LLVM syntax representation of the instruction as a type-value pair.

func (*InstFreeze) Type Uses

func (inst *InstFreeze) Type() types.Type

Type returns the type of the instruction.

type InstGetElementPtr Uses

type InstGetElementPtr struct {
    // Name of local variable associated with the result.
    LocalIdent
    // Element type.
    ElemType types.Type
    // Source address.
    Src value.Value
    // Element indicies.
    Indices []value.Value

    // Type of result produced by the instruction.
    Typ types.Type // *types.PointerType or *types.VectorType (with elements of pointer type)
    // (optional) In-bounds.
    InBounds bool
    // (optional) Metadata.
    Metadata
}

InstGetElementPtr is an LLVM IR getelementptr instruction.

func NewGetElementPtr Uses

func NewGetElementPtr(elemType types.Type, src value.Value, indices ...value.Value) *InstGetElementPtr

NewGetElementPtr returns a new getelementptr instruction based on the given element type, source address and element indices.

func (*InstGetElementPtr) LLString Uses

func (inst *InstGetElementPtr) LLString() string

LLString returns the LLVM syntax representation of the instruction.

'getelementptr' InBoundsopt ElemType=Type ',' Src=TypeValue Indices=(',' TypeValue)* Metadata=(',' MetadataAttachment)+?

func (*InstGetElementPtr) String Uses

func (inst *InstGetElementPtr) String() string

String returns the LLVM syntax representation of the instruction as a type-value pair.

func (*InstGetElementPtr) Type Uses

func (inst *InstGetElementPtr) Type() types.Type

Type returns the type of the instruction.

type InstICmp Uses

type InstICmp struct {
    // Name of local variable associated with the result.
    LocalIdent
    // Integer comparison predicate.
    Pred enum.IPred
    // Integer scalar or vector operands.
    X, Y value.Value // integer scalar, pointer, integer vector or pointer vector.

    // Type of result produced by the instruction.
    Typ types.Type // boolean or boolean vector
    // (optional) Metadata.
    Metadata
}

InstICmp is an LLVM IR icmp instruction.

func NewICmp Uses

func NewICmp(pred enum.IPred, x, y value.Value) *InstICmp

NewICmp returns a new icmp instruction based on the given integer comparison predicate and integer scalar or vector operands.

func (*InstICmp) LLString Uses

func (inst *InstICmp) LLString() string

LLString returns the LLVM syntax representation of the instruction.

'icmp' Pred=IPred X=TypeValue ',' Y=Value Metadata=(',' MetadataAttachment)+?

func (*InstICmp) String Uses

func (inst *InstICmp) String() string

String returns the LLVM syntax representation of the instruction as a type-value pair.

func (*InstICmp) Type Uses

func (inst *InstICmp) Type() types.Type

Type returns the type of the instruction. The result type is either boolean type or vector of booleans type.

type InstInsertElement Uses

type InstInsertElement struct {
    // Name of local variable associated with the result.
    LocalIdent
    // Vector.
    X   value.Value
    // Element to insert.
    Elem value.Value
    // Element index.
    Index value.Value

    // Type of result produced by the instruction.
    Typ *types.VectorType
    // (optional) Metadata.
    Metadata
}

InstInsertElement is an LLVM IR insertelement instruction.

func NewInsertElement Uses

func NewInsertElement(x, elem, index value.Value) *InstInsertElement

NewInsertElement returns a new insertelement instruction based on the given vector, element and element index.

func (*InstInsertElement) LLString Uses

func (inst *InstInsertElement) LLString() string

LLString returns the LLVM syntax representation of the instruction.

'insertelement' X=TypeValue ',' Elem=TypeValue ',' Index=TypeValue Metadata=(',' MetadataAttachment)+?

func (*InstInsertElement) String Uses

func (inst *InstInsertElement) String() string

String returns the LLVM syntax representation of the instruction as a type-value pair.

func (*InstInsertElement) Type Uses

func (inst *InstInsertElement) Type() types.Type

Type returns the type of the instruction.

type InstInsertValue Uses

type InstInsertValue struct {
    // Name of local variable associated with the result.
    LocalIdent
    // Aggregate value.
    X   value.Value // array or struct
    // Element to insert.
    Elem value.Value
    // Element indices.
    Indices []uint64

    // Type of result produced by the instruction.
    Typ types.Type
    // (optional) Metadata.
    Metadata
}

InstInsertValue is an LLVM IR insertvalue instruction.

func NewInsertValue Uses

func NewInsertValue(x, elem value.Value, indices ...uint64) *InstInsertValue

NewInsertValue returns a new insertvalue instruction based on the given aggregate value, element and indicies.

func (*InstInsertValue) LLString Uses

func (inst *InstInsertValue) LLString() string

LLString returns the LLVM syntax representation of the instruction.

'insertvalue' X=TypeValue ',' Elem=TypeValue Indices=(',' UintLit)+ Metadata=(',' MetadataAttachment)+?

func (*InstInsertValue) String Uses

func (inst *InstInsertValue) String() string

String returns the LLVM syntax representation of the instruction as a type-value pair.

func (*InstInsertValue) Type Uses

func (inst *InstInsertValue) Type() types.Type

Type returns the type of the instruction.

type InstIntToPtr Uses

type InstIntToPtr struct {
    // Name of local variable associated with the result.
    LocalIdent
    // Value before conversion.
    From value.Value
    // Type after conversion.
    To  types.Type

    // (optional) Metadata.
    Metadata
}

InstIntToPtr is an LLVM IR inttoptr instruction.

func NewIntToPtr Uses

func NewIntToPtr(from value.Value, to types.Type) *InstIntToPtr

NewIntToPtr returns a new inttoptr instruction based on the given source value and target type.

func (*InstIntToPtr) LLString Uses

func (inst *InstIntToPtr) LLString() string

LLString returns the LLVM syntax representation of the instruction.

'inttoptr' From=TypeValue 'to' To=Type Metadata=(',' MetadataAttachment)+?

func (*InstIntToPtr) String Uses

func (inst *InstIntToPtr) String() string

String returns the LLVM syntax representation of the instruction as a type-value pair.

func (*InstIntToPtr) Type Uses

func (inst *InstIntToPtr) Type() types.Type

Type returns the type of the instruction.

type InstLShr Uses

type InstLShr struct {
    // Name of local variable associated with the result.
    LocalIdent
    // Operands.
    X, Y value.Value // integer scalars or vectors

    // Type of result produced by the instruction.
    Typ types.Type
    // (optional) Exact.
    Exact bool
    // (optional) Metadata.
    Metadata
}

InstLShr is an LLVM IR lshr instruction.

func NewLShr Uses

func NewLShr(x, y value.Value) *InstLShr

NewLShr returns a new lshr instruction based on the given operands.

func (*InstLShr) LLString Uses

func (inst *InstLShr) LLString() string

LLString returns the LLVM syntax representation of the instruction.

'lshr' Exactopt X=TypeValue ',' Y=Value Metadata=(',' MetadataAttachment)+?

func (*InstLShr) String Uses

func (inst *InstLShr) String() string

String returns the LLVM syntax representation of the instruction as a type-value pair.

func (*InstLShr) Type Uses

func (inst *InstLShr) Type() types.Type

Type returns the type of the instruction.

type InstLandingPad Uses

type InstLandingPad struct {
    // Name of local variable associated with the result.
    LocalIdent
    // Result type.
    ResultType types.Type
    // (optional) Cleanup landing pad.
    Cleanup bool
    // Filter and catch clauses; zero or more if Cleanup is true, otherwise one
    // or more.
    Clauses []*Clause

    // (optional) Metadata.
    Metadata
}

InstLandingPad is an LLVM IR landingpad instruction.

func NewLandingPad Uses

func NewLandingPad(resultType types.Type, clauses ...*Clause) *InstLandingPad

NewLandingPad returns a new landingpad instruction based on the given result type and filter/catch clauses.

func (*InstLandingPad) LLString Uses

func (inst *InstLandingPad) LLString() string

LLString returns the LLVM syntax representation of the instruction.

'landingpad' ResultType=Type Cleanupopt Clauses=Clause* Metadata=(',' MetadataAttachment)+?

func (*InstLandingPad) String Uses

func (inst *InstLandingPad) String() string

String returns the LLVM syntax representation of the instruction as a type-value pair.

func (*InstLandingPad) Type Uses

func (inst *InstLandingPad) Type() types.Type

Type returns the type of the instruction.

type InstLoad Uses

type InstLoad struct {
    // Name of local variable associated with the result.
    LocalIdent
    // Element type of src.
    ElemType types.Type
    // Source address.
    Src value.Value

    // (optional) Atomic.
    Atomic bool
    // (optional) Volatile.
    Volatile bool
    // (optional) Sync scope; empty if not present.
    SyncScope string
    // (optional) Atomic memory ordering constraints; zero if not present.
    Ordering enum.AtomicOrdering
    // (optional) Alignment; zero if not present.
    Align Align
    // (optional) Metadata.
    Metadata
}

InstLoad is an LLVM IR load instruction.

func NewLoad Uses

func NewLoad(elemType types.Type, src value.Value) *InstLoad

NewLoad returns a new load instruction based on the given element type and source address.

func (*InstLoad) LLString Uses

func (inst *InstLoad) LLString() string

LLString returns the LLVM syntax representation of the instruction.

Load instruction.

'load' Volatileopt ElemType=Type ',' Src=TypeValue (',' Align)? Metadata=(',' MetadataAttachment)+?

Atomic load instruction.

'load' Atomic Volatileopt ElemType=Type ',' Src=TypeValue SyncScopeopt Ordering=AtomicOrdering (',' Align)? Metadata=(',' MetadataAttachment)+?

func (*InstLoad) String Uses

func (inst *InstLoad) String() string

String returns the LLVM syntax representation of the instruction as a type-value pair.

func (*InstLoad) Type Uses

func (inst *InstLoad) Type() types.Type

Type returns the type of the instruction.

type InstMul Uses

type InstMul struct {
    // Name of local variable associated with the result.
    LocalIdent
    // Operands.
    X, Y value.Value // integer scalar or integer vector

    // Type of result produced by the instruction.
    Typ types.Type
    // (optional) Overflow flags.
    OverflowFlags []enum.OverflowFlag
    // (optional) Metadata.
    Metadata
}

InstMul is an LLVM IR mul instruction.

func NewMul Uses

func NewMul(x, y value.Value) *InstMul

NewMul returns a new mul instruction based on the given operands.

func (*InstMul) LLString Uses

func (inst *InstMul) LLString() string

LLString returns the LLVM syntax representation of the instruction.

'mul' OverflowFlags=OverflowFlag* X=TypeValue ',' Y=Value Metadata=(',' MetadataAttachment)+?

func (*InstMul) String Uses

func (inst *InstMul) String() string

String returns the LLVM syntax representation of the instruction as a type-value pair.

func (*InstMul) Type Uses

func (inst *InstMul) Type() types.Type

Type returns the type of the instruction.

type InstOr Uses

type InstOr struct {
    // Name of local variable associated with the result.
    LocalIdent
    // Operands.
    X, Y value.Value // integer scalars or vectors

    // Type of result produced by the instruction.
    Typ types.Type
    // (optional) Metadata.
    Metadata
}

InstOr is an LLVM IR or instruction.

func NewOr Uses

func NewOr(x, y value.Value) *InstOr

NewOr returns a new or instruction based on the given operands.

func (*InstOr) LLString Uses

func (inst *InstOr) LLString() string

LLString returns the LLVM syntax representation of the instruction.

'or' X=TypeValue ',' Y=Value Metadata=(',' MetadataAttachment)+?

func (*InstOr) String Uses

func (inst *InstOr) String() string

String returns the LLVM syntax representation of the instruction as a type-value pair.

func (*InstOr) Type Uses

func (inst *InstOr) Type() types.Type

Type returns the type of the instruction.

type InstPhi Uses

type InstPhi struct {
    // Name of local variable associated with the result.
    LocalIdent
    // Incoming values.
    Incs []*Incoming

    // Type of result produced by the instruction.
    Typ types.Type // type of incoming value
    // (optional) Fast math flags.
    FastMathFlags []enum.FastMathFlag
    // (optional) Metadata.
    Metadata
}

InstPhi is an LLVM IR phi instruction.

func NewPhi Uses

func NewPhi(incs ...*Incoming) *InstPhi

NewPhi returns a new phi instruction based on the given incoming values.

func (*InstPhi) LLString Uses

func (inst *InstPhi) LLString() string

LLString returns the LLVM syntax representation of the instruction.

'phi' Typ=Type Incs=(Inc separator ',')+ Metadata=(',' MetadataAttachment)+?

func (*InstPhi) String Uses

func (inst *InstPhi) String() string

String returns the LLVM syntax representation of the instruction as a type-value pair.

func (*InstPhi) Type Uses

func (inst *InstPhi) Type() types.Type

Type returns the type of the instruction. The result type is the type of the incoming value.

type InstPtrToInt Uses

type InstPtrToInt struct {
    // Name of local variable associated with the result.
    LocalIdent
    // Value before conversion.
    From value.Value
    // Type after conversion.
    To  types.Type

    // (optional) Metadata.
    Metadata
}

InstPtrToInt is an LLVM IR ptrtoint instruction.

func NewPtrToInt Uses

func NewPtrToInt(from value.Value, to types.Type) *InstPtrToInt

NewPtrToInt returns a new ptrtoint instruction based on the given source value and target type.

func (*InstPtrToInt) LLString Uses

func (inst *InstPtrToInt) LLString() string

LLString returns the LLVM syntax representation of the instruction.

'ptrtoint' From=TypeValue 'to' To=Type Metadata=(',' MetadataAttachment)+?

func (*InstPtrToInt) String Uses

func (inst *InstPtrToInt) String() string

String returns the LLVM syntax representation of the instruction as a type-value pair.

func (*InstPtrToInt) Type Uses

func (inst *InstPtrToInt) Type() types.Type

Type returns the type of the instruction.

type InstSDiv Uses

type InstSDiv struct {
    // Name of local variable associated with the result.
    LocalIdent
    // Operands.
    X, Y value.Value // integer scalar or integer vector

    // Type of result produced by the instruction.
    Typ types.Type
    // (optional) Exact.
    Exact bool
    // (optional) Metadata.
    Metadata
}

InstSDiv is an LLVM IR sdiv instruction.

func NewSDiv Uses

func NewSDiv(x, y value.Value) *InstSDiv

NewSDiv returns a new sdiv instruction based on the given operands.

func (*InstSDiv) LLString Uses

func (inst *InstSDiv) LLString() string

LLString returns the LLVM syntax representation of the instruction.

'sdiv' Exactopt X=TypeValue ',' Y=Value Metadata=(',' MetadataAttachment)+?

func (*InstSDiv) String Uses

func (inst *InstSDiv) String() string

String returns the LLVM syntax representation of the instruction as a type-value pair.

func (*InstSDiv) Type Uses

func (inst *InstSDiv) Type() types.Type

Type returns the type of the instruction.

type InstSExt Uses

type InstSExt struct {
    // Name of local variable associated with the result.
    LocalIdent
    // Value before conversion.
    From value.Value
    // Type after conversion.
    To  types.Type

    // (optional) Metadata.
    Metadata
}

InstSExt is an LLVM IR sext instruction.

func NewSExt Uses

func NewSExt(from value.Value, to types.Type) *InstSExt

NewSExt returns a new sext instruction based on the given source value and target type.

func (*InstSExt) LLString Uses

func (inst *InstSExt) LLString() string

LLString returns the LLVM syntax representation of the instruction.

'sext' From=TypeValue 'to' To=Type Metadata=(',' MetadataAttachment)+?

func (*InstSExt) String Uses

func (inst *InstSExt) String() string

String returns the LLVM syntax representation of the instruction as a type-value pair.

func (*InstSExt) Type Uses

func (inst *InstSExt) Type() types.Type

Type returns the type of the instruction.

type InstSIToFP Uses

type InstSIToFP struct {
    // Name of local variable associated with the result.
    LocalIdent
    // Value before conversion.
    From value.Value
    // Type after conversion.
    To  types.Type

    // (optional) Metadata.
    Metadata
}

InstSIToFP is an LLVM IR sitofp instruction.

func NewSIToFP Uses

func NewSIToFP(from value.Value, to types.Type) *InstSIToFP

NewSIToFP returns a new sitofp instruction based on the given source value and target type.

func (*InstSIToFP) LLString Uses

func (inst *InstSIToFP) LLString() string

LLString returns the LLVM syntax representation of the instruction.

'sitofp' From=TypeValue 'to' To=Type Metadata=(',' MetadataAttachment)+?

func (*InstSIToFP) String Uses

func (inst *InstSIToFP) String() string

String returns the LLVM syntax representation of the instruction as a type-value pair.

func (*InstSIToFP) Type Uses

func (inst *InstSIToFP) Type() types.Type

Type returns the type of the instruction.

type InstSRem Uses

type InstSRem struct {
    // Name of local variable associated with the result.
    LocalIdent
    // Operands.
    X, Y value.Value // integer scalar or integer vector

    // Type of result produced by the instruction.
    Typ types.Type
    // (optional) Metadata.
    Metadata
}

InstSRem is an LLVM IR srem instruction.

func NewSRem Uses

func NewSRem(x, y value.Value) *InstSRem

NewSRem returns a new srem instruction based on the given operands.

func (*InstSRem) LLString Uses

func (inst *InstSRem) LLString() string

LLString returns the LLVM syntax representation of the instruction.

'srem' X=TypeValue ',' Y=Value Metadata=(',' MetadataAttachment)+?

func (*InstSRem) String Uses

func (inst *InstSRem) String() string

String returns the LLVM syntax representation of the instruction as a type-value pair.

func (*InstSRem) Type Uses

func (inst *InstSRem) Type() types.Type

Type returns the type of the instruction.

type InstSelect Uses

type InstSelect struct {
    // Name of local variable associated with the result.
    LocalIdent
    // Selection condition.
    Cond value.Value // boolean or boolean vector
    // True condition value.
    ValueTrue value.Value
    // False condition value.
    ValueFalse value.Value

    // Type of result produced by the instruction.
    Typ types.Type
    // (optional) Fast math flags.
    FastMathFlags []enum.FastMathFlag
    // (optional) Metadata.
    Metadata
}

InstSelect is an LLVM IR select instruction.

func NewSelect Uses

func NewSelect(cond, valueTrue, valueFalse value.Value) *InstSelect

NewSelect returns a new select instruction based on the given selection condition and true and false condition values.

func (*InstSelect) LLString Uses

func (inst *InstSelect) LLString() string

LLString returns the LLVM syntax representation of the instruction.

'select' FastMathFlags=FastMathFlag* Cond=TypeValue ',' ValueTrue=TypeValue ',' ValueFalse=TypeValue Metadata=(',' MetadataAttachment)+?

func (*InstSelect) String Uses

func (inst *InstSelect) String() string

String returns the LLVM syntax representation of the instruction as a type-value pair.

func (*InstSelect) Type Uses

func (inst *InstSelect) Type() types.Type

Type returns the type of the instruction.

type InstShl Uses

type InstShl struct {
    // Name of local variable associated with the result.
    LocalIdent
    // Operands.
    X, Y value.Value // integer scalar or integer vector

    // Type of result produced by the instruction.
    Typ types.Type
    // (optional) Overflow flags.
    OverflowFlags []enum.OverflowFlag
    // (optional) Metadata.
    Metadata
}

InstShl is an LLVM IR shl instruction.

func NewShl Uses

func NewShl(x, y value.Value) *InstShl

NewShl returns a new shl instruction based on the given operands.

func (*InstShl) LLString Uses

func (inst *InstShl) LLString() string

LLString returns the LLVM syntax representation of the instruction.

'shl' OverflowFlags=OverflowFlag* X=TypeValue ',' Y=Value Metadata=(',' MetadataAttachment)+?

func (*InstShl) String Uses

func (inst *InstShl) String() string

String returns the LLVM syntax representation of the instruction as a type-value pair.

func (*InstShl) Type Uses

func (inst *InstShl) Type() types.Type

Type returns the type of the instruction.

type InstShuffleVector Uses

type InstShuffleVector struct {
    // Name of local variable associated with the result.
    LocalIdent
    // Vectors.
    X, Y value.Value
    // Shuffle mask.
    Mask value.Value

    // Type of result produced by the instruction.
    Typ *types.VectorType
    // (optional) Metadata.
    Metadata
}

InstShuffleVector is an LLVM IR shufflevector instruction.

func NewShuffleVector Uses

func NewShuffleVector(x, y, mask value.Value) *InstShuffleVector

NewShuffleVector returns a new shufflevector instruction based on the given vectors and shuffle mask.

func (*InstShuffleVector) LLString Uses

func (inst *InstShuffleVector) LLString() string

LLString returns the LLVM syntax representation of the instruction.

'shufflevector' X=TypeValue ',' Y=TypeValue ',' Mask=TypeValue Metadata=(',' MetadataAttachment)+?

func (*InstShuffleVector) String Uses

func (inst *InstShuffleVector) String() string

String returns the LLVM syntax representation of the instruction as a type-value pair.

func (*InstShuffleVector) Type Uses

func (inst *InstShuffleVector) Type() types.Type

Type returns the type of the instruction.

type InstStore Uses

type InstStore struct {
    // Source value.
    Src value.Value
    // Destination address.
    Dst value.Value

    // (optional) Atomic.
    Atomic bool
    // (optional) Volatile.
    Volatile bool
    // (optional) Sync scope; empty if not present.
    SyncScope string
    // (optional) Atomic memory ordering constraints; zero if not present.
    Ordering enum.AtomicOrdering
    // (optional) Alignment; zero if not present.
    Align Align
    // (optional) Metadata.
    Metadata
}

InstStore is an LLVM IR store instruction.

func NewStore Uses

func NewStore(src, dst value.Value) *InstStore

NewStore returns a new store instruction based on the given source value and destination address.

func (*InstStore) LLString Uses

func (inst *InstStore) LLString() string

LLString returns the LLVM syntax representation of the instruction.

Store instruction.

'store' Volatileopt Src=TypeValue ',' Dst=TypeValue (',' Align)? Metadata=(',' MetadataAttachment)+?

Atomic store instruction.

'store' Atomic Volatileopt Src=TypeValue ',' Dst=TypeValue SyncScopeopt Ordering=AtomicOrdering (',' Align)? Metadata=(',' MetadataAttachment)+?

type InstSub Uses

type InstSub struct {
    // Name of local variable associated with the result.
    LocalIdent
    // Operands.
    X, Y value.Value // integer scalar or integer vector

    // Type of result produced by the instruction.
    Typ types.Type
    // (optional) Overflow flags.
    OverflowFlags []enum.OverflowFlag
    // (optional) Metadata.
    Metadata
}

InstSub is an LLVM IR sub instruction.

func NewSub Uses

func NewSub(x, y value.Value) *InstSub

NewSub returns a new sub instruction based on the given operands.

func (*InstSub) LLString Uses

func (inst *InstSub) LLString() string

LLString returns the LLVM syntax representation of the instruction.

'sub' OverflowFlags=OverflowFlag* X=TypeValue ',' Y=Value Metadata=(',' MetadataAttachment)+?

func (*InstSub) String Uses

func (inst *InstSub) String() string

String returns the LLVM syntax representation of the instruction as a type-value pair.

func (*InstSub) Type Uses

func (inst *InstSub) Type() types.Type

Type returns the type of the instruction.

type InstTrunc Uses

type InstTrunc struct {
    // Name of local variable associated with the result.
    LocalIdent
    // Value before conversion.
    From value.Value
    // Type after conversion.
    To  types.Type

    // (optional) Metadata.
    Metadata
}

InstTrunc is an LLVM IR trunc instruction.

func NewTrunc Uses

func NewTrunc(from value.Value, to types.Type) *InstTrunc

NewTrunc returns a new trunc instruction based on the given source value and target type.

func (*InstTrunc) LLString Uses

func (inst *InstTrunc) LLString() string

LLString returns the LLVM syntax representation of the instruction.

'trunc' From=TypeValue 'to' To=Type Metadata=(',' MetadataAttachment)+?

func (*InstTrunc) String Uses

func (inst *InstTrunc) String() string

String returns the LLVM syntax representation of the instruction as a type-value pair.

func (*InstTrunc) Type Uses

func (inst *InstTrunc) Type() types.Type

Type returns the type of the instruction.

type InstUDiv Uses

type InstUDiv struct {
    // Name of local variable associated with the result.
    LocalIdent
    // Operands.
    X, Y value.Value // integer scalar or integer vector

    // Type of result produced by the instruction.
    Typ types.Type
    // (optional) Exact.
    Exact bool
    // (optional) Metadata.
    Metadata
}

InstUDiv is an LLVM IR udiv instruction.

func NewUDiv Uses

func NewUDiv(x, y value.Value) *InstUDiv

NewUDiv returns a new udiv instruction based on the given operands.

func (*InstUDiv) LLString Uses

func (inst *InstUDiv) LLString() string

LLString returns the LLVM syntax representation of the instruction.

'udiv' Exactopt X=TypeValue ',' Y=Value Metadata=(',' MetadataAttachment)+?

func (*InstUDiv) String Uses

func (inst *InstUDiv) String() string

String returns the LLVM syntax representation of the instruction as a type-value pair.

func (*InstUDiv) Type Uses

func (inst *InstUDiv) Type() types.Type

Type returns the type of the instruction.

type InstUIToFP Uses

type InstUIToFP struct {
    // Name of local variable associated with the result.
    LocalIdent
    // Value before conversion.
    From value.Value
    // Type after conversion.
    To  types.Type

    // (optional) Metadata.
    Metadata
}

InstUIToFP is an LLVM IR uitofp instruction.

func NewUIToFP Uses

func NewUIToFP(from value.Value, to types.Type) *InstUIToFP

NewUIToFP returns a new uitofp instruction based on the given source value and target type.

func (*InstUIToFP) LLString Uses

func (inst *InstUIToFP) LLString() string

LLString returns the LLVM syntax representation of the instruction.

'uitofp' From=TypeValue 'to' To=Type Metadata=(',' MetadataAttachment)+?

func (*InstUIToFP) String Uses

func (inst *InstUIToFP) String() string

String returns the LLVM syntax representation of the instruction as a type-value pair.

func (*InstUIToFP) Type Uses

func (inst *InstUIToFP) Type() types.Type

Type returns the type of the instruction.

type InstURem Uses

type InstURem struct {
    // Name of local variable associated with the result.
    LocalIdent
    // Operands.
    X, Y value.Value // integer scalar or integer vector

    // Type of result produced by the instruction.
    Typ types.Type
    // (optional) Metadata.
    Metadata
}

InstURem is an LLVM IR urem instruction.

func NewURem Uses

func NewURem(x, y value.Value) *InstURem

NewURem returns a new urem instruction based on the given operands.

func (*InstURem) LLString Uses

func (inst *InstURem) LLString() string

LLString returns the LLVM syntax representation of the instruction.

'urem' X=TypeValue ',' Y=Value Metadata=(',' MetadataAttachment)+?

func (*InstURem) String Uses

func (inst *InstURem) String() string

String returns the LLVM syntax representation of the instruction as a type-value pair.

func (*InstURem) Type Uses

func (inst *InstURem) Type() types.Type

Type returns the type of the instruction.

type InstVAArg Uses

type InstVAArg struct {
    // Name of local variable associated with the result.
    LocalIdent
    // Variable argument list.
    ArgList value.Value
    // Argument type.
    ArgType types.Type

    // (optional) Metadata.
    Metadata
}

InstVAArg is an LLVM IR va_arg instruction.

func NewVAArg Uses

func NewVAArg(argList value.Value, argType types.Type) *InstVAArg

NewVAArg returns a new va_arg instruction based on the given variable argument list and argument type.

func (*InstVAArg) LLString Uses

func (inst *InstVAArg) LLString() string

LLString returns the LLVM syntax representation of the instruction.

'va_arg' ArgList=TypeValue ',' ArgType=Type Metadata=(',' MetadataAttachment)+?

func (*InstVAArg) String Uses

func (inst *InstVAArg) String() string

String returns the LLVM syntax representation of the instruction as a type-value pair.

func (*InstVAArg) Type Uses

func (inst *InstVAArg) Type() types.Type

Type returns the type of the instruction.

type InstXor Uses

type InstXor struct {
    // Name of local variable associated with the result.
    LocalIdent
    // Operands.
    X, Y value.Value // integer scalars or vectors

    // Type of result produced by the instruction.
    Typ types.Type
    // (optional) Metadata.
    Metadata
}

InstXor is an LLVM IR xor instruction.

func NewXor Uses

func NewXor(x, y value.Value) *InstXor

NewXor returns a new xor instruction based on the given operands.

func (*InstXor) LLString Uses

func (inst *InstXor) LLString() string

LLString returns the LLVM syntax representation of the instruction.

'xor' X=TypeValue ',' Y=Value Metadata=(',' MetadataAttachment)+?

func (*InstXor) String Uses

func (inst *InstXor) String() string

String returns the LLVM syntax representation of the instruction as a type-value pair.

func (*InstXor) Type Uses

func (inst *InstXor) Type() types.Type

Type returns the type of the instruction.

type InstZExt Uses

type InstZExt struct {
    // Name of local variable associated with the result.
    LocalIdent
    // Value before conversion.
    From value.Value
    // Type after conversion.
    To  types.Type

    // (optional) Metadata.
    Metadata
}

InstZExt is an LLVM IR zext instruction.

func NewZExt Uses

func NewZExt(from value.Value, to types.Type) *InstZExt

NewZExt returns a new zext instruction based on the given source value and target type.

func (*InstZExt) LLString Uses

func (inst *InstZExt) LLString() string

LLString returns the LLVM syntax representation of the instruction.

'zext' From=TypeValue 'to' To=Type Metadata=(',' MetadataAttachment)+?

func (*InstZExt) String Uses

func (inst *InstZExt) String() string

String returns the LLVM syntax representation of the instruction as a type-value pair.

func (*InstZExt) Type Uses

func (inst *InstZExt) Type() types.Type

Type returns the type of the instruction.

type Instruction Uses

type Instruction interface {
    LLStringer
    // contains filtered or unexported methods
}

Instruction is an LLVM IR instruction. All instructions (except store and fence) implement the value.Named interface and may thus be used directly as values.

An Instruction has one of the following underlying types.

Unary instructions

https://llvm.org/docs/LangRef.html#unary-operations

*ir.InstFNeg   // https://godoc.org/github.com/llir/llvm/ir#InstFNeg

Binary instructions

https://llvm.org/docs/LangRef.html#binary-operations

*ir.InstAdd    // https://godoc.org/github.com/llir/llvm/ir#InstAdd
*ir.InstFAdd   // https://godoc.org/github.com/llir/llvm/ir#InstFAdd
*ir.InstSub    // https://godoc.org/github.com/llir/llvm/ir#InstSub
*ir.InstFSub   // https://godoc.org/github.com/llir/llvm/ir#InstFSub
*ir.InstMul    // https://godoc.org/github.com/llir/llvm/ir#InstMul
*ir.InstFMul   // https://godoc.org/github.com/llir/llvm/ir#InstFMul
*ir.InstUDiv   // https://godoc.org/github.com/llir/llvm/ir#InstUDiv
*ir.InstSDiv   // https://godoc.org/github.com/llir/llvm/ir#InstSDiv
*ir.InstFDiv   // https://godoc.org/github.com/llir/llvm/ir#InstFDiv
*ir.InstURem   // https://godoc.org/github.com/llir/llvm/ir#InstURem
*ir.InstSRem   // https://godoc.org/github.com/llir/llvm/ir#InstSRem
*ir.InstFRem   // https://godoc.org/github.com/llir/llvm/ir#InstFRem

Bitwise instructions

https://llvm.org/docs/LangRef.html#bitwise-binary-operations

*ir.InstShl    // https://godoc.org/github.com/llir/llvm/ir#InstShl
*ir.InstLShr   // https://godoc.org/github.com/llir/llvm/ir#InstLShr
*ir.InstAShr   // https://godoc.org/github.com/llir/llvm/ir#InstAShr
*ir.InstAnd    // https://godoc.org/github.com/llir/llvm/ir#InstAnd
*ir.InstOr     // https://godoc.org/github.com/llir/llvm/ir#InstOr
*ir.InstXor    // https://godoc.org/github.com/llir/llvm/ir#InstXor

Vector instructions

https://llvm.org/docs/LangRef.html#vector-operations

*ir.InstExtractElement   // https://godoc.org/github.com/llir/llvm/ir#InstExtractElement
*ir.InstInsertElement    // https://godoc.org/github.com/llir/llvm/ir#InstInsertElement
*ir.InstShuffleVector    // https://godoc.org/github.com/llir/llvm/ir#InstShuffleVector

Aggregate instructions

https://llvm.org/docs/LangRef.html#aggregate-operations

*ir.InstExtractValue   // https://godoc.org/github.com/llir/llvm/ir#InstExtractValue
*ir.InstInsertValue    // https://godoc.org/github.com/llir/llvm/ir#InstInsertValue

Memory instructions

https://llvm.org/docs/LangRef.html#memory-access-and-addressing-operations

*ir.InstAlloca          // https://godoc.org/github.com/llir/llvm/ir#InstAlloca
*ir.InstLoad            // https://godoc.org/github.com/llir/llvm/ir#InstLoad
*ir.InstStore           // https://godoc.org/github.com/llir/llvm/ir#InstStore
*ir.InstFence           // https://godoc.org/github.com/llir/llvm/ir#InstFence
*ir.InstCmpXchg         // https://godoc.org/github.com/llir/llvm/ir#InstCmpXchg
*ir.InstAtomicRMW       // https://godoc.org/github.com/llir/llvm/ir#InstAtomicRMW
*ir.InstGetElementPtr   // https://godoc.org/github.com/llir/llvm/ir#InstGetElementPtr

Conversion instructions

https://llvm.org/docs/LangRef.html#conversion-operations

*ir.InstTrunc           // https://godoc.org/github.com/llir/llvm/ir#InstTrunc
*ir.InstZExt            // https://godoc.org/github.com/llir/llvm/ir#InstZExt
*ir.InstSExt            // https://godoc.org/github.com/llir/llvm/ir#InstSExt
*ir.InstFPTrunc         // https://godoc.org/github.com/llir/llvm/ir#InstFPTrunc
*ir.InstFPExt           // https://godoc.org/github.com/llir/llvm/ir#InstFPExt
*ir.InstFPToUI          // https://godoc.org/github.com/llir/llvm/ir#InstFPToUI
*ir.InstFPToSI          // https://godoc.org/github.com/llir/llvm/ir#InstFPToSI
*ir.InstUIToFP          // https://godoc.org/github.com/llir/llvm/ir#InstUIToFP
*ir.InstSIToFP          // https://godoc.org/github.com/llir/llvm/ir#InstSIToFP
*ir.InstPtrToInt        // https://godoc.org/github.com/llir/llvm/ir#InstPtrToInt
*ir.InstIntToPtr        // https://godoc.org/github.com/llir/llvm/ir#InstIntToPtr
*ir.InstBitCast         // https://godoc.org/github.com/llir/llvm/ir#InstBitCast
*ir.InstAddrSpaceCast   // https://godoc.org/github.com/llir/llvm/ir#InstAddrSpaceCast

Other instructions

https://llvm.org/docs/LangRef.html#other-operations

*ir.InstICmp         // https://godoc.org/github.com/llir/llvm/ir#InstICmp
*ir.InstFCmp         // https://godoc.org/github.com/llir/llvm/ir#InstFCmp
*ir.InstPhi          // https://godoc.org/github.com/llir/llvm/ir#InstPhi
*ir.InstSelect       // https://godoc.org/github.com/llir/llvm/ir#InstSelect
*ir.InstFreeze       // https://godoc.org/github.com/llir/llvm/ir#InstFreeze
*ir.InstCall         // https://godoc.org/github.com/llir/llvm/ir#InstCall
*ir.InstVAArg        // https://godoc.org/github.com/llir/llvm/ir#InstVAArg
*ir.InstLandingPad   // https://godoc.org/github.com/llir/llvm/ir#InstLandingPad
*ir.InstCatchPad     // https://godoc.org/github.com/llir/llvm/ir#InstCatchPad
*ir.InstCleanupPad   // https://godoc.org/github.com/llir/llvm/ir#InstCleanupPad

type LLStringer Uses

type LLStringer interface {
    // LLString returns the LLVM syntax representation of the value.
    LLString() string
}

LLStringer is implemented by any value that has a LLString method, which defines the LLVM syntax for that value.

type LocalIdent Uses

type LocalIdent struct {
    LocalName string
    LocalID   int64
}

LocalIdent is a local identifier.

func NewLocalIdent Uses

func NewLocalIdent(ident string) LocalIdent

NewLocalIdent returns a new local identifier based on the given string. An unnamed local ID is used if ident is an integer, and a local name otherwise.

func (LocalIdent) ID Uses

func (i LocalIdent) ID() int64

ID returns the ID of the local identifier.

func (LocalIdent) Ident Uses

func (i LocalIdent) Ident() string

Ident returns the identifier associated with the local identifier.

func (LocalIdent) IsUnnamed Uses

func (i LocalIdent) IsUnnamed() bool

IsUnnamed reports whether the local identifier is unnamed.

func (LocalIdent) Name Uses

func (i LocalIdent) Name() string

Name returns the name of the local identifier.

If unnamed, the local ID is returned. To distinguish numeric names from unnamed IDs, numeric names are quoted.

func (*LocalIdent) SetID Uses

func (i *LocalIdent) SetID(id int64)

SetID sets the ID of the local identifier.

func (*LocalIdent) SetName Uses

func (i *LocalIdent) SetName(name string)

SetName sets the name of the local identifier.

type Metadata Uses

type Metadata []*metadata.Attachment

Metadata is a list of metadata attachments.

func (Metadata) MDAttachments Uses

func (mds Metadata) MDAttachments() []*metadata.Attachment

MDAttachments returns the metadata attachments of the value.

type Module Uses

type Module struct {
    // Type definitions.
    TypeDefs []types.Type
    // Global variable declarations and definitions.
    Globals []*Global
    // Function declarations and definitions.
    Funcs []*Func

    // (optional) Source filename; or empty if not present.
    SourceFilename string
    // (optional) Data layout; or empty if not present.
    DataLayout string
    // (optional) Target triple; or empty if not present.
    TargetTriple string
    // (optional) Module-level inline assembly.
    ModuleAsms []string
    // (optional) Comdat definitions.
    ComdatDefs []*ComdatDef
    // (optional) Aliases.
    Aliases []*Alias
    // (optional) IFuncs.
    IFuncs []*IFunc
    // (optional) Attribute group definitions.
    AttrGroupDefs []*AttrGroupDef
    // (optional) Named metadata definitions.
    NamedMetadataDefs map[string]*metadata.NamedDef
    // (optional) Metadata definitions.
    MetadataDefs []metadata.Definition
    // (optional) Use-list order directives.
    UseListOrders []*UseListOrder
    // (optional) Basic block specific use-list order directives.
    UseListOrderBBs []*UseListOrderBB
    // contains filtered or unexported fields
}

Module is an LLVM IR module, which consists of top-level declarations and definitions.

func NewModule Uses

func NewModule() *Module

NewModule returns a new LLVM IR module.

func (*Module) AssignGlobalIDs Uses

func (m *Module) AssignGlobalIDs() error

AssignGlobalIDs assigns IDs to unnamed global variables.

func (*Module) AssignMetadataIDs Uses

func (m *Module) AssignMetadataIDs() error

AssignMetadataIDs assigns metadata IDs to the unnamed metadata definitions of the module.

func (*Module) NewAlias Uses

func (m *Module) NewAlias(name string, aliasee constant.Constant) *Alias

NewAlias appends a new alias to the module based on the given alias name and aliasee.

func (*Module) NewFunc Uses

func (m *Module) NewFunc(name string, retType types.Type, params ...*Param) *Func

NewFunc appends a new function to the module based on the given function name, return type and function parameters.

The Parent field of the function is set to m.

func (*Module) NewGlobal Uses

func (m *Module) NewGlobal(name string, contentType types.Type) *Global

NewGlobal appends a new global variable declaration to the module based on the given global variable name and content type.

func (*Module) NewGlobalDef Uses

func (m *Module) NewGlobalDef(name string, init constant.Constant) *Global

NewGlobalDef appends a new global variable definition to the module based on the given global variable name and initial value.

func (*Module) NewIFunc Uses

func (m *Module) NewIFunc(name string, resolver constant.Constant) *IFunc

NewIFunc appends a new indirect function to the module based on the given IFunc name and resolver.

func (*Module) NewTypeDef Uses

func (m *Module) NewTypeDef(name string, typ types.Type) types.Type

NewTypeDef appends a new type definition to the module based on the given type name and underlying type.

func (*Module) String Uses

func (m *Module) String() string

String returns the string representation of the module in LLVM IR assembly syntax.

func (*Module) WriteTo Uses

func (m *Module) WriteTo(w io.Writer) (n int64, err error)

WriteTo write the string representation of the module in LLVM IR assembly syntax to w.

type OperandBundle Uses

type OperandBundle struct {
    Tag    string
    Inputs []value.Value
}

OperandBundle is a tagged set of SSA values associated with a call-site.

func NewOperandBundle Uses

func NewOperandBundle(tag string, inputs ...value.Value) *OperandBundle

NewOperandBundle returns a new operand bundle based on the given tag and input values.

func (*OperandBundle) String Uses

func (o *OperandBundle) String() string

String returns a string representation of the operand bundle.

type Param Uses

type Param struct {
    // (optional) Parameter name (without '%' prefix).
    LocalIdent
    // Parameter type.
    Typ types.Type

    // (optional) Parameter attributes.
    Attrs []ParamAttribute
}

Param is an LLVM IR function parameter.

func NewParam Uses

func NewParam(name string, typ types.Type) *Param

NewParam returns a new function parameter based on the given name and type.

func (*Param) LLString Uses

func (p *Param) LLString() string

LLString returns the LLVM syntax representation of the function parameter.

Typ=Type Attrs=ParamAttribute* Name=LocalIdent?

func (*Param) String Uses

func (p *Param) String() string

String returns the LLVM syntax representation of the function parameter as a type-value pair.

func (*Param) Type Uses

func (p *Param) Type() types.Type

Type returns the type of the function parameter.

type ParamAttribute Uses

type ParamAttribute interface {
    fmt.Stringer
    // IsParamAttribute ensures that only parameter attributes can be assigned to
    // the ir.ParamAttribute interface.
    IsParamAttribute()
}

ParamAttribute is a parameter attribute.

A ParamAttribute has one of the following underlying types.

ir.AttrString
ir.AttrPair
ir.Align
ir.Dereferenceable
enum.ParamAttr

type ReturnAttribute Uses

type ReturnAttribute interface {
    fmt.Stringer
    // IsReturnAttribute ensures that only return attributes can be assigned to
    // the ir.ReturnAttribute interface.
    IsReturnAttribute()
}

ReturnAttribute is a return attribute.

A ReturnAttribute has one of the following underlying types.

ir.AttrString
ir.AttrPair
ir.Align
ir.Dereferenceable
enum.ReturnAttr

type TermBr Uses

type TermBr struct {
    // Target branch.
    Target value.Value // *ir.Block

    // Successor basic blocks of the terminator.
    Successors []*Block
    // (optional) Metadata.
    Metadata
}

TermBr is an unconditional LLVM IR br terminator.

func NewBr Uses

func NewBr(target *Block) *TermBr

NewBr returns a new unconditional br terminator based on the given target basic block.

func (*TermBr) LLString Uses

func (term *TermBr) LLString() string

LLString returns the LLVM syntax representation of the terminator.

'br' Target=Label Metadata=(',' MetadataAttachment)+?

func (*TermBr) Succs Uses

func (term *TermBr) Succs() []*Block

Succs returns the successor basic blocks of the terminator.

type TermCallBr Uses

type TermCallBr struct {
    // Name of local variable associated with the result.
    LocalIdent
    // Callee function.
    // TODO: specify the set of underlying types of Callee.
    Callee value.Value
    // Function arguments.
    //
    // Arg has one of the following underlying types:
    //    value.Value
    //    TODO: add metadata value?
    Args []value.Value
    // Normal control flow return point.
    NormalRetTarget value.Value // *ir.Block
    // Other control flow return points.
    OtherRetTargets []value.Value // slice of *ir.Block

    // Type of result produced by the terminator.
    Typ types.Type
    // Successor basic blocks of the terminator.
    Successors []*Block
    // (optional) Calling convention; zero if not present.
    CallingConv enum.CallingConv
    // (optional) Return attributes.
    ReturnAttrs []ReturnAttribute
    // (optional) Address space; zero if not present.
    AddrSpace types.AddrSpace
    // (optional) Function attributes.
    FuncAttrs []FuncAttribute
    // (optional) Operand bundles.
    OperandBundles []*OperandBundle
    // (optional) Metadata.
    Metadata
}

TermCallBr is an LLVM IR callbr terminator.

func NewCallBr Uses

func NewCallBr(callee value.Value, args []value.Value, normalRetTarget *Block, otherRetTargets ...*Block) *TermCallBr

NewCallBr returns a new callbr terminator based on the given callee, function arguments and control flow return points for normal and exceptional execution.

TODO: specify the set of underlying types of callee.

func (*TermCallBr) LLString Uses

func (term *TermCallBr) LLString() string

LLString returns the LLVM syntax representation of the terminator.

'callbr' CallingConvopt ReturnAttrs=ReturnAttribute* AddrSpaceopt Typ=Type Callee=Value '(' Args ')' FuncAttrs=FuncAttribute* OperandBundles=('[' (OperandBundle separator ',')+ ']')? 'to' NormalRetTarget=Label '[' OtherRetTargets=(Label separator ',')* ']' Metadata=(',' MetadataAttachment)+?

func (*TermCallBr) Sig Uses

func (term *TermCallBr) Sig() *types.FuncType

Sig returns the function signature of the callee.

func (*TermCallBr) String Uses

func (term *TermCallBr) String() string

String returns the LLVM syntax representation of the terminator as a type- value pair.

func (*TermCallBr) Succs Uses

func (term *TermCallBr) Succs() []*Block

Succs returns the successor basic blocks of the terminator.

func (*TermCallBr) Type Uses

func (term *TermCallBr) Type() types.Type

Type returns the type of the terminator.

type TermCatchRet Uses

type TermCatchRet struct {
    // Exit catchpad.
    CatchPad value.Value // *ir.InstCatchPad
    // Target basic block to transfer control flow to.
    Target value.Value // *ir.Block

    // Successor basic blocks of the terminator.
    Successors []*Block
    // (optional) Metadata.
    Metadata
}

TermCatchRet is an LLVM IR catchret terminator, which catches an in-flight exception from CatchPad and returns control flow to normal at Target.

func NewCatchRet Uses

func NewCatchRet(catchPad *InstCatchPad, target *Block) *TermCatchRet

NewCatchRet returns a new catchret terminator based on the given exit catchpad and target basic block.

func (*TermCatchRet) LLString Uses

func (term *TermCatchRet) LLString() string

LLString returns the LLVM syntax representation of the terminator.

'catchret' 'from' CatchPad=Value 'to' Target=Label Metadata=(',' MetadataAttachment)+?

func (*TermCatchRet) Succs Uses

func (term *TermCatchRet) Succs() []*Block

Succs returns the successor basic blocks of the terminator.

type TermCatchSwitch Uses

type TermCatchSwitch struct {
    // Name of local variable associated with the result.
    LocalIdent
    // Parent exception pad.
    ParentPad value.Value // ir.ExceptionPad
    // Exception handlers.
    Handlers []value.Value // []*ir.Block
    // Optional default target basic block to transfer control flow to; or nil to
    // unwind to caller function.
    DefaultUnwindTarget value.Value // *ir.Block or nil

    // Successor basic blocks of the terminator.
    Successors []*Block
    // (optional) Metadata.
    Metadata
}

TermCatchSwitch is an LLVM IR catchswitch terminator.

func NewCatchSwitch Uses

func NewCatchSwitch(parentPad ExceptionPad, handlers []*Block, defaultUnwindTarget *Block) *TermCatchSwitch

NewCatchSwitch returns a new catchswitch terminator based on the given parent exception pad, exception handlers and optional default unwind target. If defaultUnwindTarget is nil, catchswitch unwinds to caller function.

func (*TermCatchSwitch) LLString Uses

func (term *TermCatchSwitch) LLString() string

LLString returns the LLVM syntax representation of the terminator.

'catchswitch' 'within' ParentPad=ExceptionPad '[' Handlers=Handlers ']' 'unwind' DefaultUnwindTarget=UnwindTarget Metadata=(',' MetadataAttachment)+?

func (*TermCatchSwitch) String Uses

func (term *TermCatchSwitch) String() string

String returns the LLVM syntax representation of the terminator as a type- value pair.

func (*TermCatchSwitch) Succs Uses

func (term *TermCatchSwitch) Succs() []*Block

Succs returns the successor basic blocks of the terminator.

func (*TermCatchSwitch) Type Uses

func (term *TermCatchSwitch) Type() types.Type

Type returns the type of the terminator.

type TermCleanupRet Uses

type TermCleanupRet struct {
    // Exit cleanuppad.
    CleanupPad value.Value // *ir.InstCleanupPad
    // Optional target basic block to transfer control flow to; or nil to unwind
    // to caller function.
    UnwindTarget value.Value // *ir.Block or nil

    // Successor basic blocks of the terminator.
    Successors []*Block
    // (optional) Metadata.
    Metadata
}

TermCleanupRet is an LLVM IR cleanupret terminator, which indicates that the personality function of a cleanuppad has finished and transfers control flow to an optional target basic block or unwinds to the caller function.

func NewCleanupRet Uses

func NewCleanupRet(cleanupPad *InstCleanupPad, unwindTarget *Block) *TermCleanupRet

NewCleanupRet returns a new cleanupret terminator based on the given exit cleanuppad and optional unwind target. If unwindTarget is nil, cleanupret unwinds to caller function.

func (*TermCleanupRet) LLString Uses

func (term *TermCleanupRet) LLString() string

LLString returns the LLVM syntax representation of the terminator.

'cleanupret' 'from' CleanupPad=Value 'unwind' UnwindTarget Metadata=(',' MetadataAttachment)+?

func (*TermCleanupRet) Succs Uses

func (term *TermCleanupRet) Succs() []*Block

Succs returns the successor basic blocks of the terminator.

type TermCondBr Uses

type TermCondBr struct {
    // Branching condition.
    Cond value.Value
    // True condition target branch.
    TargetTrue value.Value // *ir.Block
    // False condition target branch.
    TargetFalse value.Value // *ir.Block

    // Successor basic blocks of the terminator.
    Successors []*Block
    // (optional) Metadata.
    Metadata
}

TermCondBr is a conditional LLVM IR br terminator.

func NewCondBr Uses

func NewCondBr(cond value.Value, targetTrue, targetFalse *Block) *TermCondBr

NewCondBr returns a new conditional br terminator based on the given branching condition and conditional target basic blocks.

func (*TermCondBr) LLString Uses

func (term *TermCondBr) LLString() string

LLString returns the LLVM syntax representation of the terminator.

'br' CondTyp=IntType Cond=Value ',' TargetTrue=Label ',' TargetFalse=Label Metadata=(',' MetadataAttachment)+?

func (*TermCondBr) Succs Uses

func (term *TermCondBr) Succs() []*Block

Succs returns the successor basic blocks of the terminator.

type TermIndirectBr Uses

type TermIndirectBr struct {
    // Target address.
    Addr value.Value // blockaddress
    // Set of valid target basic blocks.
    ValidTargets []value.Value // slice of *ir.Block

    // Successor basic blocks of the terminator.
    Successors []*Block
    // (optional) Metadata.
    Metadata
}

TermIndirectBr is an LLVM IR indirectbr terminator.

func NewIndirectBr Uses

func NewIndirectBr(addr constant.Constant, validTargets ...*Block) *TermIndirectBr

NewIndirectBr returns a new indirectbr terminator based on the given target address (derived from a blockaddress constant) and set of valid target basic blocks.

func (*TermIndirectBr) LLString Uses

func (term *TermIndirectBr) LLString() string

LLString returns the LLVM syntax representation of the terminator.

'indirectbr' Addr=TypeValue ',' '[' ValidTargets=(Label separator ',')* ']' Metadata=(',' MetadataAttachment)+?

func (*TermIndirectBr) Succs Uses

func (term *TermIndirectBr) Succs() []*Block

Succs returns the successor basic blocks of the terminator.

type TermInvoke Uses

type TermInvoke struct {
    // Name of local variable associated with the result.
    LocalIdent
    // Invokee (callee function).
    // TODO: specify the set of underlying types of Invokee.
    Invokee value.Value
    // Function arguments.
    //
    // Arg has one of the following underlying types:
    //    value.Value
    //    TODO: add metadata value?
    Args []value.Value
    // Normal control flow return point.
    NormalRetTarget value.Value // *ir.Block
    // Exception control flow return point.
    ExceptionRetTarget value.Value // *ir.Block

    // Type of result produced by the terminator.
    Typ types.Type
    // Successor basic blocks of the terminator.
    Successors []*Block
    // (optional) Calling convention; zero if not present.
    CallingConv enum.CallingConv
    // (optional) Return attributes.
    ReturnAttrs []ReturnAttribute
    // (optional) Address space; zero if not present.
    AddrSpace types.AddrSpace
    // (optional) Function attributes.
    FuncAttrs []FuncAttribute
    // (optional) Operand bundles.
    OperandBundles []*OperandBundle
    // (optional) Metadata.
    Metadata
}

TermInvoke is an LLVM IR invoke terminator.

func NewInvoke Uses

func NewInvoke(invokee value.Value, args []value.Value, normalRetTarget, exceptionRetTarget *Block) *TermInvoke

NewInvoke returns a new invoke terminator based on the given invokee, function arguments and control flow return points for normal and exceptional execution.

TODO: specify the set of underlying types of invokee.

func (*TermInvoke) LLString Uses

func (term *TermInvoke) LLString() string

LLString returns the LLVM syntax representation of the terminator.

'invoke' CallingConvopt ReturnAttrs=ReturnAttribute* AddrSpaceopt Typ=Type Invokee=Value '(' Args ')' FuncAttrs=FuncAttribute* OperandBundles=('[' (OperandBundle separator ',')+ ']')? 'to' NormalRetTarget=Label 'unwind' ExceptionRetTarget=Label Metadata=(',' MetadataAttachment)+?

func (*TermInvoke) Sig Uses

func (term *TermInvoke) Sig() *types.FuncType

Sig returns the function signature of the invokee.

func (*TermInvoke) String Uses

func (term *TermInvoke) String() string

String returns the LLVM syntax representation of the terminator as a type- value pair.

func (*TermInvoke) Succs Uses

func (term *TermInvoke) Succs() []*Block

Succs returns the successor basic blocks of the terminator.

func (*TermInvoke) Type Uses

func (term *TermInvoke) Type() types.Type

Type returns the type of the terminator.

type TermResume Uses

type TermResume struct {
    // Exception argument to propagate.
    X   value.Value

    // (optional) Metadata.
    Metadata
}

TermResume is an LLVM IR resume terminator.

func NewResume Uses

func NewResume(x value.Value) *TermResume

NewResume returns a new resume terminator based on the given exception argument to propagate.

func (*TermResume) LLString Uses

func (term *TermResume) LLString() string

LLString returns the LLVM syntax representation of the terminator.

'resume' X=TypeValue Metadata=(',' MetadataAttachment)+?

func (*TermResume) Succs Uses

func (term *TermResume) Succs() []*Block

Succs returns the successor basic blocks of the terminator.

type TermRet Uses

type TermRet struct {
    // Return value; or nil if void return.
    X   value.Value

    // (optional) Metadata.
    Metadata
}

TermRet is an LLVM IR ret terminator.

func NewRet Uses

func NewRet(x value.Value) *TermRet

NewRet returns a new ret terminator based on the given return value. A nil return value indicates a void return.

func (*TermRet) LLString Uses

func (term *TermRet) LLString() string

LLString returns the LLVM syntax representation of the terminator.

Void return instruction.

'ret' XTyp=VoidType Metadata=(',' MetadataAttachment)+?

Value return instruction.

'ret' XTyp=ConcreteType X=Value Metadata=(',' MetadataAttachment)+?

func (*TermRet) Succs Uses

func (*TermRet) Succs() []*Block

Succs returns the successor basic blocks of the terminator.

type TermSwitch Uses

type TermSwitch struct {
    // Control variable.
    X   value.Value
    // Default target branch.
    TargetDefault value.Value // *ir.Block
    // Switch cases.
    Cases []*Case

    // Successor basic blocks of the terminator.
    Successors []*Block
    // (optional) Metadata.
    Metadata
}

TermSwitch is an LLVM IR switch terminator.

func NewSwitch Uses

func NewSwitch(x value.Value, targetDefault *Block, cases ...*Case) *TermSwitch

NewSwitch returns a new switch terminator based on the given control variable, default target basic block and switch cases.

func (*TermSwitch) LLString Uses

func (term *TermSwitch) LLString() string

LLString returns the LLVM syntax representation of the terminator.

'switch' X=TypeValue ',' Default=Label '[' Cases=Case* ']' Metadata=(',' MetadataAttachment)+?

func (*TermSwitch) Succs Uses

func (term *TermSwitch) Succs() []*Block

Succs returns the successor basic blocks of the terminator.

type TermUnreachable Uses

type TermUnreachable struct {

    // (optional) Metadata.
    Metadata
}

TermUnreachable is an LLVM IR unreachable terminator.

func NewUnreachable Uses

func NewUnreachable() *TermUnreachable

NewUnreachable returns a new unreachable terminator.

func (*TermUnreachable) LLString Uses

func (term *TermUnreachable) LLString() string

LLString returns the LLVM syntax representation of the terminator.

'unreachable' Metadata=(',' MetadataAttachment)+?

func (*TermUnreachable) Succs Uses

func (term *TermUnreachable) Succs() []*Block

Succs returns the successor basic blocks of the terminator.

type Terminator Uses

type Terminator interface {
    LLStringer
    // Succs returns the successor basic blocks of the terminator.
    Succs() []*Block
}

Terminator is an LLVM IR terminator instruction (a control flow instruction).

A Terminator has one of the following underlying types.

Terminators

https://llvm.org/docs/LangRef.html#terminator-instructions

*ir.TermRet           // https://godoc.org/github.com/llir/llvm/ir#TermRet
*ir.TermBr            // https://godoc.org/github.com/llir/llvm/ir#TermBr
*ir.TermCondBr        // https://godoc.org/github.com/llir/llvm/ir#TermCondBr
*ir.TermSwitch        // https://godoc.org/github.com/llir/llvm/ir#TermSwitch
*ir.TermIndirectBr    // https://godoc.org/github.com/llir/llvm/ir#TermIndirectBr
*ir.TermInvoke        // https://godoc.org/github.com/llir/llvm/ir#TermInvoke
*ir.TermCallBr        // https://godoc.org/github.com/llir/llvm/ir#TermCallBr
*ir.TermResume        // https://godoc.org/github.com/llir/llvm/ir#TermResume
*ir.TermCatchSwitch   // https://godoc.org/github.com/llir/llvm/ir#TermCatchSwitch
*ir.TermCatchRet      // https://godoc.org/github.com/llir/llvm/ir#TermCatchRet
*ir.TermCleanupRet    // https://godoc.org/github.com/llir/llvm/ir#TermCleanupRet
*ir.TermUnreachable   // https://godoc.org/github.com/llir/llvm/ir#TermUnreachable

type UseListOrder Uses

type UseListOrder struct {
    // Value.
    Value value.Value
    // Use-list order.
    Indices []uint64
}

UseListOrder is a use-list order directive.

func (*UseListOrder) String Uses

func (u *UseListOrder) String() string

String returns the string representation of the use-list order directive definition.

type UseListOrderBB Uses

type UseListOrderBB struct {
    // Function.
    Func *Func
    // Basic block.
    Block *Block
    // Use-list order.
    Indices []uint64
}

UseListOrderBB is a basic block specific use-list order directive.

func (*UseListOrderBB) String Uses

func (u *UseListOrderBB) String() string

String returns the string representation of the basic block specific use- list order directive definition.

Directories

PathSynopsis
constantPackage constant implements values representing immutable LLVM IR constants.
enumPackage enum defines enumerate types of LLVM IR.
metadataPackage metadata provides access to LLVM IR metadata.
typesPackage types declares the data types of LLVM IR.
valuePackage value provides a definition of LLVM IR values.

Package ir imports 14 packages (graph) and is imported by 31 packages. Updated 2020-11-25. Refresh now. Tools for package owners.