ssa

package
v1.0.0-pre.1 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2026 License: Apache-2.0 Imports: 27 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	NoInline inlineAttr = iota
	AlwaysInline
	InlineHint
)
View Source
const (
	OrderingNotAtomic      = llvm.AtomicOrderingNotAtomic
	OrderingUnordered      = llvm.AtomicOrderingUnordered
	OrderingMonotonic      = llvm.AtomicOrderingMonotonic
	OrderingAcquire        = llvm.AtomicOrderingAcquire
	OrderingRelease        = llvm.AtomicOrderingRelease
	OrderingAcquireRelease = llvm.AtomicOrderingAcquireRelease
	OrderingSeqConsistent  = llvm.AtomicOrderingSequentiallyConsistent
)
View Source
const (
	ReflectArrayOf = 1 << iota
	ReflectChanOf
	ReflectFuncOf
	ReflectMapOf
	ReflectPointerTo
	ReflectSliceOf
	ReflectStructOf
	ReflectMethodByIndex
	ReflectMethodByName
	ReflectMethodDynamic
	ReflectTypeMethodByIndex
	ReflectTypeMethodByName
	ReflectTypeMethodDynamic

	ReflectMethodMask = ReflectMethodByIndex | ReflectMethodByName | ReflectMethodDynamic | reflectTypeMethodMask
)
View Source
const (
	FuncInfoMetadataName = "llgo.funcinfo"
	PCLineMetadataName   = "llgo.pcline"
)
View Source
const (
	LocalityNone   = locality.None
	ThreadLocal    = locality.Thread
	GoroutineLocal = locality.Goroutine
)
View Source
const (
	LocalStorageUnknown   = localitylayout.StorageUnknown
	LocalStorageNativeTLS = localitylayout.StorageNativeTLS
	LocalStoragePackage   = localitylayout.StoragePackage
)
View Source
const (
	PkgPython  = "github.com/goplus/lib/py"
	PkgRuntime = env.LLGoRuntimePkg + "/internal/runtime"
)
View Source
const (
	DbgFlagInstruction dbgFlags = 1 << iota

	DbgFlagAll = DbgFlagInstruction
)
View Source
const (
	LLVMModuleFlagBehaviorError = 1
)
View Source
const (
	MD_dbg = 0
)
View Source
const (
	NameValist = "__llgo_va_list"
)

Variables

View Source
var (
	NoArgsNoRet = types.NewSignatureType(nil, nil, nil, nil, nil, false)
)

Functions

func FullName

func FullName(pkg *types.Package, name string) string

FullName returns the full name of a package member.

func FuncAddCtx

func FuncAddCtx(ctx *types.Var, sig *types.Signature) *types.Signature

FuncAddCtx adds a ctx to a function signature.

func FuncName

func FuncName(pkg *types.Package, name string, recv *types.Var, org bool) string

FuncName: - func: pkg.name - method: pkg.T.name, pkg.(*T).name

func HasNameValist

func HasNameValist(sig *types.Signature) bool

func Initialize

func Initialize(flags InitFlags)

Initialize initializes the LLVM library.

func Instantiate

func Instantiate(orig types.Type, t *types.Named) (types.Type, bool)

func IsClosure

func IsClosure(raw *types.Struct) bool

func MethodSymbolName

func MethodSymbolName(receiverPkg *types.Package, method *types.Func, name string) string

MethodSymbolName qualifies an unexported method name when its declaring package differs from the receiver package. Promoted methods need this extra identity component to avoid colliding with same-named receiver methods. Package identity intentionally uses PathOf rather than Package.Path: patched runtime packages and their original counterparts must name the same symbol.

func NameOf

func NameOf(typ *types.Named) string

NameOf returns the full name of a named type.

func PathOf

func PathOf(pkg *types.Package) string

PathOf returns the package path of the specified package.

func SetDebug

func SetDebug(dbgFlags dbgFlags)

SetDebug sets debug flags.

func StripModuleTarget

func StripModuleTarget(ir string) string

func TypeArgs

func TypeArgs(typeArgs []types.Type) string

func VArg

func VArg() *types.Var

Types

type AbiSymbol

type AbiSymbol struct {
	Name    string
	PkgPath string
	Raw     types.Type
	Typ     Type
	MSet    *types.MethodSet
}

type AbiTypeInfo

type AbiTypeInfo struct {
	Name string
	Raw  types.Type
}

AbiTypeInfo is the LLVM-free identity needed to declare one runtime type descriptor in another Program.

type AtomicOp

type AtomicOp = llvm.AtomicRMWBinOp

AtomicOp is an atomic operation.

type AtomicOrdering

type AtomicOrdering = llvm.AtomicOrdering

type Background

type Background int
const (
	InGo Background
	InC
	InPython
)

type BasicBlock

type BasicBlock = *aBasicBlock

BasicBlock represents a basic block in a function.

func (BasicBlock) Addr

func (p BasicBlock) Addr() Expr

Addr returns the address of the basic block.

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) Advance

func (b Builder) Advance(ptr Expr, offset Expr) Expr

Advance returns the pointer ptr advanced by offset.

func (Builder) Aggregate

func (b Builder) Aggregate(t Type, flds ...Expr) Expr

Aggregate constructs an aggregate value from Expr fields.

func (Builder) Alloc

func (b Builder) Alloc(elem 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) AllocCStr

func (b Builder) AllocCStr(gostr Expr) (ret Expr)

AllocCStr allocates space on the heap for copy it from a Go string.

func (Builder) AllocU

func (b Builder) AllocU(elem Type, n ...int64) (ret Expr)

AllocU allocates uninitialized space for n*sizeof(elem) bytes.

func (Builder) AllocZ

func (b Builder) AllocZ(n Expr) (ret Expr)

AllocZ allocates zero initialized space for n bytes.

func (Builder) Alloca

func (b Builder) Alloca(n Expr) (ret Expr)

Alloca allocates uninitialized space for n bytes.

func (Builder) AllocaCStr

func (b Builder) AllocaCStr(gostr Expr) (ret Expr)

AllocaCStr allocates space for copy it from a Go string.

func (Builder) AllocaCStrs

func (b Builder) AllocaCStrs(strs Expr, endWithNil bool) (cstrs Expr)

func allocaCStrs(strs []string, endWithNil bool) **int8

func (Builder) AllocaSigjmpBuf

func (b Builder) AllocaSigjmpBuf() Expr

func (Builder) AllocaT

func (b Builder) AllocaT(t Type) (ret Expr)

func (Builder) ArrayAlloca

func (b Builder) ArrayAlloca(telem Type, n Expr) (ret Expr)

ArrayAlloca reserves space for an array of n elements of type telem.

func (Builder) AssertNilDeref

func (b Builder) AssertNilDeref(ptr Expr)

func (Builder) Atomic

func (b Builder) Atomic(op AtomicOp, ptr, val Expr) Expr

Atomic performs an atomic operation on the memory location pointed to by ptr.

func (Builder) AtomicCmpXchg

func (b Builder) AtomicCmpXchg(ptr, old, new Expr) Expr

AtomicCmpXchg performs an atomic compare-and-swap operation on the memory location pointed to by ptr.

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) BindRecoverFrame

func (b Builder) BindRecoverFrame()

BindRecoverFrame gives this invocation a stack-local identity. The runtime replaces a pending deferred-function token with this activation token only when this invocation is the direct deferred call. Recursive calls to the same function therefore cannot recover the caller's panic.

