ssa

package
v1.0.10 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2026 License: Apache-2.0 Imports: 37 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"

	// FuncInfoFlagWrapper marks compiler-generated forwarding wrappers. The
	// runtime uses this to match gc's abi.FuncIDWrapper stack-trace elision.
	FuncInfoFlagWrapper uint32 = 1
)
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"
)
View Source
const RuntimeGoroutineStackSizeVar = PkgRuntime + ".goroutineStackSize"

RuntimeGoroutineStackSizeVar names the private configuration global declared in runtime/internal/runtime/proc.go. Keep that declaration in sync; the build cache integration test checks injection into the actual runtime package.

View Source
const WasmGCNoScanSection = "llgo_gc_noscan"

WasmGCNoScanSection holds static storage that cannot contain Go heap roots. wasm-ld supplies its __start_/__stop_ boundaries to the linear collector.

Variables

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

Functions

func CanInlineArrayEqual added in v1.0.1

func CanInlineArrayEqual(t *types.Array) bool

CanInlineArrayEqual reports whether comparing an array element by element is cheaper than calling its equality algorithm. A single element is always safe to inline. For simple elements, use cmd/compile's four-element budget, but not its size-based allowance: this builder emits element-wise compares rather than merging adjacent loads into wider compares.

func CanInlineStructEqual added in v1.0.2

func CanInlineStructEqual(t *types.Struct, size uint64, pointerSize int) bool

CanInlineStructEqual reports whether direct field comparisons keep the module compact. It uses a four-field budget similar to array comparisons, plus a size cap because struct fields can themselves be large aggregates.

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 IsRuntimeSupportPackage added in v1.0.4

func IsRuntimeSupportPackage(path string) bool

IsRuntimeSupportPackage reports whether path is part of the selected Go or LLGo runtime implementation rather than an ordinary user/library package.

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 RuntimeSymbol added in v1.0.9

func RuntimeSymbol(name string, candidates ...string) string

RuntimeSymbol bounds a computed compiler lookup to an explicit set of names. The runtime ownership audit checks every candidate, including paths that the current compilation does not execute. Keep candidates literal at call sites.

func SIMDMaskShape added in v1.0.7

func SIMDMaskShape(typ types.Type) (*types.Array, bool)

SIMDMaskShape recognizes fixed-width SIMD masks. Masks use canonical zero or all-one integer lanes, preserving their public Go storage representation.

func SIMDNumericShape added in v1.0.7

func SIMDNumericShape(typ types.Type) (*types.Array, bool)

SIMDNumericShape validates the official numeric aggregate representation. Keep storage knowledge here, separate from operation selection and features.

func SIMDVectorShape added in v1.0.7

func SIMDVectorShape(typ types.Type) (*types.Array, bool)

SIMDVectorShape validates numeric and mask SIMD128/256 storage.

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 AESOp added in v1.0.10

type AESOp uint8

AESOp is the private interface used by the AES source patch. ARM rounds consume a key before SubBytes; the other targets consume it after the round.

const (
	AESEncryptRound AESOp = iota
	AESEncryptLast
	AESDecryptRound
	AESDecryptLast
	AESInverseMixKey
	AESXORKey
	AESXORBlock
)

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 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) AESAlloca added in v1.0.10

func (b Builder) AESAlloca(size int) Expr

AESAlloca reserves fixed-size, pointer-free AES state in the entry block. Explicit vector storage and alignment permit SROA while making counter-word accesses valid on strict-alignment targets as well.

func (Builder) AESRound added in v1.0.10

func (b Builder) AESRound(op AESOp, dst, src, key Expr) Expr

AESRound operates on unaligned byte buffers. Only the round-key operand (or both operands for InverseMixKey) uses the generic uint32 schedule layout.

func (Builder) AESSubWord added in v1.0.10

func (b Builder) AESSubWord(x Expr) Expr

AESSubWord substitutes every byte without secret-indexed table accesses.

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

Alloc allocates space for a variable of type elem.

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) AllocEx added in v1.0.4

func (b Builder) AllocEx(elem Type, heap bool, hoistToEntry bool) (ret Expr)

AllocEx allocates space for a variable of type elem with hoistToEntry control.

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) AppendFreshSliceToNil added in v1.0.10

func (b Builder) AppendFreshSliceToNil(t Type, fresh Expr) Expr

AppendFreshSliceToNil forwards a fresh, exclusively used slice whose length equals its capacity. The caller must give its backing array result lifetime. An empty append preserves nil, unlike make of a zero-length slice.

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) ArrayBinOp added in v1.0.1

func (b Builder) ArrayBinOp(op token.Token, x, y, xaddr, yaddr Expr) Expr

ArrayBinOp compares two array values while reusing their backing addresses when the frontend has proved that those addresses still hold the loaded values. A nil address falls back to a value-preserving temporary.

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) BinOpEx added in v1.0.10

func (b Builder) BinOpEx(op token.Token, x, y Expr, heap bool) Expr

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) BitCast added in v1.0.2

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

BitCast reinterprets x using t without changing its bits.

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) CallForwardVarargs added in v1.0.7

func (b Builder) CallForwardVarargs(fn Expr, args ...Expr) Expr

CallForwardVarargs forwards a variadic thunk's incoming ellipsis unchanged. CanForwardVarargs must hold, the caller must return the result immediately, and later ABI lowering must preserve the call and return without rewrites.

func (Builder) CallLLVMIntrinsic added in v1.0.10

func (b Builder) CallLLVMIntrinsic(d *LLVMIntrinsic, args ...Expr) (Expr, error)

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) CallRecoverTailAlias added in v1.0.10

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

CallRecoverTailAlias is for proven forwarding returns only. Their enclosing deferred-call scope restores the alias after the adapter returns.

func (Builder) CanForwardVarargs added in v1.0.7

func (b Builder) CanForwardVarargs(fn Expr) bool

CanForwardVarargs checks the unlowered ABI of a direct variadic forwarding call. The physical result must equal the logical Go result so Call cannot insert a result conversion between the tail call and its return.

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.

Type changes preserve values, with range checks when explicit native storage narrows an element at its ABI boundary.

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) ConvertEx added in v1.0.10

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

func (Builder) DIClosureEnv added in v1.0.9

func (b Builder) DIClosureEnv(pos token.Position, blk BasicBlock)

DIClosureEnv describes the compiler-owned environment separately from source parameters. Its type lets debuggers inspect a closure value even when that closure is not executing. Opaque //llgo:env entries intentionally keep their unsafe.Pointer type and cannot be expanded as captures.

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)

DIParam emits parameter debug information without exposing its storage. Its original signature is retained for callers that use Builder method values.

func (Builder) DIParamWithHome added in v1.0.7

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

DIParamWithHome returns the stable O0 storage backing the parameter.

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) DIStore added in v1.0.7

func (b Builder) DIStore(ptr, value Expr)

DIStore updates the stable debug-only storage for an O0 parameter.

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) DIWasmMemory added in v1.0.10

func (b Builder) DIWasmMemory(pos token.Position, blk BasicBlock)

DIWasmMemory exposes a byte at linear-memory offset 1 through each guest frame. Engines translate the indirect DWARF location through the current instance without a dependency on their private VMContext layout.

func (Builder) DebugFrameAddress added in v1.0.9

func (b Builder) DebugFrameAddress() Expr

DebugFrameAddress captures this function's physical frame base, which the Wasm debugger uses for parked DW_OP_fbreg locals after the fiber switches.

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) EmitLocationRecord added in v1.0.7

func (b Builder) EmitLocationRecord(kind, name, file string, line int, emit func() Expr)

EmitLocationRecord emits an idempotent runtime source-location update unless the current block already has the same update and debug position with no intervening call or terminator. emit returns the update it appended; any instructions following it remain visible to the tracker. Non-tail insertion keeps all records; it cannot reuse append-only history.

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) GCRootPointers added in v1.0.2

func (b Builder) GCRootPointers(value Expr) []Expr

