Documentation
¶
Overview ¶
Package abi contains target-independent lowering for LLGo's internal ABI.
Index ¶
- Constants
- func LowerAggregateCopies(td llvm.TargetData, m llvm.Module, config AggregateLoweringConfig) int
- func LowerLargeAggregates(td llvm.TargetData, m llvm.Module, config AggregateLoweringConfig)
- func MaxSSAValueSize(ptrSize int) uint64
- func PopGCRootFrame(m llvm.Module, fn llvm.Value, frame GCRootFrame)
- func ShouldLowerArrayCopy(length int, size uint64, ptrSize int) bool
- func ShouldSnapshotAggregateLoad(isArray bool, arrayLen int, isStruct bool, size uint64, ptrSize int) bool
- type AggregateLoweringConfig
- type GCRootFrame
Constants ¶
const ( // MaxStackVarSize matches cmd/compile's default limit for explicitly // declared variables. Values larger than this must not live on LLGo's // fixed native stack. MaxStackVarSize uint64 = 128 * 1024 // MaxImplicitStackVarSize matches cmd/compile's default limit for // compiler-generated temporaries. MaxImplicitStackVarSize uint64 = 64 * 1024 // MinAggregateCopySize is the point at which aggregate loads and // stores are lowered to memory intrinsics to avoid LLVM scalarization. // Return types and the native stack/return ABI still use MaxImplicitStackVarSize. MinAggregateCopySize uint64 = 4 * 1024 // MaxSSAValueWords matches cmd/compile's ssa.MaxStruct: a value may occupy // at most this many pointer-sized words and still be SSAable. MaxSSAValueWords = 4 )
const MaxEscapeStackBytes uint64 = 64 * 1024
MaxEscapeStackBytes bounds storage newly promoted by Go escape analysis and its lowering helpers in one function. Existing locals and later LLVM frame layout remain independent; this is not a bound on the entire call stack.
const SmallStackBufferSize = runtimeabi.SmallStackBufferSize
Variables ¶
This section is empty.
Functions ¶
func LowerAggregateCopies ¶ added in v1.0.10
func LowerAggregateCopies(td llvm.TargetData, m llvm.Module, config AggregateLoweringConfig) int
LowerAggregateCopies applies snapshot lowering to copies of at least 4 KiB and to multi-element arrays larger than MaxSSAValueSize. LLVM scalarizes first-class loads of those arrays, notably NTT polynomials. Smaller arrays stay first-class so they can remain in registers. Function signatures, return sret, and the native C ABI are unchanged: loads used as call arguments are left alone. config.Wasm still selects the wasm GC-root frame layout.
func LowerLargeAggregates ¶
func LowerLargeAggregates(td llvm.TargetData, m llvm.Module, config AggregateLoweringConfig)
LowerLargeAggregates converts oversized direct aggregate returns and copies to indirect memory operations before target-specific C ABI lowering runs.
func MaxSSAValueSize ¶ added in v1.0.10
MaxSSAValueSize is cmd/compile's CanSSA size limit (MaxStruct * PtrSize).
func PopGCRootFrame ¶ added in v1.0.4
func PopGCRootFrame(m llvm.Module, fn llvm.Value, frame GCRootFrame)
PopGCRootFrame restores the chain only when this frame is its actual head. Discarded entries replayed by SJLJ may return without having linked a frame.
func ShouldLowerArrayCopy ¶ added in v1.0.10
ShouldLowerArrayCopy reports whether a multi-element array should be copied in memory instead of as a first-class LLVM value. Arrays larger than MaxSSAValueSize are not SSAable in cmd/compile; smaller ones stay in registers.
func ShouldSnapshotAggregateLoad ¶ added in v1.0.10
func ShouldSnapshotAggregateLoad(isArray bool, arrayLen int, isStruct bool, size uint64, ptrSize int) bool
ShouldSnapshotAggregateLoad reports whether ABI copy lowering may heap-allocate a snapshot of this load (AllocU), which the frontend must treat as a GC safepoint. Copies smaller than MinAggregateCopySize use a stack alloca instead, including CanSSA-sized arrays, so they are not safepoints.
Types ¶
type AggregateLoweringConfig ¶ added in v1.0.4
AggregateLoweringConfig describes the Go runtime ABI used by lowering-created allocations and roots. GoWordSize can exceed the physical Wasm address size.
type GCRootFrame ¶ added in v1.0.4
type GCRootFrame struct {
Frame, Prev llvm.Value
Slots []llvm.Value
// contains filtered or unexported fields
}
GCRootFrame is the shadow-frame layout used by temporaries introduced after frontend root planning.
func NewGCRootFrame ¶ added in v1.0.4
func NewGCRootFrame(m llvm.Module, fn llvm.Value, count, pointerSize, goWordSize int, wasm bool) GCRootFrame
NewGCRootFrame adds an outer frame before the existing entry. When frames are nested by successive lowering passes, pop them in the reverse order.
func (GCRootFrame) StorePointer ¶ added in v1.0.4
func (frame GCRootFrame) StorePointer(b llvm.Builder, slot, ptr llvm.Value)
StorePointer publishes a physical address in the Go pointer storage format.