llvm

package
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 31, 2024 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Overview

Package llvm provides a way to build and write out LLVM modules.

This package was created for the express purpose of generating LLVM IR. A good portion of this code was taken from https://github.com/llir/llvm. As such, it does not contain features such as sanity checking and IR parsing. The main reason this package was created was to add support for opaque pointers and drop support for the legacy typed ones.

Index

Constants

This section is empty.

Variables

View Source
var (
	// Basic types.
	Pointer  = &TypePointer{}  // ptr
	Void     = &TypeVoid{}     // void
	MMX      = &TypeMMX{}      // x86_mmx
	Label    = &TypeLabel{}    // label
	Token    = &TypeToken{}    // token
	Metadata = &TypeMetadata{} // metadata
	// Integer types.
	I1    = &TypeInt{BitSize: 1}    // i1
	I2    = &TypeInt{BitSize: 2}    // i2
	I3    = &TypeInt{BitSize: 3}    // i3
	I4    = &TypeInt{BitSize: 4}    // i4
	I5    = &TypeInt{BitSize: 5}    // i5
	I6    = &TypeInt{BitSize: 6}    // i6
	I7    = &TypeInt{BitSize: 7}    // i7
	I8    = &TypeInt{BitSize: 8}    // i8
	I16   = &TypeInt{BitSize: 16}   // i16
	I32   = &TypeInt{BitSize: 32}   // i32
	I64   = &TypeInt{BitSize: 64}   // i64
	I128  = &TypeInt{BitSize: 128}  // i128
	I256  = &TypeInt{BitSize: 256}  // i256
	I512  = &TypeInt{BitSize: 512}  // i512
	I1024 = &TypeInt{BitSize: 1024} // i1024
	// Floating-point types.
	Half      = &TypeFloat{Kind: FloatKindHalf}      // half
	Float     = &TypeFloat{Kind: FloatKindFloat}     // float
	Double    = &TypeFloat{Kind: FloatKindDouble}    // double
	X86_FP80  = &TypeFloat{Kind: FloatKindX86_FP80}  // x86_fp80
	FP128     = &TypeFloat{Kind: FloatKindFP128}     // fp128
	PPC_FP128 = &TypeFloat{Kind: FloatKindPPC_FP128} // ppc_fp128

)

Functions

func EncodeFunctionName

func EncodeFunctionName(name string) string

func EncodeGlobalName

func EncodeGlobalName(name string) string

func EncodeLabelName

func EncodeLabelName(name string) string

func EncodeRegisterName

func EncodeRegisterName(name string) string

func EncodeTypeName

func EncodeTypeName(name string) string

func Escape

func Escape(s []byte, valid func(b byte) bool) string

func EscapeIdent

func EscapeIdent(s string) string

func EscapeQuoteString

func EscapeQuoteString(s []byte) string

func EscapeString

func EscapeString(s []byte) string

func TypesEqual

func TypesEqual(left, right Type) bool

TypesEqual checks if two types are equal to eachother, even if one or both are nil.

Types

type AbstractInstructionBinary

type AbstractInstructionBinary struct {
	Register
	Token string
	X, Y  Value
}

func (*AbstractInstructionBinary) LLString

func (this *AbstractInstructionBinary) LLString() string

type AbstractInstructionBinaryExact

type AbstractInstructionBinaryExact struct {
	AbstractInstructionBinary
	Exact bool
}

func (*AbstractInstructionBinaryExact) LLString

func (this *AbstractInstructionBinaryExact) LLString() string

type AbstractInstructionBinaryFP

type AbstractInstructionBinaryFP struct {
	AbstractInstructionBinary
	FastMathFlags []FastMathFlag
}

func (*AbstractInstructionBinaryFP) LLString

func (this *AbstractInstructionBinaryFP) LLString() string

type AbstractInstructionCast

type AbstractInstructionCast struct {
	Register
	Token string
	From  Value
	To    Type
}

func (*AbstractInstructionCast) LLString

func (this *AbstractInstructionCast) LLString() string

type AbstractType

type AbstractType struct {
	// contains filtered or unexported fields
}

func (*AbstractType) Name

func (this *AbstractType) Name() string

func (*AbstractType) Named

func (this *AbstractType) Named() bool

func (*AbstractType) SetName

func (this *AbstractType) SetName(name string)

type AddressSpace

type AddressSpace uint64

func (AddressSpace) String

func (space AddressSpace) String() string

type Align

type Align uint64

func (Align) String

func (align Align) String() string

type AtomicOp

type AtomicOp uint8
const (
	AtomicOpAdd  AtomicOp = iota + 1 // add
	AtomicOpAnd                      // and
	AtomicOpFAdd                     // fadd
	AtomicOpFSub                     // fsub
	AtomicOpMax                      // max
	AtomicOpMin                      // min
	AtomicOpNAnd                     // nand
	AtomicOpOr                       // or
	AtomicOpSub                      // sub
	AtomicOpUMax                     // umax
	AtomicOpUMin                     // umin
	AtomicOpXChg                     // xchg
	AtomicOpXor                      // xor
)

func (AtomicOp) String

func (op AtomicOp) String() string

type AtomicOrdering

type AtomicOrdering uint8
const (
	// not_atomic
	AtomicOrderingNone      AtomicOrdering = 0 // none
	AtomicOrderingUnordered AtomicOrdering = 1 // unordered
	AtomicOrderingMonotonic AtomicOrdering = 2 // monotonic
	//AtomicOrderingConsume AtomicOrdering = 3 // consume
	AtomicOrderingAcquire                AtomicOrdering = 4 // acquire
	AtomicOrderingRelease                AtomicOrdering = 5 // release
	AtomicOrderingAcquireRelease         AtomicOrdering = 6 // acq_rel
	AtomicOrderingSequentiallyConsistent AtomicOrdering = 7 // seq_cst
)

