constant

package
v0.3.6 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2022 License: 0BSD, Unlicense Imports: 18 Imported by: 68

Documentation

Overview

Package constant implements values representing immutable LLVM IR constants.

Index

Constants

This section is empty.

Variables

View Source
var (
	// None token constant.
	None = &NoneToken{} // none
	// Boolean constants.
	True  = NewInt(types.I1, 1) // true
	False = NewInt(types.I1, 0) // false
)

Convenience constants.

Functions

This section is empty.

Types

type Array

type Array struct {
	// Array type.
	Typ *types.ArrayType
	// Array elements.
	Elems []Constant
}

Array is an LLVM IR array constant.

func NewArray

func NewArray(t *types.ArrayType, elems ...Constant) *Array

NewArray returns a new array constant based on the given array type and elements. The array type is infered from the type of the elements if t is nil.

func (*Array) Ident

func (c *Array) Ident() string

Ident returns the identifier associated with the constant.

func (*Array) IsConstant

func (*Array) IsConstant()

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

func (*Array) String

func (c *Array) String() string

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

func (*Array) Type

func (c *Array) Type() types.Type

Type returns the type of the constant.

type BlockAddress

type BlockAddress struct {
	// Parent function.
	Func Constant // *ir.Func
	// Basic block to take address of.
	Block value.Named // *ir.Block
}

BlockAddress is an LLVM IR blockaddress constant.

func NewBlockAddress

func NewBlockAddress(f Constant, block value.Named) *BlockAddress

NewBlockAddress returns a new blockaddress constant based on the given parent function and basic block.

func (*BlockAddress) Ident

func (c *BlockAddress) Ident() string

Ident returns the identifier associated with the constant.

func (*BlockAddress) IsConstant

func (*BlockAddress) IsConstant()

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

func (*BlockAddress) String

func (c *BlockAddress) String() string

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

func (*BlockAddress) Type

func (c *BlockAddress) Type() types.Type

Type returns the type of the constant.

type CharArray

type CharArray struct {
	// Array type.
	Typ *types.ArrayType
	// Character array contents.
	X []byte
}

CharArray is an LLVM IR character array constant.

func NewCharArray

func NewCharArray(x []byte) *CharArray

NewCharArray returns a new character array constant based on the given character array contents.

func NewCharArrayFromString

func NewCharArrayFromString(s string) *CharArray

NewCharArrayFromString returns a new character array constant based on the given UTF-8 string contents.

func (*CharArray) Ident

func (c *CharArray) Ident() string

Ident returns the identifier associated with the constant.

func (*CharArray) IsConstant

func (*CharArray) IsConstant()

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

func (*CharArray) String

func (c *CharArray) String() string

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

func (*CharArray) Type

func (c *CharArray) Type() types.Type

Type returns the type of the constant.

type Constant

type Constant interface {
	value.Value
	// IsConstant ensures that only constants can be assigned to the
	// constant.Constant interface.
	IsConstant()
}

Constant is an LLVM IR constant; a value that is immutable at runtime, such as an integer or floating-point literal, or the address of a function or global variable.

A Constant has one of the following underlying types.

Simple constants

https://llvm.org/docs/LangRef.html#simple-constants

*constant.Int         // https://pkg.go.dev/github.com/llir/llvm/ir/constant#Int
*constant.Float       // https://pkg.go.dev/github.com/llir/llvm/ir/constant#Float
*constant.Null        // https://pkg.go.dev/github.com/llir/llvm/ir/constant#Null
*constant.NoneToken   // https://pkg.go.dev/github.com/llir/llvm/ir/constant#NoneToken

Complex constants

https://llvm.org/docs/LangRef.html#complex-constants

*constant.Struct            // https://pkg.go.dev/github.com/llir/llvm/ir/constant#Struct
*constant.Array             // https://pkg.go.dev/github.com/llir/llvm/ir/constant#Array
*constant.CharArray         // https://pkg.go.dev/github.com/llir/llvm/ir/constant#CharArray
*constant.Vector            // https://pkg.go.dev/github.com/llir/llvm/ir/constant#Vector
*constant.ZeroInitializer   // https://pkg.go.dev/github.com/llir/llvm/ir/constant#ZeroInitializer
TODO: include metadata node?

Global variable and function addresses

https://llvm.org/docs/LangRef.html#global-variable-and-function-addresses

*ir.Global   // https://pkg.go.dev/github.com/llir/llvm/ir#Global
*ir.Func     // https://pkg.go.dev/github.com/llir/llvm/ir#Func
*ir.Alias    // https://pkg.go.dev/github.com/llir/llvm/ir#Alias
*ir.IFunc    // https://pkg.go.dev/github.com/llir/llvm/ir#IFunc

Undefined values

https://llvm.org/docs/LangRef.html#undefined-values

*constant.Undef   // https://pkg.go.dev/github.com/llir/llvm/ir/constant#Undef

Poison values

https://llvm.org/docs/LangRef.html#poison-values

*constant.Poison   // https://pkg.go.dev/github.com/llir/llvm/ir/constant#Poison

Addresses of basic blocks

https://llvm.org/docs/LangRef.html#addresses-of-basic-blocks

*constant.BlockAddress   // https://pkg.go.dev/github.com/llir/llvm/ir/constant#BlockAddress

Constant expressions

https://llvm.org/docs/LangRef.html#constant-expressions

constant.Expression   // https://pkg.go.dev/github.com/llir/llvm/ir/constant#Expression

type DSOLocalEquivalent added in v0.3.6

type DSOLocalEquivalent struct {
	// Underlying function.
	Func Constant // *ir.Func
}

DSOLocalEquivalent is an LLVM IR dso_local_equivalent constant; a constant representing a function which is functionally equivalent to a given function, but is always defined in the current linkage unit.

ref: https://llvm.org/docs/LangRef.html#dso-local-equivalent

func NewDSOLocalEquivalent added in v0.3.6

func NewDSOLocalEquivalent(f Constant) *DSOLocalEquivalent

NewDSOLocalEquivalent returns a new dso_local_equivalent constant based on the given function.

func (*DSOLocalEquivalent) Ident added in v0.3.6

func (c *DSOLocalEquivalent) Ident() string

Ident returns the identifier associated with the constant.

func (*DSOLocalEquivalent) IsConstant added in v0.3.6

func (*DSOLocalEquivalent) IsConstant()

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

func (*DSOLocalEquivalent) String added in v0.3.6

func (c *DSOLocalEquivalent) String() string

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

func (*DSOLocalEquivalent) Type added in v0.3.6

func (c *DSOLocalEquivalent) Type() types.Type

Type returns the type of the constant.

type ExprAShr

type ExprAShr struct {
	// Operands.
	X, Y Constant // integer scalars or vectors

	// Type of result produced by the constant expression.
	Typ types.Type
	// (optional) The result is a poison value if any of the bits shifted out are
	// non-zero.
	Exact bool
}

ExprAShr is an LLVM IR ashr expression.

func NewAShr

func NewAShr(x, y Constant) *ExprAShr

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

func (*ExprAShr) Ident

func (e *ExprAShr) Ident() string

Ident returns the identifier associated with the constant expression.

func (*ExprAShr) IsConstant

func (*ExprAShr) IsConstant()

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

func (*ExprAShr) IsExpression added in v0.3.4

func (*ExprAShr) IsExpression()

IsExpression ensures that only constants expressions can be assigned to the constant.Expression interface.

func (*ExprAShr) String

func (e *ExprAShr) String() string

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

func (*ExprAShr) Type

func (e *ExprAShr) Type() types.Type

Type returns the type of the constant expression.

type ExprAdd

type ExprAdd struct {
	// Operands.
	X, Y Constant // integer scalar or vector constants

	// Type of result produced by the constant expression.
	Typ types.Type
	// (optional) Integer overflow flags.
	OverflowFlags []enum.OverflowFlag
}

ExprAdd is an LLVM IR add expression.

func NewAdd

func NewAdd(x, y Constant) *ExprAdd

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

func (*ExprAdd) Ident

func (e *ExprAdd) Ident() string

Ident returns the identifier associated with the constant expression.

func (*ExprAdd) IsConstant

func (*ExprAdd) IsConstant()

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

func (*ExprAdd) IsExpression added in v0.3.4

func (*ExprAdd) IsExpression()

IsExpression ensures that only constants expressions can be assigned to the constant.Expression interface.

func (*ExprAdd) String

func (e *ExprAdd) String() string

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

func (*ExprAdd) Type

func (e *ExprAdd) Type() types.Type

Type returns the type of the constant expression.

type ExprAddrSpaceCast

type ExprAddrSpaceCast struct {
	// Value before conversion.
	From Constant
	// Type after conversion.
	To types.Type
}

ExprAddrSpaceCast is an LLVM IR addrspacecast expression.

func NewAddrSpaceCast

func NewAddrSpaceCast(from Constant, to types.Type) *ExprAddrSpaceCast

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

func (*ExprAddrSpaceCast) Ident

func (e *ExprAddrSpaceCast) Ident() string

Ident returns the identifier associated with the constant expression.

func (*ExprAddrSpaceCast) IsConstant

func (*ExprAddrSpaceCast) IsConstant()

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

func (*ExprAddrSpaceCast) IsExpression added in v0.3.4

func (*ExprAddrSpaceCast) IsExpression()

IsExpression ensures that only constants expressions can be assigned to the constant.Expression interface.

func (*ExprAddrSpaceCast) String

func (e *ExprAddrSpaceCast) String() string

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

func (*ExprAddrSpaceCast) Type

func (e *ExprAddrSpaceCast) Type() types.Type

Type returns the type of the constant expression.

type ExprAnd

type ExprAnd struct {
	// Operands.
	X, Y Constant // integer scalars or vectors

	// Type of result produced by the constant expression.
	Typ types.Type
}

ExprAnd is an LLVM IR and expression.

func NewAnd

func NewAnd(x, y Constant) *ExprAnd

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

func (*ExprAnd) Ident

func (e *ExprAnd) Ident() string

Ident returns the identifier associated with the constant expression.

func (*ExprAnd) IsConstant

func (*ExprAnd) IsConstant()

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

func (*ExprAnd) IsExpression added in v0.3.4

func (*ExprAnd) IsExpression()

IsExpression ensures that only constants expressions can be assigned to the constant.Expression interface.

func (*ExprAnd) String

func (e *ExprAnd) String() string

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

func (*ExprAnd) Type

func (e *ExprAnd) Type() types.Type

Type returns the type of the constant expression.

type ExprBitCast

type ExprBitCast struct {
	// Value before conversion.
	From Constant
	// Type after conversion.
	To types.Type
}

ExprBitCast is an LLVM IR bitcast expression.

func NewBitCast

func NewBitCast(from Constant, to types.Type) *ExprBitCast

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

func (*ExprBitCast) Ident

func (e *ExprBitCast) Ident() string

Ident returns the identifier associated with the constant expression.

func (*ExprBitCast) IsConstant

func (*ExprBitCast) IsConstant()

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

func (*ExprBitCast) IsExpression added in v0.3.4

func (*ExprBitCast) IsExpression()

IsExpression ensures that only constants expressions can be assigned to the constant.Expression interface.

func (*ExprBitCast) String

func (e *ExprBitCast) String() string

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

func (*ExprBitCast) Type

func (e *ExprBitCast) Type() types.Type

Type returns the type of the constant expression.

type ExprExtractElement

type ExprExtractElement struct {
	// Vector.
	X Constant
	// Element index.
	Index Constant

	// Type of result produced by the constant expression.
	Typ types.Type
}

ExprExtractElement is an LLVM IR extractelement expression.

func NewExtractElement

func NewExtractElement(x, index Constant) *ExprExtractElement

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

func (*ExprExtractElement) Ident

func (e *ExprExtractElement) Ident() string

Ident returns the identifier associated with the constant expression.

func (*ExprExtractElement) IsConstant

func (*ExprExtractElement) IsConstant()

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

func (*ExprExtractElement) IsExpression added in v0.3.4

func (*ExprExtractElement) IsExpression()

IsExpression ensures that only constants expressions can be assigned to the constant.Expression interface.

func (*ExprExtractElement) String

func (e *ExprExtractElement) String() string

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

func (*ExprExtractElement) Type

func (e *ExprExtractElement) Type() types.Type

Type returns the type of the constant expression.

type ExprExtractValue

type ExprExtractValue struct {
	// Aggregate value.
	X Constant
	// Element indices.
	Indices []uint64

	// Type of result produced by the constant expression.
	Typ types.Type
}

ExprExtractValue is an LLVM IR extractvalue expression.

func NewExtractValue

func NewExtractValue(x Constant, indices ...uint64) *ExprExtractValue

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

func (*ExprExtractValue) Ident

func (e *ExprExtractValue) Ident() string

Ident returns the identifier associated with the constant expression.

func (*ExprExtractValue) IsConstant

func (*ExprExtractValue) IsConstant()

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

func (*ExprExtractValue) IsExpression added in v0.3.4

func (*ExprExtractValue) IsExpression()

IsExpression ensures that only constants expressions can be assigned to the constant.Expression interface.

func (*ExprExtractValue) String

func (e *ExprExtractValue) String() string

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

func (*ExprExtractValue) Type

func (e *ExprExtractValue) Type() types.Type

Type returns the type of the constant expression.

type ExprFAdd

type ExprFAdd struct {
	// Operands.
	X, Y Constant // floating-point scalar or vector constants

	// Type of result produced by the constant expression.
	Typ types.Type
}

ExprFAdd is an LLVM IR fadd expression.

func NewFAdd

func NewFAdd(x, y Constant) *ExprFAdd

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

func (*ExprFAdd) Ident

func (e *ExprFAdd) Ident() string

Ident returns the identifier associated with the constant expression.

func (*ExprFAdd) IsConstant

func (*ExprFAdd) IsConstant()

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

func (*ExprFAdd) IsExpression added in v0.3.4

func (*ExprFAdd) IsExpression()

IsExpression ensures that only constants expressions can be assigned to the constant.Expression interface.

func (*ExprFAdd) String

func (e *ExprFAdd) String() string

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

func (*ExprFAdd) Type

func (e *ExprFAdd) Type() types.Type

Type returns the type of the constant expression.

type ExprFCmp

type ExprFCmp struct {
	// Floating-point comparison predicate.
	Pred enum.FPred
	// Floating-point scalar or vector operands.
	X, Y Constant

	// Type of result produced by the constant expression.
	Typ types.Type
}

ExprFCmp is an LLVM IR fcmp expression.

func NewFCmp

func NewFCmp(pred enum.FPred, x, y Constant) *ExprFCmp

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

func (*ExprFCmp) Ident

func (e *ExprFCmp) Ident() string

Ident returns the identifier associated with the constant expression.

func (*ExprFCmp) IsConstant

func (*ExprFCmp) IsConstant()

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

func (*ExprFCmp) IsExpression added in v0.3.4