GCRootPointers extracts the heap pointers represented by value.

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) ImethodBorrowed added in v1.0.10

func (b Builder) ImethodBorrowed(intf Expr, method *types.Func, recoverToken bool) Expr

ImethodBorrowed reserves a caller-owned receiver word for a synchronous invocation. go/defer registrations must retain their longer-lived storage.

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) InlineAsmNoDebug added in v1.0.7

func (b Builder) InlineAsmNoDebug(instruction string)

InlineAsmNoDebug emits inline assembly without attaching the builder's current source location. The builder location itself is left unchanged.

func (Builder) InlineCall

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

TODO(xsw): make inline call

func (Builder) InterfaceBasicTypeUsed added in v1.0.9

func (b Builder) InterfaceBasicTypeUsed(t *types.Basic) Expr

InterfaceBasicTypeUsed reports link-time visibility of a basic type. Floating- point domains also include named types with that underlying kind. It defaults to true outside a closed Wasm executable using the development dead-code pass.

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) KeepAlive added in v1.0.10

func (b Builder) KeepAlive(x Expr) Expr

KeepAlive keeps both interface words live for conservative GC scanning. The data word may point to a stack object containing further pointers; declare memory access explicitly so its fields must remain materialized. This compiler barrier does not emit a hardware memory fence.

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) MakeClosureEx added in v1.0.10

func (b Builder) MakeClosureEx(fn Expr, bindings []Expr, heap bool) Expr

MakeClosureEx permits stack storage only when the caller has proved that the closure is invoked synchronously and never retained.

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) MakeInterfaceDataOnly added in v1.0.9

func (b Builder) MakeInterfaceDataOnly(tinter Type, x Expr) Expr

MakeInterfaceDataOnly boxes an argument for a statically checked runtime call. Its type word is unobservable and remains nil; the ordinary interface data word and GC-root layout retain the argument across allocating calls.

func (Builder) MakeInterfaceDataOnlyEx added in v1.0.10

func (b Builder) MakeInterfaceDataOnlyEx(tinter Type, x Expr, heap bool) Expr

MakeInterfaceDataOnlyEx omits unobservable type metadata and uses the heap decision supplied by escape analysis. Stack boxes obey the same ownership, target GC policy and per-function budget as ordinary interface boxes.

func (Builder) MakeInterfaceEx added in v1.0.10

func (b Builder) MakeInterfaceEx(tinter Type, x Expr, heap bool) Expr

MakeInterfaceEx constructs an interface with a heap or stack box. A stack box requires the caller to prove that its address cannot outlive this call.

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) MakeMapEx added in v1.0.10

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

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) MakeSliceEx added in v1.0.10

func (b Builder) MakeSliceEx(t Type, len, cap Expr, heap bool) (ret Expr)

func (Builder) MakeSliceStackCapacity added in v1.0.10

func (b Builder) MakeSliceStackCapacity(t Type, len, cap Expr, capacity int64) Expr

MakeSliceStackCapacity preserves runtime length checks while using a statically bounded backing array whose lifetime was proved by the frontend.

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) MapLitLoop added in v1.0.10

func (b Builder) MapLitLoop(m Expr, keys, vals []Expr)

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) RangeBorrowed added in v1.0.10

func (b Builder) RangeBorrowed(x Expr) Expr

RangeBorrowed keeps its iterator in this invocation when the shared stack budget permits. The iterator must not outlive the function's frame.

func (Builder) ReadOnlyBytesString added in v1.0.10

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

ReadOnlyBytesString requires a temporary string with no source mutation on any path from the conversion to its final consumer.

func (Builder) ReadOnlyStringBytes added in v1.0.10

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

ReadOnlyStringBytes is valid only with a frontend proof that the resulting slice neither escapes nor can be mutated, including through called helpers.

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) SIMD added in v1.0.7

func (b Builder) SIMD(op SIMDOp, result Type, args ...Expr) Expr

SIMD lowers a validated source operation. LLVM legalizes these operations for the native baseline; wasm needs the SIMD128 feature. The result type is explicit for loads and conversions whose result differs from their operands.

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) SetGCRoot added in v1.0.2

func (b Builder) SetGCRoot(root, value Expr)

SetGCRoot publishes value through a root created by NewGCRoots.

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) StructBinOp added in v1.0.2

func (b Builder) StructBinOp(op token.Token, x, y, xaddr, yaddr Expr) Expr

StructBinOp compares two struct values while allowing the frontend to reuse an operand address when it has proved that doing so preserves value semantics. Non-regular structs remain field-wise so their semantic comparisons preserve the established ordering and panic behavior; source addresses are used only for regular-memory structs.

func (Builder) StructLit added in v1.0.10

func (b Builder) StructLit(typ Type, fields []Expr) Expr

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) UMulOverflow added in v1.0.4

func (b Builder) UMulOverflow(a, c Expr) Expr

UMulOverflow returns the wrapped unsigned product and an overflow flag. Both operands must have the same unsigned integer type.

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 CallConv added in v1.0.7

type CallConv int
const (
	GoDecl CallConv
	CDecl
	PyDecl
	Stdcall
)

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. The caller must provide eight-byte alignment for 64-bit atomic loads and stores.

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) AllowSIMDDispatcherInlining added in v1.0.7

func (f Function) AllowSIMDDispatcherInlining()

AllowSIMDDispatcherInlining separates a compiler-required physical source frame from the synthetic FMV entry. The implementation retains its frame; the tail-only dispatcher may inline without changing the source call stack. Callers must not set this for an explicit noinline directive or -l.

func (Function) Block

func (p Function) Block(idx int) BasicBlock

Block returns the ith basic block of the function.

func (Function) BuildGoroutineLocalPackageAccessor added in v1.0.4

func (p Function) BuildGoroutineLocalPackageAccessor(key, size, align Expr)

BuildGoroutineLocalPackageAccessor resolves a package block through the current logical G. The global key identifies the package but never caches a worker-specific address.

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) ClosureContextParam added in v1.0.2

func (p Function) ClosureContextParam() Expr

ClosureContextParam returns the hidden closure context parameter.

func (Function) Coalesce added in v1.0.10

func (p Function) Coalesce()

Coalesce lets this definition share a COFF section group with equivalent linkonce entries. Preserve its linkage so externally visible entries remain available even when no function in this module references them.

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) MarkSIMDFMV added in v1.0.7

func (f Function) MarkSIMDFMV(available bool, query string)

MarkSIMDFMV records compiler-checked source identities for the early LLVM transform. An available variant is a cross-package ABI promise: the defining package emits it, and guarded callers may refer to it without LTO.

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) NewGCRoots added in v1.0.2

func (p Function) NewGCRoots(count int) []Expr

NewGCRoots reserves count pointer roots in one compiler-maintained frame. It must be called once, before the function emits a return.

func (Function) Param

func (p Function) Param(i int) Expr

Params returns the function's ith parameter.

func (Function) SetEscapeStackBytes added in v1.0.10

func (f Function) SetEscapeStackBytes(size uint64)

SetEscapeStackBytes reserves the Go-level plan before helper lowering starts.

func (Function) SetRecover

func (p Function) SetRecover(blk BasicBlock)

SetRecover sets the recover block for the function.

func (Function) SetWasmImport added in v1.0.2

func (p Function) SetWasmImport(module, name string)

SetWasmImport maps an external function declaration to a WebAssembly host import. LLVM preserves these attributes through the final wasm link.

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 LLVMIntrinsic added in v1.0.10

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

LLVMIntrinsic connects a checked LLVM binding to its Go result representation.

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) EmitFuncInfoFlags added in v1.0.1

func (p Package) EmitFuncInfoFlags(symbol, name, file string, line, column int, flags uint32)

EmitFuncInfoFlags is EmitFuncInfo with compiler/runtime semantic flags. Its versioned row adds one trailing i32 flags operand so old metadata remains readable while consumers can distinguish generated wrappers from ordinary methods with the same displayed Go name.

func (Package) EmitPCLineInfo

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

EmitPCLineInfo records a source-row ID and its source position. Independent zero-byte anchors for the same function/file/line can share the ID. Keeping this 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, cc CallConv, 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, cc CallConv) Function

NewFunc creates a new function.

func (Package) NewFuncEx

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

NewFuncEx creates a new function.

func (Package) NewThreadLocalVar

func (p Package) NewThreadLocalVar(name string, typ types.Type, cc CallConv) 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, cc CallConv) 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) ReplaceVarWith added in v1.0.7

func (p Package) ReplaceVarWith(name string, replacement Expr) bool

ReplaceVarWith replaces a non-alias global with an existing value, removing the original global and its attached debug information. It returns false if a previous lowering pass already removed the variable.

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

func (prog Program) ConstByteArray(t Type, value []byte) Expr

ConstByteArray creates a compact LLVM constant for a Go byte array. Unlike ConstArray, it does not allocate one LLVM value wrapper per array element.

func (Program) ConstStruct

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

ConstStruct creates an LLVM constant struct expression.

func (Program) CooperativeSafepointsEnabled added in v1.0.2

func (p Program) CooperativeSafepointsEnabled() bool

CooperativeSafepointsEnabled reports whether scheduling polls are enabled.

func (Program) DataLayout

func (p Program) DataLayout() string

func (Program) DeadcodeDropEnabled

func (p Program) DeadcodeDropEnabled() bool

func (Program) DebugInfoOptimized added in v1.0.7

func (p Program) DebugInfoOptimized() bool

DebugInfoOptimized reports whether generated debug information is marked as optimized for this program.

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) EnableCodeViewDebugInfo added in v1.0.2

func (p Program) EnableCodeViewDebugInfo(enable bool)

EnableCodeViewDebugInfo asks LLVM to lower the existing source metadata to CodeView in addition to DWARF. The final COFF link may then merge CodeView records into a PDB without removing the DWARF used by LLDB and tracebacks.

func (Program) EnableCooperativeSafepoints added in v1.0.2

func (p Program) EnableCooperativeSafepoints(enable bool)

EnableCooperativeSafepoints controls compiler-inserted scheduling polls.

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 per-function site records. The build layer may apply a narrower target policy to function-entry address records while retaining PC-line records.

func (Program) EnableGCRoots added in v1.0.2

func (p Program) EnableGCRoots(enable bool)

EnableGCRoots controls compiler-maintained GC roots.

func (Program) EnableGoGlobalDCE

func (p Program) EnableGoGlobalDCE(enable bool)

func (Program) EnableLTOPluginMarkers

func (p Program) EnableLTOPluginMarkers(enable bool)

func (Program) EnableLogicalGoroutineLocality added in v1.0.4

func (p Program) EnableLogicalGoroutineLocality(enable bool)

EnableLogicalGoroutineLocality stores GLS variables on the logical G rather than in native TLS. Bounded schedulers enable it when multiple goroutines can run sequentially on one physical worker.

func (Program) EnableThreadLocalGCRoots added in v1.0.7

func (p Program) EnableThreadLocalGCRoots(enable bool)

EnableThreadLocalGCRoots gives each native worker an independent compiler root chain and SJLJ replay flag. The runtime provides matching TLS globals.

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, cc CallConv) 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) GCRootCount added in v1.0.2

func (p Program) GCRootCount(typ Type) int

GCRootCount reports how many heap pointers typ contributes to a root frame.

func (Program) GCRootsEnabled added in v1.0.2

func (p Program) GCRootsEnabled() bool

GCRootsEnabled reports whether compiler-maintained GC roots are enabled.

func (Program) GoWordSize added in v1.0.4

func (p Program) GoWordSize() int

GoWordSize is the storage width of int, uint, uintptr, and Go pointers. The official Go WebAssembly ports use an eight-byte language word even when Core Wasm addresses are i32. Pointer expressions remain LLVM pointers so memory operations use the physical address width.

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) HasLinknameTarget added in v1.0.1

func (p Program) HasLinknameTarget(target string) bool

