BasicBlock represents the Basic Block of an SSA function.
Each BasicBlock always ends with branching instructions (e.g. Branch, Return, etc.),
and at most two branches are allowed. If there's two branches, these two are placed together at the end of the block.
In other words, there's no branching instruction in the middle of the block.
Note: we use the "block argument" variant of SSA, instead of PHI functions. See the package level doc comments.
Note: we use "parameter/param" as a placeholder which represents a variant of PHI, and "argument/arg" as an actual
Value passed to that "parameter/param". AddParam adds the parameter to the block whose type specified by `t`. EntryBlock returns true if this block represents the function entry. ID returns the unique ID of this block. LoopHeader returns true if this block is a loop header. LoopNestingForestChildren returns the children of this block in the loop nesting forest. Name returns the unique string ID of this block. e.g. blk0, blk1, ... Param returns (Variable, Value) which corresponds to the i-th parameter of this block.
The returned Value is the definition of the param in this block. Params returns the number of parameters to this block. Pred returns the i-th predecessor of this block. Preds returns the number of predecessors of this block. ReturnBlock returns ture if this block represents the function return. Root returns the root instruction of this block. Sealed is true if this block has been sealed. Succ returns the i-th successor of this block. Succs returns the number of successors of this block. Tail returns the tail instruction of this block. Valid is true if this block is still valid even after optimizations.
BasicBlock : github.com/polarsignals/frostdb/query/logicalplan.Named
func BasicBlock.LoopNestingForestChildren() []BasicBlock
func BasicBlock.Pred(i int) BasicBlock
func BasicBlock.Succ(i int) BasicBlock
func Builder.AllocateBasicBlock() BasicBlock
func Builder.BasicBlock(id BasicBlockID) BasicBlock
func Builder.BlockIteratorBegin() BasicBlock
func Builder.BlockIteratorNext() BasicBlock
func Builder.BlockIteratorReversePostOrderBegin() BasicBlock
func Builder.BlockIteratorReversePostOrderNext() BasicBlock
func Builder.CurrentBlock() BasicBlock
func Builder.EntryBlock() BasicBlock
func Builder.Idom(blk BasicBlock) BasicBlock
func Builder.LoopNestingForestRoots() []BasicBlock
func Builder.LowestCommonAncestor(blk1, blk2 BasicBlock) BasicBlock
func Builder.ReturnBlock() BasicBlock
func Builder.DefineVariable(variable Variable, value Value, block BasicBlock)
func Builder.Idom(blk BasicBlock) BasicBlock
func Builder.LowestCommonAncestor(blk1, blk2 BasicBlock) BasicBlock
func Builder.Seal(blk BasicBlock)
func Builder.SetCurrentBlock(b BasicBlock)
func (*Instruction).AsBrnz(v Value, args Values, target BasicBlock) *Instruction
func (*Instruction).AsBrz(v Value, args Values, target BasicBlock)
func (*Instruction).AsJump(vs Values, target BasicBlock) *Instruction
func github.com/tetratelabs/wazero/internal/engine/wazevo/backend.Machine.LinkAdjacentBlocks(prev, next BasicBlock)
func github.com/tetratelabs/wazero/internal/engine/wazevo/backend.Machine.StartBlock(BasicBlock)
Builder is used to builds SSA consisting of Basic Blocks per function. AllocateBasicBlock creates a basic block in SSA function. AllocateInstruction returns a new Instruction. AnnotateValue is for debugging purpose. BasicBlock returns the BasicBlock of the given ID. BlockIDMax returns the maximum value of BasicBlocksID existing in the currently-compiled function. BlockIteratorBegin initializes the state to iterate over all the valid BasicBlock(s) compiled.
Combined with BlockIteratorNext, we can use this like:
for blk := builder.BlockIteratorBegin(); blk != nil; blk = builder.BlockIteratorNext() {
// ...
}
The returned blocks are ordered in the order of AllocateBasicBlock being called. BlockIteratorNext advances the state for iteration initialized by BlockIteratorBegin.
Returns nil if there's no unseen BasicBlock. BlockIteratorReversePostOrderBegin is almost the same as BlockIteratorBegin except it returns the BasicBlock in the reverse post-order.
This is available after RunPasses is run. BlockIteratorReversePostOrderNext is almost the same as BlockIteratorPostOrderNext except it returns the BasicBlock in the reverse post-order.
This is available after RunPasses is run. CurrentBlock returns the currently handled BasicBlock which is set by the latest call to SetCurrentBlock. DeclareSignature appends the *Signature to be referenced by various instructions (e.g. OpcodeCall). DeclareVariable declares a Variable of the given Type. DefineVariable defines a variable in the `block` with value.
The defining instruction will be inserted into the `block`. DefineVariableInCurrentBB is the same as DefineVariable except the definition is
inserted into the current BasicBlock. Alias to DefineVariable(x, y, CurrentBlock()). EntryBlock returns the entry BasicBlock of the currently-compiled function. FindValueInLinearPath tries to find the latest definition of the given Variable in the linear path to the current BasicBlock.
If it cannot find the definition, or it's not sealed yet, it returns ValueInvalid. Format returns the debugging string of the SSA function. Idom returns the immediate dominator of the given BasicBlock. Init must be called to reuse this builder for the next function. InsertInstruction executes BasicBlock.InsertInstruction for the currently handled basic block. InsertUndefined inserts an undefined instruction at the current position. InsertZeroValue inserts a zero value constant instruction of the given type. InstructionOfValue returns the Instruction that produces the given Value or nil if the Value is not produced by any Instruction. LoopNestingForestRoots returns the roots of the loop nesting forest. LowestCommonAncestor returns the lowest common ancestor in the dominator tree of the given BasicBlock(s). MustFindValue searches the latest definition of the given Variable and returns the result. ResolveSignature returns the Signature which corresponds to SignatureID. ReturnBlock returns the BasicBlock which is used to return from the function. RunPasses runs various passes on the constructed SSA function. Seal declares that we've known all the predecessors to this block and were added via AddPred.
After calling this, AddPred will be forbidden. SetCurrentBlock sets the instruction insertion target to the BasicBlock `b`. SetCurrentSourceOffset sets the current source offset. The incoming instruction will be annotated with this offset. Signature returns the Signature of the currently-compiled function. Signatures returns the slice of declared Signatures. ValuesInfo returns the data per Value used to lower the SSA in backend.
This is indexed by ValueID. VarLengthPool returns the VarLengthPool of Value.
func NewBuilder() Builder
func github.com/tetratelabs/wazero/internal/engine/wazevo/backend.Compiler.SSABuilder() Builder
func BasicBlock.AddParam(b Builder, t Type) Value
func (*Instruction).Format(b Builder) string
func (*Instruction).Insert(b Builder) *Instruction
func Value.Format(b Builder) string
func github.com/tetratelabs/wazero/internal/engine/wazevo/backend.NewCompiler(ctx context.Context, mach backend.Machine, builder Builder) backend.Compiler
func github.com/tetratelabs/wazero/internal/engine/wazevo/frontend.NewFrontendCompiler(m *wasm.Module, ssaBuilder Builder, offset *wazevoapi.ModuleContextOffsetData, ensureTermination bool, listenerOn bool, sourceInfo bool) *frontend.Compiler
FuncRef is a unique identifier for a function of the frontend,
and is used to reference the function in function call. String implements fmt.Stringer.
FuncRef : expvar.Var
FuncRef : fmt.Stringer
func (*Instruction).CallData() (ref FuncRef, sigID SignatureID, args []Value)
func github.com/tetratelabs/wazero/internal/engine/wazevo/frontend.FunctionIndexToFuncRef(idx wasm.Index) FuncRef
func (*Instruction).AsCall(ref FuncRef, sig *Signature, args Values)
func github.com/tetratelabs/wazero/internal/engine/wazevo/backend.Compiler.AddRelocationInfo(funcRef FuncRef)
Instruction represents an instruction whose opcode is specified by
Opcode. Since Go doesn't have union type, we use this flattened type
for all instructions, and therefore each field has different meaning
depending on Opcode. Arg returns the first argument to this instruction. Arg2 returns the first two arguments to this instruction. Arg2WithLane returns the first two arguments to this instruction, and the lane type. Arg3 returns the first three arguments to this instruction. ArgWithLane returns the first argument to this instruction, and the lane type. Args returns the arguments to this instruction. AsAtomicCas initializes this instruction as an atomic compare-and-swap.
The size is in bytes and must be 1, 2, 4, or 8. AsAtomicLoad initializes this instruction as an atomic load.
The size is in bytes and must be 1, 2, 4, or 8. AsAtomicRmw initializes this instruction as an atomic read-modify-write.
The size is in bytes and must be 1, 2, 4, or 8. AsAtomicLoad initializes this instruction as an atomic store.
The size is in bytes and must be 1, 2, 4, or 8. AsBand initializes this instruction as an integer bitwise and instruction with OpcodeBand. AsBitcast initializes this instruction as an instruction with OpcodeBitcast. AsBor initializes this instruction as an integer bitwise or instruction with OpcodeBor. AsBrTable initializes this instruction as a branch-table instruction with OpcodeBrTable.
targets is a list of basic block IDs cast to Values. AsBrnz initializes this instruction as a branch-if-not-zero instruction with OpcodeBrnz. AsBrz initializes this instruction as a branch-if-zero instruction with OpcodeBrz. AsBxor initializes this instruction as an integer bitwise xor instruction with OpcodeBxor. AsCall initializes this instruction as a call instruction with OpcodeCall. AsCallGoRuntimeMemmove is the same as AsCallIndirect, but with a special flag set to indicate that it is a call to the Go runtime memmove function. AsCallIndirect initializes this instruction as a call-indirect instruction with OpcodeCallIndirect. AsCeil initializes this instruction as an instruction with OpcodeCeil. AsClz initializes this instruction as a Count Leading Zeroes instruction with OpcodeClz. AsCtz initializes this instruction as a Count Trailing Zeroes instruction with OpcodeCtz. AsExitIfTrueWithCode initializes this instruction as a trap instruction with OpcodeExitIfTrueWithCode. AsExitWithCode initializes this instruction as a trap instruction with OpcodeExitWithCode. AsExtIaddPairwise initializes this instruction as a lane-wise integer extended pairwise addition instruction
with OpcodeIaddPairwise on a vector. AsExtLoad initializes this instruction as a store instruction with OpcodeLoad. AsExtractlane initializes this instruction as an extract lane instruction with OpcodeExtractlane on vector. AsF32const initializes this instruction as a 32-bit floating-point constant instruction with OpcodeF32const. AsF64const initializes this instruction as a 64-bit floating-point constant instruction with OpcodeF64const. AsFabs initializes this instruction as an instruction with OpcodeFabs. AsFadd initializes this instruction as a floating-point addition instruction with OpcodeFadd. AsFallthroughJump marks this instruction as a fallthrough jump. AsFcmp initializes this instruction as an integer comparison instruction with OpcodeFcmp. AsFcopysign initializes this instruction as an instruction with OpcodeFcopysign. AsFcvtFromInt initializes this instruction as an instruction with either OpcodeFcvtFromUint or OpcodeFcvtFromSint AsFcvtToInt initializes this instruction as an instruction with either OpcodeFcvtToUint or OpcodeFcvtToSint AsFdemote initializes this instruction as an instruction with OpcodeFdemote. AsFdiv initializes this instruction as a floating-point division instruction with OpcodeFdiv. AsFence initializes this instruction as a memory fence.
A single byte immediate may be used to indicate fence ordering in the future
but is currently always 0 and ignored. AsFloor initializes this instruction as an instruction with OpcodeFloor. AsFmax initializes this instruction to take the maximum of two floating-points with OpcodeFmax. AsFmin initializes this instruction to take the minimum of two floating-points with OpcodeFmin. AsFmul initializes this instruction as a floating-point multiplication instruction with OpcodeFmul. AsFneg initializes this instruction as an instruction with OpcodeFneg. AsFpromote initializes this instruction as an instruction with OpcodeFpromote. AsFsub initializes this instruction as a floating-point subtraction instruction with OpcodeFsub. AsFvdemote initializes this instruction as an instruction with OpcodeFvdemote AsFvpromoteLow initializes this instruction as an instruction with OpcodeFvpromoteLow AsIadd initializes this instruction as an integer addition instruction with OpcodeIadd. AsIcmp initializes this instruction as an integer comparison instruction with OpcodeIcmp. AsIconst32 initializes this instruction as a 32-bit integer constant instruction with OpcodeIconst. AsIconst64 initializes this instruction as a 64-bit integer constant instruction with OpcodeIconst. AsImul initializes this instruction as an integer addition instruction with OpcodeImul. AsInsertlane initializes this instruction as an insert lane instruction with OpcodeInsertlane on vector. AsIreduce initializes this instruction as a reduction instruction with OpcodeIreduce. AsIshl initializes this instruction as an integer shift left instruction with OpcodeIshl. AsIsub initializes this instruction as an integer subtraction instruction with OpcodeIsub. AsJump initializes this instruction as a jump instruction with OpcodeJump. AsLoad initializes this instruction as a store instruction with OpcodeLoad. AsLoadSplat initializes this instruction as a store instruction with OpcodeLoadSplat. AsNarrow initializes this instruction as an instruction with either OpcodeSnarrow or OpcodeUnarrow AsNearest initializes this instruction as an instruction with OpcodeNearest. AsPopcnt initializes this instruction as a Population Count instruction with OpcodePopcnt. AsReturn initializes this instruction as a return instruction with OpcodeReturn. AsRotl initializes this instruction as a word rotate left instruction with OpcodeRotl. AsRotr initializes this instruction as a word rotate right instruction with OpcodeRotr. AsSDiv initializes this instruction as an integer bitwise and instruction with OpcodeSdiv. AsSExtend initializes this instruction as a sign extension instruction with OpcodeSExtend. AsSRem initializes this instruction as an integer bitwise and instruction with OpcodeSrem. AsSelect initializes this instruction as an unsigned extension instruction with OpcodeSelect. AsShuffle initializes this instruction as a shuffle instruction with OpcodeShuffle on vector. AsSplat initializes this instruction as an insert lane instruction with OpcodeSplat on vector. AsSqmulRoundSat initializes this instruction as a lane-wise saturating rounding multiplication
in Q15 format with OpcodeSqmulRoundSat on a vector. AsSqrt initializes this instruction as an instruction with OpcodeSqrt. AsSshr initializes this instruction as an integer signed shift right (arithmetic shift right) instruction with OpcodeSshr. AsStore initializes this instruction as a store instruction with OpcodeStore. AsSwizzle initializes this instruction as an insert lane instruction with OpcodeSwizzle on vector. AsTrunc initializes this instruction as an instruction with OpcodeTrunc. AsUDiv initializes this instruction as an integer bitwise and instruction with OpcodeUdiv. AsUExtend initializes this instruction as an unsigned extension instruction with OpcodeUExtend. AsURem initializes this instruction as an integer bitwise and instruction with OpcodeUrem. AsUshr initializes this instruction as an integer unsigned shift right (logical shift right) instruction with OpcodeUshr. AsVAvgRound initializes this instruction as an unsigned integer avg instruction, truncating to zero with OpcodeVAvgRound on a vector. AsVCeil initializes this instruction as an instruction with OpcodeCeil. AsVFabs initializes this instruction as a float abs instruction with OpcodeVFabs on a vector. AsVFadd initializes this instruction as a floating point add instruction with OpcodeVFadd on a vector. AsVFcmp initializes this instruction as a float comparison instruction with OpcodeVFcmp on Vector. AsVFcvtFromInt initializes this instruction as an instruction with either OpcodeVFcvtToSintSat or OpcodeVFcvtToUintSat AsVFcvtToIntSat initializes this instruction as an instruction with either OpcodeVFcvtToSintSat or OpcodeVFcvtToUintSat AsVFdiv initializes this instruction as a floating point division instruction with OpcodeVFdiv on a vector. AsVFloor initializes this instruction as an instruction with OpcodeFloor. AsVFmax initializes this instruction as a float max instruction with OpcodeVFmax on a vector. AsVFmin initializes this instruction as a float min instruction with OpcodeVFmin on a vector. AsVFmul initializes this instruction as a floating point multiplication instruction with OpcodeVFmul on a vector. AsVFneg initializes this instruction as a float neg instruction with OpcodeVFneg on a vector. AsVFsub initializes this instruction as a floating point subtraction instruction with OpcodeVFsub on a vector. AsVIabs initializes this instruction as a vector absolute value with OpcodeVIabs. AsVIadd initializes this instruction as an integer addition instruction with OpcodeVIadd on a vector. AsVIcmp initializes this instruction as an integer vector comparison instruction with OpcodeVIcmp. AsVImax initializes this instruction as a signed integer max instruction with OpcodeVImax on a vector. AsVImin initializes this instruction as a signed integer min instruction with OpcodeVImin on a vector. AsVImul initializes this instruction as an integer multiplication with OpcodeVImul on a vector. AsVIneg initializes this instruction as a vector negation with OpcodeVIneg. AsVIpopcnt initializes this instruction as a Population Count instruction with OpcodeVIpopcnt on a vector. AsVIshl initializes this instruction as an integer shift left instruction with OpcodeVIshl on vector. AsVIsub initializes this instruction as an integer subtraction instruction with OpcodeVIsub on a vector. AsVMaxPseudo initializes this instruction as an instruction with OpcodeVMaxPseudo. AsVMinPseudo initializes this instruction as an instruction with OpcodeVMinPseudo. AsVNearest initializes this instruction as an instruction with OpcodeNearest. AsVSaddSat initializes this instruction as a vector addition with saturation instruction with OpcodeVSaddSat on a vector. AsVSqrt initializes this instruction as a sqrt instruction with OpcodeVSqrt on a vector. AsVSshr initializes this instruction as an integer signed shift right (arithmetic shift right) instruction with OpcodeVSshr on vector. AsVSsubSat initializes this instruction as a vector addition with saturation instruction with OpcodeVSsubSat on a vector. AsVTrunc initializes this instruction as an instruction with OpcodeTrunc. AsVUaddSat initializes this instruction as a vector addition with saturation instruction with OpcodeVUaddSat on a vector. AsVUmax initializes this instruction as an unsigned integer max instruction with OpcodeVUmax on a vector. AsVUmin initializes this instruction as an unsigned integer min instruction with OpcodeVUmin on a vector. AsVUshr initializes this instruction as an integer unsigned shift right (logical shift right) instruction with OpcodeVUshr on vector. AsVUsubSat initializes this instruction as a vector addition with saturation instruction with OpcodeVUsubSat on a vector. AsVZeroExtLoad initializes this instruction as a store instruction with OpcodeVExtLoad. AsVallTrue initializes this instruction as an allTrue vector instruction with OpcodeVallTrue. AsVanyTrue initializes this instruction as an anyTrue vector instruction with OpcodeVanyTrue. AsVband initializes this instruction as an and vector instruction with OpcodeVband. AsVbandnot initializes this instruction as an and-not vector instruction with OpcodeVbandnot. AsVbitselect initializes this instruction as a bit select vector instruction with OpcodeVbitselect. AsVbnot initializes this instruction as a vector negation instruction with OpcodeVbnot. AsVbor initializes this instruction as an or vector instruction with OpcodeVbor. AsVbxor initializes this instruction as a xor vector instruction with OpcodeVbxor. AsVconst initializes this instruction as a vector constant instruction with OpcodeVconst. AsVhighBits initializes this instruction as a highBits vector instruction with OpcodeVhighBits. AsWiden initializes this instruction as a signed or unsigned widen instruction
on low half or high half of the given vector with OpcodeSwidenLow, OpcodeUwidenLow, OpcodeSwidenHigh, OpcodeUwidenHigh. AsWideningPairwiseDotProductS initializes this instruction as a lane-wise integer extended pairwise addition instruction
with OpcodeIaddPairwise on a vector. AtomicRmwData returns the data for this atomic read-modify-write instruction. AtomicTargetSize returns the target memory size of the atomic instruction. BitcastData returns the operands for a bitcast instruction. BrTableData returns the branch table data for this instruction necessary for backends. BranchData returns the branch data for this instruction necessary for backends. CallData returns the call data for this instruction necessary for backends. CallIndirectData returns the call indirect data for this instruction necessary for backends. Constant returns true if this instruction is a constant instruction. ConstantVal returns the constant value of this instruction.
How to interpret the return value depends on the opcode. ExitIfTrueWithCodeData returns the context and exit code of OpcodeExitWithCode. ExitWithCodeData returns the context and exit code of OpcodeExitWithCode. ExtIaddPairwiseData returns the operands for a lane-wise integer extended pairwise addition instruction.(*Instruction) ExtendData() (from, to byte, signed bool) ExtendFromToBits returns the from and to bit size for the extension instruction. ExtractlaneData returns the operands and sign flag of Extractlane on vector. FcmpData returns the operands and comparison condition of this floating-point comparison instruction. Format returns a string representation of this instruction with the given builder.
For debugging purposes only. GroupID returns the InstructionGroupID of this instruction. IcmpData returns the operands and comparison condition of this integer comparison instruction.(*Instruction) Insert(b Builder) *Instruction InsertlaneData returns the operands and sign flag of Insertlane on vector. InvertBrx inverts either OpcodeBrz or OpcodeBrnz to the other. IsBranching returns true if this instruction is a branching instruction. IsFallthroughJump returns true if this instruction is a fallthrough jump. LoadData returns the operands for a load instruction. LoadSplatData returns the operands for a load splat instruction. Lowered returns true if this instruction is already lowered. MarkLowered marks this instruction as already lowered. Next returns the next instruction laid out next to itself. Opcode returns the opcode of this instruction. Prev returns the previous instruction laid out prior to itself. Return returns a Value(s) produced by this instruction if any.
If there's multiple return values, only the first one is returned. ReturnVals returns the return values of OpcodeReturn. Returns Value(s) produced by this instruction if any.
The `first` is the first return value, and `rest` is the rest of the values. SelectData returns the select data for this instruction necessary for backends. ShuffleData returns the first two arguments to this instruction and 2 uint64s `lo`, `hi`.
Note: Each uint64 encodes a sequence of 8 bytes where each byte encodes a VecLane,
so that the 128bit integer `hi<<64|lo` packs a slice `[16]VecLane`,
where `lane[0]` is the least significant byte, and `lane[n]` is shifted to offset `n*8`. SourceOffset returns the source offset of this instruction. StoreData returns the operands for a store instruction. VFcmpData returns the operands and comparison condition of this float comparison instruction on vector. VIcmpData returns the operands and comparison condition of this integer comparison instruction on vector. VZeroExtLoadData returns the operands for a load instruction. The returned `typ` is the scalar type of the load target. VconstData returns the operands of this vector constant instruction.
func BasicBlock.Root() *Instruction
func BasicBlock.Tail() *Instruction
func Builder.AllocateInstruction() *Instruction
func Builder.InstructionOfValue(v Value) *Instruction
func (*Instruction).AsAtomicCas(addr, exp, repl Value, size uint64) *Instruction
func (*Instruction).AsAtomicLoad(addr Value, size uint64, typ Type) *Instruction
func (*Instruction).AsAtomicRmw(op AtomicRmwOp, addr, val Value, size uint64) *Instruction
func (*Instruction).AsAtomicStore(addr, val Value, size uint64) *Instruction
func (*Instruction).AsBand(x, amount Value) *Instruction
func (*Instruction).AsBitcast(x Value, dstType Type) *Instruction
func (*Instruction).AsBrnz(v Value, args Values, target BasicBlock) *Instruction
func (*Instruction).AsCallGoRuntimeMemmove(funcPtr Value, sig *Signature, args Values) *Instruction
func (*Instruction).AsCallIndirect(funcPtr Value, sig *Signature, args Values) *Instruction
func (*Instruction).AsCeil(x Value) *Instruction
func (*Instruction).AsExitIfTrueWithCode(ctx, c Value, code wazevoapi.ExitCode) *Instruction
func (*Instruction).AsExtIaddPairwise(x Value, srcLane VecLane, signed bool) *Instruction
func (*Instruction).AsExtLoad(op Opcode, ptr Value, offset uint32, dst64bit bool) *Instruction
func (*Instruction).AsExtractlane(x Value, index byte, lane VecLane, signed bool) *Instruction
func (*Instruction).AsF32const(f float32) *Instruction
func (*Instruction).AsF64const(f float64) *Instruction
func (*Instruction).AsFabs(x Value) *Instruction
func (*Instruction).AsFcopysign(x, y Value) *Instruction
func (*Instruction).AsFcvtFromInt(x Value, signed bool, dst64bit bool) *Instruction
func (*Instruction).AsFcvtToInt(x, ctx Value, signed bool, dst64bit bool, sat bool) *Instruction
func (*Instruction).AsFence(order byte) *Instruction
func (*Instruction).AsFloor(x Value) *Instruction
func (*Instruction).AsFneg(x Value) *Instruction
func (*Instruction).AsFvdemote(x Value, lane VecLane) *Instruction
func (*Instruction).AsFvpromoteLow(x Value, lane VecLane) *Instruction
func (*Instruction).AsIadd(x, y Value) *Instruction
func (*Instruction).AsIcmp(x, y Value, c IntegerCmpCond) *Instruction
func (*Instruction).AsIconst32(v uint32) *Instruction
func (*Instruction).AsIconst64(v uint64) *Instruction
func (*Instruction).AsImul(x, y Value) *Instruction
func (*Instruction).AsInsertlane(x, y Value, index byte, lane VecLane) *Instruction
func (*Instruction).AsIreduce(v Value, dstType Type) *Instruction
func (*Instruction).AsIshl(x, amount Value) *Instruction
func (*Instruction).AsIsub(x, y Value) *Instruction
func (*Instruction).AsJump(vs Values, target BasicBlock) *Instruction
func (*Instruction).AsLoad(ptr Value, offset uint32, typ Type) *Instruction
func (*Instruction).AsLoadSplat(ptr Value, offset uint32, lane VecLane) *Instruction
func (*Instruction).AsNarrow(x, y Value, lane VecLane, signed bool) *Instruction
func (*Instruction).AsNearest(x Value) *Instruction
func (*Instruction).AsReturn(vs wazevoapi.VarLength[Value]) *Instruction
func (*Instruction).AsSDiv(x, y, ctx Value) *Instruction
func (*Instruction).AsSelect(c, x, y Value) *Instruction
func (*Instruction).AsSExtend(v Value, from, to byte) *Instruction
func (*Instruction).AsShuffle(x, y Value, lane []byte) *Instruction
func (*Instruction).AsSplat(x Value, lane VecLane) *Instruction
func (*Instruction).AsSqmulRoundSat(x, y Value, lane VecLane) *Instruction
func (*Instruction).AsSqrt(x Value) *Instruction
func (*Instruction).AsSRem(x, y, ctx Value) *Instruction
func (*Instruction).AsSshr(x, amount Value) *Instruction
func (*Instruction).AsStore(storeOp Opcode, value, ptr Value, offset uint32) *Instruction
func (*Instruction).AsSwizzle(x, y Value, lane VecLane) *Instruction
func (*Instruction).AsTrunc(x Value) *Instruction
func (*Instruction).AsUDiv(x, y, ctx Value) *Instruction
func (*Instruction).AsUExtend(v Value, from, to byte) *Instruction
func (*Instruction).AsURem(x, y, ctx Value) *Instruction
func (*Instruction).AsUshr(x, amount Value) *Instruction
func (*Instruction).AsVallTrue(x Value, lane VecLane) *Instruction
func (*Instruction).AsVanyTrue(x Value) *Instruction
func (*Instruction).AsVAvgRound(x, y Value, lane VecLane) *Instruction
func (*Instruction).AsVband(x, y Value) *Instruction
func (*Instruction).AsVbandnot(x, y Value) *Instruction
func (*Instruction).AsVbitselect(c, x, y Value) *Instruction
func (*Instruction).AsVbnot(v Value) *Instruction
func (*Instruction).AsVbor(x, y Value) *Instruction
func (*Instruction).AsVbxor(x, y Value) *Instruction
func (*Instruction).AsVCeil(x Value, lane VecLane) *Instruction
func (*Instruction).AsVconst(lo, hi uint64) *Instruction
func (*Instruction).AsVFabs(x Value, lane VecLane) *Instruction
func (*Instruction).AsVFadd(x, y Value, lane VecLane) *Instruction
func (*Instruction).AsVFcmp(x, y Value, c FloatCmpCond, lane VecLane) *Instruction
func (*Instruction).AsVFcvtFromInt(x Value, lane VecLane, signed bool) *Instruction
func (*Instruction).AsVFcvtToIntSat(x Value, lane VecLane, signed bool) *Instruction
func (*Instruction).AsVFdiv(x, y Value, lane VecLane) *Instruction
func (*Instruction).AsVFloor(x Value, lane VecLane) *Instruction
func (*Instruction).AsVFmax(x, y Value, lane VecLane) *Instruction
func (*Instruction).AsVFmin(x, y Value, lane VecLane) *Instruction
func (*Instruction).AsVFmul(x, y Value, lane VecLane) *Instruction
func (*Instruction).AsVFneg(x Value, lane VecLane) *Instruction
func (*Instruction).AsVFsub(x, y Value, lane VecLane) *Instruction
func (*Instruction).AsVhighBits(x Value, lane VecLane) *Instruction
func (*Instruction).AsVIabs(x Value, lane VecLane) *Instruction
func (*Instruction).AsVIadd(x, y Value, lane VecLane) *Instruction
func (*Instruction).AsVIcmp(x, y Value, c IntegerCmpCond, lane VecLane) *Instruction
func (*Instruction).AsVImax(x, y Value, lane VecLane) *Instruction
func (*Instruction).AsVImin(x, y Value, lane VecLane) *Instruction
func (*Instruction).AsVImul(x, y Value, lane VecLane) *Instruction
func (*Instruction).AsVIneg(x Value, lane VecLane) *Instruction
func (*Instruction).AsVIpopcnt(x Value, lane VecLane) *Instruction
func (*Instruction).AsVIshl(x, amount Value, lane VecLane) *Instruction
func (*Instruction).AsVIsub(x, y Value, lane VecLane) *Instruction
func (*Instruction).AsVMaxPseudo(x, y Value, lane VecLane) *Instruction
func (*Instruction).AsVMinPseudo(x, y Value, lane VecLane) *Instruction
func (*Instruction).AsVNearest(x Value, lane VecLane) *Instruction
func (*Instruction).AsVSaddSat(x, y Value, lane VecLane) *Instruction
func (*Instruction).AsVSqrt(x Value, lane VecLane) *Instruction
func (*Instruction).AsVSshr(x, amount Value, lane VecLane) *Instruction
func (*Instruction).AsVSsubSat(x, y Value, lane VecLane) *Instruction
func (*Instruction).AsVTrunc(x Value, lane VecLane) *Instruction
func (*Instruction).AsVUaddSat(x, y Value, lane VecLane) *Instruction
func (*Instruction).AsVUmax(x, y Value, lane VecLane) *Instruction
func (*Instruction).AsVUmin(x, y Value, lane VecLane) *Instruction
func (*Instruction).AsVUshr(x, amount Value, lane VecLane) *Instruction
func (*Instruction).AsVUsubSat(x, y Value, lane VecLane) *Instruction
func (*Instruction).AsVZeroExtLoad(ptr Value, offset uint32, scalarType Type) *Instruction
func (*Instruction).AsWiden(v Value, lane VecLane, signed, low bool) *Instruction
func (*Instruction).AsWideningPairwiseDotProductS(x, y Value) *Instruction
func (*Instruction).Insert(b Builder) *Instruction
func (*Instruction).Next() *Instruction
func (*Instruction).Prev() *Instruction
func Builder.InsertInstruction(raw *Instruction)
func github.com/tetratelabs/wazero/internal/engine/wazevo/backend.Machine.InsertLoadConstantBlockArg(instr *Instruction, vr regalloc.VReg)
func github.com/tetratelabs/wazero/internal/engine/wazevo/backend.Machine.LowerConditionalBranch(b *Instruction)
func github.com/tetratelabs/wazero/internal/engine/wazevo/backend.Machine.LowerInstr(*Instruction)
func github.com/tetratelabs/wazero/internal/engine/wazevo/backend.Machine.LowerSingleBranch(b *Instruction)
InstructionGroupID is assigned to each instruction and represents a group of instructions
where each instruction is interchangeable with others except for the last instruction
in the group which has side effects. In short, InstructionGroupID is determined by the side effects of instructions.
That means, if there's an instruction with side effect between two instructions, then these two instructions
will have different instructionGroupID. Note that each block always ends with branching, which is with side effects,
therefore, instructions in different blocks always have different InstructionGroupID(s).
The notable application of this is used in lowering SSA-level instruction to a ISA specific instruction,
where we eagerly try to merge multiple instructions into single operation etc. Such merging cannot be done
if these instruction have different InstructionGroupID since it will change the semantics of a program.
See passDeadCodeElimination.
func (*Instruction).GroupID() InstructionGroupID
SourceOffset represents the offset of the source of an instruction. Valid returns true if this source offset is valid.
func (*Instruction).SourceOffset() SourceOffset
func Builder.SetCurrentSourceOffset(line SourceOffset)
func github.com/tetratelabs/wazero/internal/engine/wazevo/backend.Compiler.AddSourceOffsetInfo(executableOffset int64, sourceOffset SourceOffset)
ValueID is the lower 32bit of Value, which is the pure identifier of Value without type info.
func Value.ID() ValueID
ValueInfo contains the data per Value used to lower the SSA in backend. RefCount is the reference count of the Value.
func Builder.ValuesInfo() []ValueInfo
Values is a slice of Value. Use this instead of []Value to reuse the underlying memory.
Variable is a unique identifier for a source program's variable and will correspond to
multiple ssa Value(s).
For example, `Local 1` is a Variable in WebAssembly, and Value(s) will be created for it
whenever it executes `local.set 1`.
Variable is useful to track the SSA Values of a variable in the source program, and
can be used to find the corresponding latest SSA Value via Builder.FindValue.
Higher 4-bit is used to store Type for this variable. String implements fmt.Stringer.
Variable : expvar.Var
Variable : fmt.Stringer
func Builder.DeclareVariable(Type) Variable
func Builder.DefineVariable(variable Variable, value Value, block BasicBlock)
func Builder.DefineVariableInCurrentBB(variable Variable, value Value)
func Builder.FindValueInLinearPath(variable Variable) Value
func Builder.MustFindValue(variable Variable) Value
OpcodeBand performs a binary and: `v = Band x, y`.
OpcodeBitcast is a bitcast operation: `v = bitcast x`.
OpcodeBnot performs a binary not: `v = Bnot x`.
OpcodeBor performs a binary or: `v = Bor x, y`.
OpcodeBrnz branches into `blk` with `args` if the value `c` is not zero: `Brnz c, blk, args`.
OpcodeBrTable takes the index value `index`, and branches into `labelX`. If the `index` is out of range,
it branches into the last labelN: `BrTable index, [label1, label2, ... labelN]`.
OpcodeBrz branches into `blk` with `args` if the value `c` equals zero: `Brz c, blk, args`.
OpcodeBxor performs a binary xor: `v = Bxor x, y`.
OpcodeCall calls a function specified by the symbol FN with arguments `args`: `returnvals = Call FN, args...`
This is a "near" call, which means the call target is known at compile time, and the target is relatively close
to this function. If the target cannot be reached by near call, the backend fails to compile.
OpcodeCallIndirect calls a function specified by `callee` which is a function address: `returnvals = call_indirect SIG, callee, args`.
Note that this is different from call_indirect in Wasm, which also does type checking, etc.
OpcodeCeil takes the ceiling of the given floating point value: `v = ceil x`.
OpcodeClz counts the number of leading zeros: `v = clz x`.
OpcodeCtz counts the number of trailing zeros: `v = ctz x`.
OpcodeExitIfTrueWithCode exits the execution immediately if the value `c` is not zero.
OpcodeExitWithCode exit the execution immediately.
OpcodeExtIaddPairwise is a lane-wise integer extended pairwise addition producing extended results (twice wider results than the inputs): `v = extiadd_pairwise x, y` on vector.
OpcodeExtractlane extracts a lane value from a vector: `v = ExtractLane x, Idx`.
OpcodeF32const represents the single-precision const.
OpcodeF64const represents the double-precision const.
OpcodeFabs takes the absolute value of the given floating point value: `v = fabs x`.
OpcodeFadd performs a floating point addition: / `v = Fadd x, y`.
OpcodeFcmp compares two floating point values: `v = fcmp Cond, x, y`.
OpcodeFcopysign copies the sign of the second floating point value to the first floating point value:
`v = Fcopysign x, y`.
OpcodeFcvtFromSint converts a signed integer to a floating point value: `v = FcvtFromSint x`.
OpcodeFcvtFromUint converts an unsigned integer to a floating point value: `v = FcvtFromUint x`.
OpcodeFcvtToSint converts a floating point value to a signed integer: `v = FcvtToSint x`.
OpcodeFcvtToSintSat converts a floating point value to a signed integer: `v = FcvtToSintSat x` which saturates on overflow.
OpcodeFcvtToUint converts a floating point value to an unsigned integer: `v = FcvtToUint x`.
OpcodeFcvtToUintSat converts a floating point value to an unsigned integer: `v = FcvtToUintSat x` which saturates on overflow.
OpcodeFdemote demotes the given float point value: `v = Fdemote x`.
OpcodeFdiv performs a floating point division: `v = Fdiv x, y`.
OpcodeFence is a memory fence operation.
OpcodeFloor takes the floor of the given floating point value: `v = floor x`.
OpcodeFmax takes the maximum of two floating point values: `v = fmax x, y`.
OpcodeFmin takes the minimum of two floating point values: `v = fmin x, y`.
OpcodeFmul performs a floating point multiplication: `v = Fmul x, y`.
OpcodeFneg negates the given floating point value: `v = Fneg x`.
OpcodeFpromote promotes the given floating point value: `v = Fpromote x`.
OpcodeFsub performs a floating point subtraction: `v = Fsub x, y`.
OpcodeFvdemote converts the two double-precision floating point lanes
to two lower single-precision lanes of the result `v = Fvdemote.lane x`.
OpcodeFvpromoteLow converts the two lower single-precision floating point lanes
to the two double-precision lanes of the result: `v = FvpromoteLow.lane x` on vector.
OpcodeIadd performs an integer addition: `v = Iadd x, y`.
OpcodeIcmp compares two integer values with the given condition: `v = icmp Cond, x, y`.
OpcodeIcmpImm compares an integer value with the immediate value on the given condition: `v = icmp_imm Cond, x, Y`.
OpcodeIconst represents the integer const.
OpcodeImul performs an integer multiplication: `v = Imul x, y`.
OpcodeInsertlane inserts a lane value into a vector: `v = InsertLane x, y, Idx`.
TODO: complete opcode comments.
OpcodeIreduce narrow the given integer: `v = Ireduce x`.
OpcodeIshl does logical shift left: `v = Ishl x, y`.
OpcodeIstore16 stores the 16-bit value to the [base + offset] address, zero-extended to 64 bits: `Istore16 v, base, offset`.
OpcodeIstore32 stores the 32-bit value to the [base + offset] address, zero-extended to 64 bits: `Istore16 v, base, offset`.
OpcodeIstore8 stores the 8-bit value to the [base + offset] address, sign-extended to 64 bits: `Istore8 v, base, offset`.
OpcodeIsub performs an integer subtraction: `v = Isub x, y`.
OpcodeJump takes the list of args to the `block` and unconditionally jumps to it.
OpcodeLoad loads a Type value from the [base + offset] address: `v = Load base, offset`.
OpcodeLoadSplat represents a load that replicates the loaded value to all lanes `v = LoadSplat.lane p, Offset`.
OpcodeNearest takes the nearest integer of the given floating point value: `v = nearest x`.
OpcodePopcnt counts the number of 1-bits: `v = popcnt x`.
OpcodeReturn returns from the function: `return rvalues`.
OpcodeRotl rotates the given integer value to the left: `v = Rotl x, y`.
OpcodeRotr rotates the given integer value to the right: `v = Rotr x, y`.
OpcodeSdiv performs the signed integer division `v = Sdiv x, y`.
OpcodeSelect chooses between two values based on a condition `c`: `v = Select c, x, y`.
OpcodeSExtend sign-extends the given integer: `v = SExtend x, from->to`.
OpcodeShuffle shuffles two vectors using the given 128-bit immediate: `v = shuffle imm, x, y`.
For each byte in the immediate, a value i in [0, 15] selects the i-th byte in vector x;
i in [16, 31] selects the (i-16)-th byte in vector y.
OpcodeSload16 loads the 16-bit value from the [base + offset] address, sign-extended to 64 bits: `v = Sload16 base, offset`.
OpcodeSload32 loads the 32-bit value from the [base + offset] address, sign-extended to 64 bits: `v = Sload32 base, offset`.
OpcodeSload8 loads the 8-bit value from the [base + offset] address, sign-extended to 64 bits: `v = Sload8 base, offset`.
OpcodeSnarrow converts two input vectors x, y into a smaller lane vector by narrowing each lane, signed `v = Snarrow.lane x, y`.
OpcodeSplat performs a vector splat operation: `v = Splat.lane x`.
OpcodeSqmulRoundSat performs a lane-wise saturating rounding multiplication
in Q15 format: `v = SqmulRoundSat.lane x,y` on vector.
OpcodeSqrt takes the square root of the given floating point value: `v = sqrt x`.
OpcodeSrem computes the remainder of the signed integer division `v = Srem x, y`.
OpcodeSshr does arithmetic shift right: `v = Sshr x, y`.
OpcodeStore stores a Type value to the [base + offset] address: `Store v, base, offset`.
OpcodeSwidenHigh converts high half of the smaller lane vector to a larger lane vector, sign extended: `v = SwidenHigh.lane x`.
OpcodeSwidenLow converts low half of the smaller lane vector to a larger lane vector, sign extended: `v = SwidenLow.lane x`.
OpcodeUExtend zero-extends the given integer: `v = UExtend x, from->to`.
OpcodeUload16 loads the 16-bit value from the [base + offset] address, zero-extended to 64 bits: `v = Uload16 base, offset`.
OpcodeUload32 loads the 32-bit value from the [base + offset] address, zero-extended to 64 bits: `v = Uload32 base, offset`.
OpcodeUload8 loads the 8-bit value from the [base + offset] address, zero-extended to 64 bits: `v = Uload8 base, offset`.
OpcodeUnarrow converts two input vectors x, y into a smaller lane vector by narrowing each lane, unsigned `v = Unarrow.lane x, y`.
OpcodeUndefined is a placeholder for undefined opcode. This can be used for debugging to intentionally
cause a crash at certain point.
OpcodeUrem computes the remainder of the unsigned integer division `v = Urem x, y`.
OpcodeUshr does logical shift right: `v = Ushr x, y`.
OpcodeUwidenHigh converts high half of the smaller lane vector to a larger lane vector, zero (unsigned) extended: `v = UwidenHigh.lane x`.
OpcodeUwidenLow converts low half of the smaller lane vector to a larger lane vector, zero (unsigned) extended: `v = UwidenLow.lane x`.
OpcodeVallTrue performs a lane-wise all true operation: `s = VallTrue.lane a`.
OpcodeVanyTrue performs a any true operation: `s = VanyTrue a`.
OpcodeVAvgRound performs an unsigned integer avg, truncating to zero: `v = VAvgRound.lane x, y` on vector.
OpcodeVband computes binary and between two 128bit vectors: `v = band x, y`.
OpcodeVbandnot computes binary and-not between two 128bit vectors: `v = bandnot x, y`.
OpcodeVbitselect uses the bits in the control mask c to select the corresponding bit from x when 1
and y when 0: `v = bitselect c, x, y`.
OpcodeVbnot negates a 128bit vector: `v = bnot x`.
OpcodeVbor computes binary or between two 128bit vectors: `v = bor x, y`.
OpcodeVbxor computes binary xor between two 128bit vectors: `v = bxor x, y`.
OpcodeVCeil takes the ceiling of the given floating point value: `v = ceil.lane x` on vector.
OpcodeVconst represents the 128bit vector const.
OpcodeVFabs takes the absolute value of a floating point value: `v = VFabs.lane x on vector.
OpcodeVFadd performs a floating point addition: `v = VFadd.lane x, y` on vector.
OpcodeVFcmp compares two float values with the given condition: `v = VFcmp.lane Cond, x, y` on float.
OpcodeVFcvtFromSint converts a floating point value from a signed integer: `v = VFcvtFromSint.lane x` on vector.
x is always a 32-bit integer lane, and the result is either a 32-bit or 64-bit floating point-sized vector.
OpcodeVFcvtFromUint converts a floating point value from an unsigned integer: `v = FcvtFromUint.lane x` on vector.
x is always a 32-bit integer lane, and the result is either a 32-bit or 64-bit floating point-sized vector.
OpcodeVFcvtToSintSat converts a floating point value to a signed integer: `v = VFcvtToSintSat.lane x` on vector.
OpcodeVFcvtToUintSat converts a floating point value to an unsigned integer: `v = FcvtToUintSat.lane x` on vector.
OpcodeVFdiv performs a floating point division: `v = VFdiv.lane x, y` on vector.
OpcodeVFloor takes the floor of the given floating point value: `v = floor.lane x` on vector.
OpcodeVFmax takes the maximum of two floating point values: `v = VFmax.lane x, y on vector.
OpcodeVFmin takes the minimum of two floating point values: `v = VFmin.lane x, y on vector.
OpcodeVFmul performs a floating point multiplication: `v = VFmul.lane x, y` on vector.
OpcodeVFneg negates the given floating point vector value: `v = VFneg x`.
OpcodeVFsub performs a floating point subtraction: `v = VFsub.lane x, y` on vector.
OpcodeVhighBits performs a lane-wise extract of the high bits: `v = VhighBits.lane a`.
OpcodeVIabs returns the absolute value for the given vector value: `v = VIabs.lane x`.
OpcodeVIadd performs an integer addition: `v = VIadd.lane x, y` on vector.
OpcodeVIcmp compares two integer values with the given condition: `v = vicmp Cond, x, y` on vector.
OpcodeVImax performs a signed integer max: `v = VImax.lane x, y` on vector.
OpcodeVImin performs a signed integer min: `v = VImin.lane x, y` on vector.
OpcodeVImul performs an integer multiplication: `v = VImul.lane x, y` on vector.
OpcodeVIneg negates the given integer vector value: `v = VIneg x`.
OpcodeVIpopcnt counts the number of 1-bits in the given vector: `v = VIpopcnt x`.
OpcodeVIshl shifts x left by (y mod lane-width): `v = VIshl.lane x, y` on vector.
OpcodeVIsub performs an integer subtraction: `v = VIsub.lane x, y` on vector.
OpcodeVMaxPseudo computes the lane-wise maximum value `v = VMaxPseudo.lane x, y` on vector defined as `x < y ? x : y`.
OpcodeVMinPseudo computes the lane-wise minimum value `v = VMinPseudo.lane x, y` on vector defined as `y < x ? x : y`.
OpcodeVNearest takes the nearest integer of the given floating point value: `v = nearest.lane x` on vector.
OpcodeVSaddSat performs a signed saturating vector addition: `v = VSaddSat.lane x, y` on vector.
OpcodeVSqrt takes the minimum of two floating point values: `v = VFmin.lane x, y` on vector.
OpcodeVSshr shifts x right by (y mod lane-width), signed: `v = VSshr.lane x, y` on vector.
OpcodeVSsubSat performs a signed saturating vector subtraction: `v = VSsubSat.lane x, y` on vector.
OpcodeVTrunc takes the truncation of the given floating point value: `v = trunc.lane x` on vector.
OpcodeVUaddSat performs an unsigned saturating vector addition: `v = VUaddSat.lane x, y` on vector.
OpcodeVUmax performs an unsigned integer max: `v = VUmax.lane x, y` on vector.
OpcodeVUmin performs an unsigned integer min: `v = VUmin.lane x, y` on vector.
OpcodeVUshr shifts x right by (y mod lane-width), unsigned: `v = VUshr.lane x, y` on vector.
OpcodeVUsubSat performs an unsigned saturating vector subtraction: `v = VUsubSat.lane x, y` on vector.
OpcodeVZeroExtLoad loads a scalar single/double precision floating point value from the [p + Offset] address,
and zero-extend it to the V128 value: `v = VExtLoad p, Offset`.
OpcodeWideningPairwiseDotProductS is a lane-wise widening pairwise dot product with signed saturation: `v = WideningPairwiseDotProductS x, y` on vector.
Currently, the only lane is i16, and the result is i32.
The pages are generated with Goldsv0.8.2. (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu.
PR and bug reports are welcome and can be submitted to the issue list.
Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds.