Documentation ¶
Overview ¶
Package wazeroir is a pkg to compile down the standard Wasm binary to wazero's specific IR (wazeroir). The wazeroir is inspired by microwasm format (a.k.a. LightbeamIR), previously used in the lightbeam JIT compiler in Wasmtime, though it is not specified and only exists in the previous codebase of wasmtime e.g. https://github.com/bytecodealliance/wasmtime/blob/v0.29.0/crates/lightbeam/src/microwasm.rs
See RATIONALE.md for detail.
Index ¶
- Constants
- func Format(ops []Operation) string
- type BranchTarget
- type BranchTargetDrop
- type CompilationResult
- type Float
- type InclusiveRange
- type Label
- type LabelKind
- type MemoryImmediate
- type Operation
- type OperationAbs
- type OperationAdd
- type OperationAnd
- type OperationBr
- type OperationBrIf
- type OperationBrTable
- type OperationCall
- type OperationCallIndirect
- type OperationCeil
- type OperationClz
- type OperationConstF32
- type OperationConstF64
- type OperationConstI32
- type OperationConstI64
- type OperationCopysign
- type OperationCtz
- type OperationDiv
- type OperationDrop
- type OperationEq
- type OperationEqz
- type OperationExtend
- type OperationF32DemoteFromF64
- type OperationF32ReinterpretFromI32
- type OperationF64PromoteFromF32
- type OperationF64ReinterpretFromI64
- type OperationFConvertFromI
- type OperationFloor
- type OperationGe
- type OperationGlobalGet
- type OperationGlobalSet
- type OperationGt
- type OperationI32ReinterpretFromF32
- type OperationI32WrapFromI64
- type OperationI64ReinterpretFromF64
- type OperationITruncFromF
- type OperationKind
- type OperationLabel
- type OperationLe
- type OperationLoad
- type OperationLoad16
- type OperationLoad32
- type OperationLoad8
- type OperationLt
- type OperationMax
- type OperationMemoryGrow
- type OperationMemorySize
- type OperationMin
- type OperationMul
- type OperationNe
- type OperationNearest
- type OperationNeg
- type OperationOr
- type OperationPick
- type OperationPopcnt
- type OperationRem
- type OperationRotl
- type OperationRotr
- type OperationSelect
- type OperationShl
- type OperationShr
- type OperationSignExtend32From16
- type OperationSignExtend32From8
- type OperationSignExtend64From16
- type OperationSignExtend64From32
- type OperationSignExtend64From8
- type OperationSqrt
- type OperationStore
- type OperationStore16
- type OperationStore32
- type OperationStore8
- type OperationSub
- type OperationSwap
- type OperationTrunc
- type OperationUnreachable
- type OperationXor
- type SignedInt
- type SignedType
- type UnsignedInt
- type UnsignedType
Constants ¶
View Source
const EntrypointLabel = ".entrypoint"
Variables ¶
This section is empty.
Functions ¶
Types ¶
type BranchTarget ¶
type BranchTarget struct {
Label *Label
}
func (*BranchTarget) IsReturnTarget ¶
func (b *BranchTarget) IsReturnTarget() bool
func (*BranchTarget) String ¶
func (b *BranchTarget) String() (ret string)
type BranchTargetDrop ¶
type BranchTargetDrop struct { Target *BranchTarget ToDrop *InclusiveRange }
func (*BranchTargetDrop) String ¶
func (b *BranchTargetDrop) String() (ret string)
type CompilationResult ¶
type CompilationResult struct { // Operations holds wazeroir operations compiled from Wasm instructions in a Wasm function. Operations []Operation // LabelCallers maps Label.String() to the number of callers to that label. // Here "callers" means that the call-sites which jumps to the label with br, br_if or br_table // instructions. // // Note: zero possible and allowed in wasm. Ex. // // (block // (br 0) // (block i32.const 1111) // ) // // This example the label corresponding to `(block i32.const 1111)` is never be reached at runtime because `br 0` exits the function before we reach there LabelCallers map[string]uint32 // Signature is the function type of the compilation target function. Signature *wasm.FunctionType // Globals holds all the declarations of globals in the module from which this function is compiled. Globals []*wasm.GlobalType // Functions holds all the declarations of function in the module from which this function is compiled, including itself. Functions []wasm.Index // Types holds all the types in the module from which this function is compiled. Types []*wasm.FunctionType // HasMemory is true if the module from which this function is compiled has memory declaration. HasMemory bool // HasTable is true if the module from which this function is compiled has table declaration. HasTable bool }
func CompileFunctions ¶
type InclusiveRange ¶
type InclusiveRange struct {
Start, End int
}
type MemoryImmediate ¶
type MemoryImmediate struct { // Alignment the expected alignment (expressed as the exponent of a power of 2). Default to the natural alignment. // // "Natural alignment" is defined here as the smallest power of two that can hold the size of the value type. Ex // wasm.ValueTypeI64 is encoded in 8 little-endian bytes. 2^3 = 8, so the natural alignment is three. Alignment uint32 // Offset is the address offset added to the instruction's dynamic address operand, yielding a 33-bit effective // address that is the zero-based index at which the memory is accessed. Default to zero. Offset uint32 }
MemoryImmediate is the "memarg" to all memory instructions.
See https://www.w3.org/TR/2019/REC-wasm-core-1-20191205/#memory-instructions%E2%91%A0
type Operation ¶
type Operation interface {
Kind() OperationKind
}
type OperationAbs ¶
type OperationAbs struct{ Type Float }
func (*OperationAbs) Kind ¶
func (o *OperationAbs) Kind() OperationKind
type OperationAdd ¶
type OperationAdd struct{ Type UnsignedType }
func (*OperationAdd) Kind ¶
func (o *OperationAdd) Kind() OperationKind
type OperationAnd ¶
type OperationAnd struct{ Type UnsignedInt }
func (*OperationAnd) Kind ¶
func (o *OperationAnd) Kind() OperationKind
type OperationBr ¶
type OperationBr struct {
Target *BranchTarget
}
func (*OperationBr) Kind ¶
func (o *OperationBr) Kind() OperationKind
type OperationBrIf ¶
type OperationBrIf struct {
Then, Else *BranchTargetDrop
}
func (*OperationBrIf) Kind ¶
func (o *OperationBrIf) Kind() OperationKind
type OperationBrTable ¶
type OperationBrTable struct { Targets []*BranchTargetDrop Default *BranchTargetDrop }
func (*OperationBrTable) Kind ¶
func (o *OperationBrTable) Kind() OperationKind
type OperationCall ¶
type OperationCall struct {
FunctionIndex uint32
}
func (*OperationCall) Kind ¶
func (o *OperationCall) Kind() OperationKind
type OperationCallIndirect ¶
type OperationCallIndirect struct {
TypeIndex, TableIndex uint32
}
func (*OperationCallIndirect) Kind ¶
func (o *OperationCallIndirect) Kind() OperationKind
type OperationCeil ¶
type OperationCeil struct{ Type Float }
func (*OperationCeil) Kind ¶
func (o *OperationCeil) Kind() OperationKind
type OperationClz ¶
type OperationClz struct{ Type UnsignedInt }
func (*OperationClz) Kind ¶
func (o *OperationClz) Kind() OperationKind
type OperationConstF32 ¶
type OperationConstF32 struct{ Value float32 }
func (*OperationConstF32) Kind ¶
func (o *OperationConstF32) Kind() OperationKind
type OperationConstF64 ¶
type OperationConstF64 struct{ Value float64 }
func (*OperationConstF64) Kind ¶
func (o *OperationConstF64) Kind() OperationKind
type OperationConstI32 ¶
type OperationConstI32 struct{ Value uint32 }
func (*OperationConstI32) Kind ¶
func (o *OperationConstI32) Kind() OperationKind
type OperationConstI64 ¶
type OperationConstI64 struct{ Value uint64 }
func (*OperationConstI64) Kind ¶
func (o *OperationConstI64) Kind() OperationKind
type OperationCopysign ¶
type OperationCopysign struct{ Type Float }
func (*OperationCopysign) Kind ¶
func (o *OperationCopysign) Kind() OperationKind
type OperationCtz ¶
type OperationCtz struct{ Type UnsignedInt }
func (*OperationCtz) Kind ¶
func (o *OperationCtz) Kind() OperationKind
type OperationDiv ¶
type OperationDiv struct{ Type SignedType }
func (*OperationDiv) Kind ¶
func (o *OperationDiv) Kind() OperationKind
type OperationDrop ¶
type OperationDrop struct{ Depth *InclusiveRange }
func (*OperationDrop) Kind ¶
func (o *OperationDrop) Kind() OperationKind
type OperationEq ¶
type OperationEq struct{ Type UnsignedType }
func (*OperationEq) Kind ¶
func (o *OperationEq) Kind() OperationKind
type OperationEqz ¶
type OperationEqz struct{ Type UnsignedInt }
func (*OperationEqz) Kind ¶
func (o *OperationEqz) Kind() OperationKind
type OperationExtend ¶
type OperationExtend struct{ Signed bool }
func (*OperationExtend) Kind ¶
func (o *OperationExtend) Kind() OperationKind
type OperationF32DemoteFromF64 ¶
type OperationF32DemoteFromF64 struct{}
func (*OperationF32DemoteFromF64) Kind ¶
func (o *OperationF32DemoteFromF64) Kind() OperationKind
type OperationF32ReinterpretFromI32 ¶
type OperationF32ReinterpretFromI32 struct{}
func (*OperationF32ReinterpretFromI32) Kind ¶
func (o *OperationF32ReinterpretFromI32) Kind() OperationKind
type OperationF64PromoteFromF32 ¶
type OperationF64PromoteFromF32 struct{}
func (*OperationF64PromoteFromF32) Kind ¶
func (o *OperationF64PromoteFromF32) Kind() OperationKind
type OperationF64ReinterpretFromI64 ¶
type OperationF64ReinterpretFromI64 struct{}
func (*OperationF64ReinterpretFromI64) Kind ¶
func (o *OperationF64ReinterpretFromI64) Kind() OperationKind
type OperationFConvertFromI ¶
func (*OperationFConvertFromI) Kind ¶
func (o *OperationFConvertFromI) Kind() OperationKind
type OperationFloor ¶
type OperationFloor struct{ Type Float }
func (*OperationFloor) Kind ¶
func (o *OperationFloor) Kind() OperationKind
type OperationGe ¶
type OperationGe struct{ Type SignedType }
func (*OperationGe) Kind ¶
func (o *OperationGe) Kind() OperationKind
type OperationGlobalGet ¶
type OperationGlobalGet struct{ Index uint32 }
func (*OperationGlobalGet) Kind ¶
func (o *OperationGlobalGet) Kind() OperationKind
type OperationGlobalSet ¶
type OperationGlobalSet struct{ Index uint32 }
func (*OperationGlobalSet) Kind ¶
func (o *OperationGlobalSet) Kind() OperationKind
type OperationGt ¶
type OperationGt struct{ Type SignedType }
func (*OperationGt) Kind ¶
func (o *OperationGt) Kind() OperationKind
type OperationI32ReinterpretFromF32 ¶
type OperationI32ReinterpretFromF32 struct{}
func (*OperationI32ReinterpretFromF32) Kind ¶
func (o *OperationI32ReinterpretFromF32) Kind() OperationKind
type OperationI32WrapFromI64 ¶
type OperationI32WrapFromI64 struct{}
func (*OperationI32WrapFromI64) Kind ¶
func (o *OperationI32WrapFromI64) Kind() OperationKind
type OperationI64ReinterpretFromF64 ¶
type OperationI64ReinterpretFromF64 struct{}
func (*OperationI64ReinterpretFromF64) Kind ¶
func (o *OperationI64ReinterpretFromF64) Kind() OperationKind
type OperationITruncFromF ¶
func (*OperationITruncFromF) Kind ¶
func (o *OperationITruncFromF) Kind() OperationKind
type OperationKind ¶
type OperationKind byte
const ( OperationKindUnreachable OperationKind = iota OperationKindLabel OperationKindBr OperationKindBrIf OperationKindBrTable OperationKindCall OperationKindCallIndirect OperationKindDrop OperationKindSelect OperationKindPick OperationKindSwap OperationKindGlobalGet OperationKindGlobalSet OperationKindLoad OperationKindLoad8 OperationKindLoad16 OperationKindLoad32 OperationKindStore OperationKindStore8 OperationKindStore16 OperationKindStore32 OperationKindMemorySize OperationKindMemoryGrow OperationKindConstI32 OperationKindConstI64 OperationKindConstF32 OperationKindConstF64 OperationKindEq OperationKindNe OperationKindEqz OperationKindLt OperationKindGt OperationKindLe OperationKindGe OperationKindAdd OperationKindSub OperationKindMul OperationKindClz OperationKindCtz OperationKindPopcnt OperationKindDiv OperationKindRem OperationKindAnd OperationKindOr OperationKindXor OperationKindShl OperationKindShr OperationKindRotl OperationKindRotr OperationKindAbs OperationKindNeg OperationKindCeil OperationKindFloor OperationKindTrunc OperationKindNearest OperationKindSqrt OperationKindMin OperationKindMax OperationKindCopysign OperationKindI32WrapFromI64 OperationKindITruncFromF OperationKindFConvertFromI OperationKindF32DemoteFromF64 OperationKindF64PromoteFromF32 OperationKindI32ReinterpretFromF32 OperationKindI64ReinterpretFromF64 OperationKindF32ReinterpretFromI32 OperationKindF64ReinterpretFromI64 OperationKindExtend OperationKindSignExtend32From8 OperationKindSignExtend32From16 OperationKindSignExtend64From8 OperationKindSignExtend64From16 OperationKindSignExtend64From32 )
func (OperationKind) String ¶
func (o OperationKind) String() (ret string)
type OperationLabel ¶
type OperationLabel struct {
Label *Label
}
func (*OperationLabel) Kind ¶
func (o *OperationLabel) Kind() OperationKind
type OperationLe ¶
type OperationLe struct{ Type SignedType }
func (*OperationLe) Kind ¶
func (o *OperationLe) Kind() OperationKind
type OperationLoad ¶
type OperationLoad struct { Type UnsignedType Arg *MemoryImmediate }
func (*OperationLoad) Kind ¶
func (o *OperationLoad) Kind() OperationKind
type OperationLoad16 ¶
type OperationLoad16 struct { Type SignedInt Arg *MemoryImmediate }
func (*OperationLoad16) Kind ¶
func (o *OperationLoad16) Kind() OperationKind
type OperationLoad32 ¶
type OperationLoad32 struct { Signed bool Arg *MemoryImmediate }
func (*OperationLoad32) Kind ¶
func (o *OperationLoad32) Kind() OperationKind
type OperationLoad8 ¶
type OperationLoad8 struct { Type SignedInt Arg *MemoryImmediate }
func (*OperationLoad8) Kind ¶
func (o *OperationLoad8) Kind() OperationKind
type OperationLt ¶
type OperationLt struct{ Type SignedType }
func (*OperationLt) Kind ¶
func (o *OperationLt) Kind() OperationKind
type OperationMax ¶
type OperationMax struct{ Type Float }
func (*OperationMax) Kind ¶
func (o *OperationMax) Kind() OperationKind
type OperationMemoryGrow ¶
type OperationMemoryGrow struct{ Alignment uint64 }
func (*OperationMemoryGrow) Kind ¶
func (o *OperationMemoryGrow) Kind() OperationKind
type OperationMemorySize ¶
type OperationMemorySize struct{}
func (*OperationMemorySize) Kind ¶
func (o *OperationMemorySize) Kind() OperationKind
type OperationMin ¶
type OperationMin struct{ Type Float }
func (*OperationMin) Kind ¶
func (o *OperationMin) Kind() OperationKind
type OperationMul ¶
type OperationMul struct{ Type UnsignedType }
func (*OperationMul) Kind ¶
func (o *OperationMul) Kind() OperationKind
type OperationNe ¶
type OperationNe struct{ Type UnsignedType }
func (*OperationNe) Kind ¶
func (o *OperationNe) Kind() OperationKind
type OperationNearest ¶
type OperationNearest struct{ Type Float }
func (*OperationNearest) Kind ¶
func (o *OperationNearest) Kind() OperationKind
type OperationNeg ¶
type OperationNeg struct{ Type Float }
func (*OperationNeg) Kind ¶
func (o *OperationNeg) Kind() OperationKind
type OperationOr ¶
type OperationOr struct{ Type UnsignedInt }
func (*OperationOr) Kind ¶
func (o *OperationOr) Kind() OperationKind
type OperationPick ¶
type OperationPick struct{ Depth int }
func (*OperationPick) Kind ¶
func (o *OperationPick) Kind() OperationKind
type OperationPopcnt ¶
type OperationPopcnt struct{ Type UnsignedInt }
func (*OperationPopcnt) Kind ¶
func (o *OperationPopcnt) Kind() OperationKind
type OperationRem ¶
type OperationRem struct{ Type SignedInt }
func (*OperationRem) Kind ¶
func (o *OperationRem) Kind() OperationKind
type OperationRotl ¶
type OperationRotl struct{ Type UnsignedInt }
func (*OperationRotl) Kind ¶
func (o *OperationRotl) Kind() OperationKind
type OperationRotr ¶
type OperationRotr struct{ Type UnsignedInt }
func (*OperationRotr) Kind ¶
func (o *OperationRotr) Kind() OperationKind
type OperationSelect ¶
type OperationSelect struct{}
func (*OperationSelect) Kind ¶
func (o *OperationSelect) Kind() OperationKind
type OperationShl ¶
type OperationShl struct{ Type UnsignedInt }
func (*OperationShl) Kind ¶
func (o *OperationShl) Kind() OperationKind
type OperationShr ¶
type OperationShr struct{ Type SignedInt }
func (*OperationShr) Kind ¶
func (o *OperationShr) Kind() OperationKind
type OperationSignExtend32From16 ¶
type OperationSignExtend32From16 struct{}
func (*OperationSignExtend32From16) Kind ¶
func (o *OperationSignExtend32From16) Kind() OperationKind
type OperationSignExtend32From8 ¶
type OperationSignExtend32From8 struct{}
func (*OperationSignExtend32From8) Kind ¶
func (o *OperationSignExtend32From8) Kind() OperationKind
type OperationSignExtend64From16 ¶
type OperationSignExtend64From16 struct{}
func (*OperationSignExtend64From16) Kind ¶
func (o *OperationSignExtend64From16) Kind() OperationKind
type OperationSignExtend64From32 ¶
type OperationSignExtend64From32 struct{}
func (*OperationSignExtend64From32) Kind ¶
func (o *OperationSignExtend64From32) Kind() OperationKind
type OperationSignExtend64From8 ¶
type OperationSignExtend64From8 struct{}
func (*OperationSignExtend64From8) Kind ¶
func (o *OperationSignExtend64From8) Kind() OperationKind
type OperationSqrt ¶
type OperationSqrt struct{ Type Float }
func (*OperationSqrt) Kind ¶
func (o *OperationSqrt) Kind() OperationKind
type OperationStore ¶
type OperationStore struct { Type UnsignedType Arg *MemoryImmediate }
func (*OperationStore) Kind ¶
func (o *OperationStore) Kind() OperationKind
type OperationStore16 ¶
type OperationStore16 struct { // TODO: Semantically Type doesn't affect operation so consider deleting this field. Type UnsignedInt Arg *MemoryImmediate }
func (*OperationStore16) Kind ¶
func (o *OperationStore16) Kind() OperationKind
type OperationStore32 ¶
type OperationStore32 struct {
Arg *MemoryImmediate
}
func (*OperationStore32) Kind ¶
func (o *OperationStore32) Kind() OperationKind
type OperationStore8 ¶
type OperationStore8 struct { // TODO: Semantically Type doesn't affect operation so consider deleting this field. Type UnsignedInt Arg *MemoryImmediate }
func (*OperationStore8) Kind ¶
func (o *OperationStore8) Kind() OperationKind
type OperationSub ¶
type OperationSub struct{ Type UnsignedType }
func (*OperationSub) Kind ¶
func (o *OperationSub) Kind() OperationKind
type OperationSwap ¶
type OperationSwap struct{ Depth int }
func (*OperationSwap) Kind ¶
func (o *OperationSwap) Kind() OperationKind
type OperationTrunc ¶
type OperationTrunc struct{ Type Float }
func (*OperationTrunc) Kind ¶
func (o *OperationTrunc) Kind() OperationKind
type OperationUnreachable ¶
type OperationUnreachable struct{}
func (*OperationUnreachable) Kind ¶
func (o *OperationUnreachable) Kind() OperationKind
type OperationXor ¶
type OperationXor struct{ Type UnsignedInt }
func (*OperationXor) Kind ¶
func (o *OperationXor) Kind() OperationKind
type SignedType ¶
type SignedType byte
const ( SignedTypeInt32 SignedType = iota SignedTypeUint32 SignedTypeInt64 SignedTypeUint64 SignedTypeFloat32 SignedTypeFloat64 )
func (SignedType) String ¶
func (s SignedType) String() (ret string)
type UnsignedInt ¶
type UnsignedInt byte
const ( UnsignedInt32 UnsignedInt = iota UnsignedInt64 )
func (UnsignedInt) String ¶
func (s UnsignedInt) String() (ret string)
type UnsignedType ¶
type UnsignedType byte
const ( UnsignedTypeI32 UnsignedType = iota UnsignedTypeI64 UnsignedTypeF32 UnsignedTypeF64 UnsignedTypeUnknown )
func (UnsignedType) String ¶
func (s UnsignedType) String() (ret string)
Click to show internal directories.
Click to hide internal directories.