func (AtomicOrdering) String

func (ordering AtomicOrdering) String() string

type Block

type Block struct {
	BlockName    string
	Parent       *Function
	Instructions []Instruction
}

func (*Block) AddInstruction

func (this *Block) AddInstruction(instruction Instruction)

func (*Block) Identifier

func (this *Block) Identifier() string

func (*Block) LLString

func (this *Block) LLString() string

func (*Block) Name

func (this *Block) Name() string

func (*Block) NewAShr

func (this *Block) NewAShr(x, y Value) *InstructionAShr

func (*Block) NewAdd

func (this *Block) NewAdd(x, y Value) *InstructionAdd

func (*Block) NewAddrSpaceCast

func (this *Block) NewAddrSpaceCast(from Value, to Type) *InstructionAddrSpaceCast

func (*Block) NewAlloca

func (this *Block) NewAlloca(element Type) *InstructionAlloca

func (*Block) NewAnd

func (this *Block) NewAnd(x, y Value) *InstructionAnd

func (*Block) NewAtomicRMW

func (this *Block) NewAtomicRMW(op AtomicOp, destination, x Value, ordering AtomicOrdering) *InstructionAtomicRMW

func (*Block) NewBitCast

func (this *Block) NewBitCast(from Value, to Type) *InstructionBitCast

func (*Block) NewBr

func (this *Block) NewBr(target Value) *TerminatorBr

func (*Block) NewCall

func (this *Block) NewCall(callee Value, signature *TypeFunction, args ...Value) *InstructionCall

func (*Block) NewCallBr

func (this *Block) NewCallBr(
	callee Value,
	signature *TypeFunction,
	args []Value,
	normalTarget Value,
	otherTargets ...Value,
) *TerminatorCallBr

func (*Block) NewCatchPad

func (this *Block) NewCatchPad(catchSwitch Value, args ...Value) *InstructionCatchPad

func (*Block) NewCatchRet

func (this *Block) NewCatchRet(catchPad Value, target Value) *TerminatorCatchRet

func (*Block) NewCatchSwitch

func (this *Block) NewCatchSwitch(parentPad Value, handlers []Value, defaultUnwindTarget Value) *TerminatorCatchSwitch

func (*Block) NewCleanupPad

func (this *Block) NewCleanupPad(parentPad Value, args ...Value) *InstructionCleanupPad

func (*Block) NewCleanupRet

func (this *Block) NewCleanupRet(cleanupPad, unwindTarget Value) *TerminatorCleanupRet

func (*Block) NewCmpXchg

func (this *Block) NewCmpXchg(source, against, neww Value, success, failure AtomicOrdering) *InstructionCmpXchg

func (*Block) NewCondBr

func (this *Block) NewCondBr(condition Value, tru, fals Value) *TerminatorCondBr

func (*Block) NewExtractElement

func (this *Block) NewExtractElement(x, index Value) *InstructionExtractElement

func (*Block) NewExtractValue

func (this *Block) NewExtractValue(x Value, indices ...uint64) *InstructionExtractValue

func (*Block) NewFAdd

func (this *Block) NewFAdd(x, y Value) *InstructionFAdd

func (*Block) NewFCmp

func (this *Block) NewFCmp(predicate FPredicate, x, y Value) *InstructionFCmp

func (*Block) NewFDiv

func (this *Block) NewFDiv(x, y Value) *InstructionFDiv

func (*Block) NewFMul

func (this *Block) NewFMul(x, y Value) *InstructionFMul

func (*Block) NewFNeg

func (this *Block) NewFNeg(x Value) *InstructionFNeg

func (*Block) NewFPExt

func (this *Block) NewFPExt(from Value, to Type) *InstructionFPExt

func (*Block) NewFPToSI

func (this *Block) NewFPToSI(from Value, to Type) *InstructionFPToSI

func (*Block) NewFPToUI

func (this *Block) NewFPToUI(from Value, to Type) *InstructionFPToUI

func (*Block) NewFPTrunc

func (this *Block) NewFPTrunc(from Value, to Type) *InstructionFPTrunc

func (*Block) NewFRem

func (this *Block) NewFRem(x, y Value) *InstructionFRem

func (*Block) NewFSub

func (this *Block) NewFSub(x, y Value) *InstructionFSub

func (*Block) NewFence

func (this *Block) NewFence(ordering AtomicOrdering) *InstructionFence

func (*Block) NewFreeze

func (this *Block) NewFreeze(x Value) *InstructionFreeze

func (*Block) NewGetElementPtr

func (this *Block) NewGetElementPtr(element Type, source Value, indices ...Value) *InstructionGetElementPtr

func (*Block) NewICmp

func (this *Block) NewICmp(predicate IPredicate, x, y Value) *InstructionICmp

func (*Block) NewIndirectBr

func (this *Block) NewIndirectBr(address Value, validTargets ...Value) *TerminatorIndirectBr

func (*Block) NewInsertElement

func (this *Block) NewInsertElement(x, element, index Value) *InstructionInsertElement

func (*Block) NewInsertValue

func (this *Block) NewInsertValue(x, element Value, indices ...uint64) *InstructionInsertValue

func (*Block) NewIntToPtr

func (this *Block) NewIntToPtr(from Value, to Type) *InstructionIntToPtr

func (*Block) NewInvoke

func (this *Block) NewInvoke(
	invokee Value,
	signature *TypeFunction,
	args []Value,
	normalTarget Value,
	exceptionTarget Value,
) *TerminatorInvoke