func (*ExprFCmp) IsExpression()

IsExpression ensures that only constants expressions can be assigned to the constant.Expression interface.

func (*ExprFCmp) String

func (e *ExprFCmp) String() string

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

func (*ExprFCmp) Type

func (e *ExprFCmp) Type() types.Type

Type returns the type of the constant expression.

type ExprFDiv

type ExprFDiv struct {
	// Operands.
	X, Y Constant // floating-point scalar or vector constants

	// Type of result produced by the constant expression.
	Typ types.Type
}

ExprFDiv is an LLVM IR fdiv expression.

func NewFDiv

func NewFDiv(x, y Constant) *ExprFDiv

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

func (*ExprFDiv) Ident

func (e *ExprFDiv) Ident() string

Ident returns the identifier associated with the constant expression.

func (*ExprFDiv) IsConstant

func (*ExprFDiv) IsConstant()

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

func (*ExprFDiv) IsExpression added in v0.3.4

func (*ExprFDiv) IsExpression()

IsExpression ensures that only constants expressions can be assigned to the constant.Expression interface.

func (*ExprFDiv) String

func (e *ExprFDiv) String() string

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

func (*ExprFDiv) Type

func (e *ExprFDiv) Type() types.Type

Type returns the type of the constant expression.

type ExprFMul

type ExprFMul struct {
	// Operands.
	X, Y Constant // floating-point scalar or vector constants

	// Type of result produced by the constant expression.
	Typ types.Type
}

ExprFMul is an LLVM IR fmul expression.

func NewFMul

func NewFMul(x, y Constant) *ExprFMul

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

func (*ExprFMul) Ident

func (e *ExprFMul) Ident() string

Ident returns the identifier associated with the constant expression.

func (*ExprFMul) IsConstant

func (*ExprFMul) IsConstant()

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

func (*ExprFMul) IsExpression added in v0.3.4

func (*ExprFMul) IsExpression()

IsExpression ensures that only constants expressions can be assigned to the constant.Expression interface.

func (*ExprFMul) String

func (e *ExprFMul) String() string

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

func (*ExprFMul) Type

func (e *ExprFMul) Type() types.Type

Type returns the type of the constant expression.

type ExprFNeg

type ExprFNeg struct {
	// Operand.
	X Constant // floating-point scalar or vector constant

	// Type of result produced by the constant expression.
	Typ types.Type
}

ExprFNeg is an LLVM IR fneg expression.

func NewFNeg

func NewFNeg(x Constant) *ExprFNeg

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

func (*ExprFNeg) Ident

func (e *ExprFNeg) Ident() string

Ident returns the identifier associated with the constant expression.

func (*ExprFNeg) IsConstant

func (*ExprFNeg) IsConstant()

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

func (*ExprFNeg) IsExpression added in v0.3.4

func (*ExprFNeg) IsExpression()

IsExpression ensures that only constants expressions can be assigned to the constant.Expression interface.

func (*ExprFNeg) String

func (e *ExprFNeg) String() string

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

func (*ExprFNeg) Type

func (e *ExprFNeg) Type() types.Type

Type returns the type of the constant expression.

type ExprFPExt

type ExprFPExt struct {
	// Value before conversion.
	From Constant
	// Type after conversion.
	To types.Type
}

ExprFPExt is an LLVM IR fpext expression.

func NewFPExt

func NewFPExt(from Constant, to types.Type) *ExprFPExt

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

func (*ExprFPExt) Ident

func (e *ExprFPExt) Ident() string

Ident returns the identifier associated with the constant expression.

func (*ExprFPExt) IsConstant

func (*ExprFPExt) IsConstant()

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

func (*ExprFPExt) IsExpression added in v0.3.4

func (*ExprFPExt) IsExpression()

IsExpression ensures that only constants expressions can be assigned to the constant.Expression interface.

func (*ExprFPExt) String

func (e *ExprFPExt) String() string

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

func (*ExprFPExt) Type

func (e *ExprFPExt) Type() types.Type

Type returns the type of the constant expression.

type ExprFPToSI

type ExprFPToSI struct {
	// Value before conversion.
	From Constant
	// Type after conversion.
	To types.Type
}

ExprFPToSI is an LLVM IR fptosi expression.

func NewFPToSI

func NewFPToSI(from Constant, to types.Type) *ExprFPToSI

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

func (*ExprFPToSI) Ident

func (e *ExprFPToSI) Ident() string

Ident returns the identifier associated with the constant expression.

func (*ExprFPToSI) IsConstant

func (*ExprFPToSI) IsConstant()

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

func (*ExprFPToSI) IsExpression added in v0.3.4

func (*ExprFPToSI) IsExpression()

IsExpression ensures that only constants expressions can be assigned to the constant.Expression interface.

func (*ExprFPToSI) String

func (e *ExprFPToSI) String() string

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

func (*ExprFPToSI) Type

func (e *ExprFPToSI) Type() types.Type

Type returns the type of the constant expression.

type ExprFPToUI

type ExprFPToUI struct {
	// Value before conversion.
	From Constant
	// Type after conversion.
	To types.Type
}

ExprFPToUI is an LLVM IR fptoui expression.

func NewFPToUI

func NewFPToUI(from Constant, to types.Type) *ExprFPToUI

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

func (*ExprFPToUI) Ident

func (e *ExprFPToUI) Ident() string

Ident returns the identifier associated with the constant expression.

func (*ExprFPToUI) IsConstant

func (*ExprFPToUI) IsConstant()

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

func (*ExprFPToUI) IsExpression added in v0.3.4

func (*ExprFPToUI) IsExpression()

IsExpression ensures that only constants expressions can be assigned to the constant.Expression interface.

func (*ExprFPToUI) String

func (e *ExprFPToUI) String() string

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

func (*ExprFPToUI) Type

func (e *ExprFPToUI) Type() types.Type

Type returns the type of the constant expression.

type ExprFPTrunc

type ExprFPTrunc struct {
	// Value before conversion.
	From Constant
	// Type after conversion.
	To types.Type
}

ExprFPTrunc is an LLVM IR fptrunc expression.

func NewFPTrunc

func NewFPTrunc(from Constant, to types.Type) *ExprFPTrunc

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

func (*ExprFPTrunc) Ident

func (e *ExprFPTrunc) Ident() string

Ident returns the identifier associated with the constant expression.

func (*ExprFPTrunc) IsConstant

func (*ExprFPTrunc) IsConstant()

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

func (*ExprFPTrunc) IsExpression added in v0.3.4

func (*ExprFPTrunc) IsExpression()

IsExpression ensures that only constants expressions can be assigned to the constant.Expression interface.

func (*ExprFPTrunc) String

func (e *ExprFPTrunc) String() string

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

func (*ExprFPTrunc) Type

func (e *ExprFPTrunc) Type() types.Type

Type returns the type of the constant expression.

type ExprFRem

type ExprFRem struct {
	// Operands.
	X, Y Constant // floating-point scalar or vector constants

	// Type of result produced by the constant expression.
	Typ types.Type
}

ExprFRem is an LLVM IR frem expression.

func NewFRem

func NewFRem(x, y Constant) *ExprFRem

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

func (*ExprFRem) Ident

func (e *ExprFRem) Ident() string

Ident returns the identifier associated with the constant expression.

func (*ExprFRem) IsConstant

func (*ExprFRem) IsConstant()

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

func (*ExprFRem) IsExpression added in v0.3.4

func (*ExprFRem) IsExpression()

IsExpression ensures that only constants expressions can be assigned to the constant.Expression interface.