func (Builder) BuiltinCall

func (b Builder) BuiltinCall(fn string, args ...Expr) (ret Expr)

A Builtin represents a specific use of a built-in function, e.g. len.

Builtins are immutable values. Builtins do not have addresses.

`fn` indicates the function: one of the built-in functions from the Go spec (excluding "make" and "new").

func (Builder) CBytes

func (b Builder) CBytes(v Expr) Expr

CBytes returns a c-style bytes

func (Builder) CMalloc

func (b Builder) CMalloc(n Expr) Expr

CMalloc returns a c-style pointer

func (Builder) CStr

func (b Builder) CStr(v string) Expr

CStr returns a c-style string constant expression.

func (Builder) CString

func (b Builder) CString(v Expr) Expr

CString returns a c-style string

func (Builder) Call

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

The Call instruction represents a function 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()

func (Builder) CallRecoverAlias

func (b Builder) CallRecoverAlias(from Expr, mayRecover bool, fn Expr, buildCall func(Builder, Expr, ...Expr) Expr, args ...Expr) Expr

CallRecoverAlias invokes fn through a compiler-generated wrapper while preserving the wrapped function as the direct deferred call for recover.

func (Builder) ChangeInterface

func (b Builder) ChangeInterface(typ Type, x Expr) (ret Expr)

ChangeInterface constructs a value of one interface type from a value of another interface type known to be assignable to it. This operation cannot fail.

Pos() returns the ast.CallExpr.Lparen if the instruction arose from an explicit T(e) conversion; the ast.TypeAssertExpr.Lparen if the instruction arose from an explicit e.(T) operation; or token.NoPos otherwise.

Example printed form:

t1 = change interface interface{} <- I (t0)

func (Builder) ChangeType

func (b Builder) ChangeType(t Type, x Expr) (ret Expr)

The ChangeType instruction applies to X a value-preserving type change to Type().

Type changes are permitted:

  • between a named type and its underlying type.
  • between two named types of the same underlying type.
  • between (possibly named) pointers to identical base types.
  • from a bidirectional channel to a read- or write-channel, optionally adding/removing a name.
  • between a type (t) and an instance of the type (tσ), i.e. Type() == σ(X.Type()) (or X.Type()== σ(Type())) where σ is the type substitution of Parent().TypeParams by Parent().TypeArgs.

This operation cannot fail dynamically.

Type changes may to be to or from a type parameter (or both). All types in the type set of X.Type() have a value-preserving type change to all types in the type set of Type().

Example printed form:

t1 = changetype *int <- IntPtr (t0)

func (Builder) Complex

func (b Builder) Complex(r, i Expr) Expr

func (Builder) Const

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

Const returns a constant expression.

func (Builder) Convert

func (b Builder) Convert(t Type, x Expr) (ret Expr)

The Convert instruction yields the conversion of value X to type Type(). One or both of those types is basic (but possibly named).

A conversion may change the value and representation of its operand. Conversions are permitted:

  • between real numeric types.
  • between complex numeric types.
  • between string and []byte or []rune.
  • between pointers and unsafe.Pointer.
  • between unsafe.Pointer and uintptr.
  • from (Unicode) integer to (UTF-8) string.

A conversion may imply a type name change also.

Conversions may to be to or from a type parameter. All types in the type set of X.Type() can be converted to all types in the type set of Type().

This operation cannot fail dynamically.

Conversions of untyped string/number/bool constants to a specific representation are eliminated during SSA construction.

Example printed form:

t1 = convert []byte <- string (t0)

func (Builder) DIDeclare

func (b Builder) DIDeclare(variable *types.Var, v Expr, dv DIVar, scope DIScope, pos token.Position, blk BasicBlock)

func (Builder) DIGlobal

func (b Builder) DIGlobal(v Expr, name string, pos token.Position)

func (Builder) DIParam

func (b Builder) DIParam(variable *types.Var, v Expr, dv DIVar, scope DIScope, pos token.Position, blk BasicBlock)

func (Builder) DIScope

func (b Builder) DIScope(f Function, scope *types.Scope) DIScope

func (Builder) DISetCurrentDebugLocation

func (b Builder) DISetCurrentDebugLocation(diScope DIScope, pos token.Position)

func (Builder) DIValue

func (b Builder) DIValue(variable *types.Var, v Expr, dv DIVar, scope DIScope, pos token.Position, blk BasicBlock)

func (Builder) DIVarAuto

func (b Builder) DIVarAuto(scope DIScope, pos token.Position, varName string, vt Type) DIVar

func (Builder) DIVarParam

func (b Builder) DIVarParam(scope DIScope, pos token.Position, varName string, vt Type, argNo int) DIVar

func (Builder) DebugFunction

func (b Builder) DebugFunction(f Function, funcScope *types.Scope, pos token.Position, bodyPos token.Position)

func (Builder) Defer

func (b Builder) Defer(kind DoAction, fn Expr, buildCall func(Builder, Expr, ...Expr) Expr, args ...Expr)

Defer emits a defer instruction.

func (Builder) DeferData

func (b Builder) DeferData() Expr

DeferData returns the defer data (*runtime.Defer).

func (Builder) DeferRecover

func (b Builder) DeferRecover(kind DoAction, mayRecover bool, fn Expr, buildCall func(Builder, Expr, ...Expr) Expr, args ...Expr)

DeferRecover emits a defer instruction with explicit recover capability.

func (Builder) DeferStack

func (b Builder) DeferStack() Expr

DeferStack returns a stable handle to the current function's explicit loop-defer list.

func (Builder) DeferStackDrain

func (b Builder) DeferStackDrain()

DeferStackDrain registers a drain point for defers pushed through an explicit stack, such as range-over-func yield bodies.

func (Builder) DeferTo

func (b Builder) DeferTo(owner Function, stack Expr, fn Expr, buildCall func(Builder, Expr, ...Expr) Expr, args ...Expr)

DeferTo emits a defer instruction into an explicit runtime defer stack.

func (Builder) DeferToRecover

func (b Builder) DeferToRecover(owner Function, stack Expr, mayRecover bool, fn Expr, buildCall func(Builder, Expr, ...Expr) Expr, args ...Expr)

DeferToRecover emits a defer instruction into an explicit runtime defer stack with explicit recover capability.

func (Builder) Dispose

func (b Builder) Dispose()

Dispose disposes of the builder.

func (Builder) Do

func (b Builder) Do(da DoAction, fn Expr, buildCall func(Builder, Expr, ...Expr) Expr, args ...Expr) (ret Expr)

Do call a function with an action.

func (Builder) EmitReflectTypeMethodCheckedLoad

func (b Builder) EmitReflectTypeMethodCheckedLoad(ret Expr, check ReflectMethodCheck)

func (Builder) EmitReflectValueMethodCheckedLoad

func (b Builder) EmitReflectValueMethodCheckedLoad(ret Expr, check ReflectMethodCheck)

func (Builder) EndBuild

func (b Builder) EndBuild()

EndBuild ends the build process of a function.

func (Builder) EnterLocalContext

func (b Builder) EnterLocalContext() (ctx, previous Expr)

EnterLocalContext creates the stack root used by TLS/GLS locality blocks and installs it for the current outermost Go entry. previous is nonzero only for a nested entry that inherited an existing context.

func (Builder) Extract