func (*Block) NewLShr

func (this *Block) NewLShr(x, y Value) *InstructionLShr

func (*Block) NewLandingPad

func (this *Block) NewLandingPad(result Type, clauses ...*Clause) *InstructionLandingPad

func (*Block) NewLoad

func (this *Block) NewLoad(element Type, source Value) *InstructionLoad

func (*Block) NewMul

func (this *Block) NewMul(x, y Value) *InstructionMul

func (*Block) NewOr

func (this *Block) NewOr(x, y Value) *InstructionOr

func (*Block) NewPhi

func (this *Block) NewPhi(incoming ...*Incoming) *InstructionPhi

func (*Block) NewPtrToInt

func (this *Block) NewPtrToInt(from Value, to Type) *InstructionPtrToInt

func (*Block) NewResume

func (this *Block) NewResume(x Value) *TerminatorResume

func (*Block) NewRet

func (this *Block) NewRet(x Value) *TerminatorRet

func (*Block) NewSDiv

func (this *Block) NewSDiv(x, y Value) *InstructionSDiv

func (*Block) NewSExt

func (this *Block) NewSExt(from Value, to Type) *InstructionSExt

func (*Block) NewSIToFP

func (this *Block) NewSIToFP(from Value, to Type) *InstructionSExt

func (*Block) NewSRem

func (this *Block) NewSRem(x, y Value) *InstructionSRem

func (*Block) NewSelect

func (this *Block) NewSelect(condition, tru, fals Value) *InstructionSelect

func (*Block) NewShl

func (this *Block) NewShl(x, y Value) *InstructionShl

func (*Block) NewShuffleVector

func (this *Block) NewShuffleVector(x, y, mask Value) *InstructionShuffleVector

func (*Block) NewStore

func (this *Block) NewStore(source, destination Value) *InstructionStore

func (*Block) NewSub

func (this *Block) NewSub(x, y Value) *InstructionSub

func (*Block) NewSwitch

func (this *Block) NewSwitch(x, defaul Value, cases ...*Case) *TerminatorSwitch

func (*Block) NewTrunc

func (this *Block) NewTrunc(from Value, to Type) *InstructionTrunc

func (*Block) NewUDiv

func (this *Block) NewUDiv(x, y Value) *InstructionUDiv

func (*Block) NewUIToFP

func (this *Block) NewUIToFP(from Value, to Type) *InstructionUIToFP

func (*Block) NewURem

func (this *Block) NewURem(x, y Value) *InstructionURem

func (*Block) NewUnreachable

func (this *Block) NewUnreachable() *TerminatorUnreachable

func (*Block) NewVAArg

func (this *Block) NewVAArg(list Value, ty Type) *InstructionVAArg

func (*Block) NewXor

func (this *Block) NewXor(x, y Value) *InstructionXor

func (*Block) NewZext

func (this *Block) NewZext(from Value, to Type) *InstructionZext

func (*Block) SetName

func (this *Block) SetName(name string)

func (*Block) SetTerminator

func (this *Block) SetTerminator(terminator Terminator)

func (*Block) String

func (this *Block) String() string

func (*Block) Terminated

func (this *Block) Terminated() bool

func (*Block) Type

func (this *Block) Type() Type

type Case

type Case struct {
	X      Value
	Target Value
}

func (*Case) IsTerminator

func (*Case) IsTerminator()

func (*Case) String

func (this *Case) String() string

type Clause

type Clause struct {
	Type ClauseType
	X    Value
}

func (*Clause) String

func (this *Clause) String() string

type ClauseType

type ClauseType uint8
const (
	ClauseTypeCatch  ClauseType = iota + 1 // catch
	ClauseTypeFilter                       // filter
)

func (ClauseType) String

func (ty ClauseType) String() string

type Const

type Const interface {
	Value
	IsConstant()
}

type ConstArray

type ConstArray struct {
	Ty       *TypeArray
	Elements []Const
}

func (*ConstArray) Identifier

func (this *ConstArray) Identifier() string

func (*ConstArray) IsConstant

func (*ConstArray) IsConstant()

func (*ConstArray) Name

func (this *ConstArray) Name() string

func (*ConstArray) String

func (this *ConstArray) String() string

func (*ConstArray) Type

func (this *ConstArray) Type() Type

type ConstBlockAddress

type ConstBlockAddress struct {
	Function Const
	Block    Value
}

func (*ConstBlockAddress) Identifier

func (this *ConstBlockAddress) Identifier() string

func (*ConstBlockAddress) IsConstant

func (*ConstBlockAddress) IsConstant()

func (*ConstBlockAddress) Name

func (this *ConstBlockAddress) Name() string

func (*ConstBlockAddress) String

func (this *ConstBlockAddress) String() string

func (*ConstBlockAddress) Type

func (this *ConstBlockAddress) Type() Type

type ConstCharArray

type ConstCharArray struct {
	Ty       *TypeArray
	Elements []byte
}

func (*ConstCharArray) Identifier

func (this *ConstCharArray) Identifier() string

func (*ConstCharArray) IsConstant

func (*ConstCharArray) IsConstant()

func (*ConstCharArray) Name

func (this *ConstCharArray) Name() string

func (*ConstCharArray) String

func (this *ConstCharArray) String() string

func (*ConstCharArray) Type

func (this *ConstCharArray) Type() Type

type ConstDSOLocalEquivalent

type ConstDSOLocalEquivalent struct {
	Function Const
}

func (*ConstDSOLocalEquivalent) Identifier

func (this *ConstDSOLocalEquivalent) Identifier() string

func (*ConstDSOLocalEquivalent) IsConstant

func (*ConstDSOLocalEquivalent) IsConstant()

func (*ConstDSOLocalEquivalent) Name

func (this *ConstDSOLocalEquivalent) Name() string

func (*ConstDSOLocalEquivalent) String

func (this *ConstDSOLocalEquivalent) String() string

func (*ConstDSOLocalEquivalent) Type

func (this *ConstDSOLocalEquivalent) Type() Type

type ConstExpr

type ConstExpr interface {
	Const
	IsExpression()
}

type ConstFloat

type ConstFloat struct {
	Ty    *TypeFloat
	Value *big.Float
	NaN   bool
}

func NewConstFloat

func NewConstFloat(ty *TypeFloat, value float64) *ConstFloat

func (*ConstFloat) Identifier

func (this *ConstFloat) Identifier() string

func (*ConstFloat) IsConstant

func (*ConstFloat) IsConstant()

func (*ConstFloat) Name

func (this *ConstFloat) Name() string

func (*ConstFloat) String

func (this *ConstFloat) String() string

func (*ConstFloat) Type

func (this *ConstFloat) Type() Type

type ConstIndex

type ConstIndex struct {
	Const
	InRange bool
}

func (*ConstIndex) Identifier

func (this *ConstIndex) Identifier() string

func (*ConstIndex) Name

func (this *ConstIndex) Name() string

type ConstInt

type ConstInt struct {
	Ty    *TypeInt
	Value *big.Int
}

func NewConstBool

func NewConstBool(value bool) *ConstInt

func NewConstInt

func NewConstInt(ty *TypeInt, value int64) *ConstInt

func (*ConstInt) Identifier

func (this *ConstInt) Identifier() string

func (*ConstInt) IsConstant

func (*ConstInt) IsConstant()

func (*ConstInt) Name

func (this *ConstInt) Name() string

func (*ConstInt) String

func (this *ConstInt) String() string

func (*ConstInt) Type

func (this *ConstInt) Type() Type

type ConstNoCFI

type ConstNoCFI struct {
	Function Const
}

func (*ConstNoCFI) Identifier

func (this *ConstNoCFI) Identifier() string

func (*ConstNoCFI) IsConstant

func (*ConstNoCFI) IsConstant()

func (*ConstNoCFI) Name

func (this *ConstNoCFI) Name() string

func (*ConstNoCFI) String

func (this *ConstNoCFI) String() string

func (*ConstNoCFI) Type

func (this *ConstNoCFI) Type() Type

type ConstNull

type ConstNull struct{}

func (*ConstNull) Identifier

func (this *ConstNull) Identifier() string

func (*ConstNull) IsConstant

func (*ConstNull) IsConstant()

func (*ConstNull) Name

func (this *ConstNull) Name() string

func (*ConstNull) String

func (this *ConstNull) String() string

func (*ConstNull) Type

func (*ConstNull) Type() Type

type ConstPoison

type ConstPoison struct {
	Ty Type
}

func (*ConstPoison) Identifier

func (this *ConstPoison) Identifier() string

func (*ConstPoison) IsConstant

func (*ConstPoison) IsConstant()

func (*ConstPoison) Name

func (this *ConstPoison) Name() string

func (*ConstPoison) String

func (this *ConstPoison) String() string

func (*ConstPoison) Type

func (this *ConstPoison) Type() Type

type ConstStruct

type ConstStruct struct {
	Ty     *TypeStruct
	Fields []Const
}

func (*ConstStruct) Identifier

func (this *ConstStruct) Identifier() string

func (*ConstStruct) IsConstant

func (*ConstStruct) IsConstant()

func (*ConstStruct) Name

func (this *ConstStruct) Name() string

func (*ConstStruct) String

func (this *ConstStruct) String() string

func (*ConstStruct) Type

func (this *ConstStruct) Type() Type

type ConstUndef

type ConstUndef struct {
	Ty Type
}

func (*ConstUndef) Identifier

func (this *ConstUndef) Identifier() string

func (*ConstUndef) IsConstant

func (*ConstUndef) IsConstant()

func (*ConstUndef) Name

func (this *ConstUndef) Name() string

func (*ConstUndef) String

func (this *ConstUndef) String() string

func (*ConstUndef) Type

func (this *ConstUndef) Type() Type

type ConstVector

type ConstVector struct {
	Ty       *TypeVector
	Elements []Const
}

func (*ConstVector) Identifier

func (this *ConstVector) Identifier() string

func (*ConstVector) IsConstant

func (*ConstVector) IsConstant()

func (*ConstVector) Name

func (this *ConstVector) Name() string

func (*ConstVector) String

func (this *ConstVector) String() string

func (*ConstVector) Type

func (this *ConstVector) Type() Type

type ConstZeroInitializer

type ConstZeroInitializer struct {
	Ty Type
}

func NewConstZeroInitializer

func NewConstZeroInitializer(ty Type) *ConstZeroInitializer

func (*ConstZeroInitializer) Identifier

func (this *ConstZeroInitializer) Identifier() string

func (*ConstZeroInitializer) IsConstant

func (*ConstZeroInitializer) IsConstant()

func (*ConstZeroInitializer) Name

func (this *ConstZeroInitializer) Name() string

func (*ConstZeroInitializer) String

func (this *ConstZeroInitializer) String() string

func (*ConstZeroInitializer) Type

func (this *ConstZeroInitializer) Type() Type

type FPredicate

type FPredicate uint8
const (
	FPredicateFalse FPredicate = iota // false
	FPredicateOEQ                     // oeq
	FPredicateOGE                     // oge
	FPredicateOGT                     // ogt
	FPredicateOLE                     // ole
	FPredicateOLT                     // olt
	FPredicateONE                     // one
	FPredicateORD                     // ord
	FPredicateTrue                    // true
	FPredicateUEQ                     // ueq
	FPredicateUGE                     // uge
	FPredicateUGT                     // ugt
	FPredicateULE                     // ule
	FPredicateULT                     // ult
	FPredicateUNE                     // une
	FPredicateUNO                     // uno
)

func (FPredicate) String

func (predicate FPredicate) String() string

type FastMathFlag

type FastMathFlag uint8
const (
	FastMathFlagAFn      FastMathFlag = iota // afn
	FastMathFlagARcp                         // arcp
	FastMathFlagContract                     // contract
	FastMathFlagFast                         // fast
	FastMathFlagNInf                         // ninf
	FastMathFlagNNaN                         // nnan
	FastMathFlagNSZ                          // nsz
	FastMathFlagReassoc                      // reassoc
)

func (FastMathFlag) String

func (flag FastMathFlag) String() string

type FloatKind

type FloatKind uint8
const (
	// 16-bit floating-point type (IEEE 754 half precision).
	FloatKindHalf FloatKind = iota // half
	// 32-bit floating-point type (IEEE 754 single precision).
	FloatKindFloat // float
	// 64-bit floating-point type (IEEE 754 double precision).
	FloatKindDouble // double
	// 128-bit floating-point type (IEEE 754 quadruple precision).
	FloatKindFP128 // fp128
	// 80-bit floating-point type (x86 extended precision).
	FloatKindX86_FP80 // x86_fp80
	// 128-bit floating-point type (PowerPC double-double arithmetic).
	FloatKindPPC_FP128 // ppc_fp128
)

func (FloatKind) String

func (kind FloatKind) String() string

type Function

type Function struct {
	FunctionName string

	Signature  *TypeFunction
	Parameters []*Parameter
	Blocks     []*Block

	AddressSpace AddressSpace
}

func (*Function) Identifier

func (this *Function) Identifier() string

func (*Function) LLString

func (this *Function) LLString() string

func (*Function) Name

func (this *Function) Name() string

func (*Function) NewBlock

func (this *Function) NewBlock() *Block

func (*Function) SetName

func (this *Function) SetName(name string)

func (*Function) String

func (this *Function) String() string

func (*Function) Type

func (this *Function) Type() Type

type Global

type Global struct {
	Ty         Type
	GlobalName string
	Constant   bool
	Initial    Const

	AddressSpace AddressSpace
}

func (*Global) Identifier

func (this *Global) Identifier() string

func (*Global) IsConstant

func (this *Global) IsConstant()

func (*Global) LLString

func (this *Global) LLString() string

func (*Global) Name

func (this *Global) Name() string

func (*Global) Named

func (this *Global) Named() bool

func (*Global) SetName

func (this *Global) SetName(name string)

func (*Global) String

func (this *Global) String() string

func (*Global) Type

func (this *Global) Type() Type

type IPredicate

type IPredicate uint8
const (
	IPredicateEQ  IPredicate = iota // eq
	IPredicateNE                    // ne
	IPredicateSGE                   // sge
	IPredicateSGT                   // sgt
	IPredicateSLE                   // sle
	IPredicateSLT                   // slt
	IPredicateUGE                   // uge
	IPredicateUGT                   // ugt
	IPredicateULE                   // ule
	IPredicateULT                   // ult
)

func (IPredicate) String

func (predicate IPredicate) String() string

type Incoming

type Incoming struct {
	X           Value
	Predecessor Value
}

func (*Incoming) String

func (this *Incoming) String() string

type Instruction

type Instruction interface {
	LLString() string
}

type InstructionAShr

type InstructionAShr struct {
	AbstractInstructionBinaryExact
}

type InstructionAdd

type InstructionAdd struct {
	AbstractInstructionBinary
}

type InstructionAddrSpaceCast

type InstructionAddrSpaceCast struct {
	AbstractInstructionCast
}

type InstructionAlloca

type InstructionAlloca struct {
	Register
	Element      Type
	Count        Value
	InAlloca     bool
	Align        Align
	AddressSpace AddressSpace
}

func NewAlloca

func NewAlloca(element Type) *InstructionAlloca

func (*InstructionAlloca) LLString

func (this *InstructionAlloca) LLString() string

type InstructionAnd

type InstructionAnd struct {
	AbstractInstructionBinary
}

type InstructionAtomicRMW

type InstructionAtomicRMW struct {
	Register
	Op          AtomicOp
	Destination Value
	X           Value
	Ordering    AtomicOrdering
	Volatile    bool
	SyncScope   string
}

func (*InstructionAtomicRMW) LLString

func (this *InstructionAtomicRMW) LLString() string

type InstructionBitCast

type InstructionBitCast struct {
	Register
	From Value
	To   Type
}

func (*InstructionBitCast) LLString

func (this *InstructionBitCast) LLString() string

type InstructionCall

type InstructionCall struct {
	Register
	Callee       Value
	Signature    *TypeFunction
	Arguments    []Value
	AddressSpace AddressSpace
}

func (*InstructionCall) LLString

func (this *InstructionCall) LLString() string

func (*InstructionCall) Type

func (this *InstructionCall) Type() Type

type InstructionCatchPad

type InstructionCatchPad struct {
	Register
	CatchSwitch Value
	Arguments   []Value
}

func (*InstructionCatchPad) LLString

func (this *InstructionCatchPad) LLString() string

type InstructionCleanupPad

type InstructionCleanupPad struct {
	Register
	ParentPad Value
	Arguments []Value
}

func (*InstructionCleanupPad) LLString

func (this *InstructionCleanupPad) LLString() string

type InstructionCmpXchg

