podman
331 строка · 4.3 Кб
1// Copyright 2018 The Go Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style
3// license that can be found in the LICENSE file.
4
5package wasm6
7import "github.com/twitchyliquid64/golang-asm/obj"8
9//go:generate go run ../stringer.go -i $GOFILE -o anames.go -p wasm
10
11const (12/* mark flags */13DONE = 1 << iota14PRESERVEFLAGS // not allowed to clobber flags15)
16
17/*
18* wasm
19*/
20const (21ACallImport = obj.ABaseWasm + obj.A_ARCHSPECIFIC + iota22AGet
23ASet
24ATee
25ANot // alias for I32Eqz26
27// The following are low-level WebAssembly instructions.28// Their order matters, since it matches the opcode encoding.29// Gaps in the encoding are indicated by comments.30
31AUnreachable // opcode 0x0032ANop
33ABlock
34ALoop
35AIf
36AElse
37
38AEnd // opcode 0x0B39ABr
40ABrIf
41ABrTable
42// ACall and AReturn are WebAssembly instructions. obj.ACALL and obj.ARET are higher level instructions43// with Go semantics, e.g. they manipulate the Go stack on the linear memory.44AReturn
45ACall
46ACallIndirect
47
48ADrop // opcode 0x1A49ASelect
50
51ALocalGet // opcode 0x2052ALocalSet
53ALocalTee
54AGlobalGet
55AGlobalSet
56
57AI32Load // opcode 0x2858AI64Load
59AF32Load
60AF64Load
61AI32Load8S
62AI32Load8U
63AI32Load16S
64AI32Load16U
65AI64Load8S
66AI64Load8U
67AI64Load16S
68AI64Load16U
69AI64Load32S
70AI64Load32U
71AI32Store
72AI64Store
73AF32Store
74AF64Store
75AI32Store8
76AI32Store16
77AI64Store8
78AI64Store16
79AI64Store32
80ACurrentMemory
81AGrowMemory
82
83AI32Const
84AI64Const
85AF32Const
86AF64Const
87
88AI32Eqz
89AI32Eq
90AI32Ne
91AI32LtS
92AI32LtU
93AI32GtS
94AI32GtU
95AI32LeS
96AI32LeU
97AI32GeS
98AI32GeU
99
100AI64Eqz
101AI64Eq
102AI64Ne
103AI64LtS
104AI64LtU
105AI64GtS
106AI64GtU
107AI64LeS
108AI64LeU
109AI64GeS
110AI64GeU
111
112AF32Eq
113AF32Ne
114AF32Lt
115AF32Gt
116AF32Le
117AF32Ge
118
119AF64Eq
120AF64Ne
121AF64Lt
122AF64Gt
123AF64Le
124AF64Ge
125
126AI32Clz
127AI32Ctz
128AI32Popcnt
129AI32Add
130AI32Sub
131AI32Mul
132AI32DivS
133AI32DivU
134AI32RemS
135AI32RemU
136AI32And
137AI32Or
138AI32Xor
139AI32Shl
140AI32ShrS
141AI32ShrU
142AI32Rotl
143AI32Rotr
144
145AI64Clz
146AI64Ctz
147AI64Popcnt
148AI64Add
149AI64Sub
150AI64Mul
151AI64DivS
152AI64DivU
153AI64RemS
154AI64RemU
155AI64And
156AI64Or
157AI64Xor
158AI64Shl
159AI64ShrS
160AI64ShrU
161AI64Rotl
162AI64Rotr
163
164AF32Abs
165AF32Neg
166AF32Ceil
167AF32Floor
168AF32Trunc
169AF32Nearest
170AF32Sqrt
171AF32Add
172AF32Sub
173AF32Mul
174AF32Div
175AF32Min
176AF32Max
177AF32Copysign
178
179AF64Abs
180AF64Neg
181AF64Ceil
182AF64Floor
183AF64Trunc
184AF64Nearest
185AF64Sqrt
186AF64Add
187AF64Sub
188AF64Mul
189AF64Div
190AF64Min
191AF64Max
192AF64Copysign
193
194AI32WrapI64
195AI32TruncF32S
196AI32TruncF32U
197AI32TruncF64S
198AI32TruncF64U
199AI64ExtendI32S
200AI64ExtendI32U
201AI64TruncF32S
202AI64TruncF32U
203AI64TruncF64S
204AI64TruncF64U
205AF32ConvertI32S
206AF32ConvertI32U
207AF32ConvertI64S
208AF32ConvertI64U
209AF32DemoteF64
210AF64ConvertI32S
211AF64ConvertI32U
212AF64ConvertI64S
213AF64ConvertI64U
214AF64PromoteF32
215AI32ReinterpretF32
216AI64ReinterpretF64
217AF32ReinterpretI32
218AF64ReinterpretI64
219AI32Extend8S
220AI32Extend16S
221AI64Extend8S
222AI64Extend16S
223AI64Extend32S
224
225AI32TruncSatF32S // opcode 0xFC 0x00226AI32TruncSatF32U
227AI32TruncSatF64S
228AI32TruncSatF64U
229AI64TruncSatF32S
230AI64TruncSatF32U
231AI64TruncSatF64S
232AI64TruncSatF64U
233
234ALast // Sentinel: End of low-level WebAssembly instructions.235
236ARESUMEPOINT
237// ACALLNORESUME is a call which is not followed by a resume point.238// It is allowed inside of WebAssembly blocks, whereas obj.ACALL is not.239// However, it is not allowed to switch goroutines while inside of an ACALLNORESUME call.240ACALLNORESUME
241
242ARETUNWIND
243
244AMOVB
245AMOVH
246AMOVW
247AMOVD
248
249AWORD
250ALAST
251)
252
253const (254REG_NONE = 0255)
256
257const (258// globals259REG_SP = obj.RBaseWasm + iota // SP is currently 32-bit, until 64-bit memory operations are available260REG_CTXT
261REG_g
262// RET* are used by runtime.return0 and runtime.reflectcall. These functions pass return values in registers.263REG_RET0
264REG_RET1
265REG_RET2
266REG_RET3
267REG_PAUSE
268
269// i32 locals270REG_R0
271REG_R1
272REG_R2
273REG_R3
274REG_R4
275REG_R5
276REG_R6
277REG_R7
278REG_R8
279REG_R9
280REG_R10
281REG_R11
282REG_R12
283REG_R13
284REG_R14
285REG_R15
286
287// f32 locals288REG_F0
289REG_F1
290REG_F2
291REG_F3
292REG_F4
293REG_F5
294REG_F6
295REG_F7
296REG_F8
297REG_F9
298REG_F10
299REG_F11
300REG_F12
301REG_F13
302REG_F14
303REG_F15
304
305// f64 locals306REG_F16
307REG_F17
308REG_F18
309REG_F19
310REG_F20
311REG_F21
312REG_F22
313REG_F23
314REG_F24
315REG_F25
316REG_F26
317REG_F27
318REG_F28
319REG_F29
320REG_F30
321REG_F31
322
323REG_PC_B // also first parameter, i32324
325MAXREG
326
327MINREG = REG_SP328REGSP = REG_SP329REGCTXT = REG_CTXT330REGG = REG_g331)
332