func (*ExprFRem) String

func (e *ExprFRem) String() string

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

func (*ExprFRem) Type

func (e *ExprFRem) Type() types.Type

Type returns the type of the constant expression.

type ExprFSub

type ExprFSub struct {
	// Operands.
	X, Y Constant // floating-point scalar or vector constants

	// Type of result produced by the constant expression.
	Typ types.Type
}

ExprFSub is an LLVM IR fsub expression.

func NewFSub

func NewFSub(x, y Constant) *ExprFSub

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

func (*ExprFSub) Ident

func (e *ExprFSub) Ident() string

Ident returns the identifier associated with the constant expression.

func (*ExprFSub) IsConstant

func (*ExprFSub) IsConstant()

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

func (*ExprFSub) IsExpression added in v0.3.4

func (*ExprFSub) IsExpression()

IsExpression ensures that only constants expressions can be assigned to the constant.Expression interface.

func (*ExprFSub) String

func (e *ExprFSub) String() string

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

func (*ExprFSub) Type

func (e *ExprFSub) Type() types.Type

Type returns the type of the constant expression.

type ExprGetElementPtr

type ExprGetElementPtr struct {
	// Element type.
	ElemType types.Type
	// Source address.
	Src Constant
	// Element indicies.
	Indices []Constant // *Int, *Vector or *Index

	// Type of result produced by the constant expression.
	Typ types.Type // *types.PointerType or *types.VectorType (with elements of pointer type)
	// (optional) The result is a poison value if the calculated pointer is not
	// an in bounds address of the allocated source object.
	InBounds bool
}

ExprGetElementPtr is an LLVM IR getelementptr expression.

func NewGetElementPtr

func NewGetElementPtr(elemType types.Type, src Constant, indices ...Constant) *ExprGetElementPtr

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

func (*ExprGetElementPtr) Ident

func (e *ExprGetElementPtr) Ident() string

Ident returns the identifier associated with the constant expression.

func (*ExprGetElementPtr) IsConstant

func (*ExprGetElementPtr) IsConstant()

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

func (*ExprGetElementPtr) IsExpression added in v0.3.4

func (*ExprGetElementPtr) IsExpression()

IsExpression ensures that only constants expressions can be assigned to the constant.Expression interface.

func (*ExprGetElementPtr) String

func (e *ExprGetElementPtr) String() string

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

func (*ExprGetElementPtr) Type

func (e *ExprGetElementPtr) Type() types.Type

Type returns the type of the constant expression.

type ExprICmp

type ExprICmp struct {
	// Integer comparison predicate.
	Pred enum.IPred
	// Integer scalar or vector operands.
	X, Y Constant

	// Type of result produced by the constant expression.
	Typ types.Type
}

ExprICmp is an LLVM IR icmp expression.

func NewICmp

func NewICmp(pred enum.IPred, x, y Constant) *ExprICmp

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

func (*ExprICmp) Ident

func (e *ExprICmp) Ident() string

Ident returns the identifier associated with the constant expression.

func (*ExprICmp) IsConstant

func (*ExprICmp) IsConstant()

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

func (*ExprICmp) IsExpression added in v0.3.4

func (*ExprICmp) IsExpression()

IsExpression ensures that only constants expressions can be assigned to the constant.Expression interface.

func (*ExprICmp) String

func (e *ExprICmp) String() string

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

func (*ExprICmp) Type

func (e *ExprICmp) Type() types.Type

Type returns the type of the constant expression.

type ExprInsertElement

type ExprInsertElement struct {
	// Vector.
	X Constant
	// Element to insert.
	Elem Constant
	// Element index.
	Index Constant

	// Type of result produced by the constant expression.
	Typ types.Type
}

ExprInsertElement is an LLVM IR insertelement expression.

func NewInsertElement

func NewInsertElement(x, elem, index Constant) *ExprInsertElement

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

func (*ExprInsertElement) Ident

func (e *ExprInsertElement) Ident() string

Ident returns the identifier associated with the constant expression.

func (*ExprInsertElement) IsConstant

func (*ExprInsertElement) IsConstant()

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

func (*ExprInsertElement) IsExpression added in v0.3.4

func (*ExprInsertElement) IsExpression()

IsExpression ensures that only constants expressions can be assigned to the constant.Expression interface.

func (*ExprInsertElement) String

func (e *ExprInsertElement) String() string

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

func (*ExprInsertElement) Type

func (e *ExprInsertElement) Type() types.Type

Type returns the type of the constant expression.

type ExprInsertValue

type ExprInsertValue struct {
	// Aggregate value.
	X Constant
	// Element to insert.
	Elem Constant
	// Element indices.
	Indices []uint64

	// Type of result produced by the constant expression.
	Typ types.Type
}

ExprInsertValue is an LLVM IR insertvalue expression.

func NewInsertValue

func NewInsertValue(x, elem Constant, indices ...uint64) *ExprInsertValue

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

func (*ExprInsertValue) Ident

func (e *ExprInsertValue) Ident() string

Ident returns the identifier associated with the constant expression.

func (*ExprInsertValue) IsConstant

func (*ExprInsertValue) IsConstant()

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

func (*ExprInsertValue) IsExpression added in v0.3.4

func (*ExprInsertValue) IsExpression()

IsExpression ensures that only constants expressions can be assigned to the constant.Expression interface.

func (*ExprInsertValue) String

func (e *ExprInsertValue) String() string

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

func (*ExprInsertValue) Type

func (e *ExprInsertValue) Type() types.Type

Type returns the type of the constant expression.

type ExprIntToPtr

type ExprIntToPtr struct {
	// Value before conversion.
	From Constant
	// Type after conversion.
	To types.Type
}

ExprIntToPtr is an LLVM IR inttoptr expression.

func NewIntToPtr

func NewIntToPtr(from Constant, to types.Type) *ExprIntToPtr

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

func (*ExprIntToPtr) Ident

func (e *ExprIntToPtr) Ident() string

Ident returns the identifier associated with the constant expression.

func (*ExprIntToPtr) IsConstant

func (*ExprIntToPtr) IsConstant()

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

func (*ExprIntToPtr) IsExpression added in v0.3.4

func (*ExprIntToPtr) IsExpression()

IsExpression ensures that only constants expressions can be assigned to the constant.Expression interface.

func (*ExprIntToPtr) String

func (e *ExprIntToPtr) String() string

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

func (*ExprIntToPtr) Type

func (e *ExprIntToPtr) Type() types.Type

Type returns the type of the constant expression.

type ExprLShr

type ExprLShr struct {
	// Operands.
	X, Y Constant // integer scalars or vectors

	// Type of result produced by the constant expression.
	Typ types.Type
	// (optional) The result is a poison value if any of the bits shifted out are
	// non-zero.
	Exact bool
}

ExprLShr is an LLVM IR lshr expression.

func NewLShr

func NewLShr(x, y Constant) *ExprLShr

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

func (*ExprLShr) Ident

func (e *ExprLShr) Ident() string

Ident returns the identifier associated with the constant expression.

func (*ExprLShr) IsConstant

func (*ExprLShr) IsConstant()

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

func (*ExprLShr) IsExpression added in v0.3.4

func (*ExprLShr) IsExpression()

IsExpression ensures that only constants expressions can be assigned to the constant.Expression interface.

func (*ExprLShr) String

func (e *ExprLShr) String() string

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

func (*ExprLShr) Type

func (e *ExprLShr) Type() types.Type

Type returns the type of the constant expression.

type ExprMul