type InstructionCmpXchg struct {
	Register
	Source          Value
	Against         Value
	New             Value
	SuccessOrdering AtomicOrdering
	FailureOrdering AtomicOrdering
	Weak            bool
	Volatile        bool
	SyncScope       string
}

func (*InstructionCmpXchg) LLString

func (this *InstructionCmpXchg) LLString() string

type InstructionExtractElement

type InstructionExtractElement struct {
	Register
	X     Value
	Index Value
}

func (*InstructionExtractElement) LLString

func (this *InstructionExtractElement) LLString() string

type InstructionExtractValue

type InstructionExtractValue struct {
	Register
	X       Value
	Indices []uint64
}

func (*InstructionExtractValue) LLString

func (this *InstructionExtractValue) LLString() string

type InstructionFAdd

type InstructionFAdd struct {
	AbstractInstructionBinaryFP
}

type InstructionFCmp

type InstructionFCmp struct {
	AbstractInstructionBinaryFP
	Predicate FPredicate
}

func (*InstructionFCmp) LLString

func (this *InstructionFCmp) LLString() string

type InstructionFDiv

type InstructionFDiv struct {
	AbstractInstructionBinaryFP
}

type InstructionFMul

type InstructionFMul struct {
	AbstractInstructionBinaryFP
}

type InstructionFNeg

type InstructionFNeg struct {
	Register
	X             Value
	FastMathFlags []FastMathFlag
}

func (*InstructionFNeg) LLString

func (this *InstructionFNeg) LLString() string

type InstructionFPExt

type InstructionFPExt struct {
	AbstractInstructionCast
}

type InstructionFPToSI

type InstructionFPToSI struct {
	AbstractInstructionCast
}

type InstructionFPToUI

type InstructionFPToUI struct {
	AbstractInstructionCast
}

type InstructionFPTrunc

type InstructionFPTrunc struct {
	AbstractInstructionCast
}

type InstructionFRem

type InstructionFRem struct {
	AbstractInstructionBinaryFP
}

type InstructionFSub

type InstructionFSub struct {
	AbstractInstructionBinaryFP
}

type InstructionFence

type InstructionFence struct {
	Ordering  AtomicOrdering
	SyncScope string
}

func (*InstructionFence) LLString

func (this *InstructionFence) LLString() string

type InstructionFreeze

type InstructionFreeze struct {
	Register
	X Value
}

func (*InstructionFreeze) LLString

func (this *InstructionFreeze) LLString() string

type InstructionGetElementPtr

type InstructionGetElementPtr struct {
	Register
	Element  Type
	Source   Value
	Indices  []Value
	InBounds bool
}

func (*InstructionGetElementPtr) LLString

func (this *InstructionGetElementPtr) LLString() string

type InstructionICmp

type InstructionICmp struct {
	AbstractInstructionBinary
	Predicate IPredicate
}

func (*InstructionICmp) LLString

func (this *InstructionICmp) LLString() string

type InstructionInsertElement

type InstructionInsertElement struct {
	Register
	X       Value
	Element Value
	Index   Value
}

func (*InstructionInsertElement) LLString

func (this *InstructionInsertElement) LLString() string

type InstructionInsertValue

type InstructionInsertValue struct {
	Register
	X       Value
	Element Value
	Indices []uint64
}

func (*InstructionInsertValue) LLString

func (this *InstructionInsertValue) LLString() string

type InstructionIntToPtr

type InstructionIntToPtr struct {
	AbstractInstructionCast
}

type InstructionLShr

type InstructionLShr struct {
	AbstractInstructionBinaryExact
}

type InstructionLandingPad

type InstructionLandingPad struct {
	Register
	Cleanup bool
	Clauses []*Clause
}

func (*InstructionLandingPad) LLString

func (this *InstructionLandingPad) LLString() string

type InstructionLoad

type InstructionLoad struct {
	Register
	Source    Value
	Atomic    bool
	Volatile  bool
	SyncScope string
	Ordering  AtomicOrdering
	Align     Align
}

func (*InstructionLoad) LLString

func (this *InstructionLoad) LLString() string

type InstructionMul

type InstructionMul struct {
	AbstractInstructionBinary
	OverflowFlags []OverflowFlag
}

func (*InstructionMul) LLString

func (this *InstructionMul) LLString() string

type InstructionOr

type InstructionOr struct {
	AbstractInstructionBinary
}

type InstructionPhi

type InstructionPhi struct {
	Register
	Incoming      []*Incoming
	FastMathFlags []FastMathFlag
}

func (*InstructionPhi) LLString

func (this *InstructionPhi) LLString() string

type InstructionPtrToInt

type InstructionPtrToInt struct {
	AbstractInstructionCast
}

type InstructionSDiv

type InstructionSDiv struct {
	AbstractInstructionBinary
	Exact bool
}

func (*InstructionSDiv) LLString

func (this *InstructionSDiv) LLString() string

type InstructionSExt

type InstructionSExt struct {
	AbstractInstructionCast
}

type InstructionSIToFP

type InstructionSIToFP struct {
	AbstractInstructionCast
}

type InstructionSRem

type InstructionSRem struct {
	AbstractInstructionBinary
}

type InstructionSelect

type InstructionSelect struct {
	Register
	Condition     Value
	True          Value
	False         Value
	FastMathFlags []FastMathFlag
}

func (*InstructionSelect) LLString

func (this *InstructionSelect) LLString() string

type InstructionShl

type InstructionShl struct {
	AbstractInstructionBinary
	OverflowFlags []OverflowFlag
}

func (*InstructionShl) LLString

func (this *InstructionShl) LLString() string

type InstructionShuffleVector

