Debian Codegraph @

internal/engine/wazevo/backend/machine_test.go

raw
1 package backend
2
3 import (
4 "context"
5
6 "github.com/tetratelabs/wazero/internal/engine/wazevo/backend/regalloc"
7 "github.com/tetratelabs/wazero/internal/engine/wazevo/ssa"
8 "github.com/tetratelabs/wazero/internal/engine/wazevo/wazevoapi"
9 )
10
11 // mockMachine implements Machine for testing.
12 type mockMachine struct {
13 argResultInts, argResultFloats []regalloc.RealReg
14 startBlock func(block ssa.BasicBlock)
15 lowerSingleBranch func(b *ssa.Instruction)
16 lowerConditionalBranch func(b *ssa.Instruction)
17 lowerInstr func(instruction *ssa.Instruction)
18 endBlock func()
19 endLoweringFunction func()
20 reset func()
21 insertMove func(dst, src regalloc.VReg)
22 insertLoadConstant func(instr *ssa.Instruction, vr regalloc.VReg)
23 format func() string
24 linkAdjacentBlocks func(prev, next ssa.BasicBlock)
25 }
26
27 func (m mockMachine) StartLoweringFunction(maxBlockID ssa.BasicBlockID) { panic("implement me") }
28
29 func (m mockMachine) CallTrampolineIslandInfo(_ int) (_, _ int, _ error) { panic("implement me") }
30
31 func (m mockMachine) ArgsResultsRegs() (argResultInts, argResultFloats []regalloc.RealReg) {
32 return m.argResultInts, m.argResultFloats
33 }
34
35 func (m mockMachine) RegAlloc() { panic("implement me") }
36
37 func (m mockMachine) LowerParams(params []ssa.Value) { panic("implement me") }
38
39 func (m mockMachine) LowerReturns(returns []ssa.Value) { panic("implement me") }
40
41 func (m mockMachine) CompileEntryPreamble(signature *ssa.Signature) []byte {
42 panic("TODO")
43 }
44
45 func (m mockMachine) CompileStackGrowCallSequence() []byte {
46 panic("TODO")
47 }
48
49 // CompileGoFunctionTrampoline implements Machine.CompileGoFunctionTrampoline.
50 func (m mockMachine) CompileGoFunctionTrampoline(wazevoapi.ExitCode, *ssa.Signature, bool) []byte {
51 panic("TODO")
52 }
53
54 // Encode implements Machine.Encode.
55 func (m mockMachine) Encode(context.Context) (err error) { return }
56
57 // ResolveRelocations implements Machine.ResolveRelocations.
58 func (m mockMachine) ResolveRelocations([]int, int, []byte, []RelocationInfo, []int) {}
59
60 // PostRegAlloc implements Machine.SetupPrologue.
61 func (m mockMachine) PostRegAlloc() {}
62
63 // InsertReturn implements Machine.InsertReturn.
64 func (m mockMachine) InsertReturn() { panic("TODO") }
65
66 // LinkAdjacentBlocks implements Machine.LinkAdjacentBlocks.
67 func (m mockMachine) LinkAdjacentBlocks(prev, next ssa.BasicBlock) { m.linkAdjacentBlocks(prev, next) }
68
69 // SetCurrentABI implements Machine.SetCurrentABI.
70 func (m mockMachine) SetCurrentABI(*FunctionABI) {}
71
72 // SetCompiler implements Machine.SetCompiler.
73 func (m mockMachine) SetCompiler(Compiler) {}
74
75 // StartBlock implements Machine.StartBlock.
76 func (m mockMachine) StartBlock(block ssa.BasicBlock) {
77 m.startBlock(block)
78 }
79
80 // LowerSingleBranch implements Machine.LowerSingleBranch.
81 func (m mockMachine) LowerSingleBranch(b *ssa.Instruction) {
82 m.lowerSingleBranch(b)
83 }
84
85 // LowerConditionalBranch implements Machine.LowerConditionalBranch.
86 func (m mockMachine) LowerConditionalBranch(b *ssa.Instruction) {
87 m.lowerConditionalBranch(b)
88 }
89
90 // LowerInstr implements Machine.LowerInstr.
91 func (m mockMachine) LowerInstr(instruction *ssa.Instruction) {
92 m.lowerInstr(instruction)
93 }
94
95 // EndBlock implements Machine.EndBlock.
96 func (m mockMachine) EndBlock() {
97 m.endBlock()
98 }
99
100 // EndLoweringFunction implements Machine.EndLoweringFunction.
101 func (m mockMachine) EndLoweringFunction() {
102 m.endLoweringFunction()
103 }
104
105 // Reset implements Machine.Reset.
106 func (m mockMachine) Reset() {
107 m.reset()
108 }
109
110 // FlushPendingInstructions implements Machine.FlushPendingInstructions.
111 func (m mockMachine) FlushPendingInstructions() {}
112
113 // InsertMove implements Machine.InsertMove.
114 func (m mockMachine) InsertMove(dst, src regalloc.VReg, typ ssa.Type) {
115 m.insertMove(dst, src)
116 }
117
118 // InsertLoadConstantBlockArg implements Machine.InsertLoadConstantBlockArg.
119 func (m mockMachine) InsertLoadConstantBlockArg(instr *ssa.Instruction, vr regalloc.VReg) {
120 m.insertLoadConstant(instr, vr)
121 }
122
123 // Format implements Machine.Format.
124 func (m mockMachine) Format() string {
125 return m.format()
126 }
127
128 // DisableStackCheck implements Machine.DisableStackCheck.
129 func (m mockMachine) DisableStackCheck() {}
130
131 var _ Machine = (*mockMachine)(nil)