type ExprMul struct {
	// Operands.
	X, Y Constant // integer scalar or vector constants

	// Type of result produced by the constant expression.
	Typ types.Type
	// (optional) Integer overflow flags.
	OverflowFlags []enum.OverflowFlag
}

ExprMul is an LLVM IR mul expression.

func NewMul

func NewMul(x, y Constant) *ExprMul

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

func (*ExprMul) Ident

func (e *ExprMul) Ident() string

Ident returns the identifier associated with the constant expression.

func (*ExprMul) IsConstant

func (*ExprMul) IsConstant()

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

func (*ExprMul) IsExpression added in v0.3.4

func (*ExprMul) IsExpression()

IsExpression ensures that only constants expressions can be assigned to the constant.Expression interface.

func (*ExprMul) String

func (e *ExprMul) String() string

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

func (*ExprMul) Type

func (e *ExprMul) Type() types.Type

Type returns the type of the constant expression.

type ExprOr

type ExprOr struct {
	// Operands.
	X, Y Constant // integer scalars or vectors

	// Type of result produced by the constant expression.
	Typ types.Type
}

ExprOr is an LLVM IR or expression.

func NewOr

func NewOr(x, y Constant) *ExprOr

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

func (*ExprOr) Ident

func (e *ExprOr) Ident() string

Ident returns the identifier associated with the constant expression.

func (*ExprOr) IsConstant

func (*ExprOr) IsConstant()

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

func (*ExprOr) IsExpression added in v0.3.4

func (*ExprOr) IsExpression()

IsExpression ensures that only constants expressions can be assigned to the constant.Expression interface.

func (*ExprOr) String

func (e *ExprOr) String() string

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

func (*ExprOr) Type

func (e *ExprOr) Type() types.Type

Type returns the type of the constant expression.

type ExprPtrToInt

type ExprPtrToInt struct {
	// Value before conversion.
	From Constant
	// Type after conversion.
	To types.Type
}

ExprPtrToInt is an LLVM IR ptrtoint expression.

func NewPtrToInt

func NewPtrToInt(from Constant, to types.Type) *ExprPtrToInt

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

func (*ExprPtrToInt) Ident

func (e *ExprPtrToInt) Ident() string

Ident returns the identifier associated with the constant expression.

func (*ExprPtrToInt) IsConstant

func (*ExprPtrToInt) IsConstant()

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

func (*ExprPtrToInt) IsExpression added in v0.3.4

func (*ExprPtrToInt) IsExpression()

IsExpression ensures that only constants expressions can be assigned to the constant.Expression interface.

func (*ExprPtrToInt) String

func (e *ExprPtrToInt) String() string

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

func (*ExprPtrToInt) Type

func (e *ExprPtrToInt) Type() types.Type

Type returns the type of the constant expression.

type ExprSDiv

type ExprSDiv struct {
	// Operands.
	X, Y Constant // integer scalar or vector constants

	// Type of result produced by the constant expression.
	Typ types.Type
	// (optional) The result is a poison value if the result would be rounded.
	Exact bool
}

ExprSDiv is an LLVM IR sdiv expression.

func NewSDiv

func NewSDiv(x, y Constant) *ExprSDiv

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

func (*ExprSDiv) Ident

func (e *ExprSDiv) Ident() string

Ident returns the identifier associated with the constant expression.

func (*ExprSDiv) IsConstant

func (*ExprSDiv) IsConstant()

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

func (*ExprSDiv) IsExpression added in v0.3.4

func (*ExprSDiv) IsExpression()

IsExpression ensures that only constants expressions can be assigned to the constant.Expression interface.

func (*ExprSDiv) String

func (e *ExprSDiv) String() string

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

func (*ExprSDiv) Type

func (e *ExprSDiv) Type() types.Type

Type returns the type of the constant expression.

type ExprSExt

type ExprSExt struct {
	// Value before conversion.
	From Constant
	// Type after conversion.
	To types.Type
}

ExprSExt is an LLVM IR sext expression.

func NewSExt

func NewSExt(from Constant, to types.Type) *ExprSExt

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

func (*ExprSExt) Ident

func (e *ExprSExt) Ident() string

Ident returns the identifier associated with the constant expression.

func (*ExprSExt) IsConstant

func (*ExprSExt) IsConstant()

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

func (*ExprSExt) IsExpression added in v0.3.4

func (*ExprSExt) IsExpression()

IsExpression ensures that only constants expressions can be assigned to the constant.Expression interface.

func (*ExprSExt) String

func (e *ExprSExt) String() string

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

func (*ExprSExt) Type

func (e *ExprSExt) Type() types.Type

Type returns the type of the constant expression.

type ExprSIToFP

type ExprSIToFP struct {
	// Value before conversion.
	From Constant
	// Type after conversion.
	To types.Type
}

ExprSIToFP is an LLVM IR sitofp expression.

func NewSIToFP

func NewSIToFP(from Constant, to types.Type) *ExprSIToFP

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

func (*ExprSIToFP) Ident

func (e *ExprSIToFP) Ident() string

Ident returns the identifier associated with the constant expression.

func (*ExprSIToFP) IsConstant

func (*ExprSIToFP) IsConstant()

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

func (*ExprSIToFP) IsExpression added in v0.3.4

func (*ExprSIToFP) IsExpression()

IsExpression ensures that only constants expressions can be assigned to the constant.Expression interface.

func (*ExprSIToFP) String

func (e *ExprSIToFP) String() string

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

func (*ExprSIToFP) Type

func (e *ExprSIToFP) Type() types.Type

Type returns the type of the constant expression.

type ExprSRem

type ExprSRem struct {
	// Operands.
	X, Y Constant // integer scalar or vector constants

	// Type of result produced by the constant expression.
	Typ types.Type
}

ExprSRem is an LLVM IR srem expression.

func NewSRem

func NewSRem(x, y Constant) *ExprSRem

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

func (*ExprSRem) Ident

func (e *ExprSRem) Ident() string

Ident returns the identifier associated with the constant expression.

func (*ExprSRem) IsConstant

func (*ExprSRem) IsConstant()

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

func (*ExprSRem) IsExpression added in v0.3.4

func (*ExprSRem) IsExpression()

IsExpression ensures that only constants expressions can be assigned to the constant.Expression interface.

func (*ExprSRem) String

func (e *ExprSRem) String() string

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

func (*ExprSRem) Type

func (e *ExprSRem) Type() types.Type

Type returns the type of the constant expression.

type ExprSelect

type ExprSelect struct {
	// Selection condition.
	Cond Constant
	// Operands.
	X, Y Constant

	// Type of result produced by the constant expression.
	Typ types.Type
}

ExprSelect is an LLVM IR select expression.

func NewSelect

func NewSelect(cond, x, y Constant) *ExprSelect

NewSelect returns a new select expression based on the given selection condition and operands.

func (*ExprSelect) Ident

func (e *ExprSelect) Ident() string

Ident returns the identifier associated with the constant expression.

func (*ExprSelect) IsConstant

func (*ExprSelect) IsConstant()

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

func (*ExprSelect) IsExpression added in v0.3.4

func (*ExprSelect) IsExpression()

IsExpression ensures that only constants expressions can be assigned to the constant.Expression interface.

func (*ExprSelect) String

func (e *ExprSelect) String() string

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

func (*ExprSelect) Type

func (e *ExprSelect) Type() types.Type

Type returns the type of the constant expression.

type ExprShl

type ExprShl struct {
	// Operands.
	X, Y Constant // integer scalars or vectors

	// Type of result produced by the constant expression.
	Typ types.Type
	// (optional) Integer overflow flags.
	OverflowFlags []enum.OverflowFlag
}

ExprShl is an LLVM IR shl expression.

func NewShl

func NewShl(x, y Constant) *ExprShl

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

func (*ExprShl) Ident

func (e *ExprShl) Ident() string

Ident returns the identifier associated with the constant expression.

func (*ExprShl) IsConstant

func (*ExprShl) IsConstant()

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

func (*ExprShl) IsExpression added in v0.3.4

func (*ExprShl) IsExpression()

IsExpression ensures that only constants expressions can be assigned to the constant.Expression interface.

func (*ExprShl) String

func (e *ExprShl) String() string

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

func (*ExprShl) Type

func (e *ExprShl) Type() types.Type

Type returns the type of the constant expression.

type ExprShuffleVector

type ExprShuffleVector struct {
	// Vectors.
	X, Y Constant
	// Shuffle mask.
	Mask Constant

	// Type of result produced by the constant expression.
	Typ types.Type
}

ExprShuffleVector is an LLVM IR shufflevector expression.

func NewShuffleVector

func NewShuffleVector(x, y, mask Constant) *ExprShuffleVector

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

func (*ExprShuffleVector) Ident

func (e *ExprShuffleVector) Ident() string

Ident returns the identifier associated with the constant expression.

func (*ExprShuffleVector) IsConstant

func (*ExprShuffleVector) IsConstant()

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

func (*ExprShuffleVector) IsExpression added in v0.3.4

func (*ExprShuffleVector) IsExpression()

IsExpression ensures that only constants expressions can be assigned to the constant.Expression interface.

func (*ExprShuffleVector) String

func (e *ExprShuffleVector) String() string

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

func (*ExprShuffleVector) Type

func (e *ExprShuffleVector) Type() types.Type

Type returns the type of the constant expression.

type ExprSub

type ExprSub struct {
	// Operands.
	X, Y Constant // integer scalar or vector constants

	// Type of result produced by the constant expression.
	Typ types.Type
	// (optional) Integer overflow flags.
	OverflowFlags []enum.OverflowFlag
}

ExprSub is an LLVM IR sub expression.

func NewSub

func NewSub(x, y Constant) *ExprSub

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

func (*ExprSub) Ident

func (e *ExprSub) Ident() string

Ident returns the identifier associated with the constant expression.

func (*ExprSub) IsConstant

func (*ExprSub) IsConstant()

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

func (*ExprSub) IsExpression added in v0.3.4

func (*ExprSub) IsExpression()

IsExpression ensures that only constants expressions can be assigned to the constant.Expression interface.

func (*ExprSub) String

func (e *ExprSub) String() string

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

func (*ExprSub) Type

func (e *ExprSub) Type() types.Type

Type returns the type of the constant expression.

type ExprTrunc

type ExprTrunc struct {
	// Value before conversion.
	From Constant
	// Type after conversion.
	To types.Type
}

ExprTrunc is an LLVM IR trunc expression.

func NewTrunc

func NewTrunc(from Constant, to types.Type) *ExprTrunc

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

func (*ExprTrunc) Ident

func (e *ExprTrunc) Ident() string

Ident returns the identifier associated with the constant expression.

func (*ExprTrunc) IsConstant

func (*ExprTrunc) IsConstant()

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

func (*ExprTrunc) IsExpression added in v0.3.4

func (*ExprTrunc) IsExpression()

IsExpression ensures that only constants expressions can be assigned to the constant.Expression interface.

func (*ExprTrunc) String

func (e *ExprTrunc) String() string

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

func (*ExprTrunc) Type

func (e *ExprTrunc) Type() types.Type

Type returns the type of the constant expression.

type ExprUDiv

type ExprUDiv struct {
	// Operands.
	X, Y Constant // integer scalar or vector constants

	// Type of result produced by the constant expression.
	Typ types.Type
	// (optional) The result is a poison value if X is not a multiple of Y.
	Exact bool
}

ExprUDiv is an LLVM IR udiv expression.

func NewUDiv

func NewUDiv(x, y Constant) *ExprUDiv

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

func (*ExprUDiv) Ident

func (e *ExprUDiv) Ident() string

Ident returns the identifier associated with the constant expression.

func (*ExprUDiv) IsConstant

func (*ExprUDiv) IsConstant()

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

func (*ExprUDiv) IsExpression added in v0.3.4

func (*ExprUDiv) IsExpression()

IsExpression ensures that only constants expressions can be assigned to the constant.Expression interface.

func (*ExprUDiv) String

func (e *ExprUDiv) String() string

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

func (*ExprUDiv) Type

func (e *ExprUDiv) Type() types.Type

Type returns the type of the constant expression.

type ExprUIToFP

type ExprUIToFP struct {
	// Value before conversion.
	From Constant
	// Type after conversion.
	To types.Type
}

ExprUIToFP is an LLVM IR uitofp expression.

func NewUIToFP

func NewUIToFP(from Constant, to types.Type) *ExprUIToFP

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

func (*ExprUIToFP) Ident

func (e *ExprUIToFP) Ident() string

Ident returns the identifier associated with the constant expression.

func (*ExprUIToFP) IsConstant

func (*ExprUIToFP) IsConstant()

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

func (*ExprUIToFP) IsExpression added in v0.3.4

func (*ExprUIToFP) IsExpression()

IsExpression ensures that only constants expressions can be assigned to the constant.Expression interface.

func (*ExprUIToFP) String

func (e *ExprUIToFP) String() string

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

func (*ExprUIToFP) Type

func (e *ExprUIToFP) Type() types.Type

Type returns the type of the constant expression.

type ExprURem

type ExprURem struct {
	// Operands.
	X, Y Constant // integer scalar or vector constants

	// Type of result produced by the constant expression.
	Typ types.Type
}

ExprURem is an LLVM IR urem expression.

func NewURem

func NewURem(x, y Constant) *ExprURem

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

func (*ExprURem) Ident

func (e *ExprURem) Ident() string

Ident returns the identifier associated with the constant expression.

func (*ExprURem) IsConstant

func (*ExprURem) IsConstant()

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

func (*ExprURem) IsExpression added in v0.3.4

func (*ExprURem) IsExpression()

IsExpression ensures that only constants expressions can be assigned to the constant.Expression interface.

func (*ExprURem) String

func (e *ExprURem) String() string

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

func (*ExprURem) Type

func (e *ExprURem) Type() types.Type

Type returns the type of the constant expression.

type ExprXor

type ExprXor struct {
	// Operands.
	X, Y Constant // integer scalars or vectors

	// Type of result produced by the constant expression.
	Typ types.Type
}

ExprXor is an LLVM IR xor expression.

func NewXor

func NewXor(x, y Constant) *ExprXor

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

func (*ExprXor) Ident

func (e *ExprXor) Ident() string

Ident returns the identifier associated with the constant expression.

func (*ExprXor) IsConstant

func (*ExprXor) IsConstant()

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

func (*ExprXor) IsExpression added in v0.3.4

func (*ExprXor) IsExpression()

IsExpression ensures that only constants expressions can be assigned to the constant.Expression interface.

func (*ExprXor) String

func (e *ExprXor) String() string

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

func (*ExprXor) Type

func (e *ExprXor) Type() types.Type

Type returns the type of the constant expression.

type ExprZExt

type ExprZExt struct {
	// Value before conversion.
	From Constant
	// Type after conversion.
	To types.Type
}

ExprZExt is an LLVM IR zext expression.