type InstructionShuffleVector struct {
	Register
	X, Y Value
	Mask Value
}

func (*InstructionShuffleVector) LLString

func (this *InstructionShuffleVector) LLString() string

type InstructionStore

type InstructionStore struct {
	Source, Destination Value
	Atomic              bool
	Volatile            bool
	SyncScope           string
	Ordering            AtomicOrdering
	Align               Align
}

func (*InstructionStore) LLString

func (this *InstructionStore) LLString() string

type InstructionSub

type InstructionSub struct {
	AbstractInstructionBinary
	OverflowFlags []OverflowFlag
}

func (*InstructionSub) LLString

func (this *InstructionSub) LLString() string

type InstructionTrunc

type InstructionTrunc struct {
	AbstractInstructionCast
}

type InstructionUDiv

type InstructionUDiv struct {
	AbstractInstructionBinaryExact
}

type InstructionUIToFP

type InstructionUIToFP struct {
	AbstractInstructionCast
}

type InstructionURem

type InstructionURem struct {
	AbstractInstructionBinary
}

type InstructionVAArg

type InstructionVAArg struct {
	Register
	List Value
}

func (*InstructionVAArg) LLString

func (this *InstructionVAArg) LLString() string

type InstructionXor

type InstructionXor struct {
	AbstractInstructionBinary
}

type InstructionZext

type InstructionZext struct {
	AbstractInstructionCast
}

type Module

type Module struct {
	Types     []Type
	Globals   []*Global
	Functions []*Function
}

func (*Module) NewFunction

func (this *Module) NewFunction(name string, retur Type, parameters ...*Parameter) *Function

func (*Module) NewGlobal

func (this *Module) NewGlobal(name string, ty Type) *Global

func (*Module) NewType

func (this *Module) NewType(name string, ty Type) Type

func (*Module) WriteTo

func (this *Module) WriteTo(writer io.Writer) (wrote int64, err error)

type OverflowFlag

type OverflowFlag uint8
const (
	OverflowFlagNSW OverflowFlag = iota // nsw
	OverflowFlagNUW                     // nuw
)

func (OverflowFlag) String

func (flag OverflowFlag) String() string

type Parameter

type Parameter struct {
	Register
}

func NewParameter

func NewParameter(name string, ty Type) *Parameter

func (*Parameter) LLString

func (this *Parameter) LLString() string

type Register

type Register struct {
	Ty           Type
	RegisterName string
}

func (*Register) Identifier

func (this *Register) Identifier() string

func (*Register) Name

func (this *Register) Name() string

func (*Register) Named

func (this *Register) Named() bool

func (*Register) SetName

func (this *Register) SetName(name string)

func (*Register) String

func (this *Register) String() string

func (*Register) Type

func (this *Register) Type() Type

type Terminator

type Terminator interface {
	IsTerminator()
	Instruction
}

type TerminatorBr

type TerminatorBr struct {
	Target Value
}

func (*TerminatorBr) IsTerminator

func (*TerminatorBr) IsTerminator()

func (*TerminatorBr) LLString

func (this *TerminatorBr) LLString() string

type TerminatorCallBr

type TerminatorCallBr struct {
	InstructionCall
	NormalTarget Value
	OtherTargets []Value
}

func (*TerminatorCallBr) IsTerminator

func (*TerminatorCallBr) IsTerminator()

func (*TerminatorCallBr) LLString

func (this *TerminatorCallBr) LLString() string

type TerminatorCatchRet

type TerminatorCatchRet struct {
	CatchPad Value
	Target   Value
}

func (*TerminatorCatchRet) IsTerminator

func (*TerminatorCatchRet) IsTerminator()

func (*TerminatorCatchRet) LLString

func (this *TerminatorCatchRet) LLString() string

type TerminatorCatchSwitch

type TerminatorCatchSwitch struct {
	Register
	ParentPad           Value
	Handlers            []Value
	DefaultUnwindTarget Value
}

func (*TerminatorCatchSwitch) IsTerminator

func (*TerminatorCatchSwitch) IsTerminator()

func (*TerminatorCatchSwitch) LLString

func (this *TerminatorCatchSwitch) LLString() string

type TerminatorCleanupRet

type TerminatorCleanupRet struct {
	CleanupPad   Value
	UnwindTarget Value
}

func (*TerminatorCleanupRet) IsTerminator

func (*TerminatorCleanupRet) IsTerminator()

func (*TerminatorCleanupRet) LLString

func (this *TerminatorCleanupRet) LLString() string

type TerminatorCondBr

type TerminatorCondBr struct {
	Condition Value
	True      Value
	False     Value
}

func (*TerminatorCondBr) IsTerminator

func (*TerminatorCondBr) IsTerminator()

func (*TerminatorCondBr) LLString

func (this *TerminatorCondBr) LLString() string

type TerminatorIndirectBr

type TerminatorIndirectBr struct {
	Address      Value
	ValidTargets []Value
}

func (*TerminatorIndirectBr) IsTerminator

func (*TerminatorIndirectBr) IsTerminator()

func (*TerminatorIndirectBr) LLString

func (this *TerminatorIndirectBr) LLString() string

type TerminatorInvoke

type TerminatorInvoke struct {
	Register
	Invokee         Value
	Signature       *TypeFunction
	Arguments       []Value
	NormalTarget    Value
	ExceptionTarget Value
	AddressSpace    AddressSpace
}

func (*TerminatorInvoke) IsTerminator

func (*TerminatorInvoke) IsTerminator()

func (*TerminatorInvoke) LLString

func (this *TerminatorInvoke) LLString() string

type TerminatorResume

type TerminatorResume struct {
	X Value
}

func (*TerminatorResume) IsTerminator