func (b Builder) Extract(x Expr, i int) (ret Expr)

The Extract instruction yields component Index of Tuple.

This is used to access the results of instructions with multiple return values, such as Call, TypeAssert, Next, UnOp(ARROW) and IndexExpr(Map).

Example printed form:

t1 = extract t0 #1

func (Builder) Field

func (b Builder) Field(x Expr, idx int) Expr

The Field instruction yields the value of Field of struct X.

func (Builder) FieldAddr

func (b Builder) FieldAddr(x Expr, idx int) Expr

The FieldAddr instruction yields the address of Field of *struct X.

The field is identified by its index within the field list of the struct type of X.

Dynamically, this instruction panics if X evaluates to a nil pointer.

Type() returns a (possibly named) *types.Pointer.

Example printed form:

t1 = &t0.name [#1]

func (Builder) FitIntSize

func (b Builder) FitIntSize(n Expr) Expr

fit size to int

func (Builder) Go

func (b Builder) Go(fn Expr, buildCall func(Builder, Expr, ...Expr) Expr, args ...Expr)

The Go instruction creates a new goroutine and calls the specified function within it.

Example printed form:

go println(t0, t1)
go t3()
go invoke t5.Println(...t6)

func (Builder) GoBytes

func (b Builder) GoBytes(v Expr, n Expr) (ret Expr)

GoBytes returns a Go bytes

func (Builder) GoString

func (b Builder) GoString(v Expr) Expr

GoString returns a Go string

func (Builder) GoStringN

func (b Builder) GoStringN(v Expr, n Expr) Expr

GoStringN returns a Go string

func (Builder) If

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

If emits an if instruction.

func (Builder) IfThen

func (b Builder) IfThen(cond Expr, then func())

IfThen emits an if-then instruction.

func (Builder) Imethod

func (b Builder) Imethod(intf Expr, method *types.Func) Expr

Imethod returns closure of an interface method.

func (Builder) ImethodWithRecoverToken

func (b Builder) ImethodWithRecoverToken(intf Expr, method *types.Func) Expr

ImethodWithRecoverToken returns an interface method invocation whose code pointer may also be used as recover-frame bookkeeping data.

func (Builder) Index

func (b Builder) Index(x, idx Expr, takeAddr func() (addr Expr, zero bool)) Expr

The Index instruction yields element Index of collection X, an array, string or type parameter containing an array, a string, a pointer to an, array or a slice.

Example printed form:

t2 = t0[t1]

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) IndirectJump

func (b Builder) IndirectJump(addr Expr, dests []BasicBlock)

IndirectJump emits an indirect jump instruction.

func (Builder) InlineAsm

func (b Builder) InlineAsm(instruction string)

InlineAsm generates inline assembly instruction

func (Builder) InlineAsmFull

func (b Builder) InlineAsmFull(instruction, constraints string, retType Type, exprs []Expr) Expr

func (Builder) InlineCall

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

TODO(xsw): make inline call

func (Builder) InterfaceData

func (b Builder) InterfaceData(x Expr) Expr

InterfaceData returns the data pointer of an interface.

func (Builder) Jump

func (b Builder) Jump(jmpb BasicBlock)

Jump emits a jump instruction.

func (Builder) LeaveLocalContext

func (b Builder) LeaveLocalContext(ctx, previous Expr)

LeaveLocalContext restores an inherited context or drops the stack roots installed by EnterLocalContext.

func (Builder) Load

func (b Builder) Load(ptr Expr) Expr

Load returns the value at the pointer ptr.

func (Builder) Longjmp

func (b Builder) Longjmp(jb, retval Expr)

func (Builder) Lookup

func (b Builder) Lookup(x, key Expr, commaOk bool) (ret Expr)

The Lookup instruction yields element Index of collection map X. Index is the appropriate key type.

If CommaOk, the result is a 2-tuple of the value above and a boolean indicating the result of a map membership test for the key. The components of the tuple are accessed using Extract.

Example printed form:

t2 = t0[t1]
t5 = t3[t4],ok

func (Builder) MakeChan

func (b Builder) MakeChan(t Type, size Expr) (ret Expr)

The MakeChan instruction creates a new channel object and yields a value of kind chan.

Type() returns a (possibly named) *types.Chan.

Pos() returns the ast.CallExpr.Lparen for the make(chan) that created it.

Example printed form:

t0 = make chan int 0
t0 = make IntChan 0

type MakeChan struct {
	register
	Size Value // int; size of buffer; zero => synchronous.
}

func (Builder) MakeClosure

func (b Builder) MakeClosure(fn Expr, bindings []Expr) Expr

The MakeClosure instruction yields a closure value whose code is Fn and whose free variables' values are supplied by Bindings.

Type() returns a (possibly named) *types.Signature.

Example printed form:

t0 = make closure anon@1.2 [x y z]
t1 = make closure bound$(main.I).add [i]

func (Builder) MakeInterface

func (b Builder) MakeInterface(tinter Type, x Expr) (ret Expr)

MakeInterface constructs an instance of an interface type from a value of a concrete type.

Use Program.MethodSets.MethodSet(X.Type()) to find the method-set of X, and Program.MethodValue(m) to find the implementation of a method.

To construct the zero value of an interface type T, use:

NewConst(constant.MakeNil(), T, pos)

Example printed form:

t1 = make interface{} <- int (42:int)
t2 = make Stringer <- t0

func (Builder) MakeInterfaceFromPtr

func (b Builder) MakeInterfaceFromPtr(tinter Type, ptr Expr) (ret Expr)

func (Builder) MakeMap

func (b Builder) MakeMap(t Type, nReserve Expr) (ret Expr)

The MakeMap instruction creates a new hash-table-based map object and yields a value of kind map.

t is a (possibly named) *types.Map.

Example printed form:

t1 = make map[string]int t0
t1 = make StringIntMap t0

func (Builder) MakeSlice

func (b Builder) MakeSlice(t Type, len, cap Expr) (ret Expr)

The MakeSlice instruction yields a slice of length Len backed by a newly allocated array of length Cap.

Both Len and Cap must be non-nil Values of integer type.

(Alloc(types.Array) followed by Slice will not suffice because Alloc can only create arrays of constant length.)

Type() returns a (possibly named) *types.Slice.

Example printed form:

t1 = make []string 1:int t0
t1 = make StringSlice 1:int t0

func (Builder) MakeString

func (b Builder) MakeString(cstr Expr, n ...Expr) (ret Expr)

MakeString creates a new string from a C string pointer and length.

func (Builder) MapUpdate

func (b Builder) MapUpdate(m, k, v Expr)

The MapUpdate instruction updates the association of Map[Key] to Value.

Pos() returns the ast.KeyValueExpr.Colon or ast.IndexExpr.Lbrack, if explicit in the source.

Example printed form:

t0[t1] = t2

func (Builder) MarkReflectMethodByNameCall

func (b Builder) MarkReflectMethodByNameCall(call llvm.Value, kind string, nameArgIndex int)

func (Builder) MarkReflectTypeMethodByNameCall

func (b Builder) MarkReflectTypeMethodByNameCall(call llvm.Value, nameArgIndex int)

func (Builder) MarkReflectTypeMethodByNameExpr

func (b Builder) MarkReflectTypeMethodByNameExpr(call Expr, nameArgIndex int)

func (Builder) MarkReflectValueMethodByNameCall

func (b Builder) MarkReflectValueMethodByNameCall(call llvm.Value, nameArgIndex int)

func (Builder) Next

func (b Builder) Next(typ Type, iter Expr, isString bool) Expr

The Next instruction reads and advances the (map or string) iterator Iter and returns a 3-tuple value (ok, k, v). If the iterator is not exhausted, ok is true and k and v are the next elements of the domain and range, respectively. Otherwise ok is false and k and v are undefined.

Components of the tuple are accessed using Extract.

The IsString field distinguishes iterators over strings from those over maps, as the Type() alone is insufficient: consider map[int]rune.

Type() returns a *types.Tuple for the triple (ok, k, v). The types of k and/or v may be types.Invalid.

Example printed form:

t1 = next t0

func (Builder) NilDerefCheck

func (b Builder) NilDerefCheck(ptr Expr) Expr

func (Builder) Panic

func (b Builder) Panic(v Expr)

Panic emits a panic instruction.

func (Builder) Param

func (b Builder) Param(idx int) Expr

func (Builder) Phi

func (b Builder) Phi(t Type) Phi

Phi returns a phi node.

func (Builder) PrintEx

func (b Builder) PrintEx(ln bool, args ...Expr) (ret Expr)

PrintEx prints the arguments to stderr.

func (Builder) Printf

func (b Builder) Printf(fmt string, args ...Expr) Expr

func (Builder) Println

func (b Builder) Println(args ...Expr) (ret Expr)

Println prints the arguments to stderr, followed by a newline.

func (Builder) PtrCast

func (b Builder) PtrCast(t Type, x Expr) Expr

PtrCast converts a pointer/integer expression to a pointer type.

func (Builder) PyBool

func (b Builder) PyBool(bVal Expr) (ret Expr)

PyBool(bVal bool) *Object

func (Builder) PyByteArray

func (b Builder) PyByteArray(v Expr) Expr

PyByteArray(val []byte) *Object

func (Builder) PyBytes

func (b Builder) PyBytes(v Expr) Expr

PyBytes(val [...]byte) *Object

func (Builder) PyComplex64

func (b Builder) PyComplex64(v Expr) Expr

PyComplex64(val complex64) *Object

func (Builder) PyComplex128

func (b Builder) PyComplex128(v Expr) Expr

PyComplex128(val complex128) *Object

func (Builder) PyFloat

func (b Builder) PyFloat(fltVal Expr) (ret Expr)

PyFloat(fltVal float64) *Object

func (Builder) PyImportMod

func (b Builder) PyImportMod(path string) Expr

PyImportMod imports a Python module.

func (Builder) PyInt64

func (b Builder) PyInt64(intVal Expr) (ret Expr)

PyInt64(val int64) *Object

func (Builder) PyList

func (b Builder) PyList(args ...Expr) (ret Expr)

PyList(args ...Expr) *Object

func (Builder) PyListSetItem

func (b Builder) PyListSetItem(list, index, item Expr) (ret Expr)

PyListSetItem(list *Object, index uintptr, item *Object) c.Int

func (Builder) PyLoadModSyms

func (b Builder) PyLoadModSyms(modName string, objs ...PyObjRef) Expr

PyLoadModSyms loads python objects from specified module.

func (Builder) PyNewList

func (b Builder) PyNewList(n Expr) (ret Expr)

PyNewList(n uintptr) *Object

func (Builder) PyNewTuple

func (b Builder) PyNewTuple(n Expr) (ret Expr)

PyNewTuple(n int) *Object

func (Builder) PyNewVar

func (b Builder) PyNewVar(modName, name string) PyGlobal

PyNewVar creates a Python variable.

func (Builder) PyStr

func (b Builder) PyStr(v string) Expr

PyStr returns a py-style string constant expression.

func (Builder) PyStrExpr

func (b Builder) PyStrExpr(v Expr) Expr

PyStrExpr(str string) *Object

func (Builder) PyTuple

func (b Builder) PyTuple(args ...Expr) (ret Expr)

PyTuple(args ...Expr) *Object

func (Builder) PyTupleSetItem

func (b Builder) PyTupleSetItem(list, index, item Expr) (ret Expr)

PyTupleSetItem(list *Object, index uintptr, item *Object) c.Int

func (Builder) PyUint64

func (b Builder) PyUint64(uintVal Expr) (ret Expr)

PyUint64(val uint64) *Object

func (Builder) PyVal

func (b Builder) PyVal(v Expr) (ret Expr)

PyVal(v any) *Object

func (Builder) Range

func (b Builder) Range(x Expr) Expr

The Range instruction yields an iterator over the domain and range of X, which must be a string or map.

Elements are accessed via Next.

Type() returns an opaque and degenerate "rangeIter" type.

Pos() returns the ast.RangeStmt.For.

Example printed form:

t0 = range "hello":string

func (Builder) Recover

func (b Builder) Recover() Expr

Recover emits a recover instruction.

func (Builder) Recv

func (b Builder) Recv(ch Expr, commaOk bool) (ret Expr)

func (Builder) Return

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

Return emits a return instruction.

func (Builder) RunDefers

func (b Builder) RunDefers()

RunDefers emits instructions to run deferred instructions.

func (Builder) Select

func (b Builder) Select(states []*SelectState, blocking bool) (ret Expr)

The Select instruction tests whether (or blocks until) one of the specified sent or received states is entered.

Let n be the number of States for which Dir==RECV and T_i (0<=i<n) be the element type of each such state's Chan. Select returns an n+2-tuple

(index int, recvOk bool, r_0 T_0, ... r_n-1 T_n-1)

The tuple's components, described below, must be accessed via the Extract instruction.

If Blocking, select waits until exactly one state holds, i.e. a channel becomes ready for the designated operation of sending or receiving; select chooses one among the ready states pseudorandomly, performs the send or receive operation, and sets 'index' to the index of the chosen channel.

If !Blocking, select doesn't block if no states hold; instead it returns immediately with index equal to -1.

If the chosen channel was used for a receive, the r_i component is set to the received value, where i is the index of that state among all n receive states; otherwise r_i has the zero value of type T_i. Note that the receive index i is not the same as the state index index.

The second component of the triple, recvOk, is a boolean whose value is true iff the selected operation was a receive and the receive successfully yielded a value.

Pos() returns the ast.SelectStmt.Select.

Example printed form:

t3 = select nonblocking [<-t0, t1<-t2]
t4 = select blocking []

func (Builder) SelectValue

func (b Builder) SelectValue(cond Expr, a Expr, bExpr Expr) Expr

SelectValue chooses between two values based on the condition.

func (Builder) Send

func (b Builder) Send(ch Expr, x Expr) (ret Expr)

The Send instruction sends X on channel Chan.

Pos() returns the ast.SendStmt.Arrow, if explicit in the source.

Example printed form:

send t0 <- t1

func (Builder) SetBlock

func (b Builder) SetBlock(blk BasicBlock) Builder

SetBlock means SetBlockEx(blk, AtEnd, true).

func (Builder) SetBlockEx

func (b Builder) SetBlockEx(blk BasicBlock, pos InsertPoint, setBlk bool)

SetBlockEx sets blk as current basic block and pos as its insert point.

func (Builder) Setjmp

func (b Builder) Setjmp(jb Expr) Expr

func (Builder) Siglongjmp

func (b Builder) Siglongjmp(jb, retval Expr)

func (Builder) Sigsetjmp

func (b Builder) Sigsetjmp(jb, savemask Expr) Expr

func (Builder) Slice

func (b Builder) Slice(x, low, high, max Expr) (ret Expr)

The Slice instruction yields a slice of an existing string, slice or *array X between optional integer bounds Low and High.

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

Type() returns string if the type of X was string, otherwise a *types.Slice with the same element type as X.

Example printed form:

t1 = slice t0[1:]

func (Builder) SliceCap

func (b Builder) SliceCap(x Expr) Expr

SliceCap returns the length of a slice cap.

func (Builder) SliceData

func (b Builder) SliceData(x Expr) Expr

SliceData returns the data pointer of a slice.

func (Builder) SliceLen

func (b Builder) SliceLen(x Expr) Expr

SliceLen returns the length of a slice.

func (Builder) SliceLit

func (b Builder) SliceLit(t Type, elts ...Expr) Expr

SliceLit creates a new slice with the specified elements.

func (Builder) SliceToArrayPointer

func (b Builder) SliceToArrayPointer(x Expr, typ Type) (ret Expr)

The SliceToArrayPointer instruction yields the conversion of slice X to array pointer.

Pos() returns the ast.CallExpr.Lparen, if the instruction arose from an explicit conversion in the source.

Conversion may to be to or from a type parameter. All types in the type set of X.Type() must be a slice types that can be converted to all types in the type set of Type() which must all be pointer to array types.

This operation can fail dynamically if the length of the slice is less than the length of the array.

Example printed form:

t1 = slice to array pointer *[4]byte <- []byte (t0)

func (Builder) StackRestore

func (b Builder) StackRestore(sp Expr)

declare void @llvm.stackrestore.p0(ptr)

func (Builder) StackSave

func (b Builder) StackSave() Expr

declare ptr @llvm.stacksave.p0()

func (Builder) Store

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

Store stores val at the pointer ptr.

func (Builder) Str

func (b Builder) Str(v string) Expr

Str returns a Go string constant expression.

func (Builder) StringData

func (b Builder) StringData(x Expr) Expr

StringData returns the data pointer of a string.

func (Builder) StringLen

func (b Builder) StringLen(x Expr) Expr

StringLen returns the length of a string.

func (Builder) Times

func (b Builder) Times(n Expr, loop func(i Expr))

Times emits a times-loop instruction.

func (Builder) TypeAssert

func (b Builder) TypeAssert(x Expr, assertedTyp Type, commaOk bool) Expr

The TypeAssert instruction tests whether interface value X has type AssertedType.

If !CommaOk, on success it returns v, the result of the conversion (defined below); on failure it panics.

If CommaOk: on success it returns a pair (v, true) where v is the result of the conversion; on failure it returns (z, false) where z is AssertedType's zero value. The components of the pair must be accessed using the Extract instruction.

If Underlying: tests whether interface value X has the underlying type AssertedType.

If AssertedType is a concrete type, TypeAssert checks whether the dynamic type in interface X is equal to it, and if so, the result of the conversion is a copy of the value in the interface.

If AssertedType is an interface, TypeAssert checks whether the dynamic type of the interface is assignable to it, and if so, the result of the conversion is a copy of the interface value X. If AssertedType is a superinterface of X.Type(), the operation will fail iff the operand is nil. (Contrast with ChangeInterface, which performs no nil-check.)

Type() reflects the actual type of the result, possibly a 2-types.Tuple; AssertedType is the asserted type.

Depending on the TypeAssert's purpose, Pos may return:

  • the ast.CallExpr.Lparen of an explicit T(e) conversion;
  • the ast.TypeAssertExpr.Lparen of an explicit e.(T) operation;
  • the ast.CaseClause.Case of a case of a type-switch statement;
  • the Ident(m).NamePos of an interface method value i.m (for which TypeAssert may be used to effect the nil check).

Example printed form:

t1 = typeassert t0.(int)
t3 = typeassert,ok t2.(T)

func (Builder) UnOp

func (b Builder) UnOp(op token.Token, x Expr) (ret 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.

func (Builder) Unreachable

func (b Builder) Unreachable()

Unreachable emits an unreachable instruction.

func (Builder) WrapNilCheck

func (b Builder) WrapNilCheck(ptr, recvType, methodName Expr) Expr

type CompilationUnit

type CompilationUnit = *aCompilationUnit

type DIExpression

type DIExpression = *aDIExpression

type DIFile

type DIFile = *aDIFile

type DIFunction

type DIFunction = *aDIFunction

type DIGlobalVariableExpression

type DIGlobalVariableExpression = *aDIGlobalVariableExpression

type DILexicalBlock

type DILexicalBlock = *aDILexicalBlock

type DIScope

type DIScope interface {
	// contains filtered or unexported methods
}

type DIScopeMeta

type DIScopeMeta = *aDIScopeMeta

type DIType

type DIType = *aDIType

type DIVar

type DIVar = *aDIVar

type DoAction

type DoAction int
const (
	Call DoAction = iota
	Go
	DeferAlways // defer statement executes always
	DeferInCond // defer statement executes in a conditional block
	DeferInLoop // defer statement executes in a loop block
)

type Expr

type Expr struct {
	Type
	// contains filtered or unexported fields
}
var Nil Expr // Zero value is a nil Expr

func Builtin

func Builtin(name string) Expr

Builtin returns a builtin function expression.

func SizeOf

func SizeOf(prog Program, t Type, n ...int64) Expr

SizeOf returns the size of a type.

func (Expr) IsNil

func (v Expr) IsNil() bool

IsNil checks if the expression is nil or not.

func (Expr) Name

func (v Expr) Name() string

func (Expr) SetName

func (v Expr) SetName(alias string) Expr

func (Expr) SetOrdering

func (v Expr) SetOrdering(ordering AtomicOrdering) Expr

SetOrdering sets the ordering of the atomic operation.

func (Expr) SetVolatile

func (v Expr) SetVolatile(volatile bool) Expr

SetVolatile marks a load or store as volatile.

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) BuildLocalPackageAccessor

func (p Function) BuildLocalPackageAccessor(cache, size, align Expr)

BuildLocalPackageAccessor builds an always-hot package block lookup around a generated owner-local cache slot. The runtime owns allocation and rooting; the compiler needs no LocalContext or block-header layout knowledge.

func (Function) DisableTailCalls

func (p Function) DisableTailCalls()

func (Function) Env

func (p Function) Env() Expr

Env returns the physical closure environment parameter.

func (Function) EnvType

func (p Function) EnvType() Type

EnvType returns the physical closure environment pointer type, or nil.

func (Function) FreeVar

func (p Function) FreeVar(b Builder, i int) Expr

FreeVar returns the function's ith free variable.

func (Function) HasBody

func (p Function) HasBody() bool

HasBody reports whether the function has a body.

func (Function) Inline

func (p Function) Inline(inline inlineAttr)

func (Function) MakeBlock

func (p Function) MakeBlock() BasicBlock

MakeBlock creates a new basic block for 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) Name

func (p Function) Name() string

Name returns the function's name.

func (Function) NeedsEnv

func (p Function) NeedsEnv() bool

NeedsEnv reports whether the physical function entry takes a compiler-owned closure environment parameter.

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.

func (Function) SetRecover

func (p Function) SetRecover(blk BasicBlock)

SetRecover sets the recover block for the function.

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.

func (Global) InitNil

func (g Global) InitNil()

func (Global) ReplaceAllUsesWith

func (g Global) ReplaceAllUsesWith(v Expr)

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 InsertPoint

type InsertPoint int
const (
	AtEnd InsertPoint = iota
	AtStart
	BeforeLast
)

type LocalStorage

type LocalStorage = localitylayout.Storage

type Locality

type Locality = locality.Kind

type LocalityInfo

type LocalityInfo = locality.Info

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) AddGlobalString

func (pkg Package) AddGlobalString(name string, value string)

func (Package) AfterInit

func (p Package) AfterInit(b Builder, ret BasicBlock)

AfterInit is called after the package is initialized (init all packages that depends on).

func (Package) ConstBytes

func (pkg Package) ConstBytes(value []byte) Expr

ConstBytes creates an SSA expression for a []byte backed by writable static data. Each call gets its own backing store, matching []byte mutability semantics.

func (Package) ConstSlice

func (pkg Package) ConstSlice(name string, t Type, values []Expr) Expr

ConstSlice creates a slice constant backed by a writable package global. The backing store must remain writable because a Go slice literal may be mutated after package initialization.

func (Package) ConstString

func (pkg Package) ConstString(value string) Expr

ConstString creates an SSA expression representing a Go string literal. The returned value is backed by an anonymous global constant and can be used to initialize package-level variables or other constant contexts that expect a Go string value.

func (Package) EmitFuncInfo

func (p Package) EmitFuncInfo(symbol, name, file string, line, column int)

EmitFuncInfo records a function's linker symbol, Go name, and declaration source position as LLVM named metadata. The row layout is:

!{i32 version, !"symbol", !"go.name", !"file", i32 line, i32 column}

func (Package) EmitPCLineInfo

func (p Package) EmitPCLineInfo(id uint64, symbol, file string, line, column int)

EmitPCLineInfo records a PC label id and its source position. The id names a zero-byte label emitted in the function body; keeping the metadata string-only lets dead functions be removed without the line table holding address references to them.

func (Package) ExportFuncs

func (p Package) ExportFuncs() map[string]string

func (Package) FinalizeDebug

func (p Package) FinalizeDebug()

FinalizeDebug resolves temporary debug metadata and releases the package's DI builder. No debug records may be added after this call.

func (Package) FinishMetaCollection

func (p Package) FinishMetaCollection() error

func (Package) FuncOf

func (p Package) FuncOf(name string) Function

FuncOf returns a function by name.

func (Package) InitAbiTypes

func (p Package) InitAbiTypes(fname string) Function

func (Package) InitAbiTypesFor

func (p Package) InitAbiTypesFor(fname string, filter func(sym *AbiSymbol) bool) Function

func (Package) InitDebug

func (p Package) InitDebug(name, pkgPath string, positioner Positioner)

func (Package) MarkReflectMethod

func (p Package) MarkReflectMethod(funcName string)

func (Package) MaterializePreserveSyms

func (p Package) MaterializePreserveSyms()

func (Package) Module

func (p Package) Module() llvm.Module

func (Package) NewEnvFunc

func (p Package) NewEnvFunc(
	name string, sig *types.Signature, bg Background, env *types.Var, instantiated bool,
) Function

NewEnvFunc creates a function whose Go signature is sig and whose physical LLVM entry has an additional compiler-owned environment parameter.

func (Package) NewFunc

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

NewFunc creates a new function.

func (Package) NewFuncEx

func (p Package) NewFuncEx(name string, sig *types.Signature, bg Background, hasFreeVars bool, instantiated bool) Function

NewFuncEx creates a new function.

func (Package) NewThreadLocalVar

func (p Package) NewThreadLocalVar(name string, typ types.Type, bg Background) Global

NewThreadLocalVar creates a native TLS variable. Unlike NewVar, it keeps independent storage for zero-sized values instead of using the module-wide zero-sized allocation sentinel.

func (Package) NewVar

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

NewVar creates a new global variable.

func (Package) NewVarEx

func (p Package) NewVarEx(name string, t Type) Global

NewVarEx creates a new global variable.

func (Package) Path

func (p Package) Path() string

Path returns the package path.

func (Package) PyNewFunc

func (p Package) PyNewFunc(name string, sig *types.Signature, doInit bool) PyObjRef

PyNewFunc creates a new python function.

func (Package) PyNewModVar

func (p Package) PyNewModVar(name string, doInit bool) Global

PyNewModVar creates a new global variable for a Python module.

func (Package) PyObjOf

func (p Package) PyObjOf(name string) PyObjRef

PyObjOf returns a python object by name.

func (Package) RecordReflectMethodByIndex

func (p Package) RecordReflectMethodByIndex(funcName string, index int)

func (Package) RecordReflectMethodByName

func (p Package) RecordReflectMethodByName(funcName, name string)

func (Package) RegisterAbiTypes

func (p Package) RegisterAbiTypes(infos []AbiTypeInfo)

RegisterAbiTypes declares runtime type descriptors owned by other Programs. It records only Go type identity and target-local LLVM types; descriptor definitions remain in the package modules that materialized them.

func (Package) RuntimeFunc

func (p Package) RuntimeFunc(fnName string) Expr

RuntimeFunc returns a declaration for a function in LLGo's internal runtime.

func (Package) SetExport

func (p Package) SetExport(name, export string)

func (Package) SetResolveLinkname

func (p Package) SetResolveLinkname(fn func(string) string)

SetResolveLinkname sets a function to resolve linkname.

func (Package) String

func (p Package) String() string

String returns a string representation of the package.

func (Package) Undefined

func (pkg Package) Undefined(names ...string) error

Undefined global string var by names

func (Package) VarOf

func (p Package) VarOf(name string) Global

VarOf returns a global variable by name.

type Phi

type Phi struct {
	Expr
}

Phi represents a phi node.

func (Phi) AddIncoming

func (p Phi) AddIncoming(b Builder, preds []BasicBlock, f func(i int, blk BasicBlock) Expr)

AddIncoming adds incoming values to a phi node.

type Positioner

type Positioner interface {
	Position(pos token.Pos) token.Position
}

type Program

type Program = *aProgram

A Program presents a program.

func NewProgram

func NewProgram(target *Target) Program

NewProgram creates a new program.

func (Program) AbiType

func (p Program) AbiType() Type

AbiType returns abi.Type type.

func (Program) AbiTypePtr

func (p Program) AbiTypePtr() Type

AbiTypePtr returns *abi.Type type.

func (Program) AbiTypes

func (p Program) AbiTypes() []AbiTypeInfo

AbiTypes snapshots the runtime type descriptors materialized by this Program without retaining any LLVM-owned values.

func (Program) ActivateLocalitiesFor

func (p Program) ActivateLocalitiesFor(pkg *types.Package)

ActivateLocalitiesFor marks pkg's concrete import path as part of the effective build graph. Alternate packages are scanned and prepared before link reachability is known; their declarations must not require a LocalContext merely because metadata exists.

func (Program) AlignOf

func (p Program) AlignOf(typ Type) uint64

AlignOf returns the ABI alignment of typ for the current target.

func (Program) Any

func (p Program) Any() Type

Any returns the any (empty interface) type.

func (Program) Bool

func (p Program) Bool() Type

Bool returns bool type.

func (Program) BoolVal

func (p Program) BoolVal(v bool) Expr

BoolVal returns a boolean constant expression.

func (Program) Byte

func (p Program) Byte() Type

Byte returns byte type.

func (Program) CInt

func (p Program) CInt() Type

CInt returns c.Int type.

func (Program) CIntPtr

func (p Program) CIntPtr() Type

CIntPtr returns *c.Int type.

func (Program) CStr

func (p Program) CStr() Type

CStr returns *int8 type.

func (Program) Closure

func (p Program) Closure(sig *types.Signature) Type

Closure creates a closture type for a function.

func (Program) Complex64

func (p Program) Complex64() Type

Complex64 returns complex64 type.

func (Program) Complex128

func (p Program) Complex128() Type

Complex128 returns complex128 type.

func (Program) ComplexVal

func (p Program) ComplexVal(v complex128, t Type) Expr

ComplexVal returns a complex constant expression.

func (Program) ConstArray

func (prog Program) ConstArray(t Type, values []Expr) Expr

ConstArray creates an LLVM constant array expression.

func (Program) ConstStruct

func (prog Program) ConstStruct(t Type, values []Expr) Expr

ConstStruct creates an LLVM constant struct expression.

func (Program) DataLayout

func (p Program) DataLayout() string

func (Program) DeadcodeDropEnabled

func (p Program) DeadcodeDropEnabled() bool

func (Program) DeclareLocality

func (p Program) DeclareLocality(pkg *types.Package, name string, info LocalityInfo)

DeclareLocality records locality metadata found on a declaration in pkg. Alternate packages can share canonical symbol names with the packages they replace, so both ownership and metadata retain the raw import path. Repeated loads of the same raw path preserve metadata enriched during preparation.

func (Program) Defer

func (p Program) Defer() Type

Defer returns runtime.Defer type.

func (Program) DeferPtr

func (p Program) DeferPtr() Type

DeferPtr returns *runtime.Defer type.

func (Program) DisableBoundsChecks

func (p Program) DisableBoundsChecks(disable bool)

DisableBoundsChecks controls index, slice, and slice-to-array conversion bounds checks. Other dynamic validity checks, including nil pointer and unsafe builtin checks, are not affected.

func (Program) Dispose

func (p Program) Dispose()

Dispose releases the LLVM resources owned by the program: the context (and with it every module built in it), the target machine and the target data. The Program and everything created from it must not be used afterwards. In-process drivers that compile many packages sequentially (llgen goldens, the cltest run harness) call this between compiles; without it each compile's C++-side memory lives until the process exits.

func (Program) Elem

func (p Program) Elem(typ Type) Type

func (Program) EnableDeadcodeDrop

func (p Program) EnableDeadcodeDrop(enable bool)

func (Program) EnableFuncInfoMetadata

func (p Program) EnableFuncInfoMetadata(enable bool)

EnableFuncInfoMetadata controls emission of DCE-safe function source metadata. The metadata intentionally stores symbol names as strings instead of function pointer operands, so it can be consumed before materializing a final runtime line/func table without keeping otherwise-dead functions alive.

func (Program) EnableFuncInfoSites

func (p Program) EnableFuncInfoSites(enable bool)

EnableFuncInfoSites controls emission of the per-function site records (entry and PC-line inline-asm fragments inside function bodies). They are gated separately from the funcinfo metadata tables because the body-embedded anchors shift instruction/scope layout enough to confuse debuggers; debug builds keep the tables (FuncForPC name/FileLine fidelity via the dlsym path) but drop the sites.

func (Program) EnableGoGlobalDCE

func (p Program) EnableGoGlobalDCE(enable bool)

func (Program) EnableLTOPluginMarkers

func (p Program) EnableLTOPluginMarkers(enable bool)

func (Program) Field

func (p Program) Field(typ Type, i int) Type

func (Program) Float32

func (p Program) Float32() Type

Float32 returns float32 type.

func (Program) Float64

func (p Program) Float64() Type

Float64 returns float64 type.

func (Program) FloatVal

func (p Program) FloatVal(v float64, t Type) Expr

FloatVal returns a float constant expression.

func (Program) FuncDecl

func (p Program) FuncDecl(sig *types.Signature, bg Background) Type

FuncDecl converts a Go/C function declaration into raw type.

func (Program) FuncInfoMetadataEnabled

func (p Program) FuncInfoMetadataEnabled() bool

func (Program) FuncInfoSitesEnabled

func (p Program) FuncInfoSitesEnabled() bool

func (Program) HasClosureEnvDirective

func (p Program) HasClosureEnvDirective(fset *token.FileSet, name string, pos token.Pos) bool

HasClosureEnvDirective reports whether a source function declaration has the cached llgo:env directive.

func (Program) Index

func (p Program) Index(typ Type) Type

func (Program) Int

func (p Program) Int() Type

Int returns int type.

func (Program) Int32

func (p Program) Int32() Type

Int32 returns int32 type.

func (Program) Int64

func (p Program) Int64() Type

Int64 returns int64 type.

func (Program) IntVal

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

IntVal returns an integer constant expression.

func (Program) Linkname

func (p Program) Linkname(name string) (link string, ok bool)

func (Program) MarkPackageSyntaxParsed

func (p Program) MarkPackageSyntaxParsed(pkg *types.Package)

func (Program) NeedsFramePointer

func (p Program) NeedsFramePointer() bool

NeedsFramePointer reports whether functions should keep the frame-pointer chain: only on OS targets where the runtime's FP unwinder runs.

func (Program) NeedsLocalContext

func (p Program) NeedsLocalContext() bool

func (Program) NewBackendProgram

func (p Program) NewBackendProgram() Program

NewBackendProgram creates a Program with fresh LLVM-owned state and the same build configuration as p. Go-side package syntax and locality metadata are shared directly; callers must finish preparing them before backend Programs are created and use them read-only afterwards.

func (Program) NewPackage

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

NewPackage creates a new package.

func (Program) NewPackageEx

func (p Program) NewPackageEx(name, pkgPath string, metaCollect bool) Package

func (Program) Nil

func (p Program) Nil(t Type) Expr

Nil returns a null constant expression. t should be a pointer type.

func (Program) OffsetOf

func (p Program) OffsetOf(typ Type, i int) uint64

OffsetOf returns the offset of a field in a struct.

func (Program) PackageExport

func (p Program) PackageExport(name string) (string, bool)

PackageExport returns the preloaded export name for name.

func (Program) PackageLocalities

func (p Program) PackageLocalities(pkgPath string) map[string]VariableLocality

PackageLocalities returns the legacy canonical-only metadata view. Its result is unspecified when a canonical path has multiple declaration owners; use PackageLocalitiesFor in owner-aware code.

func (Program) PackageLocalitiesFor

func (p Program) PackageLocalitiesFor(pkg *types.Package) map[string]VariableLocality

PackageLocalitiesFor returns locality metadata applicable to the concrete package. Declaration entries retain both their owner and owner-specific metadata. Entries with no declaration owner remain applicable by canonical package path for compatibility with preloaded metadata.

func (Program) PackageSyntaxParsed

func (p Program) PackageSyntaxParsed(pkg *types.Package) bool

func (Program) Pointer

func (p Program) Pointer(typ Type) Type

func (Program) PointerSize

func (p Program) PointerSize() int

func (Program) PyObjectPtr

func (p Program) PyObjectPtr() Type

PyObjectPtr returns the *py.Object type.

func (Program) PyObjectPtrPtr