func NewZExt

func NewZExt(from Constant, to types.Type) *ExprZExt

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

func (*ExprZExt) Ident

func (e *ExprZExt) Ident() string

Ident returns the identifier associated with the constant expression.

func (*ExprZExt) IsConstant

func (*ExprZExt) IsConstant()

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

func (*ExprZExt) IsExpression added in v0.3.4

func (*ExprZExt) IsExpression()

IsExpression ensures that only constants expressions can be assigned to the constant.Expression interface.

func (*ExprZExt) String

func (e *ExprZExt) String() string

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

func (*ExprZExt) Type

func (e *ExprZExt) Type() types.Type

Type returns the type of the constant expression.

type Expression

type Expression interface {
	Constant
	// IsExpression ensures that only constants expressions can be assigned to
	// the constant.Expression interface.
	IsExpression()
}

Expression is an LLVM IR constant expression.

An Expression has one of the following underlying types.

Unary expressions

https://llvm.org/docs/LangRef.html#constant-expressions

*constant.ExprFNeg   // https://pkg.go.dev/github.com/llir/llvm/ir/constant#ExprFNeg

Binary expressions

https://llvm.org/docs/LangRef.html#constant-expressions

*constant.ExprAdd    // https://pkg.go.dev/github.com/llir/llvm/ir/constant#ExprAdd
*constant.ExprFAdd   // https://pkg.go.dev/github.com/llir/llvm/ir/constant#ExprFAdd
*constant.ExprSub    // https://pkg.go.dev/github.com/llir/llvm/ir/constant#ExprSub
*constant.ExprFSub   // https://pkg.go.dev/github.com/llir/llvm/ir/constant#ExprFSub
*constant.ExprMul    // https://pkg.go.dev/github.com/llir/llvm/ir/constant#ExprMul
*constant.ExprFMul   // https://pkg.go.dev/github.com/llir/llvm/ir/constant#ExprFMul
*constant.ExprUDiv   // https://pkg.go.dev/github.com/llir/llvm/ir/constant#ExprUDiv
*constant.ExprSDiv   // https://pkg.go.dev/github.com/llir/llvm/ir/constant#ExprSDiv
*constant.ExprFDiv   // https://pkg.go.dev/github.com/llir/llvm/ir/constant#ExprFDiv
*constant.ExprURem   // https://pkg.go.dev/github.com/llir/llvm/ir/constant#ExprURem
*constant.ExprSRem   // https://pkg.go.dev/github.com/llir/llvm/ir/constant#ExprSRem
*constant.ExprFRem   // https://pkg.go.dev/github.com/llir/llvm/ir/constant#ExprFRem

Bitwise expressions

https://llvm.org/docs/LangRef.html#constant-expressions

*constant.ExprShl    // https://pkg.go.dev/github.com/llir/llvm/ir/constant#ExprShl
*constant.ExprLShr   // https://pkg.go.dev/github.com/llir/llvm/ir/constant#ExprLShr
*constant.ExprAShr   // https://pkg.go.dev/github.com/llir/llvm/ir/constant#ExprAShr
*constant.ExprAnd    // https://pkg.go.dev/github.com/llir/llvm/ir/constant#ExprAnd
*constant.ExprOr     // https://pkg.go.dev/github.com/llir/llvm/ir/constant#ExprOr
*constant.ExprXor    // https://pkg.go.dev/github.com/llir/llvm/ir/constant#ExprXor

Vector expressions

https://llvm.org/docs/LangRef.html#constant-expressions

*constant.ExprExtractElement   // https://pkg.go.dev/github.com/llir/llvm/ir/constant#ExprExtractElement
*constant.ExprInsertElement    // https://pkg.go.dev/github.com/llir/llvm/ir/constant#ExprInsertElement
*constant.ExprShuffleVector    // https://pkg.go.dev/github.com/llir/llvm/ir/constant#ExprShuffleVector

Aggregate expressions

https://llvm.org/docs/LangRef.html#constant-expressions

*constant.ExprExtractValue   // https://pkg.go.dev/github.com/llir/llvm/ir/constant#ExprExtractValue
*constant.ExprInsertValue    // https://pkg.go.dev/github.com/llir/llvm/ir/constant#ExprInsertValue

Memory expressions

https://llvm.org/docs/LangRef.html#constant-expressions

*constant.ExprGetElementPtr   // https://pkg.go.dev/github.com/llir/llvm/ir/constant#ExprGetElementPtr

Conversion expressions

https://llvm.org/docs/LangRef.html#constant-expressions

*constant.ExprTrunc           // https://pkg.go.dev/github.com/llir/llvm/ir/constant#ExprTrunc
*constant.ExprZExt            // https://pkg.go.dev/github.com/llir/llvm/ir/constant#ExprZExt
*constant.ExprSExt            // https://pkg.go.dev/github.com/llir/llvm/ir/constant#ExprSExt
*constant.ExprFPTrunc         // https://pkg.go.dev/github.com/llir/llvm/ir/constant#ExprFPTrunc
*constant.ExprFPExt           // https://pkg.go.dev/github.com/llir/llvm/ir/constant#ExprFPExt
*constant.ExprFPToUI          // https://pkg.go.dev/github.com/llir/llvm/ir/constant#ExprFPToUI
*constant.ExprFPToSI          // https://pkg.go.dev/github.com/llir/llvm/ir/constant#ExprFPToSI
*constant.ExprUIToFP          // https://pkg.go.dev/github.com/llir/llvm/ir/constant#ExprUIToFP
*constant.ExprSIToFP          // https://pkg.go.dev/github.com/llir/llvm/ir/constant#ExprSIToFP
*constant.ExprPtrToInt        // https://pkg.go.dev/github.com/llir/llvm/ir/constant#ExprPtrToInt
*constant.ExprIntToPtr        // https://pkg.go.dev/github.com/llir/llvm/ir/constant#ExprIntToPtr
*constant.ExprBitCast         // https://pkg.go.dev/github.com/llir/llvm/ir/constant#ExprBitCast
*constant.ExprAddrSpaceCast   // https://pkg.go.dev/github.com/llir/llvm/ir/constant#ExprAddrSpaceCast

Other expressions

https://llvm.org/docs/LangRef.html#constant-expressions

*constant.ExprICmp     // https://pkg.go.dev/github.com/llir/llvm/ir/constant#ExprICmp
*constant.ExprFCmp     // https://pkg.go.dev/github.com/llir/llvm/ir/constant#ExprFCmp
*constant.ExprSelect   // https://pkg.go.dev/github.com/llir/llvm/ir/constant#ExprSelect

type Float

type Float struct {
	// Floating-point type.
	Typ *types.FloatType
	// Floating-point constant.
	X *big.Float
	// NaN specifies whether the floating-point constant is Not-a-Number.
	NaN bool
}

Float is an LLVM IR floating-point constant.

func NewFloat

func NewFloat(typ *types.FloatType, x float64) *Float

NewFloat returns a new floating-point constant based on the given floating-point type and double precision floating-point value.

func NewFloatFromString

func NewFloatFromString(typ *types.FloatType, s string) (*Float, error)

NewFloatFromString returns a new floating-point constant based on the given floating-point type and floating-point string.

The floating-point string may be expressed in one of the following forms.

  • fraction floating-point literal [+-]? [0-9]+ [.] [0-9]*
  • scientific notation floating-point literal [+-]? [0-9]+ [.] [0-9]* [eE] [+-]? [0-9]+
  • hexadecimal floating-point literal 0x[0-9A-Fa-f]{16} // HexFP 0xK[0-9A-Fa-f]{20} // HexFP80 0xL[0-9A-Fa-f]{32} // HexFP128 0xM[0-9A-Fa-f]{32} // HexPPC128 0xH[0-9A-Fa-f]{4} // HexHalf