func (*TerminatorResume) IsTerminator()

func (*TerminatorResume) LLString

func (this *TerminatorResume) LLString() string

type TerminatorRet

type TerminatorRet struct {
	X Value
}

func (*TerminatorRet) IsTerminator

func (*TerminatorRet) IsTerminator()

func (*TerminatorRet) LLString

func (this *TerminatorRet) LLString() string

type TerminatorSwitch

type TerminatorSwitch struct {
	X       Value
	Default Value
	Cases   []*Case
}

func (*TerminatorSwitch) IsTerminator

func (*TerminatorSwitch) IsTerminator()

func (*TerminatorSwitch) LLString

func (this *TerminatorSwitch) LLString() string

type TerminatorUnreachable

type TerminatorUnreachable struct {
}

func (*TerminatorUnreachable) IsTerminator

func (*TerminatorUnreachable) IsTerminator()

func (*TerminatorUnreachable) LLString

func (this *TerminatorUnreachable) LLString() string

type Type

type Type interface {
	fmt.Stringer
	LLString() string
	Name() string
	SetName(name string)
	Equals(Type) bool
}

func ReduceToBase

func ReduceToBase(ty Type) Type

type TypeArray

type TypeArray struct {
	AbstractType
	Element Type
	Length  uint64
}

func (*TypeArray) Equals

func (this *TypeArray) Equals(ty Type) bool

func (*TypeArray) LLString

func (this *TypeArray) LLString() string

func (*TypeArray) String

func (this *TypeArray) String() string

type TypeDefined

type TypeDefined struct {
	AbstractType
	Source Type
}

func (*TypeDefined) Equals

func (this *TypeDefined) Equals(ty Type) bool

func (*TypeDefined) LLString

func (this *TypeDefined) LLString() string

func (*TypeDefined) String

func (this *TypeDefined) String() string

type TypeFloat

type TypeFloat struct {
	AbstractType
	Kind FloatKind
}

func (*TypeFloat) Equals

func (this *TypeFloat) Equals(ty Type) bool

func (*TypeFloat) LLString

func (this *TypeFloat) LLString() string

func (*TypeFloat) String

func (this *TypeFloat) String() string

type TypeFunction

type TypeFunction struct {
	AbstractType
	Return     Type
	Parameters []Type
	Variadic   bool
}

func (*TypeFunction) Equals

func (this *TypeFunction) Equals(ty Type) bool

func (*TypeFunction) LLString

func (this *TypeFunction) LLString() string

func (*TypeFunction) String

func (this *TypeFunction) String() string

type TypeInt

type TypeInt struct {
	AbstractType
	BitSize uint64
}

func (*TypeInt) Equals

func (this *TypeInt) Equals(ty Type) bool

func (*TypeInt) LLString

func (this *TypeInt) LLString() string

func (*TypeInt) String

func (this *TypeInt) String() string

type TypeLabel

type TypeLabel struct {
	AbstractType
}

func (*TypeLabel) Equals

func (this *TypeLabel) Equals(ty Type) bool

func (*TypeLabel) LLString

func (this *TypeLabel) LLString() string

func (*TypeLabel) String

func (this *TypeLabel) String() string

type TypeMMX

type TypeMMX struct {
	AbstractType
}

func (*TypeMMX) Equals

func (this *TypeMMX) Equals(ty Type) bool

func (*TypeMMX) LLString

func (this *TypeMMX) LLString() string

func (*TypeMMX) String

func (this *TypeMMX) String() string

type TypeMetadata

type TypeMetadata struct {
	AbstractType
}

func (*TypeMetadata) Equals

func (this *TypeMetadata) Equals(ty Type) bool

func (*TypeMetadata) LLString

func (this *TypeMetadata) LLString() string

func (*TypeMetadata) String

func (this *TypeMetadata) String() string

type TypePointer

type TypePointer struct {
	AbstractType
	AddressSpace AddressSpace
}

func (*TypePointer) Equals

func (this *TypePointer) Equals(ty Type) bool

func (*TypePointer) LLString

func (this *TypePointer) LLString() string

func (*TypePointer) String

func (this *TypePointer) String() string

type TypeStruct

type TypeStruct struct {
	AbstractType
	Fields []Type
	Packed bool
	Opaque bool
}

func (*TypeStruct) Equals

func (this *TypeStruct) Equals(ty Type) bool

func (*TypeStruct) LLString

func (this *TypeStruct) LLString() string

func (*TypeStruct) String

func (this *TypeStruct) String() string

type TypeToken

type TypeToken struct {
	AbstractType
}

func (*TypeToken) Equals

func (this *TypeToken) Equals(ty Type) bool

func (*TypeToken) LLString

func (this *TypeToken) LLString() string

func (*TypeToken) String

func (this *TypeToken) String() string

type TypeVector

type TypeVector struct {
	AbstractType
	Element  Type
	Length   uint64
	Scalable bool
}

func (*TypeVector) Equals

func (this *TypeVector) Equals(ty Type) bool

func (*TypeVector) LLString

func (this *TypeVector) LLString() string

func (*TypeVector) String

func (this *TypeVector) String() string

type TypeVoid

type TypeVoid struct {
	AbstractType
}

func (*TypeVoid) Equals

func (this *TypeVoid) Equals(ty Type) bool

func (*TypeVoid) LLString

func (this *TypeVoid) LLString() string

func (*TypeVoid) String

func (this *TypeVoid) String() string

type Value

type Value interface {
	fmt.Stringer
	Type() Type
	Name() string
	Identifier() string
}

type ValueInstruction

type ValueInstruction interface {
	fmt.Stringer
	Instruction
	Value
	SetName(name string)
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL