a.out.go 4.3 KB

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