ssa

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DbgFlagInstruction dbgFlags = 1 << iota

	DbgFlagAll = DbgFlagInstruction
)
View Source
const (
	NameValist = "__llgo_va_list"
)

Variables

This section is empty.

Functions

func HasVArg

func HasVArg(t *types.Tuple, n int) bool

func Initialize

func Initialize(flags InitFlags)

Initialize initializes the LLVM library.

func IsVArg

func IsVArg(arg *types.Var) bool

func SetDebug

func SetDebug(dbgFlags dbgFlags)

SetDebug sets debug flags.

func VArg

func VArg() *types.Var

Types

type BasicBlock

type BasicBlock = *aBasicBlock

BasicBlock represents a basic block in a function.

func (BasicBlock) Index

func (p BasicBlock) Index() int

Index returns the index of the basic block in the parent function.

func (BasicBlock) Parent

func (p BasicBlock) Parent() Function

Parent returns the function to which the basic block belongs.

type Builder

type Builder = *aBuilder

Builder represents a builder for creating instructions in a function.

func (Builder) Alloc

func (b Builder) Alloc(t Type, heap bool) (ret Expr)

The Alloc instruction reserves space for a variable of the given type, zero-initializes it, and yields its address.

If heap is false, Alloc zero-initializes the same local variable in the call frame and returns its address; in this case the Alloc must be present in Function.Locals. We call this a "local" alloc.

If heap is true, Alloc allocates a new zero-initialized variable each time the instruction is executed. We call this a "new" alloc.

When Alloc is applied to a channel, map or slice type, it returns the address of an uninitialized (nil) reference of that kind; store the result of MakeSlice, MakeMap or MakeChan in that location to instantiate these types.

Example printed form:

t0 = local int
t1 = new int

func (Builder) BinOp

func (b Builder) BinOp(op token.Token, x, y Expr) Expr

The BinOp instruction yields the result of binary operation (x op y). op can be: ADD SUB MUL QUO REM + - * / % AND OR XOR SHL SHR AND_NOT & | ^ << >> &^ EQL NEQ LSS LEQ GTR GEQ == != < <= < >=

func (Builder) Call

func (b Builder) Call(fn Expr, args ...Expr) (ret Expr)

The Call instruction represents a function or method call.

The Call instruction yields the function result if there is exactly one. Otherwise it returns a tuple, the components of which are accessed via Extract.

Example printed form:

t2 = println(t0, t1)
t4 = t3()
t7 = invoke t5.Println(...t6)

func (Builder) Const

func (b Builder) Const(v constant.Value, typ Type) Expr

func (Builder) If

func (b Builder) If(cond Expr, thenb, elseb BasicBlock)

If emits an if instruction.

func (Builder) IndexAddr

func (b Builder) IndexAddr(x, idx Expr) Expr

The IndexAddr instruction yields the address of the element at index `idx` of collection `x`. `idx` is an integer expression.

The elements of maps and strings are not addressable; use Lookup (map), Index (string), or MapUpdate instead.

Dynamically, this instruction panics if `x` evaluates to a nil *array pointer.

Example printed form:

t2 = &t0[t1]

func (Builder) Jump

func (b Builder) Jump(jmpb BasicBlock)

Jump emits a jump instruction.

func (Builder) Load

func (b Builder) Load(ptr Expr) Expr

Load returns the value at the pointer ptr.

func (Builder) Return

func (b Builder) Return(results ...Expr)

Return emits a return instruction.

func (Builder) SetBlock

func (b Builder) SetBlock(blk BasicBlock) Builder

SetBlock sets the current block to the specified basic block.

func (Builder) Store

func (b Builder) Store(ptr, val Expr) Builder

Store stores val at the pointer ptr.

func (Builder) UnOp

func (b Builder) UnOp(op token.Token, x Expr) Expr

The UnOp instruction yields the result of (op x). ARROW is channel receive. MUL is pointer indirection (load). XOR is bitwise complement. SUB is negation. NOT is logical negation.

type Expr

type Expr struct {
	Type
	// contains filtered or unexported fields
}

type Function

type Function = *aFunction

Function represents a function or method.

func (Function) Block

func (p Function) Block(idx int) BasicBlock

Block returns the ith basic block of the function.

func (Function) MakeBlocks

func (p Function) MakeBlocks(nblk int) []BasicBlock

MakeBlocks creates nblk basic blocks for the function.

func (Function) MakeBody

func (p Function) MakeBody(nblk int) Builder

MakeBody creates nblk basic blocks for the function, and creates a new Builder associated to #0 block.

func (Function) NewBuilder

func (p Function) NewBuilder() Builder

NewBuilder creates a new Builder for the function.

func (Function) Param

func (p Function) Param(i int) Expr

Params returns the function's ith parameter.

type Global

type Global = *aGlobal

A Global is a named Value holding the address of a package-level variable.

func (Global) Init

func (g Global) Init(v Expr)

Init initializes the global variable with the given value.

type InitFlags

type InitFlags int

InitFlags is a set of flags for initializing the LLVM library.

const (
	InitNativeTarget InitFlags = 1 << iota
	InitAllTargets
	InitAllTargetInfos
	InitAllTargetMCs

	InitNativeAsmPrinter
	InitAllAsmPrinters

	InitAllAsmParsers

	InitNative = InitNativeTarget | InitNativeAsmPrinter
	InitAll    = InitAllTargets | InitAllAsmParsers | InitAllAsmPrinters | InitAllTargetInfos | InitAllTargetMCs
)

type NamedConst

type NamedConst = *aNamedConst

A NamedConst is a Member of a Package representing a package-level named constant.

Pos() returns the position of the declaring ast.ValueSpec.Names[*] identifier.

NB: a NamedConst is not a Value; it contains a constant Value, which it augments with the name and position of its 'const' declaration.

type Package

type Package = *aPackage

func (Package) FuncOf

func (p Package) FuncOf(name string) Function

FuncOf returns a function by name.

func (Package) NewConst

func (p Package) NewConst(name string, val constant.Value) NamedConst

func (Package) NewFunc

func (p Package) NewFunc(name string, sig *types.Signature) Function

NewFunc creates a new function.

func (Package) NewVar

func (p Package) NewVar(name string, typ types.Type) Global

NewVar creates a new global variable.

func (Package) String

func (p Package) String() string

String returns a string representation of the package.

func (Package) VarOf

func (p Package) VarOf(name string) Global

VarOf returns a global variable by name.

type Program

type Program = *aProgram

A Program presents a program.

func NewProgram

func NewProgram(target *Target) Program

NewProgram creates a new program.

func (Program) Bool

func (p Program) Bool() Type

Bool returns bool type.

func (Program) BoolVal

func (p Program) BoolVal(v bool) Expr

func (Program) Elem

func (p Program) Elem(typ Type) Type

func (Program) Float64

func (p Program) Float64() Type

Float64 returns float64 type.

func (Program) Index

func (p Program) Index(typ Type) Type

func (Program) Int

func (p Program) Int() Type

Int returns int type.

func (Program) IntVal

func (p Program) IntVal(v uint64, t Type) Expr

func (Program) NewPackage

func (p Program) NewPackage(name, pkgPath string) Package

NewPackage creates a new package.

func (Program) Null

func (p Program) Null(t Type) Expr

func (Program) Pointer

func (p Program) Pointer(typ Type) Type

func (Program) Type

func (p Program) Type(typ types.Type) Type

func (Program) Val

func (p Program) Val(v interface{}) Expr

func (Program) Void

func (p Program) Void() Type

Void returns void type.

type Target

type Target struct {
	GOOS   string
	GOARCH string
	GOARM  string // "5", "6", "7" (default)
}

type Type

type Type = *aType

Jump to

Keyboard shortcuts

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