ABIArg represents either argument or return value's location. Index is the index of the argument. Kind is the kind of the argument. Offset is valid if Kind == ABIArgKindStack.
This is the offset from the beginning of either arg or ret stack slot. Reg is valid if Kind == ABIArgKindReg.
This VReg must be based on RealReg. Type is the type of the argument. String implements fmt.Stringer.
*ABIArg : expvar.Var
*ABIArg : fmt.Stringer
ABIArgKind is the kind of ABI argument. String implements fmt.Stringer.
ABIArgKind : expvar.Var
ABIArgKind : fmt.Stringer
Compiler is the backend of wazevo which takes ssa.Builder and Machine,
use the information there to emit the final machine code. AddRelocationInfo appends the relocation information for the function reference at the current buffer offset. AddSourceOffsetInfo appends the source offset information for the given offset. AllocateVReg allocates a new virtual register of the given type. Buf returns the buffer of the encoded machine code. This is only used for testing purpose.( Compiler) BufPtr() *[]byte Compile executes the following steps:
1. Lower()
2. RegAlloc()
3. Finalize()
4. Encode()
Each step can be called individually for testing purpose, therefore they are exposed in this interface too.
The returned byte slices are the machine code and the relocation information for the machine code.
The caller is responsible for copying them immediately since the compiler may reuse the buffer. Emit4Bytes appends 4 bytes to the buffer. Used during the code emission. Emit8Bytes appends 8 bytes to the buffer. Used during the code emission. EmitByte appends a byte to the buffer. Used during the code emission. Finalize performs the finalization of the compilation, including machine code emission.
This must be called after RegAlloc. Format returns the debug string of the current state of the compiler. GetFunctionABI returns the ABI information for the given signature. Init initializes the internal state of the compiler for the next compilation. Lower lowers the given ssa.Instruction to the machine-specific instructions. MatchInstr returns true if the given definition is from an instruction with the given opcode, the current group ID,
and a refcount of 1. That means, the instruction can be merged/swapped within the current instruction group. MatchInstrOneOf is the same as MatchInstr but for multiple opcodes. If it matches one of ssa.Opcode,
this returns the opcode. Otherwise, this returns ssa.OpcodeInvalid.
Note: caller should be careful to avoid excessive allocation on opcodes slice. RegAlloc performs the register allocation after Lower is called. SSABuilder returns the ssa.Builder used by this compiler. SourceOffsetInfo returns the source offset information for the current buffer offset. TypeOf returns the ssa.Type of the given virtual register. VRegOf returns the virtual register of the given ssa.Value. ValueDefinition returns the definition of the given value.
func NewCompiler(ctx context.Context, mach Machine, builder ssa.Builder) Compiler
func Machine.SetCompiler(Compiler)
Machine is a backend for a specific ISA machine. ArgsResultsRegs returns the registers used for arguments and return values. CallTrampolineIslandInfo returns the interval of the offset where the trampoline island is placed, and
the size of the trampoline island. If islandSize is zero, the trampoline island is not used on this machine. CompileEntryPreamble returns the sequence of instructions shared by multiple functions to
enter the function from Go. CompileGoFunctionTrampoline compiles the trampoline function to call a Go function of the given exit code and signature. CompileStackGrowCallSequence returns the sequence of instructions shared by all functions to
call the stack grow builtin function. DisableStackCheck disables the stack check for the current compilation for debugging/testing. Encode encodes the machine instructions to the Compiler. EndBlock is called when the compilation of the current block is finished. FlushPendingInstructions flushes the pending instructions to the buffer.
This will be called after the lowering of each SSA Instruction. Format returns the string representation of the currently compiled machine code.
This is only for testing purpose. InsertLoadConstantBlockArg inserts the instruction(s) to load the constant value into the given regalloc.VReg. InsertMove inserts a move instruction from src to dst whose type is typ. InsertReturn inserts the return instruction to return from the current function. LinkAdjacentBlocks is called after finished lowering all blocks in order to create one single instruction list. LowerConditionalBranch is called when the compilation of the given conditional branch is started. LowerInstr is called for each instruction in the given block except for the ones marked as already lowered
via Compiler.MarkLowered. The order is reverse, i.e. from the last instruction to the first one.
Note: this can lower multiple instructions (which produce the inputs) at once whenever it's possible
for optimization. LowerParams lowers the given parameters. LowerReturns lowers the given returns. LowerSingleBranch is called when the compilation of the given single branch is started. PostRegAlloc does the post register allocation, e.g. setting up prologue/epilogue, redundant move elimination, etc. RegAlloc does the register allocation after lowering. Reset resets the machine state for the next compilation. ResolveRelocations resolves the relocations after emitting machine code.
* refToBinaryOffset: the map from the function reference (ssa.FuncRef) to the executable offset.
* importedFns: the max index of the imported functions at the beginning of refToBinaryOffset
* executable: the binary to resolve the relocations.
* relocations: the relocations to resolve.
* callTrampolineIslandOffsets: the offsets of the trampoline islands in the executable. SetCompiler sets the compilation context used for the lifetime of Machine.
This is only called once per Machine, i.e. before the first compilation. SetCurrentABI initializes the FunctionABI for the given signature. StartBlock is called when the compilation of the given block is started.
The order of this being called is the reverse post order of the ssa.BasicBlock(s) as we iterate with
ssa.Builder BlockIteratorReversePostOrderBegin and BlockIteratorReversePostOrderEnd. StartLoweringFunction is called when the compilation of the given function is started.
The maxBlockID is the maximum ssa.BasicBlockID in the function.
func github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/amd64.NewBackend() Machine
func NewCompiler(ctx context.Context, mach Machine, builder ssa.Builder) Compiler
RelocationInfo represents the relocation information for a call instruction. Target is the target function of the call instruction. Offset represents the offset from the beginning of the machine code of either a function or the entire module.
func Compiler.Compile(ctx context.Context) (_ []byte, _ []RelocationInfo, _ error)
func Machine.ResolveRelocations(refToBinaryOffset []int, importedFns int, executable []byte, relocations []RelocationInfo, callTrampolineIslandOffsets []int)
SourceOffsetInfo is a data to associate the source offset with the executable offset. ExecutableOffset is the offset in the compiled executable. SourceOffset is the source offset in the original source code.
func Compiler.SourceOffsetInfo() []SourceOffsetInfo
SSAValueDefinition represents a definition of an SSA value. Instr is not nil if this is a definition from an instruction. RefCount is the number of references to the result.Vssa.Value IsFromInstr returns true if this definition is from an instruction.
func Compiler.ValueDefinition(ssa.Value) SSAValueDefinition
func Compiler.MatchInstr(def SSAValueDefinition, opcode ssa.Opcode) bool
func Compiler.MatchInstrOneOf(def SSAValueDefinition, opcodes []ssa.Opcode) ssa.Opcode
GoFunctionCallRequiredStackSize returns the size of the stack required for the Go function call.
argBegin is the index of the first argument in the signature which is not either execution context or module context.
NewCompiler returns a new Compiler that can generate a machine code.
Package-Level Constants (total 2)
ABIArgKindReg represents an argument passed in a register.
ABIArgKindStack represents an argument passed in the stack.
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.