func (*Float) Ident

func (c *Float) Ident() string

Ident returns the identifier associated with the constant.

func (*Float) IsConstant

func (*Float) IsConstant()

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

func (*Float) String

func (c *Float) String() string

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

func (*Float) Type

func (c *Float) Type() types.Type

Type returns the type of the constant.

type Index

type Index struct {
	// Element index.
	Constant

	// (optional) States that the element index is not out the bounds of the
	// allocated object. If inrange is stated but the element index is out of
	// bounds, the behaviour is undefined.
	InRange bool
}

Index is an index of a getelementptr constant expression.

func NewIndex

func NewIndex(index Constant) *Index

NewIndex returns a new gep element index.

func (*Index) String

func (index *Index) String() string

String returns a string representation of the getelementptr index.

type Int

type Int struct {
	// Integer type.
	Typ *types.IntType
	// Integer constant.
	X *big.Int
}

Int is an LLVM IR integer constant.

func NewBool

func NewBool(x bool) *Int

NewBool returns a new boolean constant based on the given boolean value.

func NewInt

func NewInt(typ *types.IntType, x int64) *Int

NewInt returns a new integer constant based on the given integer type and 64-bit interger value.

func NewIntFromString

func NewIntFromString(typ *types.IntType, s string) (*Int, error)

NewIntFromString returns a new integer constant based on the given integer type and string.

The integer string may be expressed in one of the following forms.

  • boolean literal true | false
  • integer literal [-]?[0-9]+
  • hexadecimal integer literal [us]0x[0-9A-Fa-f]+

func (*Int) Ident

func (c *Int) Ident() string

Ident returns the identifier associated with the constant.

func (*Int) IsConstant

func (*Int) IsConstant()

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

func (*Int) String

func (c *Int) String() string

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

func (*Int) Type

func (c *Int) Type() types.Type

Type returns the type of the constant.

type NoCFI added in v0.3.6

type NoCFI struct {
	// Underlying function.
	Func Constant // *ir.Func
}

NoCFI is an LLVM IR no_cfi constant; a constant representing a function which does not get replaced with a reference to the CFI jump table (control-flow integrity).

ref: https://llvm.org/docs/LangRef.html#no-cfi

func NewNoCFI added in v0.3.6

func NewNoCFI(f Constant) *NoCFI

NewNoCFI returns a new no_cfi constant based on the given function.

func (*NoCFI) Ident added in v0.3.6

func (c *NoCFI) Ident() string

Ident returns the identifier associated with the constant.

func (*NoCFI) IsConstant added in v0.3.6

func (*NoCFI) IsConstant()

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

func (*NoCFI) String added in v0.3.6

func (c *NoCFI) String() string

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

func (*NoCFI) Type added in v0.3.6

func (c *NoCFI) Type() types.Type

Type returns the type of the constant.

type NoneToken

type NoneToken struct {
}

NoneToken is an LLVM IR none token constant.

func (*NoneToken) Ident

func (*NoneToken) Ident() string

Ident returns the identifier associated with the constant.

func (*NoneToken) IsConstant

func (*NoneToken) IsConstant()

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

func (*NoneToken) String

func (c *NoneToken) String() string

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

func (*NoneToken) Type

func (*NoneToken) Type() types.Type

Type returns the type of the constant.

type Null

type Null struct {
	// Pointer type.
	Typ *types.PointerType
}

Null is an LLVM IR null pointer constant.

func NewNull

func NewNull(typ *types.PointerType) *Null

NewNull returns a new null pointer constant based on the given pointer type.

func (*Null) Ident

func (*Null) Ident() string

Ident returns the identifier associated with the constant.

func (*Null) IsConstant

func (*Null) IsConstant()

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

func (*Null) String

func (c *Null) String() string

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

func (*Null) Type

func (c *Null) Type() types.Type

Type returns the type of the constant.

type Poison added in v0.3.4

type Poison struct {
	// Poison value type.
	Typ types.Type
}

Poison is an LLVM IR poison value.

func NewPoison added in v0.3.4

func NewPoison(typ types.Type) *Poison

NewPoison returns a new poison value based on the given type.

func (*Poison) Ident added in v0.3.4

func (*Poison) Ident() string

Ident returns the identifier associated with the constant.

func (*Poison) IsConstant added in v0.3.4

func (*Poison) IsConstant()

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

func (*Poison) String added in v0.3.4

func (c *Poison) String() string

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

func (*Poison) Type added in v0.3.4

func (c *Poison) Type() types.Type

Type returns the type of the constant.

type Struct

type Struct struct {
	// Struct type.
	Typ *types.StructType
	// Struct fields.
	Fields []Constant
}

Struct is an LLVM IR struct constant.

func NewStruct

func NewStruct(t *types.StructType, fields ...Constant) *Struct

NewStruct returns a new struct constant based on the given struct type and fields. The struct type is infered from the type of the fields if t is nil.

func (*Struct) Ident

func (c *Struct) Ident() string

Ident returns the identifier associated with the constant.

func (*Struct) IsConstant

func (*Struct) IsConstant()

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

func (*Struct) String

func (c *Struct) String() string

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

func (*Struct) Type

func (c *Struct) Type() types.Type

Type returns the type of the constant.

type Undef

type Undef struct {
	// Undefined value type.
	Typ types.Type
}

Undef is an LLVM IR undefined value.

func NewUndef

func NewUndef(typ types.Type) *Undef

NewUndef returns a new undefined value based on the given type.

func (*Undef) Ident

func (*Undef) Ident() string

Ident returns the identifier associated with the constant.

func (*Undef) IsConstant

func (*Undef) IsConstant()

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

func (*Undef) String

func (c *Undef) String() string

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

func (*Undef) Type

func (c *Undef) Type() types.Type

Type returns the type of the constant.

type Vector

type Vector struct {
	// Vector type.
	Typ *types.VectorType
	// Vector elements.
	Elems []Constant
}

Vector is an LLVM IR vector constant.

func NewVector

func NewVector(t *types.VectorType, elems ...Constant) *Vector

NewVector returns a new vector constant based on the given vector type and elements. The vector type is infered from the type of the elements if t is nil.

func (*Vector) Ident

func (c *Vector) Ident() string

Ident returns the identifier associated with the constant.

func (*Vector) IsConstant

func (*Vector) IsConstant()

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

func (*Vector) String

func (c *Vector) String() string

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

func (*Vector) Type

func (c *Vector) Type() types.Type

Type returns the type of the constant.

type ZeroInitializer

type ZeroInitializer struct {
	// zeroinitializer type.
	Typ types.Type
}

ZeroInitializer is an LLVM IR zeroinitializer constant.

func NewZeroInitializer

func NewZeroInitializer(typ types.Type) *ZeroInitializer

NewZeroInitializer returns a new zeroinitializer constant based on the given type.

func (*ZeroInitializer) Ident

func (c *ZeroInitializer) Ident() string

Ident returns the identifier associated with the constant.

func (*ZeroInitializer) IsConstant

func (*ZeroInitializer) IsConstant()

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

func (*ZeroInitializer) String

func (c *ZeroInitializer) String() string

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

func (*ZeroInitializer) Type

func (c *ZeroInitializer) Type() types.Type

Type returns the type of the constant.

Jump to

Keyboard shortcuts

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