func (p Program) PyObjectPtrPtr() Type

PyObjectPtrPtr returns the **py.Object type.

func (Program) ResolveLocality

func (p Program) ResolveLocality(name string) (string, VariableLocality, bool, error)

ResolveLocality returns locality metadata for one declaration. Locality variables cannot participate in go:linkname alias chains.

func (Program) ResolveLocalityFor

func (p Program) ResolveLocalityFor(pkg *types.Package, name string) (string, VariableLocality, bool, error)

ResolveLocalityFor resolves locality metadata using the concrete package's declaration when the canonical package path has multiple owners. Owner-less preloaded metadata remains a canonical-name compatibility fallback.

func (Program) SetClosureEnvDirective

func (p Program) SetClosureEnvDirective(fset *token.FileSet, name string, pos token.Pos)

SetClosureEnvDirective records that a source function declaration has the llgo:env directive. name and pos identify the source declaration rather than its resolved linker symbol, so aliases retain independent ABI metadata.

func (Program) SetCompileMethods

func (p Program) SetCompileMethods(check func(Package, types.Type))

func (Program) SetDebugInfoOptimized

func (p Program) SetDebugInfoOptimized(enable bool)

SetDebugInfoOptimized records whether DWARF should mark generated code as optimized. It never selects compiler passes.

func (Program) SetLinkname

func (p Program) SetLinkname(name, link string)

func (Program) SetLocalStorage

func (p Program) SetLocalStorage(name string, storage LocalStorage)

func (Program) SetLocalStorageFor

func (p Program) SetLocalStorageFor(pkg *types.Package, name string, storage LocalStorage)

SetLocalStorageFor records the selected storage for one concrete package declaration.

func (Program) SetLocalityInfo

func (p Program) SetLocalityInfo(name string, info LocalityInfo)

func (Program) SetLocalityInfoFor

func (p Program) SetLocalityInfoFor(pkg *types.Package, name string, info LocalityInfo)

SetLocalityInfoFor updates locality metadata for one concrete package declaration. It preserves distinct metadata for standard and alternate packages whose canonical symbol names are identical.

func (Program) SetNoInterfaceMethod

func (p Program) SetNoInterfaceMethod(fullName string)

func (Program) SetPackageExport

func (p Program) SetPackageExport(name, export string)

SetPackageExport records an export directive before the LLVM Package that will later preserve the symbol exists.

func (Program) SetPatch

func (p Program) SetPatch(patchType func(types.Type) types.Type)

func (Program) SetPthreadStackSize

func (p Program) SetPthreadStackSize(size uint64)

func (Program) SetPython

func (p Program) SetPython(py any)

SetPython sets the Python package. Its type can be *types.Package or func() *types.Package.

func (Program) SetRuntime

func (p Program) SetRuntime(runtime any)

SetRuntime sets the runtime. Its type can be *types.Package or func() *types.Package.

func (Program) SetTypeBackground

func (p Program) SetTypeBackground(fullName string, bg Background)

func (Program) SizeOf

func (p Program) SizeOf(typ Type, n ...int64) uint64

TODO(xsw): how to generate platform independent code?

func (Program) Slice

func (p Program) Slice(typ Type) Type

func (Program) String

func (p Program) String() Type

String returns string type.

func (Program) Struct

func (p Program) Struct(typs ...Type) Type

Struct returns a struct type.

func (Program) Target

func (p Program) Target() *Target

func (Program) TargetData

func (p Program) TargetData() llvm.TargetData

func (Program) TargetMachine

func (p Program) TargetMachine() llvm.TargetMachine

func (Program) Type

func (p Program) Type(typ types.Type, bg Background) Type

Type convert a Go/C type into raw type. C type = raw type Go type: convert to raw type (because of closure)

func (Program) TypeSizes

func (p Program) TypeSizes(sizes types.Sizes) types.Sizes

TypeSizes returns the sizes of the types.

func (Program) Uint

func (p Program) Uint() Type

Uint returns uint type.

func (Program) Uint16

func (p Program) Uint16() Type

Uint16 returns uint16 type.

func (Program) Uint32

func (p Program) Uint32() Type

Uint32 returns uint32 type.

func (Program) Uint64

func (p Program) Uint64() Type

Uint64 returns uint64 type.

func (Program) Uintptr

func (p Program) Uintptr() Type

Uintptr returns uintptr type.

func (Program) Val

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

Val returns a constant expression.

func (Program) ValidateLocalities

func (p Program) ValidateLocalities(pkgPath string) error

ValidateLocalities validates the legacy canonical-only metadata view. Its result is unspecified when multiple declaration owners share a canonical path; use ValidateLocalitiesFor in owner-aware code.

func (Program) ValidateLocalitiesFor

func (p Program) ValidateLocalitiesFor(pkg *types.Package) error

ValidateLocalitiesFor validates only declarations that belong to pkg, plus owner-less preloaded metadata for its canonical package path.

func (Program) VariableLocality

func (p Program) VariableLocality(name string) (VariableLocality, bool)

VariableLocality returns the legacy canonical-only metadata view. Its result is unspecified when multiple declaration owners share name; use VariableLocalityFor in owner-aware code.

func (Program) VariableLocalityFor

func (p Program) VariableLocalityFor(pkg *types.Package, name string) (VariableLocality, bool)

VariableLocalityFor returns metadata for a concrete declaration, falling back to owner-less preloaded metadata by canonical symbol name.

func (Program) Void

func (p Program) Void() Type

Void returns void type.

func (Program) VoidPtr

func (p Program) VoidPtr() Type

VoidPtr returns *void type.

func (Program) VoidPtrPtr

func (p Program) VoidPtrPtr() Type

VoidPtrPtr returns **void type.

func (Program) Zero

func (p Program) Zero(t Type) Expr

Zero returns a zero constant expression.

type PyGlobal

type PyGlobal = *aPyGlobal

type PyObjRef

type PyObjRef = *aPyObjRef

PyObjRef represents a python object reference.

type ReflectMethodCheck

type ReflectMethodCheck struct {
	Kind int
	Name string
}

type SelectState

type SelectState struct {
	Chan  Expr // channel to use (for send or receive)
	Value Expr // value to send (for send)
	Send  bool // direction of case (SendOnly or RecvOnly)
}

type Target

type Target struct {
	GOOS                    string
	GOARCH                  string
	GOARM                   string // "5", "6", "7" (default)
	Target                  string // target name from -target flag (e.g., "esp32", "arm7tdmi", "wasi")
	LLVMTarget              string // physical LLVM target selected by a target configuration
	OptLevel                optlevel.Level
	SaturatingFloatToUint32 bool
}

func (*Target) ClosureEnvBuildTag

func (p *Target) ClosureEnvBuildTag() string

ClosureEnvBuildTag selects the runtime half of the same physical ABI used by the backend. It must be added after a named target has resolved its real LLVM triple; GOARCH may only be a package-selection compatibility value.

func (*Target) Spec

func (p *Target) Spec() (spec TargetSpec)

type TargetSpec

type TargetSpec struct {
	Triple   string
	CPU      string
	Features string
}

type Type

type Type = *aType

func (Type) RawType

func (t Type) RawType() types.Type

RawType returns the raw type.

type VariableLocality

type VariableLocality struct {
	LocalStorage LocalStorage
	locality.Info
}

VariableLocality is the locality metadata attached to one package variable.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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