HasLinknameTarget reports whether a declaration aliases target. It lets build-time dead-code decisions preserve symbols that another package can reference only through //go:linkname.

func (Program) Index

func (p Program) Index(typ Type) Type

func (Program) InitPthreadStackSize added in v1.0.3

func (p Program) InitPthreadStackSize(g Global)

InitPthreadStackSize initializes the runtime's private stack configuration. Keeping the immutable value in the runtime module lets LLVM fold it into NewProc without baking build configuration into every goroutine caller.

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) InterfaceIndirect added in v1.0.10

func (p Program) InterfaceIndirect(t Type) bool

InterfaceIndirect reports whether an interface data word points at a copy of t. Frontend lifetime analysis must use the same representation as lowering, including LLGo's two-word Go closures and one-word native callbacks.

func (Program) IsRegularMemory added in v1.0.2

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

IsRegularMemory reports whether values of typ may be compared bytewise.

func (Program) Linkname

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

func (Program) LogicalGoroutineLocalityEnabled added in v1.0.4

func (p Program) LogicalGoroutineLocalityEnabled() bool

LogicalGoroutineLocalityEnabled reports whether GLS follows the logical G.

func (Program) MapStackStorage added in v1.0.10

func (p Program) MapStackStorage(t Type) (header, bucket Type)

MapStackStorage shares the exact header/bucket layout and eligibility policy between escape-analysis reservation and allocation lowering.

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) NeedsLocalContextForPackages added in v1.0.5

func (p Program) NeedsLocalContextForPackages(pkgs []*types.Package) bool

NeedsLocalContextForPackages reports the startup requirement for one set of concrete packages without changing the shared declaration registry.

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) ResolveLLVMIntrinsic added in v1.0.10

func (p Program) ResolveLLVMIntrinsic(name string, sig *types.Signature) (*LLVMIntrinsic, error)

ResolveLLVMIntrinsic maps Go value types, then delegates validation and overload resolution to llvmintrinsic. Callers cache it per Go declaration.

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 an LLGo closure-environment directive. name and pos identify the declaration 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) SetNativeStructFields added in v1.0.9

func (p Program) SetNativeStructFields(positions []token.Pos)

SetNativeStructFields supplies the context missing from types.Sizes.Offsetsof: its argument contains fields, but not their enclosing named struct. Positions must be the valid field identifiers from the same parsed declarations as the type calling convention, including the first field. Synthetic structs must not reuse those positions: Offsetsof has no enclosing type with which to disambiguate them. Empty structs need no positions.

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)

SetPthreadStackSize configures the runtime module's goroutine stack size. Goroutine call sites do not embed this value.

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) SetTypeCallConv added in v1.0.7

func (p Program) SetTypeCallConv(typFullName string, cc CallConv, fields ...*types.Var)

SetTypeCallConv sets the default calling convention for the named type, controlling how that type (and functions using it) are lowered. For a programmatically constructed native struct, supply its original fields so types.Sizes.Offsetsof can identify the enclosing layout without a named type or source positions. Source loaders instead call SetNativeStructFields before type checking. Synthetic structs must not reuse registered fields.

func (Program) SetWasmImport added in v1.0.2

func (p Program) SetWasmImport(name, module, importName string)

SetWasmImport records a //go:wasmimport directive before its declaration is lowered into the package's LLVM module.

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) StackRootBytes added in v1.0.10

func (p Program) StackRootBytes(typ Type) uint64

StackRootBytes reserves field-address slots plus a possible frame header. Charging the header per object is conservative when objects share a frame.

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) ThreadLocalGCRootsEnabled added in v1.0.7

func (p Program) ThreadLocalGCRootsEnabled() bool

ThreadLocalGCRootsEnabled reports whether compiler roots are worker-local.

func (Program) Type

func (p Program) Type(typ types.Type, cc CallConv) 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) ValidateVectorMaps added in v1.0.9

func (p Program) ValidateVectorMaps(t types.Type) error

ValidateVectorMaps rejects map storage requiring native vector alignment. Follow containers to find maps, but check each key/value's by-value layout: a pointer to a vector is allowed, while arrays and structs containing one are not. Keep the runtime's bucket layout and indirection policy unchanged.

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) VectorMapValidator added in v1.0.9

func (p Program) VectorMapValidator() func(types.Type) error

VectorMapValidator returns a checker with a per-compilation type cache. Use after source metadata and type checking are complete.

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) WasmImport added in v1.0.2

func (p Program) WasmImport(name string) (module, importName string, ok bool)

WasmImport returns the WebAssembly host import attached to name.

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 SIMDOp added in v1.0.7

type SIMDOp uint8

SIMDOp identifies semantic operations independently of Go syntax tokens.

const (
	SIMDAdd SIMDOp = iota
	SIMDSub
	SIMDAnd
	SIMDOr
	SIMDXor
	SIMDExtractLane
	SIMDInsertLane
	SIMDUnimplemented
	SIMDLoad
	SIMDStore
	SIMDBroadcast
	SIMDSplatLane0
	SIMDMul
	SIMDDiv
	SIMDAndNot
	SIMDOrNot
	SIMDNot
	SIMDNeg
	SIMDAbs
	SIMDSqrt
	SIMDCeil
	SIMDFloor
	SIMDTrunc
	SIMDRound
	SIMDBitcast
	SIMDEqual
	SIMDNotEqual
	SIMDLess
	SIMDLessEqual
	SIMDGreater
	SIMDGreaterEqual
	SIMDToMask
	SIMDBitSelect
	SIMDBitSelectNot
	SIMDBlend
	SIMDMaskFromBits
	SIMDMaskToBits
	SIMDShiftAllLeft
	SIMDShiftAllRight
	SIMDShiftLeft
	SIMDShiftRight
	SIMDShift
	SIMDAddSaturated
	SIMDSubSaturated
	SIMDMin
	SIMDMax
	SIMDConvert
	SIMDLookupOrZero
	SIMDPermuteOrZero
	SIMDPermute
	SIMDAverage
	SIMDFMA
	SIMDMulWidenLo
	SIMDRotateAllLeft
	SIMDRotateAllRight
	SIMDCarrylessMultiply
	SIMDCarrylessMultiplyLo
	SIMDStoreMasked
	SIMDExtendLo
	SIMDExtendHi
	SIMDSaturate
	SIMDSaturateConcat
	SIMDGetLo
	SIMDGetHi
	SIMDSetLo
	SIMDSetHi
	SIMDInterleaveLo
	SIMDInterleaveHi
	SIMDInterleaveLoGrouped
	SIMDInterleaveHiGrouped
	SIMDConcatEven
	SIMDConcatOdd
	SIMDInterleaveEven
	SIMDInterleaveOdd
	SIMDExtend
	SIMDTruncate
	SIMDSaturateConcatGrouped
	SIMDConvertLo
	SIMDConcatSelected
	SIMDConcatSelectedGrouped
	SIMDConcatPermute128
	SIMDConcatAddPairs
	SIMDConcatAddPairsGrouped
	SIMDConcatSubPairs
	SIMDConcatSubPairsGrouped
)

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
	GO386                string // "sse2" (default) or "softfloat"
	GOAMD64              string // "v1" (default), "v2", "v3", or "v4"
	GOARM                string // "5", "6", "7" (default), with optional float mode
	GOARM64              string // "v8.0" (default) through "v9.5", with optional extensions
	Target               string // target name from -target flag (e.g., "esp32", "arm7tdmi", "wasi")
	LLVMTarget           string // physical LLVM target selected by a target configuration
	WasmProfile          string // logical hosted WebAssembly profile (j32, j64, or w32)
	WasmProvider         string // hosted WebAssembly provider (gojs, emscripten, or wasi)
	WasmReflectBridges   bool   // emit statically typed reflection bridges for this program
	WasmFuncInfoEntries  bool   // emit table-index symbolization records for this program
	OptLevel             optlevel.Level
	SaturatingFloatToInt bool // enable Go's experimental converthash behavior
}

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