typenative 0.6.1 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (1004) hide show
  1. package/CHANGELOG.md +412 -0
  2. package/README.md +1 -1
  3. package/bin/cli.js +18 -8
  4. package/bin/go/overrides.js +21 -1
  5. package/bin/index.js +48 -25
  6. package/bin/main.js +2 -1
  7. package/bin/node/assert.js +54 -15
  8. package/bin/node/async_hooks.js +69 -10
  9. package/bin/node/buffer.js +321 -7
  10. package/bin/node/child_process.js +154 -8
  11. package/bin/node/cluster.js +436 -32
  12. package/bin/node/crypto.js +814 -5
  13. package/bin/node/crypto_curves.js +142 -0
  14. package/bin/node/crypto_keys.js +1147 -48
  15. package/bin/node/crypto_pem.js +313 -0
  16. package/bin/node/crypto_pkcs12.js +17 -0
  17. package/bin/node/dgram.js +161 -10
  18. package/bin/node/diagnostics_channel.js +5 -1
  19. package/bin/node/events.js +358 -8
  20. package/bin/node/ffi.js +933 -0
  21. package/bin/node/fs.js +334 -6
  22. package/bin/node/http.js +630 -55
  23. package/bin/node/http2.js +1141 -88
  24. package/bin/node/intl.js +4576 -0
  25. package/bin/node/intl_data.js +65412 -0
  26. package/bin/node/module_v8.js +155 -16
  27. package/bin/node/net.js +59 -10
  28. package/bin/node/path.js +5 -1
  29. package/bin/node/process.js +342 -3
  30. package/bin/node/readline.js +558 -8
  31. package/bin/node/registry.js +2 -0
  32. package/bin/node/sqlite.js +51 -2
  33. package/bin/node/stream.js +370 -32
  34. package/bin/node/stream_web.js +422 -15
  35. package/bin/node/system_extra.js +154 -1
  36. package/bin/node/temporal.js +96 -0
  37. package/bin/node/temporal_runtime.js +5075 -0
  38. package/bin/node/temporal_zones.js +460 -0
  39. package/bin/node/test.js +153 -8
  40. package/bin/node/test_coverage.js +58 -0
  41. package/bin/node/test_report.js +3 -3
  42. package/bin/node/test_run.js +7 -1
  43. package/bin/node/timers.js +123 -0
  44. package/bin/node/tls.js +346 -12
  45. package/bin/node/tls_roots.js +122 -0
  46. package/bin/node/typed_arrays.js +867 -93
  47. package/bin/node/url.js +657 -0
  48. package/bin/node/util.js +441 -2
  49. package/bin/node/util_extra.js +6 -0
  50. package/bin/node/wasi.js +214 -0
  51. package/bin/node/webassembly.js +1122 -0
  52. package/bin/node/websocket.js +763 -0
  53. package/bin/node/worker_threads.js +434 -52
  54. package/bin/node/zlib.js +338 -9
  55. package/bin/node/zlib_zip.js +2392 -0
  56. package/bin/transpiler.js +2083 -254
  57. package/bin/typecheck-node.js +49 -17
  58. package/bin/version.js +1 -1
  59. package/conformance.md +160 -113
  60. package/examples/README.md +21 -20
  61. package/examples/angular-templates/README.md +12 -12
  62. package/examples/desktop-notes/README.md +7 -7
  63. package/examples/dupe-finder/README.md +4 -4
  64. package/examples/fibonacci/README.md +6 -6
  65. package/examples/hello-world/README.md +4 -4
  66. package/examples/json-server/README.md +13 -12
  67. package/examples/mandelbrot-png/README.md +4 -4
  68. package/examples/marked-cli/README.md +16 -17
  69. package/examples/openai-chat/README.md +5 -5
  70. package/examples/react-compiler/README.md +10 -10
  71. package/examples/todo-cli/README.md +8 -8
  72. package/examples/yaml-cli/README.md +10 -10
  73. package/govendor/github.com/cloudflare/circl/.golangci.yaml +64 -0
  74. package/govendor/github.com/cloudflare/circl/.semgrepignore +1 -0
  75. package/govendor/github.com/cloudflare/circl/AGENTS.md +91 -0
  76. package/govendor/github.com/cloudflare/circl/CITATION.cff +30 -0
  77. package/govendor/github.com/cloudflare/circl/LICENSE +57 -0
  78. package/govendor/github.com/cloudflare/circl/Makefile +70 -0
  79. package/govendor/github.com/cloudflare/circl/README.md +206 -0
  80. package/govendor/github.com/cloudflare/circl/REVIEW.md +83 -0
  81. package/govendor/github.com/cloudflare/circl/codecov.yml +21 -0
  82. package/govendor/github.com/cloudflare/circl/dh/x448/curve.go +104 -0
  83. package/govendor/github.com/cloudflare/circl/dh/x448/curve_amd64.go +30 -0
  84. package/govendor/github.com/cloudflare/circl/dh/x448/curve_amd64.h +111 -0
  85. package/govendor/github.com/cloudflare/circl/dh/x448/curve_amd64.s +194 -0
  86. package/govendor/github.com/cloudflare/circl/dh/x448/curve_generic.go +100 -0
  87. package/govendor/github.com/cloudflare/circl/dh/x448/curve_noasm.go +11 -0
  88. package/govendor/github.com/cloudflare/circl/dh/x448/doc.go +19 -0
  89. package/govendor/github.com/cloudflare/circl/dh/x448/key.go +46 -0
  90. package/govendor/github.com/cloudflare/circl/dh/x448/table.go +460 -0
  91. package/govendor/github.com/cloudflare/circl/doc.go +8 -0
  92. package/govendor/github.com/cloudflare/circl/ecc/goldilocks/constants.go +71 -0
  93. package/govendor/github.com/cloudflare/circl/ecc/goldilocks/curve.go +90 -0
  94. package/govendor/github.com/cloudflare/circl/ecc/goldilocks/isogeny.go +52 -0
  95. package/govendor/github.com/cloudflare/circl/ecc/goldilocks/point.go +181 -0
  96. package/govendor/github.com/cloudflare/circl/ecc/goldilocks/scalar.go +203 -0
  97. package/govendor/github.com/cloudflare/circl/ecc/goldilocks/twist.go +138 -0
  98. package/govendor/github.com/cloudflare/circl/ecc/goldilocks/twistPoint.go +135 -0
  99. package/govendor/github.com/cloudflare/circl/ecc/goldilocks/twistTables.go +216 -0
  100. package/govendor/github.com/cloudflare/circl/ecc/goldilocks/twist_basemult.go +62 -0
  101. package/govendor/github.com/cloudflare/circl/go.mod +3 -0
  102. package/govendor/github.com/cloudflare/circl/internal/conv/conv.go +173 -0
  103. package/govendor/github.com/cloudflare/circl/internal/sha3/doc.go +62 -0
  104. package/govendor/github.com/cloudflare/circl/internal/sha3/hashes.go +69 -0
  105. package/govendor/github.com/cloudflare/circl/internal/sha3/keccakf.go +391 -0
  106. package/govendor/github.com/cloudflare/circl/internal/sha3/rc.go +29 -0
  107. package/govendor/github.com/cloudflare/circl/internal/sha3/sha3.go +200 -0
  108. package/govendor/github.com/cloudflare/circl/internal/sha3/sha3_s390x.s +33 -0
  109. package/govendor/github.com/cloudflare/circl/internal/sha3/shake.go +119 -0
  110. package/govendor/github.com/cloudflare/circl/internal/sha3/xor.go +15 -0
  111. package/govendor/github.com/cloudflare/circl/internal/sha3/xor_generic.go +33 -0
  112. package/govendor/github.com/cloudflare/circl/internal/sha3/xor_unaligned.go +61 -0
  113. package/govendor/github.com/cloudflare/circl/math/fp448/fp.go +164 -0
  114. package/govendor/github.com/cloudflare/circl/math/fp448/fp_amd64.go +43 -0
  115. package/govendor/github.com/cloudflare/circl/math/fp448/fp_amd64.h +591 -0
  116. package/govendor/github.com/cloudflare/circl/math/fp448/fp_amd64.s +75 -0
  117. package/govendor/github.com/cloudflare/circl/math/fp448/fp_generic.go +339 -0
  118. package/govendor/github.com/cloudflare/circl/math/fp448/fp_noasm.go +12 -0
  119. package/govendor/github.com/cloudflare/circl/math/fp448/fuzzer.go +75 -0
  120. package/govendor/github.com/cloudflare/circl/math/integer.go +16 -0
  121. package/govendor/github.com/cloudflare/circl/math/mlsbset/mlsbset.go +145 -0
  122. package/govendor/github.com/cloudflare/circl/math/mlsbset/power.go +64 -0
  123. package/govendor/github.com/cloudflare/circl/math/primes.go +34 -0
  124. package/govendor/github.com/cloudflare/circl/math/wnaf.go +84 -0
  125. package/govendor/github.com/cloudflare/circl/sign/ed448/ed448.go +417 -0
  126. package/govendor/github.com/cloudflare/circl/sign/ed448/signapi.go +89 -0
  127. package/govendor/github.com/cloudflare/circl/sign/sign.go +119 -0
  128. package/govendor/github.com/decred/dcrd/dcrec/secp256k1/v4/LICENSE +17 -0
  129. package/govendor/github.com/decred/dcrd/dcrec/secp256k1/v4/README.md +72 -0
  130. package/govendor/github.com/decred/dcrd/dcrec/secp256k1/v4/compressedbytepoints.go +18 -0
  131. package/govendor/github.com/decred/dcrd/dcrec/secp256k1/v4/curve.go +1310 -0
  132. package/govendor/github.com/decred/dcrd/dcrec/secp256k1/v4/curve_embedded.go +14 -0
  133. package/govendor/github.com/decred/dcrd/dcrec/secp256k1/v4/curve_precompute.go +14 -0
  134. package/govendor/github.com/decred/dcrd/dcrec/secp256k1/v4/doc.go +59 -0
  135. package/govendor/github.com/decred/dcrd/dcrec/secp256k1/v4/ecdh.go +21 -0
  136. package/govendor/github.com/decred/dcrd/dcrec/secp256k1/v4/ecdsa/README.md +52 -0
  137. package/govendor/github.com/decred/dcrd/dcrec/secp256k1/v4/ecdsa/doc.go +42 -0
  138. package/govendor/github.com/decred/dcrd/dcrec/secp256k1/v4/ecdsa/error.go +134 -0
  139. package/govendor/github.com/decred/dcrd/dcrec/secp256k1/v4/ecdsa/signature.go +1001 -0
  140. package/govendor/github.com/decred/dcrd/dcrec/secp256k1/v4/ellipticadaptor.go +296 -0
  141. package/govendor/github.com/decred/dcrd/dcrec/secp256k1/v4/error.go +67 -0
  142. package/govendor/github.com/decred/dcrd/dcrec/secp256k1/v4/field.go +1696 -0
  143. package/govendor/github.com/decred/dcrd/dcrec/secp256k1/v4/go.mod +3 -0
  144. package/govendor/github.com/decred/dcrd/dcrec/secp256k1/v4/loadprecomputed.go +91 -0
  145. package/govendor/github.com/decred/dcrd/dcrec/secp256k1/v4/modnscalar.go +1105 -0
  146. package/govendor/github.com/decred/dcrd/dcrec/secp256k1/v4/nonce.go +263 -0
  147. package/govendor/github.com/decred/dcrd/dcrec/secp256k1/v4/privkey.go +111 -0
  148. package/govendor/github.com/decred/dcrd/dcrec/secp256k1/v4/pubkey.go +236 -0
  149. package/govendor/github.com/ebitengine/purego/LICENSE +201 -0
  150. package/govendor/github.com/ebitengine/purego/README.md +124 -0
  151. package/govendor/github.com/ebitengine/purego/abi_amd64.h +99 -0
  152. package/govendor/github.com/ebitengine/purego/abi_arm64.h +39 -0
  153. package/govendor/github.com/ebitengine/purego/abi_loong64.h +60 -0
  154. package/govendor/github.com/ebitengine/purego/cdecl.go +11 -0
  155. package/govendor/github.com/ebitengine/purego/cgo.go +19 -0
  156. package/govendor/github.com/ebitengine/purego/dlerror.go +17 -0
  157. package/govendor/github.com/ebitengine/purego/dlfcn.go +99 -0
  158. package/govendor/github.com/ebitengine/purego/dlfcn_android.go +34 -0
  159. package/govendor/github.com/ebitengine/purego/dlfcn_darwin.go +20 -0
  160. package/govendor/github.com/ebitengine/purego/dlfcn_freebsd.go +14 -0
  161. package/govendor/github.com/ebitengine/purego/dlfcn_linux.go +16 -0
  162. package/govendor/github.com/ebitengine/purego/dlfcn_netbsd.go +15 -0
  163. package/govendor/github.com/ebitengine/purego/dlfcn_nocgo_freebsd.go +11 -0
  164. package/govendor/github.com/ebitengine/purego/dlfcn_nocgo_linux.go +19 -0
  165. package/govendor/github.com/ebitengine/purego/dlfcn_nocgo_netbsd.go +11 -0
  166. package/govendor/github.com/ebitengine/purego/dlfcn_playground.go +24 -0
  167. package/govendor/github.com/ebitengine/purego/dlfcn_stubs.s +22 -0
  168. package/govendor/github.com/ebitengine/purego/func.go +780 -0
  169. package/govendor/github.com/ebitengine/purego/gen.go +6 -0
  170. package/govendor/github.com/ebitengine/purego/go.mod +3 -0
  171. package/govendor/github.com/ebitengine/purego/go_runtime.go +19 -0
  172. package/govendor/github.com/ebitengine/purego/internal/cgo/dlfcn_cgo_unix.go +56 -0
  173. package/govendor/github.com/ebitengine/purego/internal/cgo/empty.go +6 -0
  174. package/govendor/github.com/ebitengine/purego/internal/cgo/syscall_cgo_unix.go +49 -0
  175. package/govendor/github.com/ebitengine/purego/internal/fakecgo/abi_amd64.h +99 -0
  176. package/govendor/github.com/ebitengine/purego/internal/fakecgo/abi_arm64.h +39 -0
  177. package/govendor/github.com/ebitengine/purego/internal/fakecgo/abi_loong64.h +60 -0
  178. package/govendor/github.com/ebitengine/purego/internal/fakecgo/abi_ppc64x.h +195 -0
  179. package/govendor/github.com/ebitengine/purego/internal/fakecgo/abi_riscv64.h +72 -0
  180. package/govendor/github.com/ebitengine/purego/internal/fakecgo/asm_386.s +29 -0
  181. package/govendor/github.com/ebitengine/purego/internal/fakecgo/asm_amd64.s +39 -0
  182. package/govendor/github.com/ebitengine/purego/internal/fakecgo/asm_arm.s +58 -0
  183. package/govendor/github.com/ebitengine/purego/internal/fakecgo/asm_arm64.s +35 -0
  184. package/govendor/github.com/ebitengine/purego/internal/fakecgo/asm_loong64.s +38 -0
  185. package/govendor/github.com/ebitengine/purego/internal/fakecgo/asm_ppc64le.s +79 -0
  186. package/govendor/github.com/ebitengine/purego/internal/fakecgo/asm_riscv64.s +36 -0
  187. package/govendor/github.com/ebitengine/purego/internal/fakecgo/asm_s390x.s +52 -0
  188. package/govendor/github.com/ebitengine/purego/internal/fakecgo/callbacks.go +93 -0
  189. package/govendor/github.com/ebitengine/purego/internal/fakecgo/doc.go +32 -0
  190. package/govendor/github.com/ebitengine/purego/internal/fakecgo/fakecgo.go +14 -0
  191. package/govendor/github.com/ebitengine/purego/internal/fakecgo/freebsd.go +27 -0
  192. package/govendor/github.com/ebitengine/purego/internal/fakecgo/go_darwin.go +86 -0
  193. package/govendor/github.com/ebitengine/purego/internal/fakecgo/go_freebsd.go +77 -0
  194. package/govendor/github.com/ebitengine/purego/internal/fakecgo/go_libinit.go +72 -0
  195. package/govendor/github.com/ebitengine/purego/internal/fakecgo/go_linux.go +77 -0
  196. package/govendor/github.com/ebitengine/purego/internal/fakecgo/go_netbsd.go +83 -0
  197. package/govendor/github.com/ebitengine/purego/internal/fakecgo/go_setenv.go +18 -0
  198. package/govendor/github.com/ebitengine/purego/internal/fakecgo/go_util.go +38 -0
  199. package/govendor/github.com/ebitengine/purego/internal/fakecgo/iscgo.go +19 -0
  200. package/govendor/github.com/ebitengine/purego/internal/fakecgo/libcgo.go +37 -0
  201. package/govendor/github.com/ebitengine/purego/internal/fakecgo/libcgo_darwin.go +37 -0
  202. package/govendor/github.com/ebitengine/purego/internal/fakecgo/libcgo_freebsd.go +27 -0
  203. package/govendor/github.com/ebitengine/purego/internal/fakecgo/libcgo_linux.go +27 -0
  204. package/govendor/github.com/ebitengine/purego/internal/fakecgo/libcgo_netbsd.go +36 -0
  205. package/govendor/github.com/ebitengine/purego/internal/fakecgo/linux.go +189 -0
  206. package/govendor/github.com/ebitengine/purego/internal/fakecgo/netbsd.go +23 -0
  207. package/govendor/github.com/ebitengine/purego/internal/fakecgo/setenv.go +19 -0
  208. package/govendor/github.com/ebitengine/purego/internal/fakecgo/threadentry_amd64.go +15 -0
  209. package/govendor/github.com/ebitengine/purego/internal/fakecgo/threadentry_noasm.go +24 -0
  210. package/govendor/github.com/ebitengine/purego/internal/fakecgo/trampolines_386.s +130 -0
  211. package/govendor/github.com/ebitengine/purego/internal/fakecgo/trampolines_amd64.s +124 -0
  212. package/govendor/github.com/ebitengine/purego/internal/fakecgo/trampolines_arm.s +131 -0
  213. package/govendor/github.com/ebitengine/purego/internal/fakecgo/trampolines_arm64.s +81 -0
  214. package/govendor/github.com/ebitengine/purego/internal/fakecgo/trampolines_linux_386.s +78 -0
  215. package/govendor/github.com/ebitengine/purego/internal/fakecgo/trampolines_linux_amd64.s +69 -0
  216. package/govendor/github.com/ebitengine/purego/internal/fakecgo/trampolines_linux_arm.s +69 -0
  217. package/govendor/github.com/ebitengine/purego/internal/fakecgo/trampolines_linux_arm64.s +60 -0
  218. package/govendor/github.com/ebitengine/purego/internal/fakecgo/trampolines_linux_loong64.s +60 -0
  219. package/govendor/github.com/ebitengine/purego/internal/fakecgo/trampolines_linux_ppc64le.s +69 -0
  220. package/govendor/github.com/ebitengine/purego/internal/fakecgo/trampolines_linux_riscv64.s +60 -0
  221. package/govendor/github.com/ebitengine/purego/internal/fakecgo/trampolines_linux_s390x.s +51 -0
  222. package/govendor/github.com/ebitengine/purego/internal/fakecgo/trampolines_loong64.s +78 -0
  223. package/govendor/github.com/ebitengine/purego/internal/fakecgo/trampolines_ppc64le.s +132 -0
  224. package/govendor/github.com/ebitengine/purego/internal/fakecgo/trampolines_riscv64.s +76 -0
  225. package/govendor/github.com/ebitengine/purego/internal/fakecgo/trampolines_s390x.s +158 -0
  226. package/govendor/github.com/ebitengine/purego/internal/fakecgo/zsymbols.go +165 -0
  227. package/govendor/github.com/ebitengine/purego/internal/fakecgo/zsymbols_darwin.go +59 -0
  228. package/govendor/github.com/ebitengine/purego/internal/fakecgo/zsymbols_freebsd.go +48 -0
  229. package/govendor/github.com/ebitengine/purego/internal/fakecgo/zsymbols_linux.go +158 -0
  230. package/govendor/github.com/ebitengine/purego/internal/fakecgo/zsymbols_netbsd.go +59 -0
  231. package/govendor/github.com/ebitengine/purego/internal/fakecgo/ztrampolines_darwin.s +19 -0
  232. package/govendor/github.com/ebitengine/purego/internal/fakecgo/ztrampolines_freebsd.s +16 -0
  233. package/govendor/github.com/ebitengine/purego/internal/fakecgo/ztrampolines_linux.s +46 -0
  234. package/govendor/github.com/ebitengine/purego/internal/fakecgo/ztrampolines_netbsd.s +19 -0
  235. package/govendor/github.com/ebitengine/purego/internal/fakecgo/ztrampolines_stubs.s +55 -0
  236. package/govendor/github.com/ebitengine/purego/internal/strings/strings.go +40 -0
  237. package/govendor/github.com/ebitengine/purego/is_ios.go +13 -0
  238. package/govendor/github.com/ebitengine/purego/nocgo.go +25 -0
  239. package/govendor/github.com/ebitengine/purego/struct_amd64.go +518 -0
  240. package/govendor/github.com/ebitengine/purego/struct_arm.go +100 -0
  241. package/govendor/github.com/ebitengine/purego/struct_arm64.go +757 -0
  242. package/govendor/github.com/ebitengine/purego/struct_loong64.go +244 -0
  243. package/govendor/github.com/ebitengine/purego/struct_other.go +54 -0
  244. package/govendor/github.com/ebitengine/purego/struct_ppc64le.go +180 -0
  245. package/govendor/github.com/ebitengine/purego/struct_riscv64.go +158 -0
  246. package/govendor/github.com/ebitengine/purego/struct_s390x.go +158 -0
  247. package/govendor/github.com/ebitengine/purego/sys_386.s +153 -0
  248. package/govendor/github.com/ebitengine/purego/sys_amd64.s +206 -0
  249. package/govendor/github.com/ebitengine/purego/sys_arm.s +153 -0
  250. package/govendor/github.com/ebitengine/purego/sys_arm64.s +133 -0
  251. package/govendor/github.com/ebitengine/purego/sys_loong64.s +131 -0
  252. package/govendor/github.com/ebitengine/purego/sys_ppc64le.s +126 -0
  253. package/govendor/github.com/ebitengine/purego/sys_riscv64.s +135 -0
  254. package/govendor/github.com/ebitengine/purego/sys_s390x.s +148 -0
  255. package/govendor/github.com/ebitengine/purego/sys_unix_386.s +234 -0
  256. package/govendor/github.com/ebitengine/purego/sys_unix_arm.s +99 -0
  257. package/govendor/github.com/ebitengine/purego/sys_unix_arm64.s +75 -0
  258. package/govendor/github.com/ebitengine/purego/sys_unix_loong64.s +79 -0
  259. package/govendor/github.com/ebitengine/purego/sys_unix_ppc64le.s +114 -0
  260. package/govendor/github.com/ebitengine/purego/sys_unix_riscv64.s +79 -0
  261. package/govendor/github.com/ebitengine/purego/sys_unix_s390x.s +111 -0
  262. package/govendor/github.com/ebitengine/purego/syscall.go +95 -0
  263. package/govendor/github.com/ebitengine/purego/syscall_32bit.go +97 -0
  264. package/govendor/github.com/ebitengine/purego/syscall_cgo_linux.go +20 -0
  265. package/govendor/github.com/ebitengine/purego/syscall_notstackargs.go +55 -0
  266. package/govendor/github.com/ebitengine/purego/syscall_ppc64le.go +73 -0
  267. package/govendor/github.com/ebitengine/purego/syscall_stackargs_ppc64le.go +38 -0
  268. package/govendor/github.com/ebitengine/purego/syscall_stackargs_s390x.go +38 -0
  269. package/govendor/github.com/ebitengine/purego/syscall_unix.go +392 -0
  270. package/govendor/github.com/ebitengine/purego/syscall_windows.go +54 -0
  271. package/govendor/github.com/ebitengine/purego/zcallback_386.s +4014 -0
  272. package/govendor/github.com/ebitengine/purego/zcallback_amd64.s +2014 -0
  273. package/govendor/github.com/ebitengine/purego/zcallback_arm.s +4014 -0
  274. package/govendor/github.com/ebitengine/purego/zcallback_arm64.s +4014 -0
  275. package/govendor/github.com/ebitengine/purego/zcallback_loong64.s +4014 -0
  276. package/govendor/github.com/ebitengine/purego/zcallback_ppc64le.s +4014 -0
  277. package/govendor/github.com/ebitengine/purego/zcallback_riscv64.s +4051 -0
  278. package/govendor/github.com/ebitengine/purego/zcallback_s390x.s +4015 -0
  279. package/govendor/github.com/klauspost/compress/.gitattributes +3 -0
  280. package/govendor/github.com/klauspost/compress/.goreleaser.yml +132 -0
  281. package/govendor/github.com/klauspost/compress/AGENTS.md +106 -0
  282. package/govendor/github.com/klauspost/compress/LICENSE +304 -0
  283. package/govendor/github.com/klauspost/compress/README.md +766 -0
  284. package/govendor/github.com/klauspost/compress/SECURITY.md +25 -0
  285. package/govendor/github.com/klauspost/compress/compressible.go +85 -0
  286. package/govendor/github.com/klauspost/compress/fse/README.md +79 -0
  287. package/govendor/github.com/klauspost/compress/fse/bitreader.go +122 -0
  288. package/govendor/github.com/klauspost/compress/fse/bitwriter.go +167 -0
  289. package/govendor/github.com/klauspost/compress/fse/bytereader.go +47 -0
  290. package/govendor/github.com/klauspost/compress/fse/compress.go +685 -0
  291. package/govendor/github.com/klauspost/compress/fse/decompress.go +383 -0
  292. package/govendor/github.com/klauspost/compress/fse/fse.go +150 -0
  293. package/govendor/github.com/klauspost/compress/gen.sh +4 -0
  294. package/govendor/github.com/klauspost/compress/go.mod +3 -0
  295. package/govendor/github.com/klauspost/compress/huff0/README.md +89 -0
  296. package/govendor/github.com/klauspost/compress/huff0/bitreader.go +323 -0
  297. package/govendor/github.com/klauspost/compress/huff0/bitwriter.go +97 -0
  298. package/govendor/github.com/klauspost/compress/huff0/build_table.go +168 -0
  299. package/govendor/github.com/klauspost/compress/huff0/compress.go +747 -0
  300. package/govendor/github.com/klauspost/compress/huff0/decompress.go +1188 -0
  301. package/govendor/github.com/klauspost/compress/huff0/decompress_amd64.go +128 -0
  302. package/govendor/github.com/klauspost/compress/huff0/decompress_amd64.s +3476 -0
  303. package/govendor/github.com/klauspost/compress/huff0/decompress_arm64.go +72 -0
  304. package/govendor/github.com/klauspost/compress/huff0/decompress_arm64.s +1648 -0
  305. package/govendor/github.com/klauspost/compress/huff0/decompress_asm.go +252 -0
  306. package/govendor/github.com/klauspost/compress/huff0/decompress_generic.go +278 -0
  307. package/govendor/github.com/klauspost/compress/huff0/huff0.go +337 -0
  308. package/govendor/github.com/klauspost/compress/internal/cpuinfo/cpuinfo.go +34 -0
  309. package/govendor/github.com/klauspost/compress/internal/cpuinfo/cpuinfo_amd64.go +10 -0
  310. package/govendor/github.com/klauspost/compress/internal/cpuinfo/cpuinfo_amd64.s +34 -0
  311. package/govendor/github.com/klauspost/compress/internal/le/le.go +5 -0
  312. package/govendor/github.com/klauspost/compress/internal/le/unsafe_disabled.go +42 -0
  313. package/govendor/github.com/klauspost/compress/internal/le/unsafe_enabled.go +52 -0
  314. package/govendor/github.com/klauspost/compress/internal/regmask/regmask.go +50 -0
  315. package/govendor/github.com/klauspost/compress/internal/regmask/regmask_386.go +39 -0
  316. package/govendor/github.com/klauspost/compress/internal/snapref/LICENSE +27 -0
  317. package/govendor/github.com/klauspost/compress/internal/snapref/decode.go +264 -0
  318. package/govendor/github.com/klauspost/compress/internal/snapref/decode_other.go +113 -0
  319. package/govendor/github.com/klauspost/compress/internal/snapref/encode.go +291 -0
  320. package/govendor/github.com/klauspost/compress/internal/snapref/encode_other.go +250 -0
  321. package/govendor/github.com/klauspost/compress/internal/snapref/snappy.go +98 -0
  322. package/govendor/github.com/klauspost/compress/s2sx.mod +3 -0
  323. package/govendor/github.com/klauspost/compress/s2sx.sum +0 -0
  324. package/govendor/github.com/klauspost/compress/zstd/README.md +487 -0
  325. package/govendor/github.com/klauspost/compress/zstd/bitreader.go +176 -0
  326. package/govendor/github.com/klauspost/compress/zstd/bitwriter.go +151 -0
  327. package/govendor/github.com/klauspost/compress/zstd/blockdec.go +728 -0
  328. package/govendor/github.com/klauspost/compress/zstd/blockenc.go +923 -0
  329. package/govendor/github.com/klauspost/compress/zstd/blocktype_string.go +85 -0
  330. package/govendor/github.com/klauspost/compress/zstd/bytebuf.go +131 -0
  331. package/govendor/github.com/klauspost/compress/zstd/bytereader.go +82 -0
  332. package/govendor/github.com/klauspost/compress/zstd/decodeheader.go +261 -0
  333. package/govendor/github.com/klauspost/compress/zstd/decoder.go +995 -0
  334. package/govendor/github.com/klauspost/compress/zstd/decoder_options.go +213 -0
  335. package/govendor/github.com/klauspost/compress/zstd/dict.go +605 -0
  336. package/govendor/github.com/klauspost/compress/zstd/enc_base.go +200 -0
  337. package/govendor/github.com/klauspost/compress/zstd/enc_best.go +572 -0
  338. package/govendor/github.com/klauspost/compress/zstd/enc_better.go +1262 -0
  339. package/govendor/github.com/klauspost/compress/zstd/enc_dfast.go +1136 -0
  340. package/govendor/github.com/klauspost/compress/zstd/enc_fast.go +892 -0
  341. package/govendor/github.com/klauspost/compress/zstd/enc_jobs.go +352 -0
  342. package/govendor/github.com/klauspost/compress/zstd/encoder.go +881 -0
  343. package/govendor/github.com/klauspost/compress/zstd/encoder_options.go +422 -0
  344. package/govendor/github.com/klauspost/compress/zstd/framedec.go +404 -0
  345. package/govendor/github.com/klauspost/compress/zstd/frameenc.go +137 -0
  346. package/govendor/github.com/klauspost/compress/zstd/fse_decoder.go +333 -0
  347. package/govendor/github.com/klauspost/compress/zstd/fse_decoder_amd64.s +132 -0
  348. package/govendor/github.com/klauspost/compress/zstd/fse_decoder_arm64.s +148 -0
  349. package/govendor/github.com/klauspost/compress/zstd/fse_decoder_asm.go +70 -0
  350. package/govendor/github.com/klauspost/compress/zstd/fse_decoder_generic.go +71 -0
  351. package/govendor/github.com/klauspost/compress/zstd/fse_encoder.go +701 -0
  352. package/govendor/github.com/klauspost/compress/zstd/fse_predefined.go +168 -0
  353. package/govendor/github.com/klauspost/compress/zstd/hash.go +57 -0
  354. package/govendor/github.com/klauspost/compress/zstd/history.go +119 -0
  355. package/govendor/github.com/klauspost/compress/zstd/internal/xxhash/LICENSE.txt +22 -0
  356. package/govendor/github.com/klauspost/compress/zstd/internal/xxhash/README.md +71 -0
  357. package/govendor/github.com/klauspost/compress/zstd/internal/xxhash/xxhash.go +242 -0
  358. package/govendor/github.com/klauspost/compress/zstd/internal/xxhash/xxhash_amd64.s +210 -0
  359. package/govendor/github.com/klauspost/compress/zstd/internal/xxhash/xxhash_arm64.s +184 -0
  360. package/govendor/github.com/klauspost/compress/zstd/internal/xxhash/xxhash_asm.go +11 -0
  361. package/govendor/github.com/klauspost/compress/zstd/internal/xxhash/xxhash_other.go +75 -0
  362. package/govendor/github.com/klauspost/compress/zstd/internal/xxhash/xxhash_safe.go +11 -0
  363. package/govendor/github.com/klauspost/compress/zstd/matchlen_amd64.go +15 -0
  364. package/govendor/github.com/klauspost/compress/zstd/matchlen_amd64.s +66 -0
  365. package/govendor/github.com/klauspost/compress/zstd/matchlen_generic.go +37 -0
  366. package/govendor/github.com/klauspost/compress/zstd/seqdec.go +620 -0
  367. package/govendor/github.com/klauspost/compress/zstd/seqdec_amd64.go +115 -0
  368. package/govendor/github.com/klauspost/compress/zstd/seqdec_amd64.s +4762 -0
  369. package/govendor/github.com/klauspost/compress/zstd/seqdec_arm64.go +81 -0
  370. package/govendor/github.com/klauspost/compress/zstd/seqdec_arm64.s +2919 -0
  371. package/govendor/github.com/klauspost/compress/zstd/seqdec_asm.go +327 -0
  372. package/govendor/github.com/klauspost/compress/zstd/seqdec_generic.go +258 -0
  373. package/govendor/github.com/klauspost/compress/zstd/seqenc.go +159 -0
  374. package/govendor/github.com/klauspost/compress/zstd/simple.go +54 -0
  375. package/govendor/github.com/klauspost/compress/zstd/snappy.go +447 -0
  376. package/govendor/github.com/klauspost/compress/zstd/zip.go +141 -0
  377. package/govendor/github.com/klauspost/compress/zstd/zstd.go +126 -0
  378. package/govendor/github.com/tetratelabs/wazero/.editorconfig +7 -0
  379. package/govendor/github.com/tetratelabs/wazero/.gitattributes +2 -0
  380. package/govendor/github.com/tetratelabs/wazero/.gitmodules +3 -0
  381. package/govendor/github.com/tetratelabs/wazero/CONTRIBUTING.md +75 -0
  382. package/govendor/github.com/tetratelabs/wazero/LICENSE +201 -0
  383. package/govendor/github.com/tetratelabs/wazero/Makefile +385 -0
  384. package/govendor/github.com/tetratelabs/wazero/NOTICE +2 -0
  385. package/govendor/github.com/tetratelabs/wazero/RATIONALE.md +1577 -0
  386. package/govendor/github.com/tetratelabs/wazero/README.md +135 -0
  387. package/govendor/github.com/tetratelabs/wazero/api/features.go +228 -0
  388. package/govendor/github.com/tetratelabs/wazero/api/wasm.go +766 -0
  389. package/govendor/github.com/tetratelabs/wazero/builder.go +367 -0
  390. package/govendor/github.com/tetratelabs/wazero/cache.go +123 -0
  391. package/govendor/github.com/tetratelabs/wazero/codecov.yml +9 -0
  392. package/govendor/github.com/tetratelabs/wazero/config.go +899 -0
  393. package/govendor/github.com/tetratelabs/wazero/experimental/checkpoint.go +35 -0
  394. package/govendor/github.com/tetratelabs/wazero/experimental/close.go +63 -0
  395. package/govendor/github.com/tetratelabs/wazero/experimental/compilationworkers.go +19 -0
  396. package/govendor/github.com/tetratelabs/wazero/experimental/experimental.go +41 -0
  397. package/govendor/github.com/tetratelabs/wazero/experimental/features.go +39 -0
  398. package/govendor/github.com/tetratelabs/wazero/experimental/importresolver.go +19 -0
  399. package/govendor/github.com/tetratelabs/wazero/experimental/listener.go +324 -0
  400. package/govendor/github.com/tetratelabs/wazero/experimental/memory.go +52 -0
  401. package/govendor/github.com/tetratelabs/wazero/experimental/sys/dir.go +92 -0
  402. package/govendor/github.com/tetratelabs/wazero/experimental/sys/errno.go +98 -0
  403. package/govendor/github.com/tetratelabs/wazero/experimental/sys/error.go +45 -0
  404. package/govendor/github.com/tetratelabs/wazero/experimental/sys/file.go +356 -0
  405. package/govendor/github.com/tetratelabs/wazero/experimental/sys/fs.go +292 -0
  406. package/govendor/github.com/tetratelabs/wazero/experimental/sys/oflag.go +70 -0
  407. package/govendor/github.com/tetratelabs/wazero/experimental/sys/poll.go +48 -0
  408. package/govendor/github.com/tetratelabs/wazero/experimental/sys/syscall_errno.go +106 -0
  409. package/govendor/github.com/tetratelabs/wazero/experimental/sys/syscall_errno_notwindows.go +13 -0
  410. package/govendor/github.com/tetratelabs/wazero/experimental/sys/syscall_errno_unsupported.go +7 -0
  411. package/govendor/github.com/tetratelabs/wazero/experimental/sys/syscall_errno_windows.go +37 -0
  412. package/govendor/github.com/tetratelabs/wazero/experimental/sys/time.go +10 -0
  413. package/govendor/github.com/tetratelabs/wazero/experimental/sys/unimplemented.go +160 -0
  414. package/govendor/github.com/tetratelabs/wazero/fsconfig.go +213 -0
  415. package/govendor/github.com/tetratelabs/wazero/go.mod +3 -0
  416. package/govendor/github.com/tetratelabs/wazero/imports/wasi_snapshot_preview1/args.go +97 -0
  417. package/govendor/github.com/tetratelabs/wazero/imports/wasi_snapshot_preview1/clock.go +116 -0
  418. package/govendor/github.com/tetratelabs/wazero/imports/wasi_snapshot_preview1/environ.go +100 -0
  419. package/govendor/github.com/tetratelabs/wazero/imports/wasi_snapshot_preview1/fs.go +2015 -0
  420. package/govendor/github.com/tetratelabs/wazero/imports/wasi_snapshot_preview1/poll.go +247 -0
  421. package/govendor/github.com/tetratelabs/wazero/imports/wasi_snapshot_preview1/proc.go +44 -0
  422. package/govendor/github.com/tetratelabs/wazero/imports/wasi_snapshot_preview1/random.go +55 -0
  423. package/govendor/github.com/tetratelabs/wazero/imports/wasi_snapshot_preview1/sched.go +22 -0
  424. package/govendor/github.com/tetratelabs/wazero/imports/wasi_snapshot_preview1/sock.go +188 -0
  425. package/govendor/github.com/tetratelabs/wazero/imports/wasi_snapshot_preview1/wasi.go +314 -0
  426. package/govendor/github.com/tetratelabs/wazero/internal/descriptor/table.go +149 -0
  427. package/govendor/github.com/tetratelabs/wazero/internal/engine/interpreter/compiler.go +3884 -0
  428. package/govendor/github.com/tetratelabs/wazero/internal/engine/interpreter/format.go +22 -0
  429. package/govendor/github.com/tetratelabs/wazero/internal/engine/interpreter/interpreter.go +4963 -0
  430. package/govendor/github.com/tetratelabs/wazero/internal/engine/interpreter/operations.go +2978 -0
  431. package/govendor/github.com/tetratelabs/wazero/internal/engine/interpreter/signature.go +825 -0
  432. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/abi.go +170 -0
  433. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/backend.go +3 -0
  434. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/compiler.go +402 -0
  435. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/compiler_lower.go +226 -0
  436. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/go_call.go +33 -0
  437. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/amd64/abi.go +186 -0
  438. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/amd64/abi_entry_amd64.go +9 -0
  439. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/amd64/abi_entry_amd64.s +29 -0
  440. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/amd64/abi_entry_preamble.go +248 -0
  441. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/amd64/abi_go_call.go +440 -0
  442. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/amd64/cond.go +168 -0
  443. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/amd64/ext.go +35 -0
  444. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/amd64/instr.go +2495 -0
  445. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/amd64/instr_encoding.go +1714 -0
  446. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/amd64/lower_constant.go +71 -0
  447. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/amd64/lower_mem.go +187 -0
  448. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/amd64/machine.go +3782 -0
  449. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/amd64/machine_pro_epi_logue.go +334 -0
  450. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/amd64/machine_regalloc.go +352 -0
  451. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/amd64/machine_vec.go +992 -0
  452. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/amd64/operands.go +336 -0
  453. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/amd64/reg.go +181 -0
  454. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/amd64/stack.go +130 -0
  455. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/arm64/abi.go +376 -0
  456. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/arm64/abi_entry_arm64.go +9 -0
  457. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/arm64/abi_entry_arm64.s +29 -0
  458. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/arm64/abi_entry_preamble.go +233 -0
  459. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/arm64/abi_go_call.go +430 -0
  460. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/arm64/cond.go +215 -0
  461. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/arm64/instr.go +2562 -0
  462. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/arm64/instr_encoding.go +2357 -0
  463. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/arm64/lower_constant.go +301 -0
  464. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/arm64/lower_instr.go +2227 -0
  465. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/arm64/lower_instr_operands.go +340 -0
  466. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/arm64/lower_mem.go +451 -0
  467. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/arm64/machine.go +631 -0
  468. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/arm64/machine_pro_epi_logue.go +486 -0
  469. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/arm64/machine_regalloc.go +351 -0
  470. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/arm64/machine_relocation.go +128 -0
  471. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/arm64/reg.go +397 -0
  472. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/isa/arm64/unwind_stack.go +84 -0
  473. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/machine.go +119 -0
  474. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/regalloc/api.go +124 -0
  475. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/regalloc/reg.go +123 -0
  476. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/regalloc/regalloc.go +1189 -0
  477. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/regalloc/regset.go +96 -0
  478. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/backend/vdef.go +19 -0
  479. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/call_engine.go +884 -0
  480. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/engine.go +1008 -0
  481. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/engine_cache.go +347 -0
  482. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/entrypoint_amd64.go +13 -0
  483. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/entrypoint_arm64.go +13 -0
  484. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/entrypoint_other.go +15 -0
  485. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/frontend/frontend.go +663 -0
  486. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/frontend/lower.go +5045 -0
  487. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/frontend/misc.go +10 -0
  488. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/frontend/sort_id.go +13 -0
  489. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/hostmodule.go +88 -0
  490. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/isa_amd64.go +30 -0
  491. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/isa_arm64.go +32 -0
  492. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/isa_other.go +29 -0
  493. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/memmove.go +11 -0
  494. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/module_engine.go +403 -0
  495. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/ssa/basic_block.go +381 -0
  496. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/ssa/basic_block_sort.go +32 -0
  497. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/ssa/builder.go +790 -0
  498. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/ssa/cmp.go +107 -0
  499. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/ssa/funcref.go +12 -0
  500. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/ssa/instructions.go +3024 -0
  501. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/ssa/pass.go +393 -0
  502. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/ssa/pass_blk_layouts.go +334 -0
  503. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/ssa/pass_cfg.go +313 -0
  504. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/ssa/signature.go +49 -0
  505. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/ssa/ssa.go +14 -0
  506. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/ssa/type.go +115 -0
  507. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/ssa/vs.go +114 -0
  508. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/wazevoapi/debug_options.go +189 -0
  509. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/wazevoapi/exitcode.go +150 -0
  510. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/wazevoapi/offsetdata.go +248 -0
  511. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/wazevoapi/perfmap.go +96 -0
  512. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/wazevoapi/perfmap_disabled.go +5 -0
  513. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/wazevoapi/perfmap_enabled.go +5 -0
  514. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/wazevoapi/pool.go +215 -0
  515. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/wazevoapi/ptr.go +15 -0
  516. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/wazevoapi/queue.go +26 -0
  517. package/govendor/github.com/tetratelabs/wazero/internal/engine/wazevo/wazevoapi/resetmap.go +11 -0
  518. package/govendor/github.com/tetratelabs/wazero/internal/expctxkeys/checkpoint.go +10 -0
  519. package/govendor/github.com/tetratelabs/wazero/internal/expctxkeys/close.go +5 -0
  520. package/govendor/github.com/tetratelabs/wazero/internal/expctxkeys/compilationworkers.go +6 -0
  521. package/govendor/github.com/tetratelabs/wazero/internal/expctxkeys/expctxkeys.go +2 -0
  522. package/govendor/github.com/tetratelabs/wazero/internal/expctxkeys/importresolver.go +6 -0
  523. package/govendor/github.com/tetratelabs/wazero/internal/expctxkeys/listener.go +7 -0
  524. package/govendor/github.com/tetratelabs/wazero/internal/expctxkeys/memory.go +4 -0
  525. package/govendor/github.com/tetratelabs/wazero/internal/filecache/compilationcache.go +42 -0
  526. package/govendor/github.com/tetratelabs/wazero/internal/filecache/file_cache.go +76 -0
  527. package/govendor/github.com/tetratelabs/wazero/internal/ieee754/ieee754.go +29 -0
  528. package/govendor/github.com/tetratelabs/wazero/internal/internalapi/internal.go +9 -0
  529. package/govendor/github.com/tetratelabs/wazero/internal/leb128/leb128.go +285 -0
  530. package/govendor/github.com/tetratelabs/wazero/internal/moremath/moremath.go +271 -0
  531. package/govendor/github.com/tetratelabs/wazero/internal/platform/cpuid.go +26 -0
  532. package/govendor/github.com/tetratelabs/wazero/internal/platform/cpuid_amd64.go +22 -0
  533. package/govendor/github.com/tetratelabs/wazero/internal/platform/cpuid_arm64.go +13 -0
  534. package/govendor/github.com/tetratelabs/wazero/internal/platform/cpuid_unsupported.go +5 -0
  535. package/govendor/github.com/tetratelabs/wazero/internal/platform/crypto.go +17 -0
  536. package/govendor/github.com/tetratelabs/wazero/internal/platform/mmap_linux.go +72 -0
  537. package/govendor/github.com/tetratelabs/wazero/internal/platform/mmap_other.go +19 -0
  538. package/govendor/github.com/tetratelabs/wazero/internal/platform/mmap_unix.go +14 -0
  539. package/govendor/github.com/tetratelabs/wazero/internal/platform/mmap_unsupported.go +22 -0
  540. package/govendor/github.com/tetratelabs/wazero/internal/platform/mmap_windows.go +31 -0
  541. package/govendor/github.com/tetratelabs/wazero/internal/platform/path.go +6 -0
  542. package/govendor/github.com/tetratelabs/wazero/internal/platform/path_windows.go +17 -0
  543. package/govendor/github.com/tetratelabs/wazero/internal/platform/platform.go +71 -0
  544. package/govendor/github.com/tetratelabs/wazero/internal/platform/time.go +76 -0
  545. package/govendor/github.com/tetratelabs/wazero/internal/platform/time_notwindows.go +11 -0
  546. package/govendor/github.com/tetratelabs/wazero/internal/platform/time_windows.go +40 -0
  547. package/govendor/github.com/tetratelabs/wazero/internal/sock/sock.go +89 -0
  548. package/govendor/github.com/tetratelabs/wazero/internal/sock/sock_supported.go +11 -0
  549. package/govendor/github.com/tetratelabs/wazero/internal/sock/sock_unsupported.go +10 -0
  550. package/govendor/github.com/tetratelabs/wazero/internal/sys/fs.go +458 -0
  551. package/govendor/github.com/tetratelabs/wazero/internal/sys/lazy.go +135 -0
  552. package/govendor/github.com/tetratelabs/wazero/internal/sys/stdio.go +125 -0
  553. package/govendor/github.com/tetratelabs/wazero/internal/sys/sys.go +228 -0
  554. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/adapter.go +105 -0
  555. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/datasync_linux.go +12 -0
  556. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/datasync_unsupported.go +14 -0
  557. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/dir.go +24 -0
  558. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/dirfs.go +137 -0
  559. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/file.go +576 -0
  560. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/file_unix.go +39 -0
  561. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/file_unsupported.go +28 -0
  562. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/file_windows.go +133 -0
  563. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/futimens.go +29 -0
  564. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/futimens_darwin.go +42 -0
  565. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/futimens_darwin.s +8 -0
  566. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/futimens_linux.go +38 -0
  567. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/futimens_unsupported.go +18 -0
  568. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/futimens_windows.go +42 -0
  569. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/ino_unix.go +22 -0
  570. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/ino_unsupported.go +17 -0
  571. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/ino_windows.go +28 -0
  572. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/nonblock_unix.go +17 -0
  573. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/nonblock_unsupported.go +13 -0
  574. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/nonblock_windows.go +23 -0
  575. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/oflag.go +38 -0
  576. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/open_file_bsd.go +26 -0
  577. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/open_file_darwin.go +26 -0
  578. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/open_file_supported.go +30 -0
  579. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/open_file_unix.go +20 -0
  580. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/open_file_unsupported.go +16 -0
  581. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/open_file_windows.go +163 -0
  582. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/osfile.go +318 -0
  583. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/poll.go +17 -0
  584. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/poll_darwin.go +55 -0
  585. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/poll_darwin.s +8 -0
  586. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/poll_linux.go +57 -0
  587. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/poll_unsupported.go +12 -0
  588. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/poll_windows.go +224 -0
  589. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/readfs.go +117 -0
  590. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/rename_unix.go +16 -0
  591. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/rename_unsupported.go +16 -0
  592. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/rename_windows.go +55 -0
  593. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/sock.go +186 -0
  594. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/sock_supported.go +76 -0
  595. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/sock_unix.go +48 -0
  596. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/sock_unsupported.go +79 -0
  597. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/sock_windows.go +80 -0
  598. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/stat.go +16 -0
  599. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/stat_supported.go +40 -0
  600. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/stat_unsupported.go +40 -0
  601. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/stat_windows.go +118 -0
  602. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/sync.go +13 -0
  603. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/sync_windows.go +20 -0
  604. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/syscall6_darwin.go +13 -0
  605. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/sysfs.go +6 -0
  606. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/unlink_unix.go +17 -0
  607. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/unlink_unsupported.go +14 -0
  608. package/govendor/github.com/tetratelabs/wazero/internal/sysfs/unlink_windows.go +25 -0
  609. package/govendor/github.com/tetratelabs/wazero/internal/u32/u32.go +11 -0
  610. package/govendor/github.com/tetratelabs/wazero/internal/u64/u64.go +15 -0
  611. package/govendor/github.com/tetratelabs/wazero/internal/version/version.go +52 -0
  612. package/govendor/github.com/tetratelabs/wazero/internal/wasip1/args.go +6 -0
  613. package/govendor/github.com/tetratelabs/wazero/internal/wasip1/clock.go +16 -0
  614. package/govendor/github.com/tetratelabs/wazero/internal/wasip1/environ.go +6 -0
  615. package/govendor/github.com/tetratelabs/wazero/internal/wasip1/errno.go +314 -0
  616. package/govendor/github.com/tetratelabs/wazero/internal/wasip1/fs.go +164 -0
  617. package/govendor/github.com/tetratelabs/wazero/internal/wasip1/poll.go +15 -0
  618. package/govendor/github.com/tetratelabs/wazero/internal/wasip1/proc.go +6 -0
  619. package/govendor/github.com/tetratelabs/wazero/internal/wasip1/random.go +3 -0
  620. package/govendor/github.com/tetratelabs/wazero/internal/wasip1/rights.go +148 -0
  621. package/govendor/github.com/tetratelabs/wazero/internal/wasip1/sched.go +3 -0
  622. package/govendor/github.com/tetratelabs/wazero/internal/wasip1/sock.go +71 -0
  623. package/govendor/github.com/tetratelabs/wazero/internal/wasip1/wasi.go +26 -0
  624. package/govendor/github.com/tetratelabs/wazero/internal/wasm/binary/code.go +124 -0
  625. package/govendor/github.com/tetratelabs/wazero/internal/wasm/binary/const_expr.go +116 -0
  626. package/govendor/github.com/tetratelabs/wazero/internal/wasm/binary/custom.go +22 -0
  627. package/govendor/github.com/tetratelabs/wazero/internal/wasm/binary/data.go +79 -0
  628. package/govendor/github.com/tetratelabs/wazero/internal/wasm/binary/decoder.go +235 -0
  629. package/govendor/github.com/tetratelabs/wazero/internal/wasm/binary/element.go +250 -0
  630. package/govendor/github.com/tetratelabs/wazero/internal/wasm/binary/errors.go +11 -0
  631. package/govendor/github.com/tetratelabs/wazero/internal/wasm/binary/export.go +32 -0
  632. package/govendor/github.com/tetratelabs/wazero/internal/wasm/binary/function.go +56 -0
  633. package/govendor/github.com/tetratelabs/wazero/internal/wasm/binary/global.go +50 -0
  634. package/govendor/github.com/tetratelabs/wazero/internal/wasm/binary/header.go +9 -0
  635. package/govendor/github.com/tetratelabs/wazero/internal/wasm/binary/import.go +68 -0
  636. package/govendor/github.com/tetratelabs/wazero/internal/wasm/binary/limits.go +47 -0
  637. package/govendor/github.com/tetratelabs/wazero/internal/wasm/binary/memory.go +42 -0
  638. package/govendor/github.com/tetratelabs/wazero/internal/wasm/binary/names.go +151 -0
  639. package/govendor/github.com/tetratelabs/wazero/internal/wasm/binary/section.go +309 -0
  640. package/govendor/github.com/tetratelabs/wazero/internal/wasm/binary/table.go +79 -0
  641. package/govendor/github.com/tetratelabs/wazero/internal/wasm/binary/value.go +97 -0
  642. package/govendor/github.com/tetratelabs/wazero/internal/wasm/const_expr.go +259 -0
  643. package/govendor/github.com/tetratelabs/wazero/internal/wasm/counts.go +53 -0
  644. package/govendor/github.com/tetratelabs/wazero/internal/wasm/engine.go +76 -0
  645. package/govendor/github.com/tetratelabs/wazero/internal/wasm/exception.go +9 -0
  646. package/govendor/github.com/tetratelabs/wazero/internal/wasm/func_validation.go +2804 -0
  647. package/govendor/github.com/tetratelabs/wazero/internal/wasm/function_definition.go +210 -0
  648. package/govendor/github.com/tetratelabs/wazero/internal/wasm/global.go +55 -0
  649. package/govendor/github.com/tetratelabs/wazero/internal/wasm/gofunc.go +279 -0
  650. package/govendor/github.com/tetratelabs/wazero/internal/wasm/host.go +179 -0
  651. package/govendor/github.com/tetratelabs/wazero/internal/wasm/instruction.go +1962 -0
  652. package/govendor/github.com/tetratelabs/wazero/internal/wasm/memory.go +475 -0
  653. package/govendor/github.com/tetratelabs/wazero/internal/wasm/memory_definition.go +128 -0
  654. package/govendor/github.com/tetratelabs/wazero/internal/wasm/module.go +1359 -0
  655. package/govendor/github.com/tetratelabs/wazero/internal/wasm/module_instance.go +251 -0
  656. package/govendor/github.com/tetratelabs/wazero/internal/wasm/module_instance_lookup.go +73 -0
  657. package/govendor/github.com/tetratelabs/wazero/internal/wasm/store.go +726 -0
  658. package/govendor/github.com/tetratelabs/wazero/internal/wasm/store_module_list.go +95 -0
  659. package/govendor/github.com/tetratelabs/wazero/internal/wasm/table.go +321 -0
  660. package/govendor/github.com/tetratelabs/wazero/internal/wasmdebug/debug.go +170 -0
  661. package/govendor/github.com/tetratelabs/wazero/internal/wasmdebug/dwarf.go +225 -0
  662. package/govendor/github.com/tetratelabs/wazero/internal/wasmruntime/errors.go +54 -0
  663. package/govendor/github.com/tetratelabs/wazero/netlify.toml +15 -0
  664. package/govendor/github.com/tetratelabs/wazero/runtime.go +399 -0
  665. package/govendor/github.com/tetratelabs/wazero/sys/clock.go +26 -0
  666. package/govendor/github.com/tetratelabs/wazero/sys/error.go +83 -0
  667. package/govendor/github.com/tetratelabs/wazero/sys/stat.go +105 -0
  668. package/govendor/github.com/tetratelabs/wazero/sys/stat_bsd.go +29 -0
  669. package/govendor/github.com/tetratelabs/wazero/sys/stat_posix.go +29 -0
  670. package/govendor/github.com/tetratelabs/wazero/sys/stat_unsupported.go +14 -0
  671. package/govendor/github.com/tetratelabs/wazero/sys/stat_windows.go +24 -0
  672. package/govendor/golang.org/x/crypto/LICENSE +27 -0
  673. package/govendor/golang.org/x/crypto/PATENTS +22 -0
  674. package/govendor/golang.org/x/crypto/cryptobyte/asn1/asn1.go +46 -0
  675. package/govendor/golang.org/x/crypto/cryptobyte/asn1.go +825 -0
  676. package/govendor/golang.org/x/crypto/cryptobyte/builder.go +350 -0
  677. package/govendor/golang.org/x/crypto/cryptobyte/string.go +183 -0
  678. package/govendor/golang.org/x/crypto/go.mod +3 -0
  679. package/govendor/golang.org/x/crypto/pbkdf2/pbkdf2.go +30 -0
  680. package/govendor/golang.org/x/net/LICENSE +27 -0
  681. package/govendor/golang.org/x/net/PATENTS +22 -0
  682. package/govendor/golang.org/x/net/dns/dnsmessage/message.go +2733 -0
  683. package/govendor/golang.org/x/net/dns/dnsmessage/svcb.go +333 -0
  684. package/govendor/golang.org/x/net/go.mod +3 -0
  685. package/govendor/golang.org/x/net/http/httpguts/guts.go +50 -0
  686. package/govendor/golang.org/x/net/http/httpguts/httplex.go +347 -0
  687. package/govendor/golang.org/x/net/http2/README.md +19 -0
  688. package/govendor/golang.org/x/net/http2/ascii.go +65 -0
  689. package/govendor/golang.org/x/net/http2/ciphers.go +641 -0
  690. package/govendor/golang.org/x/net/http2/client_conn_pool.go +301 -0
  691. package/govendor/golang.org/x/net/http2/client_priority_go126.go +20 -0
  692. package/govendor/golang.org/x/net/http2/client_priority_go127.go +13 -0
  693. package/govendor/golang.org/x/net/http2/clientconn.go +57 -0
  694. package/govendor/golang.org/x/net/http2/config.go +171 -0
  695. package/govendor/golang.org/x/net/http2/config_go125.go +15 -0
  696. package/govendor/golang.org/x/net/http2/config_go126.go +15 -0
  697. package/govendor/golang.org/x/net/http2/databuffer.go +146 -0
  698. package/govendor/golang.org/x/net/http2/errors.go +145 -0
  699. package/govendor/golang.org/x/net/http2/flow.go +175 -0
  700. package/govendor/golang.org/x/net/http2/frame.go +1887 -0
  701. package/govendor/golang.org/x/net/http2/gotrack.go +181 -0
  702. package/govendor/golang.org/x/net/http2/hpack/encode.go +244 -0
  703. package/govendor/golang.org/x/net/http2/hpack/hpack.go +522 -0
  704. package/govendor/golang.org/x/net/http2/hpack/huffman.go +226 -0
  705. package/govendor/golang.org/x/net/http2/hpack/static_table.go +188 -0
  706. package/govendor/golang.org/x/net/http2/hpack/tables.go +426 -0
  707. package/govendor/golang.org/x/net/http2/http2.go +415 -0
  708. package/govendor/golang.org/x/net/http2/pipe.go +184 -0
  709. package/govendor/golang.org/x/net/http2/server.go +3239 -0
  710. package/govendor/golang.org/x/net/http2/server_common.go +268 -0
  711. package/govendor/golang.org/x/net/http2/server_wrap.go +217 -0
  712. package/govendor/golang.org/x/net/http2/transport.go +3084 -0
  713. package/govendor/golang.org/x/net/http2/transport_common.go +516 -0
  714. package/govendor/golang.org/x/net/http2/transport_wrap.go +583 -0
  715. package/govendor/golang.org/x/net/http2/unencrypted.go +32 -0
  716. package/govendor/golang.org/x/net/http2/write.go +381 -0
  717. package/govendor/golang.org/x/net/http2/writesched.go +253 -0
  718. package/govendor/golang.org/x/net/http2/writesched_common.go +90 -0
  719. package/govendor/golang.org/x/net/http2/writesched_priority_rfc7540.go +420 -0
  720. package/govendor/golang.org/x/net/http2/writesched_priority_rfc9218.go +226 -0
  721. package/govendor/golang.org/x/net/http2/writesched_random.go +81 -0
  722. package/govendor/golang.org/x/net/http2/writesched_roundrobin.go +121 -0
  723. package/govendor/golang.org/x/net/idna/idna.go +884 -0
  724. package/govendor/golang.org/x/net/idna/punycode.go +220 -0
  725. package/govendor/golang.org/x/net/idna/tables15.0.0.go +5144 -0
  726. package/govendor/golang.org/x/net/idna/tables17.0.0.go +5302 -0
  727. package/govendor/golang.org/x/net/idna/trie.go +51 -0
  728. package/govendor/golang.org/x/net/idna/trieval.go +119 -0
  729. package/govendor/golang.org/x/net/internal/httpcommon/README.md +7 -0
  730. package/govendor/golang.org/x/net/internal/httpcommon/ascii.go +53 -0
  731. package/govendor/golang.org/x/net/internal/httpcommon/gzip.go +132 -0
  732. package/govendor/golang.org/x/net/internal/httpcommon/headermap.go +115 -0
  733. package/govendor/golang.org/x/net/internal/httpcommon/request.go +503 -0
  734. package/govendor/golang.org/x/net/internal/httpsfv/httpsfv.go +665 -0
  735. package/govendor/golang.org/x/sys/cpu/asm_aix_ppc64.s +17 -0
  736. package/govendor/golang.org/x/sys/cpu/asm_darwin_arm64_gc.s +12 -0
  737. package/govendor/golang.org/x/sys/cpu/asm_darwin_x86_gc.s +17 -0
  738. package/govendor/golang.org/x/sys/cpu/byteorder.go +66 -0
  739. package/govendor/golang.org/x/sys/cpu/cpu.go +357 -0
  740. package/govendor/golang.org/x/sys/cpu/cpu_aix.go +33 -0
  741. package/govendor/golang.org/x/sys/cpu/cpu_arm.go +73 -0
  742. package/govendor/golang.org/x/sys/cpu/cpu_arm64.go +191 -0
  743. package/govendor/golang.org/x/sys/cpu/cpu_arm64.s +35 -0
  744. package/govendor/golang.org/x/sys/cpu/cpu_darwin_arm64.go +67 -0
  745. package/govendor/golang.org/x/sys/cpu/cpu_darwin_arm64_other.go +31 -0
  746. package/govendor/golang.org/x/sys/cpu/cpu_darwin_x86.go +61 -0
  747. package/govendor/golang.org/x/sys/cpu/cpu_gc_arm64.go +12 -0
  748. package/govendor/golang.org/x/sys/cpu/cpu_gc_riscv64.go +11 -0
  749. package/govendor/golang.org/x/sys/cpu/cpu_gc_s390x.go +21 -0
  750. package/govendor/golang.org/x/sys/cpu/cpu_gc_x86.go +15 -0
  751. package/govendor/golang.org/x/sys/cpu/cpu_gc_x86.s +26 -0
  752. package/govendor/golang.org/x/sys/cpu/cpu_gccgo_arm64.go +12 -0
  753. package/govendor/golang.org/x/sys/cpu/cpu_gccgo_s390x.go +22 -0
  754. package/govendor/golang.org/x/sys/cpu/cpu_gccgo_x86.c +37 -0
  755. package/govendor/golang.org/x/sys/cpu/cpu_gccgo_x86.go +25 -0
  756. package/govendor/golang.org/x/sys/cpu/cpu_linux.go +15 -0
  757. package/govendor/golang.org/x/sys/cpu/cpu_linux_arm.go +39 -0
  758. package/govendor/golang.org/x/sys/cpu/cpu_linux_arm64.go +120 -0
  759. package/govendor/golang.org/x/sys/cpu/cpu_linux_loong64.go +22 -0
  760. package/govendor/golang.org/x/sys/cpu/cpu_linux_mips64x.go +22 -0
  761. package/govendor/golang.org/x/sys/cpu/cpu_linux_noinit.go +9 -0
  762. package/govendor/golang.org/x/sys/cpu/cpu_linux_ppc64x.go +34 -0
  763. package/govendor/golang.org/x/sys/cpu/cpu_linux_riscv64.go +173 -0
  764. package/govendor/golang.org/x/sys/cpu/cpu_linux_s390x.go +40 -0
  765. package/govendor/golang.org/x/sys/cpu/cpu_loong64.go +62 -0
  766. package/govendor/golang.org/x/sys/cpu/cpu_loong64.s +13 -0
  767. package/govendor/golang.org/x/sys/cpu/cpu_mips64x.go +15 -0
  768. package/govendor/golang.org/x/sys/cpu/cpu_mipsx.go +11 -0
  769. package/govendor/golang.org/x/sys/cpu/cpu_netbsd_amd64.go +47 -0
  770. package/govendor/golang.org/x/sys/cpu/cpu_netbsd_arm64.go +173 -0
  771. package/govendor/golang.org/x/sys/cpu/cpu_openbsd_arm64.go +65 -0
  772. package/govendor/golang.org/x/sys/cpu/cpu_openbsd_arm64.s +11 -0
  773. package/govendor/golang.org/x/sys/cpu/cpu_other_arm.go +9 -0
  774. package/govendor/golang.org/x/sys/cpu/cpu_other_arm64.go +11 -0
  775. package/govendor/golang.org/x/sys/cpu/cpu_other_mips64x.go +11 -0
  776. package/govendor/golang.org/x/sys/cpu/cpu_other_ppc64x.go +12 -0
  777. package/govendor/golang.org/x/sys/cpu/cpu_other_riscv64.go +11 -0
  778. package/govendor/golang.org/x/sys/cpu/cpu_other_x86.go +11 -0
  779. package/govendor/golang.org/x/sys/cpu/cpu_ppc64x.go +16 -0
  780. package/govendor/golang.org/x/sys/cpu/cpu_riscv64.go +33 -0
  781. package/govendor/golang.org/x/sys/cpu/cpu_riscv64.s +17 -0
  782. package/govendor/golang.org/x/sys/cpu/cpu_s390x.go +172 -0
  783. package/govendor/golang.org/x/sys/cpu/cpu_s390x.s +57 -0
  784. package/govendor/golang.org/x/sys/cpu/cpu_sparc64.go +12 -0
  785. package/govendor/golang.org/x/sys/cpu/cpu_wasm.go +17 -0
  786. package/govendor/golang.org/x/sys/cpu/cpu_windows.go +26 -0
  787. package/govendor/golang.org/x/sys/cpu/cpu_windows_arm64.go +38 -0
  788. package/govendor/golang.org/x/sys/cpu/cpu_x86.go +259 -0
  789. package/govendor/golang.org/x/sys/cpu/cpu_zos.go +10 -0
  790. package/govendor/golang.org/x/sys/cpu/cpu_zos_s390x.go +25 -0
  791. package/govendor/golang.org/x/sys/cpu/endian_big.go +10 -0
  792. package/govendor/golang.org/x/sys/cpu/endian_little.go +10 -0
  793. package/govendor/golang.org/x/sys/cpu/hwcap_linux.go +71 -0
  794. package/govendor/golang.org/x/sys/cpu/parse.go +55 -0
  795. package/govendor/golang.org/x/sys/cpu/proc_cpuinfo_linux.go +53 -0
  796. package/govendor/golang.org/x/sys/cpu/runtime_auxv.go +16 -0
  797. package/govendor/golang.org/x/sys/cpu/runtime_auxv_go121.go +18 -0
  798. package/govendor/golang.org/x/sys/cpu/syscall_aix_gccgo.go +26 -0
  799. package/govendor/golang.org/x/sys/cpu/syscall_aix_ppc64_gc.go +35 -0
  800. package/govendor/golang.org/x/sys/cpu/syscall_darwin_arm64_gc.go +54 -0
  801. package/govendor/golang.org/x/sys/cpu/syscall_darwin_x86_gc.go +98 -0
  802. package/govendor/golang.org/x/sys/cpu/zcpu_windows.go +48 -0
  803. package/govendor/golang.org/x/sys/unix/asm_linux_ppc64x.s +20 -0
  804. package/govendor/golang.org/x/sys/unix/asm_linux_sparc64.s +48 -0
  805. package/govendor/golang.org/x/sys/unix/asm_zos_s390x.s +4 -186
  806. package/govendor/golang.org/x/sys/unix/bpxsvc_zos.s +9 -9
  807. package/govendor/golang.org/x/sys/unix/fcntl_darwin.go +2 -2
  808. package/govendor/golang.org/x/sys/unix/mkerrors.sh +1 -1
  809. package/govendor/golang.org/x/sys/unix/ptrace_zos.go +537 -0
  810. package/govendor/golang.org/x/sys/unix/ptrace_zos_singlestep.go +425 -0
  811. package/govendor/golang.org/x/sys/unix/syscall_darwin.go +1 -0
  812. package/govendor/golang.org/x/sys/unix/syscall_freebsd.go +9 -0
  813. package/govendor/golang.org/x/sys/unix/syscall_linux.go +20 -1
  814. package/govendor/golang.org/x/sys/unix/syscall_linux_sparc64.go +3 -3
  815. package/govendor/golang.org/x/sys/unix/syscall_netbsd.go +9 -0
  816. package/govendor/golang.org/x/sys/unix/syscall_unix_gc.go +1 -1
  817. package/govendor/golang.org/x/sys/unix/syscall_zos_s390x.go +0 -4
  818. package/govendor/golang.org/x/sys/unix/xattr_bsd.go +12 -12
  819. package/govendor/golang.org/x/sys/unix/zerrors_darwin_amd64.go +6 -0
  820. package/govendor/golang.org/x/sys/unix/zerrors_darwin_arm64.go +6 -0
  821. package/govendor/golang.org/x/sys/unix/zerrors_linux.go +32 -0
  822. package/govendor/golang.org/x/sys/unix/zerrors_linux_386.go +2 -0
  823. package/govendor/golang.org/x/sys/unix/zerrors_linux_amd64.go +2 -0
  824. package/govendor/golang.org/x/sys/unix/zerrors_linux_arm.go +2 -0
  825. package/govendor/golang.org/x/sys/unix/zerrors_linux_arm64.go +2 -0
  826. package/govendor/golang.org/x/sys/unix/zerrors_linux_loong64.go +2 -0
  827. package/govendor/golang.org/x/sys/unix/zerrors_linux_mips.go +2 -0
  828. package/govendor/golang.org/x/sys/unix/zerrors_linux_mips64.go +2 -0
  829. package/govendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go +2 -0
  830. package/govendor/golang.org/x/sys/unix/zerrors_linux_mipsle.go +2 -0
  831. package/govendor/golang.org/x/sys/unix/zerrors_linux_ppc.go +2 -0
  832. package/govendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go +2 -0
  833. package/govendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go +2 -0
  834. package/govendor/golang.org/x/sys/unix/zerrors_linux_riscv64.go +2 -0
  835. package/govendor/golang.org/x/sys/unix/zerrors_linux_s390x.go +2 -0
  836. package/govendor/golang.org/x/sys/unix/zerrors_linux_sparc64.go +2 -0
  837. package/govendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.go +11 -0
  838. package/govendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go +11 -0
  839. package/govendor/golang.org/x/sys/unix/zsyscall_freebsd_386.go +159 -0
  840. package/govendor/golang.org/x/sys/unix/zsyscall_freebsd_amd64.go +159 -0
  841. package/govendor/golang.org/x/sys/unix/zsyscall_freebsd_arm.go +159 -0
  842. package/govendor/golang.org/x/sys/unix/zsyscall_freebsd_arm64.go +159 -0
  843. package/govendor/golang.org/x/sys/unix/zsyscall_freebsd_riscv64.go +159 -0
  844. package/govendor/golang.org/x/sys/unix/zsyscall_linux.go +28 -1
  845. package/govendor/golang.org/x/sys/unix/zsyscall_linux_sparc64.go +3 -3
  846. package/govendor/golang.org/x/sys/unix/zsyscall_netbsd_386.go +159 -0
  847. package/govendor/golang.org/x/sys/unix/zsyscall_netbsd_amd64.go +159 -0
  848. package/govendor/golang.org/x/sys/unix/zsyscall_netbsd_arm.go +159 -0
  849. package/govendor/golang.org/x/sys/unix/zsyscall_netbsd_arm64.go +159 -0
  850. package/govendor/golang.org/x/sys/unix/zsysnum_zos_s390x.go +13 -0
  851. package/govendor/golang.org/x/sys/unix/ztypes_linux.go +65 -36
  852. package/govendor/golang.org/x/sys/unix/ztypes_linux_386.go +6 -0
  853. package/govendor/golang.org/x/sys/unix/ztypes_linux_amd64.go +7 -0
  854. package/govendor/golang.org/x/sys/unix/ztypes_linux_arm.go +6 -0
  855. package/govendor/golang.org/x/sys/unix/ztypes_linux_arm64.go +7 -0
  856. package/govendor/golang.org/x/sys/unix/ztypes_linux_loong64.go +7 -0
  857. package/govendor/golang.org/x/sys/unix/ztypes_linux_mips.go +6 -0
  858. package/govendor/golang.org/x/sys/unix/ztypes_linux_mips64.go +7 -0
  859. package/govendor/golang.org/x/sys/unix/ztypes_linux_mips64le.go +7 -0
  860. package/govendor/golang.org/x/sys/unix/ztypes_linux_mipsle.go +6 -0
  861. package/govendor/golang.org/x/sys/unix/ztypes_linux_ppc.go +6 -0
  862. package/govendor/golang.org/x/sys/unix/ztypes_linux_ppc64.go +7 -0
  863. package/govendor/golang.org/x/sys/unix/ztypes_linux_ppc64le.go +7 -0
  864. package/govendor/golang.org/x/sys/unix/ztypes_linux_riscv64.go +7 -0
  865. package/govendor/golang.org/x/sys/unix/ztypes_linux_s390x.go +7 -0
  866. package/govendor/golang.org/x/sys/unix/ztypes_linux_sparc64.go +10 -5
  867. package/govendor/golang.org/x/sys/unix/ztypes_zos_s390x.go +78 -0
  868. package/govendor/golang.org/x/text/.gitattributes +10 -0
  869. package/govendor/golang.org/x/text/CONTRIBUTING.md +26 -0
  870. package/govendor/golang.org/x/text/LICENSE +27 -0
  871. package/govendor/golang.org/x/text/PATENTS +22 -0
  872. package/govendor/golang.org/x/text/README.md +81 -0
  873. package/govendor/golang.org/x/text/cases/cases.go +162 -0
  874. package/govendor/golang.org/x/text/cases/context.go +376 -0
  875. package/govendor/golang.org/x/text/cases/fold.go +34 -0
  876. package/govendor/golang.org/x/text/cases/icu.go +61 -0
  877. package/govendor/golang.org/x/text/cases/info.go +82 -0
  878. package/govendor/golang.org/x/text/cases/map.go +816 -0
  879. package/govendor/golang.org/x/text/cases/tables15.0.0.go +2527 -0
  880. package/govendor/golang.org/x/text/cases/tables17.0.0.go +2642 -0
  881. package/govendor/golang.org/x/text/cases/trieval.go +217 -0
  882. package/govendor/golang.org/x/text/codereview.cfg +1 -0
  883. package/govendor/golang.org/x/text/collate/collate.go +402 -0
  884. package/govendor/golang.org/x/text/collate/index.go +32 -0
  885. package/govendor/golang.org/x/text/collate/option.go +239 -0
  886. package/govendor/golang.org/x/text/collate/sort.go +81 -0
  887. package/govendor/golang.org/x/text/collate/tables.go +73789 -0
  888. package/govendor/golang.org/x/text/currency/common.go +67 -0
  889. package/govendor/golang.org/x/text/currency/currency.go +185 -0
  890. package/govendor/golang.org/x/text/currency/format.go +220 -0
  891. package/govendor/golang.org/x/text/currency/query.go +152 -0
  892. package/govendor/golang.org/x/text/currency/tables.go +2629 -0
  893. package/govendor/golang.org/x/text/doc.go +16 -0
  894. package/govendor/golang.org/x/text/feature/plural/common.go +70 -0
  895. package/govendor/golang.org/x/text/feature/plural/message.go +244 -0
  896. package/govendor/golang.org/x/text/feature/plural/plural.go +262 -0
  897. package/govendor/golang.org/x/text/feature/plural/tables.go +552 -0
  898. package/govendor/golang.org/x/text/go.mod +3 -0
  899. package/govendor/golang.org/x/text/internal/catmsg/catmsg.go +417 -0
  900. package/govendor/golang.org/x/text/internal/catmsg/codec.go +407 -0
  901. package/govendor/golang.org/x/text/internal/catmsg/varint.go +62 -0
  902. package/govendor/golang.org/x/text/internal/colltab/collelem.go +374 -0
  903. package/govendor/golang.org/x/text/internal/colltab/colltab.go +105 -0
  904. package/govendor/golang.org/x/text/internal/colltab/contract.go +145 -0
  905. package/govendor/golang.org/x/text/internal/colltab/iter.go +178 -0
  906. package/govendor/golang.org/x/text/internal/colltab/numeric.go +236 -0
  907. package/govendor/golang.org/x/text/internal/colltab/table.go +275 -0
  908. package/govendor/golang.org/x/text/internal/colltab/trie.go +159 -0
  909. package/govendor/golang.org/x/text/internal/colltab/weighter.go +31 -0
  910. package/govendor/golang.org/x/text/internal/format/format.go +41 -0
  911. package/govendor/golang.org/x/text/internal/format/parser.go +358 -0
  912. package/govendor/golang.org/x/text/internal/internal.go +49 -0
  913. package/govendor/golang.org/x/text/internal/language/common.go +16 -0
  914. package/govendor/golang.org/x/text/internal/language/compact/compact.go +61 -0
  915. package/govendor/golang.org/x/text/internal/language/compact/language.go +260 -0
  916. package/govendor/golang.org/x/text/internal/language/compact/parents.go +120 -0
  917. package/govendor/golang.org/x/text/internal/language/compact/tables.go +1015 -0
  918. package/govendor/golang.org/x/text/internal/language/compact/tags.go +91 -0
  919. package/govendor/golang.org/x/text/internal/language/compact.go +29 -0
  920. package/govendor/golang.org/x/text/internal/language/compose.go +167 -0
  921. package/govendor/golang.org/x/text/internal/language/coverage.go +28 -0
  922. package/govendor/golang.org/x/text/internal/language/language.go +627 -0
  923. package/govendor/golang.org/x/text/internal/language/lookup.go +412 -0
  924. package/govendor/golang.org/x/text/internal/language/match.go +226 -0
  925. package/govendor/golang.org/x/text/internal/language/parse.go +608 -0
  926. package/govendor/golang.org/x/text/internal/language/tables.go +3494 -0
  927. package/govendor/golang.org/x/text/internal/language/tags.go +48 -0
  928. package/govendor/golang.org/x/text/internal/match.go +67 -0
  929. package/govendor/golang.org/x/text/internal/number/common.go +55 -0
  930. package/govendor/golang.org/x/text/internal/number/decimal.go +500 -0
  931. package/govendor/golang.org/x/text/internal/number/format.go +533 -0
  932. package/govendor/golang.org/x/text/internal/number/number.go +152 -0
  933. package/govendor/golang.org/x/text/internal/number/pattern.go +485 -0
  934. package/govendor/golang.org/x/text/internal/number/roundingmode_string.go +30 -0
  935. package/govendor/golang.org/x/text/internal/number/tables.go +1219 -0
  936. package/govendor/golang.org/x/text/internal/stringset/set.go +86 -0
  937. package/govendor/golang.org/x/text/internal/tag/tag.go +100 -0
  938. package/govendor/golang.org/x/text/language/coverage.go +187 -0
  939. package/govendor/golang.org/x/text/language/display/dict.go +92 -0
  940. package/govendor/golang.org/x/text/language/display/display.go +420 -0
  941. package/govendor/golang.org/x/text/language/display/lookup.go +253 -0
  942. package/govendor/golang.org/x/text/language/display/tables.go +53114 -0
  943. package/govendor/golang.org/x/text/language/doc.go +98 -0
  944. package/govendor/golang.org/x/text/language/language.go +605 -0
  945. package/govendor/golang.org/x/text/language/match.go +735 -0
  946. package/govendor/golang.org/x/text/language/parse.go +258 -0
  947. package/govendor/golang.org/x/text/language/tables.go +298 -0
  948. package/govendor/golang.org/x/text/language/tags.go +145 -0
  949. package/govendor/golang.org/x/text/message/catalog/catalog.go +365 -0
  950. package/govendor/golang.org/x/text/message/catalog/dict.go +133 -0
  951. package/govendor/golang.org/x/text/secure/bidirule/bidirule.go +346 -0
  952. package/govendor/golang.org/x/text/transform/transform.go +709 -0
  953. package/govendor/golang.org/x/text/unicode/bidi/bidi.go +359 -0
  954. package/govendor/golang.org/x/text/unicode/bidi/bracket.go +335 -0
  955. package/govendor/golang.org/x/text/unicode/bidi/core.go +1050 -0
  956. package/govendor/golang.org/x/text/unicode/bidi/prop.go +206 -0
  957. package/govendor/golang.org/x/text/unicode/bidi/tables15.0.0.go +2042 -0
  958. package/govendor/golang.org/x/text/unicode/bidi/tables17.0.0.go +2135 -0
  959. package/govendor/golang.org/x/text/unicode/bidi/trieval.go +48 -0
  960. package/govendor/golang.org/x/text/unicode/norm/composition.go +524 -0
  961. package/govendor/golang.org/x/text/unicode/norm/forminfo.go +296 -0
  962. package/govendor/golang.org/x/text/unicode/norm/input.go +109 -0
  963. package/govendor/golang.org/x/text/unicode/norm/iter.go +454 -0
  964. package/govendor/golang.org/x/text/unicode/norm/normalize.go +613 -0
  965. package/govendor/golang.org/x/text/unicode/norm/readwriter.go +125 -0
  966. package/govendor/golang.org/x/text/unicode/norm/tables15.0.0.go +7907 -0
  967. package/govendor/golang.org/x/text/unicode/norm/tables17.0.0.go +8104 -0
  968. package/govendor/golang.org/x/text/unicode/norm/transform.go +89 -0
  969. package/govendor/golang.org/x/text/unicode/norm/trie.go +54 -0
  970. package/govendor/manifest.txt +11 -2
  971. package/package.json +2 -1
  972. package/performance/README.md +87 -35
  973. package/performance/arr-for-of.ts +29 -0
  974. package/performance/arr-push-local.ts +39 -0
  975. package/performance/arr-slice-concat.ts +24 -0
  976. package/performance/async-promise-all.ts +38 -0
  977. package/performance/bigint-arith.ts +36 -0
  978. package/performance/buf-encode.ts +29 -0
  979. package/performance/class-accessors.ts +48 -0
  980. package/performance/date-format.ts +18 -0
  981. package/performance/fn-rest-spread.ts +43 -0
  982. package/performance/gen-next.ts +32 -0
  983. package/performance/iter-helpers.ts +38 -0
  984. package/performance/json-any.ts +30 -0
  985. package/performance/map-iterate.ts +26 -0
  986. package/performance/map-number-keys.ts +37 -0
  987. package/performance/num-hash-imul.ts +36 -0
  988. package/performance/obj-keys-entries.ts +44 -0
  989. package/performance/obj-optional-chain.ts +42 -0
  990. package/performance/obj-record-dict.ts +24 -0
  991. package/performance/obj-spread-destructure.ts +40 -0
  992. package/performance/regex-replace-fn.ts +24 -0
  993. package/performance/str-methods.ts +24 -0
  994. package/performance/str-switch-compare.ts +50 -0
  995. package/performance/str-unicode.ts +25 -0
  996. package/performance/typed-array.ts +30 -0
  997. package/performance/union-typeof.ts +40 -0
  998. package/performance/wasm-call.ts +63 -0
  999. package/tsparser/go.mod +1 -1
  1000. package/tsparser/go.sum +2 -2
  1001. package/types/typenative-npm.d.ts +836 -69
  1002. package/types/typenative.d.ts +1224 -23
  1003. package/govendor/golang.org/x/sys/unix/syscall_unix_gc_ppc64x.go +0 -22
  1004. package/govendor/golang.org/x/sys/windows/types_windows_arm.go +0 -35
@@ -0,0 +1,3024 @@
1
+ package ssa
2
+
3
+ import (
4
+ "fmt"
5
+ "math"
6
+ "strings"
7
+
8
+ "github.com/tetratelabs/wazero/internal/engine/wazevo/wazevoapi"
9
+ )
10
+
11
+ // Opcode represents a SSA instruction.
12
+ type Opcode uint32
13
+
14
+ // Instruction represents an instruction whose opcode is specified by
15
+ // Opcode. Since Go doesn't have union type, we use this flattened type
16
+ // for all instructions, and therefore each field has different meaning
17
+ // depending on Opcode.
18
+ type Instruction struct {
19
+ // id is the unique ID of this instruction which ascends from 0 following the order of program.
20
+ id int
21
+ opcode Opcode
22
+ u1, u2 uint64
23
+ v Value
24
+ v2 Value
25
+ v3 Value
26
+ vs Values
27
+ typ Type
28
+ prev, next *Instruction
29
+
30
+ // rValue is the (first) return value of this instruction.
31
+ // For branching instructions except for OpcodeBrTable, they hold BlockID to jump cast to Value.
32
+ rValue Value
33
+ // rValues are the rest of the return values of this instruction.
34
+ // For OpcodeBrTable, it holds the list of BlockID to jump cast to Value.
35
+ rValues Values
36
+ gid InstructionGroupID
37
+ sourceOffset SourceOffset
38
+ live bool
39
+ alreadyLowered bool
40
+ }
41
+
42
+ // SourceOffset represents the offset of the source of an instruction.
43
+ type SourceOffset int64
44
+
45
+ const sourceOffsetUnknown = -1
46
+
47
+ // Valid returns true if this source offset is valid.
48
+ func (l SourceOffset) Valid() bool {
49
+ return l != sourceOffsetUnknown
50
+ }
51
+
52
+ func (i *Instruction) annotateSourceOffset(line SourceOffset) {
53
+ i.sourceOffset = line
54
+ }
55
+
56
+ // SourceOffset returns the source offset of this instruction.
57
+ func (i *Instruction) SourceOffset() SourceOffset {
58
+ return i.sourceOffset
59
+ }
60
+
61
+ // Opcode returns the opcode of this instruction.
62
+ func (i *Instruction) Opcode() Opcode {
63
+ return i.opcode
64
+ }
65
+
66
+ // GroupID returns the InstructionGroupID of this instruction.
67
+ func (i *Instruction) GroupID() InstructionGroupID {
68
+ return i.gid
69
+ }
70
+
71
+ // MarkLowered marks this instruction as already lowered.
72
+ func (i *Instruction) MarkLowered() {
73
+ i.alreadyLowered = true
74
+ }
75
+
76
+ // Lowered returns true if this instruction is already lowered.
77
+ func (i *Instruction) Lowered() bool {
78
+ return i.alreadyLowered
79
+ }
80
+
81
+ // resetInstruction resets this instruction to the initial state.
82
+ func resetInstruction(i *Instruction) {
83
+ *i = Instruction{}
84
+ i.v = ValueInvalid
85
+ i.v2 = ValueInvalid
86
+ i.v3 = ValueInvalid
87
+ i.rValue = ValueInvalid
88
+ i.typ = typeInvalid
89
+ i.vs = ValuesNil
90
+ i.sourceOffset = sourceOffsetUnknown
91
+ }
92
+
93
+ // InstructionGroupID is assigned to each instruction and represents a group of instructions
94
+ // where each instruction is interchangeable with others except for the last instruction
95
+ // in the group which has side effects. In short, InstructionGroupID is determined by the side effects of instructions.
96
+ // That means, if there's an instruction with side effect between two instructions, then these two instructions
97
+ // will have different instructionGroupID. Note that each block always ends with branching, which is with side effects,
98
+ // therefore, instructions in different blocks always have different InstructionGroupID(s).
99
+ //
100
+ // The notable application of this is used in lowering SSA-level instruction to a ISA specific instruction,
101
+ // where we eagerly try to merge multiple instructions into single operation etc. Such merging cannot be done
102
+ // if these instruction have different InstructionGroupID since it will change the semantics of a program.
103
+ //
104
+ // See passDeadCodeElimination.
105
+ type InstructionGroupID uint32
106
+
107
+ // Returns Value(s) produced by this instruction if any.
108
+ // The `first` is the first return value, and `rest` is the rest of the values.
109
+ func (i *Instruction) Returns() (first Value, rest []Value) {
110
+ if i.IsBranching() {
111
+ return ValueInvalid, nil
112
+ }
113
+ return i.rValue, i.rValues.View()
114
+ }
115
+
116
+ // Return returns a Value(s) produced by this instruction if any.
117
+ // If there's multiple return values, only the first one is returned.
118
+ func (i *Instruction) Return() (first Value) {
119
+ return i.rValue
120
+ }
121
+
122
+ // Args returns the arguments to this instruction.
123
+ func (i *Instruction) Args() (v1, v2, v3 Value, vs []Value) {
124
+ return i.v, i.v2, i.v3, i.vs.View()
125
+ }
126
+
127
+ // Arg returns the first argument to this instruction.
128
+ func (i *Instruction) Arg() Value {
129
+ return i.v
130
+ }
131
+
132
+ // Arg2 returns the first two arguments to this instruction.
133
+ func (i *Instruction) Arg2() (Value, Value) {
134
+ return i.v, i.v2
135
+ }
136
+
137
+ // ArgWithLane returns the first argument to this instruction, and the lane type.
138
+ func (i *Instruction) ArgWithLane() (Value, VecLane) {
139
+ return i.v, VecLane(i.u1)
140
+ }
141
+
142
+ // Arg2WithLane returns the first two arguments to this instruction, and the lane type.
143
+ func (i *Instruction) Arg2WithLane() (Value, Value, VecLane) {
144
+ return i.v, i.v2, VecLane(i.u1)
145
+ }
146
+
147
+ // ShuffleData returns the first two arguments to this instruction and 2 uint64s `lo`, `hi`.
148
+ //
149
+ // Note: Each uint64 encodes a sequence of 8 bytes where each byte encodes a VecLane,
150
+ // so that the 128bit integer `hi<<64|lo` packs a slice `[16]VecLane`,
151
+ // where `lane[0]` is the least significant byte, and `lane[n]` is shifted to offset `n*8`.
152
+ func (i *Instruction) ShuffleData() (v Value, v2 Value, lo uint64, hi uint64) {
153
+ return i.v, i.v2, i.u1, i.u2
154
+ }
155
+
156
+ // Arg3 returns the first three arguments to this instruction.
157
+ func (i *Instruction) Arg3() (Value, Value, Value) {
158
+ return i.v, i.v2, i.v3
159
+ }
160
+
161
+ // Next returns the next instruction laid out next to itself.
162
+ func (i *Instruction) Next() *Instruction {
163
+ return i.next
164
+ }
165
+
166
+ // Prev returns the previous instruction laid out prior to itself.
167
+ func (i *Instruction) Prev() *Instruction {
168
+ return i.prev
169
+ }
170
+
171
+ // IsBranching returns true if this instruction is a branching instruction.
172
+ func (i *Instruction) IsBranching() bool {
173
+ switch i.opcode {
174
+ case OpcodeJump, OpcodeBrz, OpcodeBrnz, OpcodeBrTable:
175
+ return true
176
+ default:
177
+ return false
178
+ }
179
+ }
180
+
181
+ // TODO: complete opcode comments.
182
+ const (
183
+ OpcodeInvalid Opcode = iota
184
+
185
+ // OpcodeUndefined is a placeholder for undefined opcode. This can be used for debugging to intentionally
186
+ // cause a crash at certain point.
187
+ OpcodeUndefined
188
+
189
+ // OpcodeJump takes the list of args to the `block` and unconditionally jumps to it.
190
+ OpcodeJump
191
+
192
+ // OpcodeBrz branches into `blk` with `args` if the value `c` equals zero: `Brz c, blk, args`.
193
+ OpcodeBrz
194
+
195
+ // OpcodeBrnz branches into `blk` with `args` if the value `c` is not zero: `Brnz c, blk, args`.
196
+ OpcodeBrnz
197
+
198
+ // OpcodeBrTable takes the index value `index`, and branches into `labelX`. If the `index` is out of range,
199
+ // it branches into the last labelN: `BrTable index, [label1, label2, ... labelN]`.
200
+ OpcodeBrTable
201
+
202
+ // OpcodeExitWithCode exit the execution immediately.
203
+ OpcodeExitWithCode
204
+
205
+ // OpcodeExitIfTrueWithCode exits the execution immediately if the value `c` is not zero.
206
+ OpcodeExitIfTrueWithCode
207
+
208
+ // OpcodeReturn returns from the function: `return rvalues`.
209
+ OpcodeReturn
210
+
211
+ // OpcodeCall calls a function specified by the symbol FN with arguments `args`: `returnvals = Call FN, args...`
212
+ // This is a "near" call, which means the call target is known at compile time, and the target is relatively close
213
+ // to this function. If the target cannot be reached by near call, the backend fails to compile.
214
+ OpcodeCall
215
+
216
+ // OpcodeCallIndirect calls a function specified by `callee` which is a function address: `returnvals = call_indirect SIG, callee, args`.
217
+ // Note that this is different from call_indirect in Wasm, which also does type checking, etc.
218
+ OpcodeCallIndirect
219
+
220
+ // OpcodeSplat performs a vector splat operation: `v = Splat.lane x`.
221
+ OpcodeSplat
222
+
223
+ // OpcodeSwizzle performs a vector swizzle operation: `v = Swizzle.lane x, y`.
224
+ OpcodeSwizzle
225
+
226
+ // OpcodeInsertlane inserts a lane value into a vector: `v = InsertLane x, y, Idx`.
227
+ OpcodeInsertlane
228
+
229
+ // OpcodeExtractlane extracts a lane value from a vector: `v = ExtractLane x, Idx`.
230
+ OpcodeExtractlane
231
+
232
+ // OpcodeLoad loads a Type value from the [base + offset] address: `v = Load base, offset`.
233
+ OpcodeLoad
234
+
235
+ // OpcodeStore stores a Type value to the [base + offset] address: `Store v, base, offset`.
236
+ OpcodeStore
237
+
238
+ // OpcodeUload8 loads the 8-bit value from the [base + offset] address, zero-extended to 64 bits: `v = Uload8 base, offset`.
239
+ OpcodeUload8
240
+
241
+ // OpcodeSload8 loads the 8-bit value from the [base + offset] address, sign-extended to 64 bits: `v = Sload8 base, offset`.
242
+ OpcodeSload8
243
+
244
+ // OpcodeIstore8 stores the 8-bit value to the [base + offset] address, sign-extended to 64 bits: `Istore8 v, base, offset`.
245
+ OpcodeIstore8
246
+
247
+ // OpcodeUload16 loads the 16-bit value from the [base + offset] address, zero-extended to 64 bits: `v = Uload16 base, offset`.
248
+ OpcodeUload16
249
+
250
+ // OpcodeSload16 loads the 16-bit value from the [base + offset] address, sign-extended to 64 bits: `v = Sload16 base, offset`.
251
+ OpcodeSload16
252
+
253
+ // OpcodeIstore16 stores the 16-bit value to the [base + offset] address, zero-extended to 64 bits: `Istore16 v, base, offset`.
254
+ OpcodeIstore16
255
+
256
+ // OpcodeUload32 loads the 32-bit value from the [base + offset] address, zero-extended to 64 bits: `v = Uload32 base, offset`.
257
+ OpcodeUload32
258
+
259
+ // OpcodeSload32 loads the 32-bit value from the [base + offset] address, sign-extended to 64 bits: `v = Sload32 base, offset`.
260
+ OpcodeSload32
261
+
262
+ // OpcodeIstore32 stores the 32-bit value to the [base + offset] address, zero-extended to 64 bits: `Istore16 v, base, offset`.
263
+ OpcodeIstore32
264
+
265
+ // OpcodeLoadSplat represents a load that replicates the loaded value to all lanes `v = LoadSplat.lane p, Offset`.
266
+ OpcodeLoadSplat
267
+
268
+ // OpcodeVZeroExtLoad loads a scalar single/double precision floating point value from the [p + Offset] address,
269
+ // and zero-extend it to the V128 value: `v = VExtLoad p, Offset`.
270
+ OpcodeVZeroExtLoad
271
+
272
+ // OpcodeIconst represents the integer const.
273
+ OpcodeIconst
274
+
275
+ // OpcodeF32const represents the single-precision const.
276
+ OpcodeF32const
277
+
278
+ // OpcodeF64const represents the double-precision const.
279
+ OpcodeF64const
280
+
281
+ // OpcodeVconst represents the 128bit vector const.
282
+ OpcodeVconst
283
+
284
+ // OpcodeVbor computes binary or between two 128bit vectors: `v = bor x, y`.
285
+ OpcodeVbor
286
+
287
+ // OpcodeVbxor computes binary xor between two 128bit vectors: `v = bxor x, y`.
288
+ OpcodeVbxor
289
+
290
+ // OpcodeVband computes binary and between two 128bit vectors: `v = band x, y`.
291
+ OpcodeVband
292
+
293
+ // OpcodeVbandnot computes binary and-not between two 128bit vectors: `v = bandnot x, y`.
294
+ OpcodeVbandnot
295
+
296
+ // OpcodeVbnot negates a 128bit vector: `v = bnot x`.
297
+ OpcodeVbnot
298
+
299
+ // OpcodeVbitselect uses the bits in the control mask c to select the corresponding bit from x when 1
300
+ // and y when 0: `v = bitselect c, x, y`.
301
+ OpcodeVbitselect
302
+
303
+ // OpcodeShuffle shuffles two vectors using the given 128-bit immediate: `v = shuffle imm, x, y`.
304
+ // For each byte in the immediate, a value i in [0, 15] selects the i-th byte in vector x;
305
+ // i in [16, 31] selects the (i-16)-th byte in vector y.
306
+ OpcodeShuffle
307
+
308
+ // OpcodeSelect chooses between two values based on a condition `c`: `v = Select c, x, y`.
309
+ OpcodeSelect
310
+
311
+ // OpcodeVanyTrue performs a any true operation: `s = VanyTrue a`.
312
+ OpcodeVanyTrue
313
+
314
+ // OpcodeVallTrue performs a lane-wise all true operation: `s = VallTrue.lane a`.
315
+ OpcodeVallTrue
316
+
317
+ // OpcodeVhighBits performs a lane-wise extract of the high bits: `v = VhighBits.lane a`.
318
+ OpcodeVhighBits
319
+
320
+ // OpcodeIcmp compares two integer values with the given condition: `v = icmp Cond, x, y`.
321
+ OpcodeIcmp
322
+
323
+ // OpcodeVIcmp compares two integer values with the given condition: `v = vicmp Cond, x, y` on vector.
324
+ OpcodeVIcmp
325
+
326
+ // OpcodeIcmpImm compares an integer value with the immediate value on the given condition: `v = icmp_imm Cond, x, Y`.
327
+ OpcodeIcmpImm
328
+
329
+ // OpcodeIadd performs an integer addition: `v = Iadd x, y`.
330
+ OpcodeIadd
331
+
332
+ // OpcodeVIadd performs an integer addition: `v = VIadd.lane x, y` on vector.
333
+ OpcodeVIadd
334
+
335
+ // OpcodeVSaddSat performs a signed saturating vector addition: `v = VSaddSat.lane x, y` on vector.
336
+ OpcodeVSaddSat
337
+
338
+ // OpcodeVUaddSat performs an unsigned saturating vector addition: `v = VUaddSat.lane x, y` on vector.
339
+ OpcodeVUaddSat
340
+
341
+ // OpcodeIsub performs an integer subtraction: `v = Isub x, y`.
342
+ OpcodeIsub
343
+
344
+ // OpcodeVIsub performs an integer subtraction: `v = VIsub.lane x, y` on vector.
345
+ OpcodeVIsub
346
+
347
+ // OpcodeVSsubSat performs a signed saturating vector subtraction: `v = VSsubSat.lane x, y` on vector.
348
+ OpcodeVSsubSat
349
+
350
+ // OpcodeVUsubSat performs an unsigned saturating vector subtraction: `v = VUsubSat.lane x, y` on vector.
351
+ OpcodeVUsubSat
352
+
353
+ // OpcodeVImin performs a signed integer min: `v = VImin.lane x, y` on vector.
354
+ OpcodeVImin
355
+
356
+ // OpcodeVUmin performs an unsigned integer min: `v = VUmin.lane x, y` on vector.
357
+ OpcodeVUmin
358
+
359
+ // OpcodeVImax performs a signed integer max: `v = VImax.lane x, y` on vector.
360
+ OpcodeVImax
361
+
362
+ // OpcodeVUmax performs an unsigned integer max: `v = VUmax.lane x, y` on vector.
363
+ OpcodeVUmax
364
+
365
+ // OpcodeVAvgRound performs an unsigned integer avg, truncating to zero: `v = VAvgRound.lane x, y` on vector.
366
+ OpcodeVAvgRound
367
+
368
+ // OpcodeVImul performs an integer multiplication: `v = VImul.lane x, y` on vector.
369
+ OpcodeVImul
370
+
371
+ // OpcodeVIneg negates the given integer vector value: `v = VIneg x`.
372
+ OpcodeVIneg
373
+
374
+ // OpcodeVIpopcnt counts the number of 1-bits in the given vector: `v = VIpopcnt x`.
375
+ OpcodeVIpopcnt
376
+
377
+ // OpcodeVIabs returns the absolute value for the given vector value: `v = VIabs.lane x`.
378
+ OpcodeVIabs
379
+
380
+ // OpcodeVIshl shifts x left by (y mod lane-width): `v = VIshl.lane x, y` on vector.
381
+ OpcodeVIshl
382
+
383
+ // OpcodeVUshr shifts x right by (y mod lane-width), unsigned: `v = VUshr.lane x, y` on vector.
384
+ OpcodeVUshr
385
+
386
+ // OpcodeVSshr shifts x right by (y mod lane-width), signed: `v = VSshr.lane x, y` on vector.
387
+ OpcodeVSshr
388
+
389
+ // OpcodeVFabs takes the absolute value of a floating point value: `v = VFabs.lane x on vector.
390
+ OpcodeVFabs
391
+
392
+ // OpcodeVFmax takes the maximum of two floating point values: `v = VFmax.lane x, y on vector.
393
+ OpcodeVFmax
394
+
395
+ // OpcodeVFmin takes the minimum of two floating point values: `v = VFmin.lane x, y on vector.
396
+ OpcodeVFmin
397
+
398
+ // OpcodeVFneg negates the given floating point vector value: `v = VFneg x`.
399
+ OpcodeVFneg
400
+
401
+ // OpcodeVFadd performs a floating point addition: `v = VFadd.lane x, y` on vector.
402
+ OpcodeVFadd
403
+
404
+ // OpcodeVFsub performs a floating point subtraction: `v = VFsub.lane x, y` on vector.
405
+ OpcodeVFsub
406
+
407
+ // OpcodeVFmul performs a floating point multiplication: `v = VFmul.lane x, y` on vector.
408
+ OpcodeVFmul
409
+
410
+ // OpcodeVFdiv performs a floating point division: `v = VFdiv.lane x, y` on vector.
411
+ OpcodeVFdiv
412
+
413
+ // OpcodeVFcmp compares two float values with the given condition: `v = VFcmp.lane Cond, x, y` on float.
414
+ OpcodeVFcmp
415
+
416
+ // OpcodeVCeil takes the ceiling of the given floating point value: `v = ceil.lane x` on vector.
417
+ OpcodeVCeil
418
+
419
+ // OpcodeVFloor takes the floor of the given floating point value: `v = floor.lane x` on vector.
420
+ OpcodeVFloor
421
+
422
+ // OpcodeVTrunc takes the truncation of the given floating point value: `v = trunc.lane x` on vector.
423
+ OpcodeVTrunc
424
+
425
+ // OpcodeVNearest takes the nearest integer of the given floating point value: `v = nearest.lane x` on vector.
426
+ OpcodeVNearest
427
+
428
+ // OpcodeVMaxPseudo computes the lane-wise maximum value `v = VMaxPseudo.lane x, y` on vector defined as `x < y ? x : y`.
429
+ OpcodeVMaxPseudo
430
+
431
+ // OpcodeVMinPseudo computes the lane-wise minimum value `v = VMinPseudo.lane x, y` on vector defined as `y < x ? x : y`.
432
+ OpcodeVMinPseudo
433
+
434
+ // OpcodeVSqrt takes the minimum of two floating point values: `v = VFmin.lane x, y` on vector.
435
+ OpcodeVSqrt
436
+
437
+ // OpcodeVFcvtToUintSat converts a floating point value to an unsigned integer: `v = FcvtToUintSat.lane x` on vector.
438
+ OpcodeVFcvtToUintSat
439
+
440
+ // OpcodeVFcvtToSintSat converts a floating point value to a signed integer: `v = VFcvtToSintSat.lane x` on vector.
441
+ OpcodeVFcvtToSintSat
442
+
443
+ // OpcodeVFcvtFromUint converts a floating point value from an unsigned integer: `v = FcvtFromUint.lane x` on vector.
444
+ // x is always a 32-bit integer lane, and the result is either a 32-bit or 64-bit floating point-sized vector.
445
+ OpcodeVFcvtFromUint
446
+
447
+ // OpcodeVFcvtFromSint converts a floating point value from a signed integer: `v = VFcvtFromSint.lane x` on vector.
448
+ // x is always a 32-bit integer lane, and the result is either a 32-bit or 64-bit floating point-sized vector.
449
+ OpcodeVFcvtFromSint
450
+
451
+ // OpcodeImul performs an integer multiplication: `v = Imul x, y`.
452
+ OpcodeImul
453
+
454
+ // OpcodeUdiv performs the unsigned integer division `v = Udiv x, y`.
455
+ OpcodeUdiv
456
+
457
+ // OpcodeSdiv performs the signed integer division `v = Sdiv x, y`.
458
+ OpcodeSdiv
459
+
460
+ // OpcodeUrem computes the remainder of the unsigned integer division `v = Urem x, y`.
461
+ OpcodeUrem
462
+
463
+ // OpcodeSrem computes the remainder of the signed integer division `v = Srem x, y`.
464
+ OpcodeSrem
465
+
466
+ // OpcodeBand performs a binary and: `v = Band x, y`.
467
+ OpcodeBand
468
+
469
+ // OpcodeBor performs a binary or: `v = Bor x, y`.
470
+ OpcodeBor
471
+
472
+ // OpcodeBxor performs a binary xor: `v = Bxor x, y`.
473
+ OpcodeBxor
474
+
475
+ // OpcodeBnot performs a binary not: `v = Bnot x`.
476
+ OpcodeBnot
477
+
478
+ // OpcodeRotl rotates the given integer value to the left: `v = Rotl x, y`.
479
+ OpcodeRotl
480
+
481
+ // OpcodeRotr rotates the given integer value to the right: `v = Rotr x, y`.
482
+ OpcodeRotr
483
+
484
+ // OpcodeIshl does logical shift left: `v = Ishl x, y`.
485
+ OpcodeIshl
486
+
487
+ // OpcodeUshr does logical shift right: `v = Ushr x, y`.
488
+ OpcodeUshr
489
+
490
+ // OpcodeSshr does arithmetic shift right: `v = Sshr x, y`.
491
+ OpcodeSshr
492
+
493
+ // OpcodeClz counts the number of leading zeros: `v = clz x`.
494
+ OpcodeClz
495
+
496
+ // OpcodeCtz counts the number of trailing zeros: `v = ctz x`.
497
+ OpcodeCtz
498
+
499
+ // OpcodePopcnt counts the number of 1-bits: `v = popcnt x`.
500
+ OpcodePopcnt
501
+
502
+ // OpcodeFcmp compares two floating point values: `v = fcmp Cond, x, y`.
503
+ OpcodeFcmp
504
+
505
+ // OpcodeFadd performs a floating point addition: / `v = Fadd x, y`.
506
+ OpcodeFadd
507
+
508
+ // OpcodeFsub performs a floating point subtraction: `v = Fsub x, y`.
509
+ OpcodeFsub
510
+
511
+ // OpcodeFmul performs a floating point multiplication: `v = Fmul x, y`.
512
+ OpcodeFmul
513
+
514
+ // OpcodeSqmulRoundSat performs a lane-wise saturating rounding multiplication
515
+ // in Q15 format: `v = SqmulRoundSat.lane x,y` on vector.
516
+ OpcodeSqmulRoundSat
517
+
518
+ // OpcodeFdiv performs a floating point division: `v = Fdiv x, y`.
519
+ OpcodeFdiv
520
+
521
+ // OpcodeSqrt takes the square root of the given floating point value: `v = sqrt x`.
522
+ OpcodeSqrt
523
+
524
+ // OpcodeFneg negates the given floating point value: `v = Fneg x`.
525
+ OpcodeFneg
526
+
527
+ // OpcodeFabs takes the absolute value of the given floating point value: `v = fabs x`.
528
+ OpcodeFabs
529
+
530
+ // OpcodeFcopysign copies the sign of the second floating point value to the first floating point value:
531
+ // `v = Fcopysign x, y`.
532
+ OpcodeFcopysign
533
+
534
+ // OpcodeFmin takes the minimum of two floating point values: `v = fmin x, y`.
535
+ OpcodeFmin
536
+
537
+ // OpcodeFmax takes the maximum of two floating point values: `v = fmax x, y`.
538
+ OpcodeFmax
539
+
540
+ // OpcodeCeil takes the ceiling of the given floating point value: `v = ceil x`.
541
+ OpcodeCeil
542
+
543
+ // OpcodeFloor takes the floor of the given floating point value: `v = floor x`.
544
+ OpcodeFloor
545
+
546
+ // OpcodeTrunc takes the truncation of the given floating point value: `v = trunc x`.
547
+ OpcodeTrunc
548
+
549
+ // OpcodeNearest takes the nearest integer of the given floating point value: `v = nearest x`.
550
+ OpcodeNearest
551
+
552
+ // OpcodeBitcast is a bitcast operation: `v = bitcast x`.
553
+ OpcodeBitcast
554
+
555
+ // OpcodeIreduce narrow the given integer: `v = Ireduce x`.
556
+ OpcodeIreduce
557
+
558
+ // OpcodeSnarrow converts two input vectors x, y into a smaller lane vector by narrowing each lane, signed `v = Snarrow.lane x, y`.
559
+ OpcodeSnarrow
560
+
561
+ // OpcodeUnarrow converts two input vectors x, y into a smaller lane vector by narrowing each lane, unsigned `v = Unarrow.lane x, y`.
562
+ OpcodeUnarrow
563
+
564
+ // OpcodeSwidenLow converts low half of the smaller lane vector to a larger lane vector, sign extended: `v = SwidenLow.lane x`.
565
+ OpcodeSwidenLow
566
+
567
+ // OpcodeSwidenHigh converts high half of the smaller lane vector to a larger lane vector, sign extended: `v = SwidenHigh.lane x`.
568
+ OpcodeSwidenHigh
569
+
570
+ // OpcodeUwidenLow converts low half of the smaller lane vector to a larger lane vector, zero (unsigned) extended: `v = UwidenLow.lane x`.
571
+ OpcodeUwidenLow
572
+
573
+ // OpcodeUwidenHigh converts high half of the smaller lane vector to a larger lane vector, zero (unsigned) extended: `v = UwidenHigh.lane x`.
574
+ OpcodeUwidenHigh
575
+
576
+ // 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.
577
+ OpcodeExtIaddPairwise
578
+
579
+ // OpcodeWideningPairwiseDotProductS is a lane-wise widening pairwise dot product with signed saturation: `v = WideningPairwiseDotProductS x, y` on vector.
580
+ // Currently, the only lane is i16, and the result is i32.
581
+ OpcodeWideningPairwiseDotProductS
582
+
583
+ // OpcodeUExtend zero-extends the given integer: `v = UExtend x, from->to`.
584
+ OpcodeUExtend
585
+
586
+ // OpcodeSExtend sign-extends the given integer: `v = SExtend x, from->to`.
587
+ OpcodeSExtend
588
+
589
+ // OpcodeFpromote promotes the given floating point value: `v = Fpromote x`.
590
+ OpcodeFpromote
591
+
592
+ // OpcodeFvpromoteLow converts the two lower single-precision floating point lanes
593
+ // to the two double-precision lanes of the result: `v = FvpromoteLow.lane x` on vector.
594
+ OpcodeFvpromoteLow
595
+
596
+ // OpcodeFdemote demotes the given float point value: `v = Fdemote x`.
597
+ OpcodeFdemote
598
+
599
+ // OpcodeFvdemote converts the two double-precision floating point lanes
600
+ // to two lower single-precision lanes of the result `v = Fvdemote.lane x`.
601
+ OpcodeFvdemote
602
+
603
+ // OpcodeFcvtToUint converts a floating point value to an unsigned integer: `v = FcvtToUint x`.
604
+ OpcodeFcvtToUint
605
+
606
+ // OpcodeFcvtToSint converts a floating point value to a signed integer: `v = FcvtToSint x`.
607
+ OpcodeFcvtToSint
608
+
609
+ // OpcodeFcvtToUintSat converts a floating point value to an unsigned integer: `v = FcvtToUintSat x` which saturates on overflow.
610
+ OpcodeFcvtToUintSat
611
+
612
+ // OpcodeFcvtToSintSat converts a floating point value to a signed integer: `v = FcvtToSintSat x` which saturates on overflow.
613
+ OpcodeFcvtToSintSat
614
+
615
+ // OpcodeFcvtFromUint converts an unsigned integer to a floating point value: `v = FcvtFromUint x`.
616
+ OpcodeFcvtFromUint
617
+
618
+ // OpcodeFcvtFromSint converts a signed integer to a floating point value: `v = FcvtFromSint x`.
619
+ OpcodeFcvtFromSint
620
+
621
+ // OpcodeAtomicRmw is atomic read-modify-write operation: `v = atomic_rmw op, p, offset, value`.
622
+ OpcodeAtomicRmw
623
+
624
+ // OpcodeAtomicCas is atomic compare-and-swap operation.
625
+ OpcodeAtomicCas
626
+
627
+ // OpcodeAtomicLoad is atomic load operation.
628
+ OpcodeAtomicLoad
629
+
630
+ // OpcodeAtomicStore is atomic store operation.
631
+ OpcodeAtomicStore
632
+
633
+ // OpcodeFence is a memory fence operation.
634
+ OpcodeFence
635
+
636
+ // OpcodeTailCallReturnCall is the equivalent of OpcodeCall (a "near" call)
637
+ // for tail calls. Semantically, it combines Call + Return into a single operation.
638
+ OpcodeTailCallReturnCall
639
+
640
+ // OpcodeTailCallReturnCallIndirect is the equivalent of OpcodeCallIndirect (a call to a function address)
641
+ // for tail calls. Semantically, it combines CallIndirect + Return into a single operation.
642
+ OpcodeTailCallReturnCallIndirect
643
+
644
+ // opcodeEnd marks the end of the opcode list.
645
+ opcodeEnd
646
+ )
647
+
648
+ // AtomicRmwOp represents the atomic read-modify-write operation.
649
+ type AtomicRmwOp byte
650
+
651
+ const (
652
+ // AtomicRmwOpAdd is an atomic add operation.
653
+ AtomicRmwOpAdd AtomicRmwOp = iota
654
+ // AtomicRmwOpSub is an atomic sub operation.
655
+ AtomicRmwOpSub
656
+ // AtomicRmwOpAnd is an atomic and operation.
657
+ AtomicRmwOpAnd
658
+ // AtomicRmwOpOr is an atomic or operation.
659
+ AtomicRmwOpOr
660
+ // AtomicRmwOpXor is an atomic xor operation.
661
+ AtomicRmwOpXor
662
+ // AtomicRmwOpXchg is an atomic swap operation.
663
+ AtomicRmwOpXchg
664
+ )
665
+
666
+ // String implements the fmt.Stringer.
667
+ func (op AtomicRmwOp) String() string {
668
+ switch op {
669
+ case AtomicRmwOpAdd:
670
+ return "add"
671
+ case AtomicRmwOpSub:
672
+ return "sub"
673
+ case AtomicRmwOpAnd:
674
+ return "and"
675
+ case AtomicRmwOpOr:
676
+ return "or"
677
+ case AtomicRmwOpXor:
678
+ return "xor"
679
+ case AtomicRmwOpXchg:
680
+ return "xchg"
681
+ }
682
+ panic(fmt.Sprintf("unknown AtomicRmwOp: %d", op))
683
+ }
684
+
685
+ // returnTypesFn provides the info to determine the type of instruction.
686
+ // t1 is the type of the first result, ts are the types of the remaining results.
687
+ type returnTypesFn func(b *builder, instr *Instruction) (t1 Type, ts []Type)
688
+
689
+ var (
690
+ returnTypesFnNoReturns returnTypesFn = func(b *builder, instr *Instruction) (t1 Type, ts []Type) { return typeInvalid, nil }
691
+ returnTypesFnSingle = func(b *builder, instr *Instruction) (t1 Type, ts []Type) { return instr.typ, nil }
692
+ returnTypesFnI32 = func(b *builder, instr *Instruction) (t1 Type, ts []Type) { return TypeI32, nil }
693
+ returnTypesFnF32 = func(b *builder, instr *Instruction) (t1 Type, ts []Type) { return TypeF32, nil }
694
+ returnTypesFnF64 = func(b *builder, instr *Instruction) (t1 Type, ts []Type) { return TypeF64, nil }
695
+ returnTypesFnV128 = func(b *builder, instr *Instruction) (t1 Type, ts []Type) { return TypeV128, nil }
696
+ returnTypesFnCallIndirect = func(b *builder, instr *Instruction) (t1 Type, ts []Type) {
697
+ sigID := SignatureID(instr.u1)
698
+ sig, ok := b.signatures[sigID]
699
+ if !ok {
700
+ panic("BUG")
701
+ }
702
+ switch len(sig.Results) {
703
+ case 0:
704
+ t1 = typeInvalid
705
+ case 1:
706
+ t1 = sig.Results[0]
707
+ default:
708
+ t1, ts = sig.Results[0], sig.Results[1:]
709
+ }
710
+ return
711
+ }
712
+ returnTypesFnCall = func(b *builder, instr *Instruction) (t1 Type, ts []Type) {
713
+ sigID := SignatureID(instr.u2)
714
+ sig, ok := b.signatures[sigID]
715
+ if !ok {
716
+ panic("BUG")
717
+ }
718
+ switch len(sig.Results) {
719
+ case 0:
720
+ t1 = typeInvalid
721
+ case 1:
722
+ t1 = sig.Results[0]
723
+ default:
724
+ t1, ts = sig.Results[0], sig.Results[1:]
725
+ }
726
+ return
727
+ }
728
+ )
729
+
730
+ // sideEffect provides the info to determine if an instruction has side effects which
731
+ // is used to determine if it can be optimized out, interchanged with others, etc.
732
+ type sideEffect byte
733
+
734
+ const (
735
+ sideEffectUnknown sideEffect = iota
736
+ // sideEffectStrict represents an instruction with side effects, and should be always alive plus cannot be reordered.
737
+ sideEffectStrict
738
+ // sideEffectTraps represents an instruction that can trap, and should be always alive but can be reordered within the group.
739
+ sideEffectTraps
740
+ // sideEffectNone represents an instruction without side effects, and can be eliminated if the result is not used, plus can be reordered within the group.
741
+ sideEffectNone
742
+ )
743
+
744
+ // instructionSideEffects provides the info to determine if an instruction has side effects.
745
+ // Instructions with side effects must not be eliminated regardless whether the result is used or not.
746
+ var instructionSideEffects = [opcodeEnd]sideEffect{
747
+ OpcodeUndefined: sideEffectStrict,
748
+ OpcodeJump: sideEffectStrict,
749
+ OpcodeIconst: sideEffectNone,
750
+ OpcodeCall: sideEffectStrict,
751
+ OpcodeCallIndirect: sideEffectStrict,
752
+ OpcodeIadd: sideEffectNone,
753
+ OpcodeImul: sideEffectNone,
754
+ OpcodeIsub: sideEffectNone,
755
+ OpcodeIcmp: sideEffectNone,
756
+ OpcodeExtractlane: sideEffectNone,
757
+ OpcodeInsertlane: sideEffectNone,
758
+ OpcodeBand: sideEffectNone,
759
+ OpcodeBor: sideEffectNone,
760
+ OpcodeBxor: sideEffectNone,
761
+ OpcodeRotl: sideEffectNone,
762
+ OpcodeRotr: sideEffectNone,
763
+ OpcodeFcmp: sideEffectNone,
764
+ OpcodeFadd: sideEffectNone,
765
+ OpcodeClz: sideEffectNone,
766
+ OpcodeCtz: sideEffectNone,
767
+ OpcodePopcnt: sideEffectNone,
768
+ OpcodeLoad: sideEffectNone,
769
+ OpcodeLoadSplat: sideEffectNone,
770
+ OpcodeUload8: sideEffectNone,
771
+ OpcodeUload16: sideEffectNone,
772
+ OpcodeUload32: sideEffectNone,
773
+ OpcodeSload8: sideEffectNone,
774
+ OpcodeSload16: sideEffectNone,
775
+ OpcodeSload32: sideEffectNone,
776
+ OpcodeSExtend: sideEffectNone,
777
+ OpcodeUExtend: sideEffectNone,
778
+ OpcodeSwidenLow: sideEffectNone,
779
+ OpcodeUwidenLow: sideEffectNone,
780
+ OpcodeSwidenHigh: sideEffectNone,
781
+ OpcodeUwidenHigh: sideEffectNone,
782
+ OpcodeSnarrow: sideEffectNone,
783
+ OpcodeUnarrow: sideEffectNone,
784
+ OpcodeSwizzle: sideEffectNone,
785
+ OpcodeShuffle: sideEffectNone,
786
+ OpcodeSplat: sideEffectNone,
787
+ OpcodeFsub: sideEffectNone,
788
+ OpcodeF32const: sideEffectNone,
789
+ OpcodeF64const: sideEffectNone,
790
+ OpcodeIshl: sideEffectNone,
791
+ OpcodeSshr: sideEffectNone,
792
+ OpcodeUshr: sideEffectNone,
793
+ OpcodeStore: sideEffectStrict,
794
+ OpcodeIstore8: sideEffectStrict,
795
+ OpcodeIstore16: sideEffectStrict,
796
+ OpcodeIstore32: sideEffectStrict,
797
+ OpcodeExitWithCode: sideEffectStrict,
798
+ OpcodeExitIfTrueWithCode: sideEffectStrict,
799
+ OpcodeReturn: sideEffectStrict,
800
+ OpcodeBrz: sideEffectStrict,
801
+ OpcodeBrnz: sideEffectStrict,
802
+ OpcodeBrTable: sideEffectStrict,
803
+ OpcodeFdiv: sideEffectNone,
804
+ OpcodeFmul: sideEffectNone,
805
+ OpcodeFmax: sideEffectNone,
806
+ OpcodeSqmulRoundSat: sideEffectNone,
807
+ OpcodeSelect: sideEffectNone,
808
+ OpcodeFmin: sideEffectNone,
809
+ OpcodeFneg: sideEffectNone,
810
+ OpcodeFcvtToSint: sideEffectTraps,
811
+ OpcodeFcvtToUint: sideEffectTraps,
812
+ OpcodeFcvtFromSint: sideEffectNone,
813
+ OpcodeFcvtFromUint: sideEffectNone,
814
+ OpcodeFcvtToSintSat: sideEffectNone,
815
+ OpcodeFcvtToUintSat: sideEffectNone,
816
+ OpcodeVFcvtFromUint: sideEffectNone,
817
+ OpcodeVFcvtFromSint: sideEffectNone,
818
+ OpcodeFdemote: sideEffectNone,
819
+ OpcodeFvpromoteLow: sideEffectNone,
820
+ OpcodeFvdemote: sideEffectNone,
821
+ OpcodeFpromote: sideEffectNone,
822
+ OpcodeBitcast: sideEffectNone,
823
+ OpcodeIreduce: sideEffectNone,
824
+ OpcodeSqrt: sideEffectNone,
825
+ OpcodeCeil: sideEffectNone,
826
+ OpcodeFloor: sideEffectNone,
827
+ OpcodeTrunc: sideEffectNone,
828
+ OpcodeNearest: sideEffectNone,
829
+ OpcodeSdiv: sideEffectTraps,
830
+ OpcodeSrem: sideEffectTraps,
831
+ OpcodeUdiv: sideEffectTraps,
832
+ OpcodeUrem: sideEffectTraps,
833
+ OpcodeFabs: sideEffectNone,
834
+ OpcodeFcopysign: sideEffectNone,
835
+ OpcodeExtIaddPairwise: sideEffectNone,
836
+ OpcodeVconst: sideEffectNone,
837
+ OpcodeVbor: sideEffectNone,
838
+ OpcodeVbxor: sideEffectNone,
839
+ OpcodeVband: sideEffectNone,
840
+ OpcodeVbandnot: sideEffectNone,
841
+ OpcodeVbnot: sideEffectNone,
842
+ OpcodeVbitselect: sideEffectNone,
843
+ OpcodeVanyTrue: sideEffectNone,
844
+ OpcodeVallTrue: sideEffectNone,
845
+ OpcodeVhighBits: sideEffectNone,
846
+ OpcodeVIadd: sideEffectNone,
847
+ OpcodeVSaddSat: sideEffectNone,
848
+ OpcodeVUaddSat: sideEffectNone,
849
+ OpcodeVIsub: sideEffectNone,
850
+ OpcodeVSsubSat: sideEffectNone,
851
+ OpcodeVUsubSat: sideEffectNone,
852
+ OpcodeVIcmp: sideEffectNone,
853
+ OpcodeVImin: sideEffectNone,
854
+ OpcodeVUmin: sideEffectNone,
855
+ OpcodeVImax: sideEffectNone,
856
+ OpcodeVUmax: sideEffectNone,
857
+ OpcodeVAvgRound: sideEffectNone,
858
+ OpcodeVImul: sideEffectNone,
859
+ OpcodeVIabs: sideEffectNone,
860
+ OpcodeVIneg: sideEffectNone,
861
+ OpcodeVIpopcnt: sideEffectNone,
862
+ OpcodeVIshl: sideEffectNone,
863
+ OpcodeVSshr: sideEffectNone,
864
+ OpcodeVUshr: sideEffectNone,
865
+ OpcodeVSqrt: sideEffectNone,
866
+ OpcodeVFabs: sideEffectNone,
867
+ OpcodeVFmin: sideEffectNone,
868
+ OpcodeVFmax: sideEffectNone,
869
+ OpcodeVFneg: sideEffectNone,
870
+ OpcodeVFadd: sideEffectNone,
871
+ OpcodeVFsub: sideEffectNone,
872
+ OpcodeVFmul: sideEffectNone,
873
+ OpcodeVFdiv: sideEffectNone,
874
+ OpcodeVFcmp: sideEffectNone,
875
+ OpcodeVCeil: sideEffectNone,
876
+ OpcodeVFloor: sideEffectNone,
877
+ OpcodeVTrunc: sideEffectNone,
878
+ OpcodeVNearest: sideEffectNone,
879
+ OpcodeVMaxPseudo: sideEffectNone,
880
+ OpcodeVMinPseudo: sideEffectNone,
881
+ OpcodeVFcvtToUintSat: sideEffectNone,
882
+ OpcodeVFcvtToSintSat: sideEffectNone,
883
+ OpcodeVZeroExtLoad: sideEffectNone,
884
+ OpcodeAtomicRmw: sideEffectStrict,
885
+ OpcodeAtomicLoad: sideEffectStrict,
886
+ OpcodeAtomicStore: sideEffectStrict,
887
+ OpcodeAtomicCas: sideEffectStrict,
888
+ OpcodeFence: sideEffectStrict,
889
+ OpcodeTailCallReturnCall: sideEffectStrict,
890
+ OpcodeTailCallReturnCallIndirect: sideEffectStrict,
891
+ OpcodeWideningPairwiseDotProductS: sideEffectNone,
892
+ }
893
+
894
+ // sideEffect returns true if this instruction has side effects.
895
+ func (i *Instruction) sideEffect() sideEffect {
896
+ if e := instructionSideEffects[i.opcode]; e == sideEffectUnknown {
897
+ panic("BUG: side effect info not registered for " + i.opcode.String())
898
+ } else {
899
+ return e
900
+ }
901
+ }
902
+
903
+ // instructionReturnTypes provides the function to determine the return types of an instruction.
904
+ var instructionReturnTypes = [opcodeEnd]returnTypesFn{
905
+ OpcodeExtIaddPairwise: returnTypesFnV128,
906
+ OpcodeVbor: returnTypesFnV128,
907
+ OpcodeVbxor: returnTypesFnV128,
908
+ OpcodeVband: returnTypesFnV128,
909
+ OpcodeVbnot: returnTypesFnV128,
910
+ OpcodeVbandnot: returnTypesFnV128,
911
+ OpcodeVbitselect: returnTypesFnV128,
912
+ OpcodeVanyTrue: returnTypesFnI32,
913
+ OpcodeVallTrue: returnTypesFnI32,
914
+ OpcodeVhighBits: returnTypesFnI32,
915
+ OpcodeVIadd: returnTypesFnV128,
916
+ OpcodeVSaddSat: returnTypesFnV128,
917
+ OpcodeVUaddSat: returnTypesFnV128,
918
+ OpcodeVIsub: returnTypesFnV128,
919
+ OpcodeVSsubSat: returnTypesFnV128,
920
+ OpcodeVUsubSat: returnTypesFnV128,
921
+ OpcodeVIcmp: returnTypesFnV128,
922
+ OpcodeVImin: returnTypesFnV128,
923
+ OpcodeVUmin: returnTypesFnV128,
924
+ OpcodeVImax: returnTypesFnV128,
925
+ OpcodeVUmax: returnTypesFnV128,
926
+ OpcodeVImul: returnTypesFnV128,
927
+ OpcodeVAvgRound: returnTypesFnV128,
928
+ OpcodeVIabs: returnTypesFnV128,
929
+ OpcodeVIneg: returnTypesFnV128,
930
+ OpcodeVIpopcnt: returnTypesFnV128,
931
+ OpcodeVIshl: returnTypesFnV128,
932
+ OpcodeVSshr: returnTypesFnV128,
933
+ OpcodeVUshr: returnTypesFnV128,
934
+ OpcodeExtractlane: returnTypesFnSingle,
935
+ OpcodeInsertlane: returnTypesFnV128,
936
+ OpcodeBand: returnTypesFnSingle,
937
+ OpcodeFcopysign: returnTypesFnSingle,
938
+ OpcodeBitcast: returnTypesFnSingle,
939
+ OpcodeBor: returnTypesFnSingle,
940
+ OpcodeBxor: returnTypesFnSingle,
941
+ OpcodeRotl: returnTypesFnSingle,
942
+ OpcodeRotr: returnTypesFnSingle,
943
+ OpcodeIshl: returnTypesFnSingle,
944
+ OpcodeSshr: returnTypesFnSingle,
945
+ OpcodeSdiv: returnTypesFnSingle,
946
+ OpcodeSrem: returnTypesFnSingle,
947
+ OpcodeUdiv: returnTypesFnSingle,
948
+ OpcodeUrem: returnTypesFnSingle,
949
+ OpcodeUshr: returnTypesFnSingle,
950
+ OpcodeJump: returnTypesFnNoReturns,
951
+ OpcodeUndefined: returnTypesFnNoReturns,
952
+ OpcodeIconst: returnTypesFnSingle,
953
+ OpcodeSelect: returnTypesFnSingle,
954
+ OpcodeSExtend: returnTypesFnSingle,
955
+ OpcodeUExtend: returnTypesFnSingle,
956
+ OpcodeSwidenLow: returnTypesFnV128,
957
+ OpcodeUwidenLow: returnTypesFnV128,
958
+ OpcodeSwidenHigh: returnTypesFnV128,
959
+ OpcodeUwidenHigh: returnTypesFnV128,
960
+ OpcodeSnarrow: returnTypesFnV128,
961
+ OpcodeUnarrow: returnTypesFnV128,
962
+ OpcodeSwizzle: returnTypesFnSingle,
963
+ OpcodeShuffle: returnTypesFnV128,
964
+ OpcodeSplat: returnTypesFnV128,
965
+ OpcodeIreduce: returnTypesFnSingle,
966
+ OpcodeFabs: returnTypesFnSingle,
967
+ OpcodeSqrt: returnTypesFnSingle,
968
+ OpcodeCeil: returnTypesFnSingle,
969
+ OpcodeFloor: returnTypesFnSingle,
970
+ OpcodeTrunc: returnTypesFnSingle,
971
+ OpcodeNearest: returnTypesFnSingle,
972
+ OpcodeCallIndirect: returnTypesFnCallIndirect,
973
+ OpcodeCall: returnTypesFnCall,
974
+ OpcodeLoad: returnTypesFnSingle,
975
+ OpcodeVZeroExtLoad: returnTypesFnV128,
976
+ OpcodeLoadSplat: returnTypesFnV128,
977
+ OpcodeIadd: returnTypesFnSingle,
978
+ OpcodeIsub: returnTypesFnSingle,
979
+ OpcodeImul: returnTypesFnSingle,
980
+ OpcodeIcmp: returnTypesFnI32,
981
+ OpcodeFcmp: returnTypesFnI32,
982
+ OpcodeFadd: returnTypesFnSingle,
983
+ OpcodeFsub: returnTypesFnSingle,
984
+ OpcodeFdiv: returnTypesFnSingle,
985
+ OpcodeFmul: returnTypesFnSingle,
986
+ OpcodeFmax: returnTypesFnSingle,
987
+ OpcodeFmin: returnTypesFnSingle,
988
+ OpcodeSqmulRoundSat: returnTypesFnV128,
989
+ OpcodeF32const: returnTypesFnF32,
990
+ OpcodeF64const: returnTypesFnF64,
991
+ OpcodeClz: returnTypesFnSingle,
992
+ OpcodeCtz: returnTypesFnSingle,
993
+ OpcodePopcnt: returnTypesFnSingle,
994
+ OpcodeStore: returnTypesFnNoReturns,
995
+ OpcodeIstore8: returnTypesFnNoReturns,
996
+ OpcodeIstore16: returnTypesFnNoReturns,
997
+ OpcodeIstore32: returnTypesFnNoReturns,
998
+ OpcodeExitWithCode: returnTypesFnNoReturns,
999
+ OpcodeExitIfTrueWithCode: returnTypesFnNoReturns,
1000
+ OpcodeReturn: returnTypesFnNoReturns,
1001
+ OpcodeBrz: returnTypesFnNoReturns,
1002
+ OpcodeBrnz: returnTypesFnNoReturns,
1003
+ OpcodeBrTable: returnTypesFnNoReturns,
1004
+ OpcodeUload8: returnTypesFnSingle,
1005
+ OpcodeUload16: returnTypesFnSingle,
1006
+ OpcodeUload32: returnTypesFnSingle,
1007
+ OpcodeSload8: returnTypesFnSingle,
1008
+ OpcodeSload16: returnTypesFnSingle,
1009
+ OpcodeSload32: returnTypesFnSingle,
1010
+ OpcodeFcvtToSint: returnTypesFnSingle,
1011
+ OpcodeFcvtToUint: returnTypesFnSingle,
1012
+ OpcodeFcvtFromSint: returnTypesFnSingle,
1013
+ OpcodeFcvtFromUint: returnTypesFnSingle,
1014
+ OpcodeFcvtToSintSat: returnTypesFnSingle,
1015
+ OpcodeFcvtToUintSat: returnTypesFnSingle,
1016
+ OpcodeVFcvtFromUint: returnTypesFnV128,
1017
+ OpcodeVFcvtFromSint: returnTypesFnV128,
1018
+ OpcodeFneg: returnTypesFnSingle,
1019
+ OpcodeFdemote: returnTypesFnF32,
1020
+ OpcodeFvdemote: returnTypesFnV128,
1021
+ OpcodeFvpromoteLow: returnTypesFnV128,
1022
+ OpcodeFpromote: returnTypesFnF64,
1023
+ OpcodeVconst: returnTypesFnV128,
1024
+ OpcodeVFabs: returnTypesFnV128,
1025
+ OpcodeVSqrt: returnTypesFnV128,
1026
+ OpcodeVFmax: returnTypesFnV128,
1027
+ OpcodeVFmin: returnTypesFnV128,
1028
+ OpcodeVFneg: returnTypesFnV128,
1029
+ OpcodeVFadd: returnTypesFnV128,
1030
+ OpcodeVFsub: returnTypesFnV128,
1031
+ OpcodeVFmul: returnTypesFnV128,
1032
+ OpcodeVFdiv: returnTypesFnV128,
1033
+ OpcodeVFcmp: returnTypesFnV128,
1034
+ OpcodeVCeil: returnTypesFnV128,
1035
+ OpcodeVFloor: returnTypesFnV128,
1036
+ OpcodeVTrunc: returnTypesFnV128,
1037
+ OpcodeVNearest: returnTypesFnV128,
1038
+ OpcodeVMaxPseudo: returnTypesFnV128,
1039
+ OpcodeVMinPseudo: returnTypesFnV128,
1040
+ OpcodeVFcvtToUintSat: returnTypesFnV128,
1041
+ OpcodeVFcvtToSintSat: returnTypesFnV128,
1042
+ OpcodeAtomicRmw: returnTypesFnSingle,
1043
+ OpcodeAtomicLoad: returnTypesFnSingle,
1044
+ OpcodeAtomicStore: returnTypesFnNoReturns,
1045
+ OpcodeAtomicCas: returnTypesFnSingle,
1046
+ OpcodeFence: returnTypesFnNoReturns,
1047
+ OpcodeTailCallReturnCallIndirect: returnTypesFnCallIndirect,
1048
+ OpcodeTailCallReturnCall: returnTypesFnCall,
1049
+ OpcodeWideningPairwiseDotProductS: returnTypesFnV128,
1050
+ }
1051
+
1052
+ // AsLoad initializes this instruction as a store instruction with OpcodeLoad.
1053
+ func (i *Instruction) AsLoad(ptr Value, offset uint32, typ Type) *Instruction {
1054
+ i.opcode = OpcodeLoad
1055
+ i.v = ptr
1056
+ i.u1 = uint64(offset)
1057
+ i.typ = typ
1058
+ return i
1059
+ }
1060
+
1061
+ // AsExtLoad initializes this instruction as a store instruction with OpcodeLoad.
1062
+ func (i *Instruction) AsExtLoad(op Opcode, ptr Value, offset uint32, dst64bit bool) *Instruction {
1063
+ i.opcode = op
1064
+ i.v = ptr
1065
+ i.u1 = uint64(offset)
1066
+ if dst64bit {
1067
+ i.typ = TypeI64
1068
+ } else {
1069
+ i.typ = TypeI32
1070
+ }
1071
+ return i
1072
+ }
1073
+
1074
+ // AsVZeroExtLoad initializes this instruction as a store instruction with OpcodeVExtLoad.
1075
+ func (i *Instruction) AsVZeroExtLoad(ptr Value, offset uint32, scalarType Type) *Instruction {
1076
+ i.opcode = OpcodeVZeroExtLoad
1077
+ i.v = ptr
1078
+ i.u1 = uint64(offset)
1079
+ i.u2 = uint64(scalarType)
1080
+ i.typ = TypeV128
1081
+ return i
1082
+ }
1083
+
1084
+ // VZeroExtLoadData returns the operands for a load instruction. The returned `typ` is the scalar type of the load target.
1085
+ func (i *Instruction) VZeroExtLoadData() (ptr Value, offset uint32, typ Type) {
1086
+ return i.v, uint32(i.u1), Type(i.u2)
1087
+ }
1088
+
1089
+ // AsLoadSplat initializes this instruction as a store instruction with OpcodeLoadSplat.
1090
+ func (i *Instruction) AsLoadSplat(ptr Value, offset uint32, lane VecLane) *Instruction {
1091
+ i.opcode = OpcodeLoadSplat
1092
+ i.v = ptr
1093
+ i.u1 = uint64(offset)
1094
+ i.u2 = uint64(lane)
1095
+ i.typ = TypeV128
1096
+ return i
1097
+ }
1098
+
1099
+ // LoadData returns the operands for a load instruction.
1100
+ func (i *Instruction) LoadData() (ptr Value, offset uint32, typ Type) {
1101
+ return i.v, uint32(i.u1), i.typ
1102
+ }
1103
+
1104
+ // LoadSplatData returns the operands for a load splat instruction.
1105
+ func (i *Instruction) LoadSplatData() (ptr Value, offset uint32, lane VecLane) {
1106
+ return i.v, uint32(i.u1), VecLane(i.u2)
1107
+ }
1108
+
1109
+ // AsStore initializes this instruction as a store instruction with OpcodeStore.
1110
+ func (i *Instruction) AsStore(storeOp Opcode, value, ptr Value, offset uint32) *Instruction {
1111
+ i.opcode = storeOp
1112
+ i.v = value
1113
+ i.v2 = ptr
1114
+
1115
+ var dstSize uint64
1116
+ switch storeOp {
1117
+ case OpcodeStore:
1118
+ dstSize = uint64(value.Type().Bits())
1119
+ case OpcodeIstore8:
1120
+ dstSize = 8
1121
+ case OpcodeIstore16:
1122
+ dstSize = 16
1123
+ case OpcodeIstore32:
1124
+ dstSize = 32
1125
+ default:
1126
+ panic("invalid store opcode" + storeOp.String())
1127
+ }
1128
+ i.u1 = uint64(offset) | dstSize<<32
1129
+ return i
1130
+ }
1131
+
1132
+ // StoreData returns the operands for a store instruction.
1133
+ func (i *Instruction) StoreData() (value, ptr Value, offset uint32, storeSizeInBits byte) {
1134
+ return i.v, i.v2, uint32(i.u1), byte(i.u1 >> 32)
1135
+ }
1136
+
1137
+ // AsIconst64 initializes this instruction as a 64-bit integer constant instruction with OpcodeIconst.
1138
+ func (i *Instruction) AsIconst64(v uint64) *Instruction {
1139
+ i.opcode = OpcodeIconst
1140
+ i.typ = TypeI64
1141
+ i.u1 = v
1142
+ return i
1143
+ }
1144
+
1145
+ // AsIconst32 initializes this instruction as a 32-bit integer constant instruction with OpcodeIconst.
1146
+ func (i *Instruction) AsIconst32(v uint32) *Instruction {
1147
+ i.opcode = OpcodeIconst
1148
+ i.typ = TypeI32
1149
+ i.u1 = uint64(v)
1150
+ return i
1151
+ }
1152
+
1153
+ // AsIadd initializes this instruction as an integer addition instruction with OpcodeIadd.
1154
+ func (i *Instruction) AsIadd(x, y Value) *Instruction {
1155
+ i.opcode = OpcodeIadd
1156
+ i.v = x
1157
+ i.v2 = y
1158
+ i.typ = x.Type()
1159
+ return i
1160
+ }
1161
+
1162
+ // AsVIadd initializes this instruction as an integer addition instruction with OpcodeVIadd on a vector.
1163
+ func (i *Instruction) AsVIadd(x, y Value, lane VecLane) *Instruction {
1164
+ i.opcode = OpcodeVIadd
1165
+ i.v = x
1166
+ i.v2 = y
1167
+ i.u1 = uint64(lane)
1168
+ i.typ = TypeV128
1169
+ return i
1170
+ }
1171
+
1172
+ // AsWideningPairwiseDotProductS initializes this instruction as a lane-wise integer extended pairwise addition instruction
1173
+ // with OpcodeIaddPairwise on a vector.
1174
+ func (i *Instruction) AsWideningPairwiseDotProductS(x, y Value) *Instruction {
1175
+ i.opcode = OpcodeWideningPairwiseDotProductS
1176
+ i.v = x
1177
+ i.v2 = y
1178
+ i.typ = TypeV128
1179
+ return i
1180
+ }
1181
+
1182
+ // AsExtIaddPairwise initializes this instruction as a lane-wise integer extended pairwise addition instruction
1183
+ // with OpcodeIaddPairwise on a vector.
1184
+ func (i *Instruction) AsExtIaddPairwise(x Value, srcLane VecLane, signed bool) *Instruction {
1185
+ i.opcode = OpcodeExtIaddPairwise
1186
+ i.v = x
1187
+ i.u1 = uint64(srcLane)
1188
+ if signed {
1189
+ i.u2 = 1
1190
+ }
1191
+ i.typ = TypeV128
1192
+ return i
1193
+ }
1194
+
1195
+ // ExtIaddPairwiseData returns the operands for a lane-wise integer extended pairwise addition instruction.
1196
+ func (i *Instruction) ExtIaddPairwiseData() (x Value, srcLane VecLane, signed bool) {
1197
+ return i.v, VecLane(i.u1), i.u2 != 0
1198
+ }
1199
+
1200
+ // AsVSaddSat initializes this instruction as a vector addition with saturation instruction with OpcodeVSaddSat on a vector.
1201
+ func (i *Instruction) AsVSaddSat(x, y Value, lane VecLane) *Instruction {
1202
+ i.opcode = OpcodeVSaddSat
1203
+ i.v = x
1204
+ i.v2 = y
1205
+ i.u1 = uint64(lane)
1206
+ i.typ = TypeV128
1207
+ return i
1208
+ }
1209
+
1210
+ // AsVUaddSat initializes this instruction as a vector addition with saturation instruction with OpcodeVUaddSat on a vector.
1211
+ func (i *Instruction) AsVUaddSat(x, y Value, lane VecLane) *Instruction {
1212
+ i.opcode = OpcodeVUaddSat
1213
+ i.v = x
1214
+ i.v2 = y
1215
+ i.u1 = uint64(lane)
1216
+ i.typ = TypeV128
1217
+ return i
1218
+ }
1219
+
1220
+ // AsVIsub initializes this instruction as an integer subtraction instruction with OpcodeVIsub on a vector.
1221
+ func (i *Instruction) AsVIsub(x, y Value, lane VecLane) *Instruction {
1222
+ i.opcode = OpcodeVIsub
1223
+ i.v = x
1224
+ i.v2 = y
1225
+ i.u1 = uint64(lane)
1226
+ i.typ = TypeV128
1227
+ return i
1228
+ }
1229
+
1230
+ // AsVSsubSat initializes this instruction as a vector addition with saturation instruction with OpcodeVSsubSat on a vector.
1231
+ func (i *Instruction) AsVSsubSat(x, y Value, lane VecLane) *Instruction {
1232
+ i.opcode = OpcodeVSsubSat
1233
+ i.v = x
1234
+ i.v2 = y
1235
+ i.u1 = uint64(lane)
1236
+ i.typ = TypeV128
1237
+ return i
1238
+ }
1239
+
1240
+ // AsVUsubSat initializes this instruction as a vector addition with saturation instruction with OpcodeVUsubSat on a vector.
1241
+ func (i *Instruction) AsVUsubSat(x, y Value, lane VecLane) *Instruction {
1242
+ i.opcode = OpcodeVUsubSat
1243
+ i.v = x
1244
+ i.v2 = y
1245
+ i.u1 = uint64(lane)
1246
+ i.typ = TypeV128
1247
+ return i
1248
+ }
1249
+
1250
+ // AsVImin initializes this instruction as a signed integer min instruction with OpcodeVImin on a vector.
1251
+ func (i *Instruction) AsVImin(x, y Value, lane VecLane) *Instruction {
1252
+ i.opcode = OpcodeVImin
1253
+ i.v = x
1254
+ i.v2 = y
1255
+ i.u1 = uint64(lane)
1256
+ i.typ = TypeV128
1257
+ return i
1258
+ }
1259
+
1260
+ // AsVUmin initializes this instruction as an unsigned integer min instruction with OpcodeVUmin on a vector.
1261
+ func (i *Instruction) AsVUmin(x, y Value, lane VecLane) *Instruction {
1262
+ i.opcode = OpcodeVUmin
1263
+ i.v = x
1264
+ i.v2 = y
1265
+ i.u1 = uint64(lane)
1266
+ i.typ = TypeV128
1267
+ return i
1268
+ }
1269
+
1270
+ // AsVImax initializes this instruction as a signed integer max instruction with OpcodeVImax on a vector.
1271
+ func (i *Instruction) AsVImax(x, y Value, lane VecLane) *Instruction {
1272
+ i.opcode = OpcodeVImax
1273
+ i.v = x
1274
+ i.v2 = y
1275
+ i.u1 = uint64(lane)
1276
+ i.typ = TypeV128
1277
+ return i
1278
+ }
1279
+
1280
+ // AsVUmax initializes this instruction as an unsigned integer max instruction with OpcodeVUmax on a vector.
1281
+ func (i *Instruction) AsVUmax(x, y Value, lane VecLane) *Instruction {
1282
+ i.opcode = OpcodeVUmax
1283
+ i.v = x
1284
+ i.v2 = y
1285
+ i.u1 = uint64(lane)
1286
+ i.typ = TypeV128
1287
+ return i
1288
+ }
1289
+
1290
+ // AsVAvgRound initializes this instruction as an unsigned integer avg instruction, truncating to zero with OpcodeVAvgRound on a vector.
1291
+ func (i *Instruction) AsVAvgRound(x, y Value, lane VecLane) *Instruction {
1292
+ i.opcode = OpcodeVAvgRound
1293
+ i.v = x
1294
+ i.v2 = y
1295
+ i.u1 = uint64(lane)
1296
+ i.typ = TypeV128
1297
+ return i
1298
+ }
1299
+
1300
+ // AsVImul initializes this instruction as an integer multiplication with OpcodeVImul on a vector.
1301
+ func (i *Instruction) AsVImul(x, y Value, lane VecLane) *Instruction {
1302
+ i.opcode = OpcodeVImul
1303
+ i.v = x
1304
+ i.v2 = y
1305
+ i.u1 = uint64(lane)
1306
+ i.typ = TypeV128
1307
+ return i
1308
+ }
1309
+
1310
+ // AsSqmulRoundSat initializes this instruction as a lane-wise saturating rounding multiplication
1311
+ // in Q15 format with OpcodeSqmulRoundSat on a vector.
1312
+ func (i *Instruction) AsSqmulRoundSat(x, y Value, lane VecLane) *Instruction {
1313
+ i.opcode = OpcodeSqmulRoundSat
1314
+ i.v = x
1315
+ i.v2 = y
1316
+ i.u1 = uint64(lane)
1317
+ i.typ = TypeV128
1318
+ return i
1319
+ }
1320
+
1321
+ // AsVIabs initializes this instruction as a vector absolute value with OpcodeVIabs.
1322
+ func (i *Instruction) AsVIabs(x Value, lane VecLane) *Instruction {
1323
+ i.opcode = OpcodeVIabs
1324
+ i.v = x
1325
+ i.u1 = uint64(lane)
1326
+ i.typ = TypeV128
1327
+ return i
1328
+ }
1329
+
1330
+ // AsVIneg initializes this instruction as a vector negation with OpcodeVIneg.
1331
+ func (i *Instruction) AsVIneg(x Value, lane VecLane) *Instruction {
1332
+ i.opcode = OpcodeVIneg
1333
+ i.v = x
1334
+ i.u1 = uint64(lane)
1335
+ i.typ = TypeV128
1336
+ return i
1337
+ }
1338
+
1339
+ // AsVIpopcnt initializes this instruction as a Population Count instruction with OpcodeVIpopcnt on a vector.
1340
+ func (i *Instruction) AsVIpopcnt(x Value, lane VecLane) *Instruction {
1341
+ if lane != VecLaneI8x16 {
1342
+ panic("Unsupported lane type " + lane.String())
1343
+ }
1344
+ i.opcode = OpcodeVIpopcnt
1345
+ i.v = x
1346
+ i.u1 = uint64(lane)
1347
+ i.typ = TypeV128
1348
+ return i
1349
+ }
1350
+
1351
+ // AsVSqrt initializes this instruction as a sqrt instruction with OpcodeVSqrt on a vector.
1352
+ func (i *Instruction) AsVSqrt(x Value, lane VecLane) *Instruction {
1353
+ i.opcode = OpcodeVSqrt
1354
+ i.v = x
1355
+ i.u1 = uint64(lane)
1356
+ i.typ = TypeV128
1357
+ return i
1358
+ }
1359
+
1360
+ // AsVFabs initializes this instruction as a float abs instruction with OpcodeVFabs on a vector.
1361
+ func (i *Instruction) AsVFabs(x Value, lane VecLane) *Instruction {
1362
+ i.opcode = OpcodeVFabs
1363
+ i.v = x
1364
+ i.u1 = uint64(lane)
1365
+ i.typ = TypeV128
1366
+ return i
1367
+ }
1368
+
1369
+ // AsVFneg initializes this instruction as a float neg instruction with OpcodeVFneg on a vector.
1370
+ func (i *Instruction) AsVFneg(x Value, lane VecLane) *Instruction {
1371
+ i.opcode = OpcodeVFneg
1372
+ i.v = x
1373
+ i.u1 = uint64(lane)
1374
+ i.typ = TypeV128
1375
+ return i
1376
+ }
1377
+
1378
+ // AsVFmax initializes this instruction as a float max instruction with OpcodeVFmax on a vector.
1379
+ func (i *Instruction) AsVFmax(x, y Value, lane VecLane) *Instruction {
1380
+ i.opcode = OpcodeVFmax
1381
+ i.v = x
1382
+ i.v2 = y
1383
+ i.u1 = uint64(lane)
1384
+ i.typ = TypeV128
1385
+ return i
1386
+ }
1387
+
1388
+ // AsVFmin initializes this instruction as a float min instruction with OpcodeVFmin on a vector.
1389
+ func (i *Instruction) AsVFmin(x, y Value, lane VecLane) *Instruction {
1390
+ i.opcode = OpcodeVFmin
1391
+ i.v = x
1392
+ i.v2 = y
1393
+ i.u1 = uint64(lane)
1394
+ i.typ = TypeV128
1395
+ return i
1396
+ }
1397
+
1398
+ // AsVFadd initializes this instruction as a floating point add instruction with OpcodeVFadd on a vector.
1399
+ func (i *Instruction) AsVFadd(x, y Value, lane VecLane) *Instruction {
1400
+ i.opcode = OpcodeVFadd
1401
+ i.v = x
1402
+ i.v2 = y
1403
+ i.u1 = uint64(lane)
1404
+ i.typ = TypeV128
1405
+ return i
1406
+ }
1407
+
1408
+ // AsVFsub initializes this instruction as a floating point subtraction instruction with OpcodeVFsub on a vector.
1409
+ func (i *Instruction) AsVFsub(x, y Value, lane VecLane) *Instruction {
1410
+ i.opcode = OpcodeVFsub
1411
+ i.v = x
1412
+ i.v2 = y
1413
+ i.u1 = uint64(lane)
1414
+ i.typ = TypeV128
1415
+ return i
1416
+ }
1417
+
1418
+ // AsVFmul initializes this instruction as a floating point multiplication instruction with OpcodeVFmul on a vector.
1419
+ func (i *Instruction) AsVFmul(x, y Value, lane VecLane) *Instruction {
1420
+ i.opcode = OpcodeVFmul
1421
+ i.v = x
1422
+ i.v2 = y
1423
+ i.u1 = uint64(lane)
1424
+ i.typ = TypeV128
1425
+ return i
1426
+ }
1427
+
1428
+ // AsVFdiv initializes this instruction as a floating point division instruction with OpcodeVFdiv on a vector.
1429
+ func (i *Instruction) AsVFdiv(x, y Value, lane VecLane) *Instruction {
1430
+ i.opcode = OpcodeVFdiv
1431
+ i.v = x
1432
+ i.v2 = y
1433
+ i.u1 = uint64(lane)
1434
+ i.typ = TypeV128
1435
+ return i
1436
+ }
1437
+
1438
+ // AsImul initializes this instruction as an integer addition instruction with OpcodeImul.
1439
+ func (i *Instruction) AsImul(x, y Value) *Instruction {
1440
+ i.opcode = OpcodeImul
1441
+ i.v = x
1442
+ i.v2 = y
1443
+ i.typ = x.Type()
1444
+ return i
1445
+ }
1446
+
1447
+ func (i *Instruction) Insert(b Builder) *Instruction {
1448
+ b.InsertInstruction(i)
1449
+ return i
1450
+ }
1451
+
1452
+ // AsIsub initializes this instruction as an integer subtraction instruction with OpcodeIsub.
1453
+ func (i *Instruction) AsIsub(x, y Value) *Instruction {
1454
+ i.opcode = OpcodeIsub
1455
+ i.v = x
1456
+ i.v2 = y
1457
+ i.typ = x.Type()
1458
+ return i
1459
+ }
1460
+
1461
+ // AsIcmp initializes this instruction as an integer comparison instruction with OpcodeIcmp.
1462
+ func (i *Instruction) AsIcmp(x, y Value, c IntegerCmpCond) *Instruction {
1463
+ i.opcode = OpcodeIcmp
1464
+ i.v = x
1465
+ i.v2 = y
1466
+ i.u1 = uint64(c)
1467
+ i.typ = TypeI32
1468
+ return i
1469
+ }
1470
+
1471
+ // AsFcmp initializes this instruction as an integer comparison instruction with OpcodeFcmp.
1472
+ func (i *Instruction) AsFcmp(x, y Value, c FloatCmpCond) {
1473
+ i.opcode = OpcodeFcmp
1474
+ i.v = x
1475
+ i.v2 = y
1476
+ i.u1 = uint64(c)
1477
+ i.typ = TypeI32
1478
+ }
1479
+
1480
+ // AsVIcmp initializes this instruction as an integer vector comparison instruction with OpcodeVIcmp.
1481
+ func (i *Instruction) AsVIcmp(x, y Value, c IntegerCmpCond, lane VecLane) *Instruction {
1482
+ i.opcode = OpcodeVIcmp
1483
+ i.v = x
1484
+ i.v2 = y
1485
+ i.u1 = uint64(c)
1486
+ i.u2 = uint64(lane)
1487
+ i.typ = TypeV128
1488
+ return i
1489
+ }
1490
+
1491
+ // AsVFcmp initializes this instruction as a float comparison instruction with OpcodeVFcmp on Vector.
1492
+ func (i *Instruction) AsVFcmp(x, y Value, c FloatCmpCond, lane VecLane) *Instruction {
1493
+ i.opcode = OpcodeVFcmp
1494
+ i.v = x
1495
+ i.v2 = y
1496
+ i.u1 = uint64(c)
1497
+ i.typ = TypeV128
1498
+ i.u2 = uint64(lane)
1499
+ return i
1500
+ }
1501
+
1502
+ // AsVCeil initializes this instruction as an instruction with OpcodeCeil.
1503
+ func (i *Instruction) AsVCeil(x Value, lane VecLane) *Instruction {
1504
+ i.opcode = OpcodeVCeil
1505
+ i.v = x
1506
+ i.typ = x.Type()
1507
+ i.u1 = uint64(lane)
1508
+ return i
1509
+ }
1510
+
1511
+ // AsVFloor initializes this instruction as an instruction with OpcodeFloor.
1512
+ func (i *Instruction) AsVFloor(x Value, lane VecLane) *Instruction {
1513
+ i.opcode = OpcodeVFloor
1514
+ i.v = x
1515
+ i.typ = x.Type()
1516
+ i.u1 = uint64(lane)
1517
+ return i
1518
+ }
1519
+
1520
+ // AsVTrunc initializes this instruction as an instruction with OpcodeTrunc.
1521
+ func (i *Instruction) AsVTrunc(x Value, lane VecLane) *Instruction {
1522
+ i.opcode = OpcodeVTrunc
1523
+ i.v = x
1524
+ i.typ = x.Type()
1525
+ i.u1 = uint64(lane)
1526
+ return i
1527
+ }
1528
+
1529
+ // AsVNearest initializes this instruction as an instruction with OpcodeNearest.
1530
+ func (i *Instruction) AsVNearest(x Value, lane VecLane) *Instruction {
1531
+ i.opcode = OpcodeVNearest
1532
+ i.v = x
1533
+ i.typ = x.Type()
1534
+ i.u1 = uint64(lane)
1535
+ return i
1536
+ }
1537
+
1538
+ // AsVMaxPseudo initializes this instruction as an instruction with OpcodeVMaxPseudo.
1539
+ func (i *Instruction) AsVMaxPseudo(x, y Value, lane VecLane) *Instruction {
1540
+ i.opcode = OpcodeVMaxPseudo
1541
+ i.typ = x.Type()
1542
+ i.v = x
1543
+ i.v2 = y
1544
+ i.u1 = uint64(lane)
1545
+ return i
1546
+ }
1547
+
1548
+ // AsVMinPseudo initializes this instruction as an instruction with OpcodeVMinPseudo.
1549
+ func (i *Instruction) AsVMinPseudo(x, y Value, lane VecLane) *Instruction {
1550
+ i.opcode = OpcodeVMinPseudo
1551
+ i.typ = x.Type()
1552
+ i.v = x
1553
+ i.v2 = y
1554
+ i.u1 = uint64(lane)
1555
+ return i
1556
+ }
1557
+
1558
+ // AsSDiv initializes this instruction as an integer bitwise and instruction with OpcodeSdiv.
1559
+ func (i *Instruction) AsSDiv(x, y, ctx Value) *Instruction {
1560
+ i.opcode = OpcodeSdiv
1561
+ i.v = x
1562
+ i.v2 = y
1563
+ i.v3 = ctx
1564
+ i.typ = x.Type()
1565
+ return i
1566
+ }
1567
+
1568
+ // AsUDiv initializes this instruction as an integer bitwise and instruction with OpcodeUdiv.
1569
+ func (i *Instruction) AsUDiv(x, y, ctx Value) *Instruction {
1570
+ i.opcode = OpcodeUdiv
1571
+ i.v = x
1572
+ i.v2 = y
1573
+ i.v3 = ctx
1574
+ i.typ = x.Type()
1575
+ return i
1576
+ }
1577
+
1578
+ // AsSRem initializes this instruction as an integer bitwise and instruction with OpcodeSrem.
1579
+ func (i *Instruction) AsSRem(x, y, ctx Value) *Instruction {
1580
+ i.opcode = OpcodeSrem
1581
+ i.v = x
1582
+ i.v2 = y
1583
+ i.v3 = ctx
1584
+ i.typ = x.Type()
1585
+ return i
1586
+ }
1587
+
1588
+ // AsURem initializes this instruction as an integer bitwise and instruction with OpcodeUrem.
1589
+ func (i *Instruction) AsURem(x, y, ctx Value) *Instruction {
1590
+ i.opcode = OpcodeUrem
1591
+ i.v = x
1592
+ i.v2 = y
1593
+ i.v3 = ctx
1594
+ i.typ = x.Type()
1595
+ return i
1596
+ }
1597
+
1598
+ // AsBand initializes this instruction as an integer bitwise and instruction with OpcodeBand.
1599
+ func (i *Instruction) AsBand(x, amount Value) *Instruction {
1600
+ i.opcode = OpcodeBand
1601
+ i.v = x
1602
+ i.v2 = amount
1603
+ i.typ = x.Type()
1604
+ return i
1605
+ }
1606
+
1607
+ // AsBor initializes this instruction as an integer bitwise or instruction with OpcodeBor.
1608
+ func (i *Instruction) AsBor(x, amount Value) {
1609
+ i.opcode = OpcodeBor
1610
+ i.v = x
1611
+ i.v2 = amount
1612
+ i.typ = x.Type()
1613
+ }
1614
+
1615
+ // AsBxor initializes this instruction as an integer bitwise xor instruction with OpcodeBxor.
1616
+ func (i *Instruction) AsBxor(x, amount Value) {
1617
+ i.opcode = OpcodeBxor
1618
+ i.v = x
1619
+ i.v2 = amount
1620
+ i.typ = x.Type()
1621
+ }
1622
+
1623
+ // AsIshl initializes this instruction as an integer shift left instruction with OpcodeIshl.
1624
+ func (i *Instruction) AsIshl(x, amount Value) *Instruction {
1625
+ i.opcode = OpcodeIshl
1626
+ i.v = x
1627
+ i.v2 = amount
1628
+ i.typ = x.Type()
1629
+ return i
1630
+ }
1631
+
1632
+ // AsVIshl initializes this instruction as an integer shift left instruction with OpcodeVIshl on vector.
1633
+ func (i *Instruction) AsVIshl(x, amount Value, lane VecLane) *Instruction {
1634
+ i.opcode = OpcodeVIshl
1635
+ i.v = x
1636
+ i.v2 = amount
1637
+ i.u1 = uint64(lane)
1638
+ i.typ = x.Type()
1639
+ return i
1640
+ }
1641
+
1642
+ // AsUshr initializes this instruction as an integer unsigned shift right (logical shift right) instruction with OpcodeUshr.
1643
+ func (i *Instruction) AsUshr(x, amount Value) *Instruction {
1644
+ i.opcode = OpcodeUshr
1645
+ i.v = x
1646
+ i.v2 = amount
1647
+ i.typ = x.Type()
1648
+ return i
1649
+ }
1650
+
1651
+ // AsVUshr initializes this instruction as an integer unsigned shift right (logical shift right) instruction with OpcodeVUshr on vector.
1652
+ func (i *Instruction) AsVUshr(x, amount Value, lane VecLane) *Instruction {
1653
+ i.opcode = OpcodeVUshr
1654
+ i.v = x
1655
+ i.v2 = amount
1656
+ i.u1 = uint64(lane)
1657
+ i.typ = x.Type()
1658
+ return i
1659
+ }
1660
+
1661
+ // AsSshr initializes this instruction as an integer signed shift right (arithmetic shift right) instruction with OpcodeSshr.
1662
+ func (i *Instruction) AsSshr(x, amount Value) *Instruction {
1663
+ i.opcode = OpcodeSshr
1664
+ i.v = x
1665
+ i.v2 = amount
1666
+ i.typ = x.Type()
1667
+ return i
1668
+ }
1669
+
1670
+ // AsVSshr initializes this instruction as an integer signed shift right (arithmetic shift right) instruction with OpcodeVSshr on vector.
1671
+ func (i *Instruction) AsVSshr(x, amount Value, lane VecLane) *Instruction {
1672
+ i.opcode = OpcodeVSshr
1673
+ i.v = x
1674
+ i.v2 = amount
1675
+ i.u1 = uint64(lane)
1676
+ i.typ = x.Type()
1677
+ return i
1678
+ }
1679
+
1680
+ // AsExtractlane initializes this instruction as an extract lane instruction with OpcodeExtractlane on vector.
1681
+ func (i *Instruction) AsExtractlane(x Value, index byte, lane VecLane, signed bool) *Instruction {
1682
+ i.opcode = OpcodeExtractlane
1683
+ i.v = x
1684
+ // We do not have a field for signedness, but `index` is a byte,
1685
+ // so we just encode the flag in the high bits of `u1`.
1686
+ i.u1 = uint64(index)
1687
+ if signed {
1688
+ i.u1 = i.u1 | 1<<32
1689
+ }
1690
+ i.u2 = uint64(lane)
1691
+ switch lane {
1692
+ case VecLaneI8x16, VecLaneI16x8, VecLaneI32x4:
1693
+ i.typ = TypeI32
1694
+ case VecLaneI64x2:
1695
+ i.typ = TypeI64
1696
+ case VecLaneF32x4:
1697
+ i.typ = TypeF32
1698
+ case VecLaneF64x2:
1699
+ i.typ = TypeF64
1700
+ }
1701
+ return i
1702
+ }
1703
+
1704
+ // AsInsertlane initializes this instruction as an insert lane instruction with OpcodeInsertlane on vector.
1705
+ func (i *Instruction) AsInsertlane(x, y Value, index byte, lane VecLane) *Instruction {
1706
+ i.opcode = OpcodeInsertlane
1707
+ i.v = x
1708
+ i.v2 = y
1709
+ i.u1 = uint64(index)
1710
+ i.u2 = uint64(lane)
1711
+ i.typ = TypeV128
1712
+ return i
1713
+ }
1714
+
1715
+ // AsShuffle initializes this instruction as a shuffle instruction with OpcodeShuffle on vector.
1716
+ func (i *Instruction) AsShuffle(x, y Value, lane []byte) *Instruction {
1717
+ i.opcode = OpcodeShuffle
1718
+ i.v = x
1719
+ i.v2 = y
1720
+ // Encode the 16 bytes as 8 bytes in u1, and 8 bytes in u2.
1721
+ i.u1 = uint64(lane[7])<<56 | uint64(lane[6])<<48 | uint64(lane[5])<<40 | uint64(lane[4])<<32 | uint64(lane[3])<<24 | uint64(lane[2])<<16 | uint64(lane[1])<<8 | uint64(lane[0])
1722
+ i.u2 = uint64(lane[15])<<56 | uint64(lane[14])<<48 | uint64(lane[13])<<40 | uint64(lane[12])<<32 | uint64(lane[11])<<24 | uint64(lane[10])<<16 | uint64(lane[9])<<8 | uint64(lane[8])
1723
+ i.typ = TypeV128
1724
+ return i
1725
+ }
1726
+
1727
+ // AsSwizzle initializes this instruction as an insert lane instruction with OpcodeSwizzle on vector.
1728
+ func (i *Instruction) AsSwizzle(x, y Value, lane VecLane) *Instruction {
1729
+ i.opcode = OpcodeSwizzle
1730
+ i.v = x
1731
+ i.v2 = y
1732
+ i.u1 = uint64(lane)
1733
+ i.typ = TypeV128
1734
+ return i
1735
+ }
1736
+
1737
+ // AsSplat initializes this instruction as an insert lane instruction with OpcodeSplat on vector.
1738
+ func (i *Instruction) AsSplat(x Value, lane VecLane) *Instruction {
1739
+ i.opcode = OpcodeSplat
1740
+ i.v = x
1741
+ i.u1 = uint64(lane)
1742
+ i.typ = TypeV128
1743
+ return i
1744
+ }
1745
+
1746
+ // AsRotl initializes this instruction as a word rotate left instruction with OpcodeRotl.
1747
+ func (i *Instruction) AsRotl(x, amount Value) {
1748
+ i.opcode = OpcodeRotl
1749
+ i.v = x
1750
+ i.v2 = amount
1751
+ i.typ = x.Type()
1752
+ }
1753
+
1754
+ // AsRotr initializes this instruction as a word rotate right instruction with OpcodeRotr.
1755
+ func (i *Instruction) AsRotr(x, amount Value) {
1756
+ i.opcode = OpcodeRotr
1757
+ i.v = x
1758
+ i.v2 = amount
1759
+ i.typ = x.Type()
1760
+ }
1761
+
1762
+ // IcmpData returns the operands and comparison condition of this integer comparison instruction.
1763
+ func (i *Instruction) IcmpData() (x, y Value, c IntegerCmpCond) {
1764
+ return i.v, i.v2, IntegerCmpCond(i.u1)
1765
+ }
1766
+
1767
+ // FcmpData returns the operands and comparison condition of this floating-point comparison instruction.
1768
+ func (i *Instruction) FcmpData() (x, y Value, c FloatCmpCond) {
1769
+ return i.v, i.v2, FloatCmpCond(i.u1)
1770
+ }
1771
+
1772
+ // VIcmpData returns the operands and comparison condition of this integer comparison instruction on vector.
1773
+ func (i *Instruction) VIcmpData() (x, y Value, c IntegerCmpCond, l VecLane) {
1774
+ return i.v, i.v2, IntegerCmpCond(i.u1), VecLane(i.u2)
1775
+ }
1776
+
1777
+ // VFcmpData returns the operands and comparison condition of this float comparison instruction on vector.
1778
+ func (i *Instruction) VFcmpData() (x, y Value, c FloatCmpCond, l VecLane) {
1779
+ return i.v, i.v2, FloatCmpCond(i.u1), VecLane(i.u2)
1780
+ }
1781
+
1782
+ // ExtractlaneData returns the operands and sign flag of Extractlane on vector.
1783
+ func (i *Instruction) ExtractlaneData() (x Value, index byte, signed bool, l VecLane) {
1784
+ x = i.v
1785
+ index = byte(0b00001111 & i.u1)
1786
+ signed = i.u1>>32 != 0
1787
+ l = VecLane(i.u2)
1788
+ return
1789
+ }
1790
+
1791
+ // InsertlaneData returns the operands and sign flag of Insertlane on vector.
1792
+ func (i *Instruction) InsertlaneData() (x, y Value, index byte, l VecLane) {
1793
+ x = i.v
1794
+ y = i.v2
1795
+ index = byte(i.u1)
1796
+ l = VecLane(i.u2)
1797
+ return
1798
+ }
1799
+
1800
+ // AsFadd initializes this instruction as a floating-point addition instruction with OpcodeFadd.
1801
+ func (i *Instruction) AsFadd(x, y Value) {
1802
+ i.opcode = OpcodeFadd
1803
+ i.v = x
1804
+ i.v2 = y
1805
+ i.typ = x.Type()
1806
+ }
1807
+
1808
+ // AsFsub initializes this instruction as a floating-point subtraction instruction with OpcodeFsub.
1809
+ func (i *Instruction) AsFsub(x, y Value) {
1810
+ i.opcode = OpcodeFsub
1811
+ i.v = x
1812
+ i.v2 = y
1813
+ i.typ = x.Type()
1814
+ }
1815
+
1816
+ // AsFmul initializes this instruction as a floating-point multiplication instruction with OpcodeFmul.
1817
+ func (i *Instruction) AsFmul(x, y Value) {
1818
+ i.opcode = OpcodeFmul
1819
+ i.v = x
1820
+ i.v2 = y
1821
+ i.typ = x.Type()
1822
+ }
1823
+
1824
+ // AsFdiv initializes this instruction as a floating-point division instruction with OpcodeFdiv.
1825
+ func (i *Instruction) AsFdiv(x, y Value) {
1826
+ i.opcode = OpcodeFdiv
1827
+ i.v = x
1828
+ i.v2 = y
1829
+ i.typ = x.Type()
1830
+ }
1831
+
1832
+ // AsFmin initializes this instruction to take the minimum of two floating-points with OpcodeFmin.
1833
+ func (i *Instruction) AsFmin(x, y Value) {
1834
+ i.opcode = OpcodeFmin
1835
+ i.v = x
1836
+ i.v2 = y
1837
+ i.typ = x.Type()
1838
+ }
1839
+
1840
+ // AsFmax initializes this instruction to take the maximum of two floating-points with OpcodeFmax.
1841
+ func (i *Instruction) AsFmax(x, y Value) {
1842
+ i.opcode = OpcodeFmax
1843
+ i.v = x
1844
+ i.v2 = y
1845
+ i.typ = x.Type()
1846
+ }
1847
+
1848
+ // AsF32const initializes this instruction as a 32-bit floating-point constant instruction with OpcodeF32const.
1849
+ func (i *Instruction) AsF32const(f float32) *Instruction {
1850
+ i.opcode = OpcodeF32const
1851
+ i.typ = TypeF64
1852
+ i.u1 = uint64(math.Float32bits(f))
1853
+ return i
1854
+ }
1855
+
1856
+ // AsF64const initializes this instruction as a 64-bit floating-point constant instruction with OpcodeF64const.
1857
+ func (i *Instruction) AsF64const(f float64) *Instruction {
1858
+ i.opcode = OpcodeF64const
1859
+ i.typ = TypeF64
1860
+ i.u1 = math.Float64bits(f)
1861
+ return i
1862
+ }
1863
+
1864
+ // AsVconst initializes this instruction as a vector constant instruction with OpcodeVconst.
1865
+ func (i *Instruction) AsVconst(lo, hi uint64) *Instruction {
1866
+ i.opcode = OpcodeVconst
1867
+ i.typ = TypeV128
1868
+ i.u1 = lo
1869
+ i.u2 = hi
1870
+ return i
1871
+ }
1872
+
1873
+ // AsVbnot initializes this instruction as a vector negation instruction with OpcodeVbnot.
1874
+ func (i *Instruction) AsVbnot(v Value) *Instruction {
1875
+ i.opcode = OpcodeVbnot
1876
+ i.typ = TypeV128
1877
+ i.v = v
1878
+ return i
1879
+ }
1880
+
1881
+ // AsVband initializes this instruction as an and vector instruction with OpcodeVband.
1882
+ func (i *Instruction) AsVband(x, y Value) *Instruction {
1883
+ i.opcode = OpcodeVband
1884
+ i.typ = TypeV128
1885
+ i.v = x
1886
+ i.v2 = y
1887
+ return i
1888
+ }
1889
+
1890
+ // AsVbor initializes this instruction as an or vector instruction with OpcodeVbor.
1891
+ func (i *Instruction) AsVbor(x, y Value) *Instruction {
1892
+ i.opcode = OpcodeVbor
1893
+ i.typ = TypeV128
1894
+ i.v = x
1895
+ i.v2 = y
1896
+ return i
1897
+ }
1898
+
1899
+ // AsVbxor initializes this instruction as a xor vector instruction with OpcodeVbxor.
1900
+ func (i *Instruction) AsVbxor(x, y Value) *Instruction {
1901
+ i.opcode = OpcodeVbxor
1902
+ i.typ = TypeV128
1903
+ i.v = x
1904
+ i.v2 = y
1905
+ return i
1906
+ }
1907
+
1908
+ // AsVbandnot initializes this instruction as an and-not vector instruction with OpcodeVbandnot.
1909
+ func (i *Instruction) AsVbandnot(x, y Value) *Instruction {
1910
+ i.opcode = OpcodeVbandnot
1911
+ i.typ = TypeV128
1912
+ i.v = x
1913
+ i.v2 = y
1914
+ return i
1915
+ }
1916
+
1917
+ // AsVbitselect initializes this instruction as a bit select vector instruction with OpcodeVbitselect.
1918
+ func (i *Instruction) AsVbitselect(c, x, y Value) *Instruction {
1919
+ i.opcode = OpcodeVbitselect
1920
+ i.typ = TypeV128
1921
+ i.v = c
1922
+ i.v2 = x
1923
+ i.v3 = y
1924
+ return i
1925
+ }
1926
+
1927
+ // AsVanyTrue initializes this instruction as an anyTrue vector instruction with OpcodeVanyTrue.
1928
+ func (i *Instruction) AsVanyTrue(x Value) *Instruction {
1929
+ i.opcode = OpcodeVanyTrue
1930
+ i.typ = TypeI32
1931
+ i.v = x
1932
+ return i
1933
+ }
1934
+
1935
+ // AsVallTrue initializes this instruction as an allTrue vector instruction with OpcodeVallTrue.
1936
+ func (i *Instruction) AsVallTrue(x Value, lane VecLane) *Instruction {
1937
+ i.opcode = OpcodeVallTrue
1938
+ i.typ = TypeI32
1939
+ i.v = x
1940
+ i.u1 = uint64(lane)
1941
+ return i
1942
+ }
1943
+
1944
+ // AsVhighBits initializes this instruction as a highBits vector instruction with OpcodeVhighBits.
1945
+ func (i *Instruction) AsVhighBits(x Value, lane VecLane) *Instruction {
1946
+ i.opcode = OpcodeVhighBits
1947
+ i.typ = TypeI32
1948
+ i.v = x
1949
+ i.u1 = uint64(lane)
1950
+ return i
1951
+ }
1952
+
1953
+ // VconstData returns the operands of this vector constant instruction.
1954
+ func (i *Instruction) VconstData() (lo, hi uint64) {
1955
+ return i.u1, i.u2
1956
+ }
1957
+
1958
+ // AsReturn initializes this instruction as a return instruction with OpcodeReturn.
1959
+ func (i *Instruction) AsReturn(vs wazevoapi.VarLength[Value]) *Instruction {
1960
+ i.opcode = OpcodeReturn
1961
+ i.vs = vs
1962
+ return i
1963
+ }
1964
+
1965
+ // AsIreduce initializes this instruction as a reduction instruction with OpcodeIreduce.
1966
+ func (i *Instruction) AsIreduce(v Value, dstType Type) *Instruction {
1967
+ i.opcode = OpcodeIreduce
1968
+ i.v = v
1969
+ i.typ = dstType
1970
+ return i
1971
+ }
1972
+
1973
+ // AsWiden initializes this instruction as a signed or unsigned widen instruction
1974
+ // on low half or high half of the given vector with OpcodeSwidenLow, OpcodeUwidenLow, OpcodeSwidenHigh, OpcodeUwidenHigh.
1975
+ func (i *Instruction) AsWiden(v Value, lane VecLane, signed, low bool) *Instruction {
1976
+ switch {
1977
+ case signed && low:
1978
+ i.opcode = OpcodeSwidenLow
1979
+ case !signed && low:
1980
+ i.opcode = OpcodeUwidenLow
1981
+ case signed && !low:
1982
+ i.opcode = OpcodeSwidenHigh
1983
+ case !signed && !low:
1984
+ i.opcode = OpcodeUwidenHigh
1985
+ }
1986
+ i.v = v
1987
+ i.u1 = uint64(lane)
1988
+ return i
1989
+ }
1990
+
1991
+ // AsAtomicLoad initializes this instruction as an atomic load.
1992
+ // The size is in bytes and must be 1, 2, 4, or 8.
1993
+ func (i *Instruction) AsAtomicLoad(addr Value, size uint64, typ Type) *Instruction {
1994
+ i.opcode = OpcodeAtomicLoad
1995
+ i.u1 = size
1996
+ i.v = addr
1997
+ i.typ = typ
1998
+ return i
1999
+ }
2000
+
2001
+ // AsAtomicLoad initializes this instruction as an atomic store.
2002
+ // The size is in bytes and must be 1, 2, 4, or 8.
2003
+ func (i *Instruction) AsAtomicStore(addr, val Value, size uint64) *Instruction {
2004
+ i.opcode = OpcodeAtomicStore
2005
+ i.u1 = size
2006
+ i.v = addr
2007
+ i.v2 = val
2008
+ i.typ = val.Type()
2009
+ return i
2010
+ }
2011
+
2012
+ // AsAtomicRmw initializes this instruction as an atomic read-modify-write.
2013
+ // The size is in bytes and must be 1, 2, 4, or 8.
2014
+ func (i *Instruction) AsAtomicRmw(op AtomicRmwOp, addr, val Value, size uint64) *Instruction {
2015
+ i.opcode = OpcodeAtomicRmw
2016
+ i.u1 = uint64(op)
2017
+ i.u2 = size
2018
+ i.v = addr
2019
+ i.v2 = val
2020
+ i.typ = val.Type()
2021
+ return i
2022
+ }
2023
+
2024
+ // AsAtomicCas initializes this instruction as an atomic compare-and-swap.
2025
+ // The size is in bytes and must be 1, 2, 4, or 8.
2026
+ func (i *Instruction) AsAtomicCas(addr, exp, repl Value, size uint64) *Instruction {
2027
+ i.opcode = OpcodeAtomicCas
2028
+ i.u1 = size
2029
+ i.v = addr
2030
+ i.v2 = exp
2031
+ i.v3 = repl
2032
+ i.typ = repl.Type()
2033
+ return i
2034
+ }
2035
+
2036
+ // AsFence initializes this instruction as a memory fence.
2037
+ // A single byte immediate may be used to indicate fence ordering in the future
2038
+ // but is currently always 0 and ignored.
2039
+ func (i *Instruction) AsFence(order byte) *Instruction {
2040
+ i.opcode = OpcodeFence
2041
+ i.u1 = uint64(order)
2042
+ return i
2043
+ }
2044
+
2045
+ // AtomicRmwData returns the data for this atomic read-modify-write instruction.
2046
+ func (i *Instruction) AtomicRmwData() (op AtomicRmwOp, size uint64) {
2047
+ return AtomicRmwOp(i.u1), i.u2
2048
+ }
2049
+
2050
+ // AtomicTargetSize returns the target memory size of the atomic instruction.
2051
+ func (i *Instruction) AtomicTargetSize() (size uint64) {
2052
+ return i.u1
2053
+ }
2054
+
2055
+ // AsTailCallReturnCall initializes this instruction as a call instruction with OpcodeTailCallReturnCall.
2056
+ func (i *Instruction) AsTailCallReturnCall(ref FuncRef, sig *Signature, args Values) {
2057
+ i.opcode = OpcodeTailCallReturnCall
2058
+ i.u1 = uint64(ref)
2059
+ i.vs = args
2060
+ i.u2 = uint64(sig.ID)
2061
+ sig.used = true
2062
+ }
2063
+
2064
+ // AsTailCallReturnCallIndirect initializes this instruction as a call-indirect instruction with OpcodeTailCallReturnCallIndirect.
2065
+ func (i *Instruction) AsTailCallReturnCallIndirect(funcPtr Value, sig *Signature, args Values) *Instruction {
2066
+ i.opcode = OpcodeTailCallReturnCallIndirect
2067
+ i.vs = args
2068
+ i.v = funcPtr
2069
+ i.u1 = uint64(sig.ID)
2070
+ sig.used = true
2071
+ return i
2072
+ }
2073
+
2074
+ // ReturnVals returns the return values of OpcodeReturn.
2075
+ func (i *Instruction) ReturnVals() []Value {
2076
+ return i.vs.View()
2077
+ }
2078
+
2079
+ // AsExitWithCode initializes this instruction as a trap instruction with OpcodeExitWithCode.
2080
+ func (i *Instruction) AsExitWithCode(ctx Value, code wazevoapi.ExitCode) {
2081
+ i.opcode = OpcodeExitWithCode
2082
+ i.v = ctx
2083
+ i.u1 = uint64(code)
2084
+ }
2085
+
2086
+ // AsExitIfTrueWithCode initializes this instruction as a trap instruction with OpcodeExitIfTrueWithCode.
2087
+ func (i *Instruction) AsExitIfTrueWithCode(ctx, c Value, code wazevoapi.ExitCode) *Instruction {
2088
+ i.opcode = OpcodeExitIfTrueWithCode
2089
+ i.v = ctx
2090
+ i.v2 = c
2091
+ i.u1 = uint64(code)
2092
+ return i
2093
+ }
2094
+
2095
+ // ExitWithCodeData returns the context and exit code of OpcodeExitWithCode.
2096
+ func (i *Instruction) ExitWithCodeData() (ctx Value, code wazevoapi.ExitCode) {
2097
+ return i.v, wazevoapi.ExitCode(i.u1)
2098
+ }
2099
+
2100
+ // ExitIfTrueWithCodeData returns the context and exit code of OpcodeExitWithCode.
2101
+ func (i *Instruction) ExitIfTrueWithCodeData() (ctx, c Value, code wazevoapi.ExitCode) {
2102
+ return i.v, i.v2, wazevoapi.ExitCode(i.u1)
2103
+ }
2104
+
2105
+ // InvertBrx inverts either OpcodeBrz or OpcodeBrnz to the other.
2106
+ func (i *Instruction) InvertBrx() {
2107
+ switch i.opcode {
2108
+ case OpcodeBrz:
2109
+ i.opcode = OpcodeBrnz
2110
+ case OpcodeBrnz:
2111
+ i.opcode = OpcodeBrz
2112
+ default:
2113
+ panic("BUG")
2114
+ }
2115
+ }
2116
+
2117
+ // BranchData returns the branch data for this instruction necessary for backends.
2118
+ func (i *Instruction) BranchData() (condVal Value, blockArgs []Value, target BasicBlockID) {
2119
+ switch i.opcode {
2120
+ case OpcodeJump:
2121
+ condVal = ValueInvalid
2122
+ case OpcodeBrz, OpcodeBrnz:
2123
+ condVal = i.v
2124
+ default:
2125
+ panic("BUG")
2126
+ }
2127
+ blockArgs = i.vs.View()
2128
+ target = BasicBlockID(i.rValue)
2129
+ return
2130
+ }
2131
+
2132
+ // BrTableData returns the branch table data for this instruction necessary for backends.
2133
+ func (i *Instruction) BrTableData() (index Value, targets Values) {
2134
+ if i.opcode != OpcodeBrTable {
2135
+ panic("BUG: BrTableData only available for OpcodeBrTable")
2136
+ }
2137
+ index = i.v
2138
+ targets = i.rValues
2139
+ return
2140
+ }
2141
+
2142
+ // AsJump initializes this instruction as a jump instruction with OpcodeJump.
2143
+ func (i *Instruction) AsJump(vs Values, target BasicBlock) *Instruction {
2144
+ i.opcode = OpcodeJump
2145
+ i.vs = vs
2146
+ i.rValue = Value(target.ID())
2147
+ return i
2148
+ }
2149
+
2150
+ // IsFallthroughJump returns true if this instruction is a fallthrough jump.
2151
+ func (i *Instruction) IsFallthroughJump() bool {
2152
+ if i.opcode != OpcodeJump {
2153
+ panic("BUG: IsFallthrough only available for OpcodeJump")
2154
+ }
2155
+ return i.opcode == OpcodeJump && i.u1 != 0
2156
+ }
2157
+
2158
+ // AsFallthroughJump marks this instruction as a fallthrough jump.
2159
+ func (i *Instruction) AsFallthroughJump() {
2160
+ if i.opcode != OpcodeJump {
2161
+ panic("BUG: AsFallthroughJump only available for OpcodeJump")
2162
+ }
2163
+ i.u1 = 1
2164
+ }
2165
+
2166
+ // AsBrz initializes this instruction as a branch-if-zero instruction with OpcodeBrz.
2167
+ func (i *Instruction) AsBrz(v Value, args Values, target BasicBlock) {
2168
+ i.opcode = OpcodeBrz
2169
+ i.v = v
2170
+ i.vs = args
2171
+ i.rValue = Value(target.ID())
2172
+ }
2173
+
2174
+ // AsBrnz initializes this instruction as a branch-if-not-zero instruction with OpcodeBrnz.
2175
+ func (i *Instruction) AsBrnz(v Value, args Values, target BasicBlock) *Instruction {
2176
+ i.opcode = OpcodeBrnz
2177
+ i.v = v
2178
+ i.vs = args
2179
+ i.rValue = Value(target.ID())
2180
+ return i
2181
+ }
2182
+
2183
+ // AsBrTable initializes this instruction as a branch-table instruction with OpcodeBrTable.
2184
+ // targets is a list of basic block IDs cast to Values.
2185
+ func (i *Instruction) AsBrTable(index Value, targets Values) {
2186
+ i.opcode = OpcodeBrTable
2187
+ i.v = index
2188
+ i.rValues = targets
2189
+ }
2190
+
2191
+ // AsCall initializes this instruction as a call instruction with OpcodeCall.
2192
+ func (i *Instruction) AsCall(ref FuncRef, sig *Signature, args Values) {
2193
+ i.opcode = OpcodeCall
2194
+ i.u1 = uint64(ref)
2195
+ i.vs = args
2196
+ i.u2 = uint64(sig.ID)
2197
+ sig.used = true
2198
+ }
2199
+
2200
+ // CallData returns the call data for this instruction necessary for backends.
2201
+ func (i *Instruction) CallData() (ref FuncRef, sigID SignatureID, args []Value) {
2202
+ if i.opcode != OpcodeCall && i.opcode != OpcodeTailCallReturnCall {
2203
+ panic("BUG: CallData only available for OpcodeCall")
2204
+ }
2205
+ ref = FuncRef(i.u1)
2206
+ sigID = SignatureID(i.u2)
2207
+ args = i.vs.View()
2208
+ return
2209
+ }
2210
+
2211
+ // AsCallIndirect initializes this instruction as a call-indirect instruction with OpcodeCallIndirect.
2212
+ func (i *Instruction) AsCallIndirect(funcPtr Value, sig *Signature, args Values) *Instruction {
2213
+ i.opcode = OpcodeCallIndirect
2214
+ i.typ = TypeF64
2215
+ i.vs = args
2216
+ i.v = funcPtr
2217
+ i.u1 = uint64(sig.ID)
2218
+ sig.used = true
2219
+ return i
2220
+ }
2221
+
2222
+ // 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.
2223
+ func (i *Instruction) AsCallGoRuntimeMemmove(funcPtr Value, sig *Signature, args Values) *Instruction {
2224
+ i.AsCallIndirect(funcPtr, sig, args)
2225
+ i.u2 = 1
2226
+ return i
2227
+ }
2228
+
2229
+ // CallIndirectData returns the call indirect data for this instruction necessary for backends.
2230
+ func (i *Instruction) CallIndirectData() (funcPtr Value, sigID SignatureID, args []Value, isGoMemmove bool) {
2231
+ if i.opcode != OpcodeCallIndirect && i.opcode != OpcodeTailCallReturnCallIndirect {
2232
+ panic("BUG: CallIndirectData only available for OpcodeCallIndirect and OpcodeTailCallReturnCallIndirect")
2233
+ }
2234
+ funcPtr = i.v
2235
+ sigID = SignatureID(i.u1)
2236
+ args = i.vs.View()
2237
+ isGoMemmove = i.u2 == 1
2238
+ return
2239
+ }
2240
+
2241
+ // AsClz initializes this instruction as a Count Leading Zeroes instruction with OpcodeClz.
2242
+ func (i *Instruction) AsClz(x Value) {
2243
+ i.opcode = OpcodeClz
2244
+ i.v = x
2245
+ i.typ = x.Type()
2246
+ }
2247
+
2248
+ // AsCtz initializes this instruction as a Count Trailing Zeroes instruction with OpcodeCtz.
2249
+ func (i *Instruction) AsCtz(x Value) {
2250
+ i.opcode = OpcodeCtz
2251
+ i.v = x
2252
+ i.typ = x.Type()
2253
+ }
2254
+
2255
+ // AsPopcnt initializes this instruction as a Population Count instruction with OpcodePopcnt.
2256
+ func (i *Instruction) AsPopcnt(x Value) {
2257
+ i.opcode = OpcodePopcnt
2258
+ i.v = x
2259
+ i.typ = x.Type()
2260
+ }
2261
+
2262
+ // AsFneg initializes this instruction as an instruction with OpcodeFneg.
2263
+ func (i *Instruction) AsFneg(x Value) *Instruction {
2264
+ i.opcode = OpcodeFneg
2265
+ i.v = x
2266
+ i.typ = x.Type()
2267
+ return i
2268
+ }
2269
+
2270
+ // AsSqrt initializes this instruction as an instruction with OpcodeSqrt.
2271
+ func (i *Instruction) AsSqrt(x Value) *Instruction {
2272
+ i.opcode = OpcodeSqrt
2273
+ i.v = x
2274
+ i.typ = x.Type()
2275
+ return i
2276
+ }
2277
+
2278
+ // AsFabs initializes this instruction as an instruction with OpcodeFabs.
2279
+ func (i *Instruction) AsFabs(x Value) *Instruction {
2280
+ i.opcode = OpcodeFabs
2281
+ i.v = x
2282
+ i.typ = x.Type()
2283
+ return i
2284
+ }
2285
+
2286
+ // AsFcopysign initializes this instruction as an instruction with OpcodeFcopysign.
2287
+ func (i *Instruction) AsFcopysign(x, y Value) *Instruction {
2288
+ i.opcode = OpcodeFcopysign
2289
+ i.v = x
2290
+ i.v2 = y
2291
+ i.typ = x.Type()
2292
+ return i
2293
+ }
2294
+
2295
+ // AsCeil initializes this instruction as an instruction with OpcodeCeil.
2296
+ func (i *Instruction) AsCeil(x Value) *Instruction {
2297
+ i.opcode = OpcodeCeil
2298
+ i.v = x
2299
+ i.typ = x.Type()
2300
+ return i
2301
+ }
2302
+
2303
+ // AsFloor initializes this instruction as an instruction with OpcodeFloor.
2304
+ func (i *Instruction) AsFloor(x Value) *Instruction {
2305
+ i.opcode = OpcodeFloor
2306
+ i.v = x
2307
+ i.typ = x.Type()
2308
+ return i
2309
+ }
2310
+
2311
+ // AsTrunc initializes this instruction as an instruction with OpcodeTrunc.
2312
+ func (i *Instruction) AsTrunc(x Value) *Instruction {
2313
+ i.opcode = OpcodeTrunc
2314
+ i.v = x
2315
+ i.typ = x.Type()
2316
+ return i
2317
+ }
2318
+
2319
+ // AsNearest initializes this instruction as an instruction with OpcodeNearest.
2320
+ func (i *Instruction) AsNearest(x Value) *Instruction {
2321
+ i.opcode = OpcodeNearest
2322
+ i.v = x
2323
+ i.typ = x.Type()
2324
+ return i
2325
+ }
2326
+
2327
+ // AsBitcast initializes this instruction as an instruction with OpcodeBitcast.
2328
+ func (i *Instruction) AsBitcast(x Value, dstType Type) *Instruction {
2329
+ i.opcode = OpcodeBitcast
2330
+ i.v = x
2331
+ i.typ = dstType
2332
+ return i
2333
+ }
2334
+
2335
+ // BitcastData returns the operands for a bitcast instruction.
2336
+ func (i *Instruction) BitcastData() (x Value, dstType Type) {
2337
+ return i.v, i.typ
2338
+ }
2339
+
2340
+ // AsFdemote initializes this instruction as an instruction with OpcodeFdemote.
2341
+ func (i *Instruction) AsFdemote(x Value) {
2342
+ i.opcode = OpcodeFdemote
2343
+ i.v = x
2344
+ i.typ = TypeF32
2345
+ }
2346
+
2347
+ // AsFpromote initializes this instruction as an instruction with OpcodeFpromote.
2348
+ func (i *Instruction) AsFpromote(x Value) {
2349
+ i.opcode = OpcodeFpromote
2350
+ i.v = x
2351
+ i.typ = TypeF64
2352
+ }
2353
+
2354
+ // AsFcvtFromInt initializes this instruction as an instruction with either OpcodeFcvtFromUint or OpcodeFcvtFromSint
2355
+ func (i *Instruction) AsFcvtFromInt(x Value, signed bool, dst64bit bool) *Instruction {
2356
+ if signed {
2357
+ i.opcode = OpcodeFcvtFromSint
2358
+ } else {
2359
+ i.opcode = OpcodeFcvtFromUint
2360
+ }
2361
+ i.v = x
2362
+ if dst64bit {
2363
+ i.typ = TypeF64
2364
+ } else {
2365
+ i.typ = TypeF32
2366
+ }
2367
+ return i
2368
+ }
2369
+
2370
+ // AsFcvtToInt initializes this instruction as an instruction with either OpcodeFcvtToUint or OpcodeFcvtToSint
2371
+ func (i *Instruction) AsFcvtToInt(x, ctx Value, signed bool, dst64bit bool, sat bool) *Instruction {
2372
+ switch {
2373
+ case signed && !sat:
2374
+ i.opcode = OpcodeFcvtToSint
2375
+ case !signed && !sat:
2376
+ i.opcode = OpcodeFcvtToUint
2377
+ case signed && sat:
2378
+ i.opcode = OpcodeFcvtToSintSat
2379
+ case !signed && sat:
2380
+ i.opcode = OpcodeFcvtToUintSat
2381
+ }
2382
+ i.v = x
2383
+ i.v2 = ctx
2384
+ if dst64bit {
2385
+ i.typ = TypeI64
2386
+ } else {
2387
+ i.typ = TypeI32
2388
+ }
2389
+ return i
2390
+ }
2391
+
2392
+ // AsVFcvtToIntSat initializes this instruction as an instruction with either OpcodeVFcvtToSintSat or OpcodeVFcvtToUintSat
2393
+ func (i *Instruction) AsVFcvtToIntSat(x Value, lane VecLane, signed bool) *Instruction {
2394
+ if signed {
2395
+ i.opcode = OpcodeVFcvtToSintSat
2396
+ } else {
2397
+ i.opcode = OpcodeVFcvtToUintSat
2398
+ }
2399
+ i.v = x
2400
+ i.u1 = uint64(lane)
2401
+ return i
2402
+ }
2403
+
2404
+ // AsVFcvtFromInt initializes this instruction as an instruction with either OpcodeVFcvtToSintSat or OpcodeVFcvtToUintSat
2405
+ func (i *Instruction) AsVFcvtFromInt(x Value, lane VecLane, signed bool) *Instruction {
2406
+ if signed {
2407
+ i.opcode = OpcodeVFcvtFromSint
2408
+ } else {
2409
+ i.opcode = OpcodeVFcvtFromUint
2410
+ }
2411
+ i.v = x
2412
+ i.u1 = uint64(lane)
2413
+ return i
2414
+ }
2415
+
2416
+ // AsNarrow initializes this instruction as an instruction with either OpcodeSnarrow or OpcodeUnarrow
2417
+ func (i *Instruction) AsNarrow(x, y Value, lane VecLane, signed bool) *Instruction {
2418
+ if signed {
2419
+ i.opcode = OpcodeSnarrow
2420
+ } else {
2421
+ i.opcode = OpcodeUnarrow
2422
+ }
2423
+ i.v = x
2424
+ i.v2 = y
2425
+ i.u1 = uint64(lane)
2426
+ return i
2427
+ }
2428
+
2429
+ // AsFvpromoteLow initializes this instruction as an instruction with OpcodeFvpromoteLow
2430
+ func (i *Instruction) AsFvpromoteLow(x Value, lane VecLane) *Instruction {
2431
+ i.opcode = OpcodeFvpromoteLow
2432
+ i.v = x
2433
+ i.u1 = uint64(lane)
2434
+ return i
2435
+ }
2436
+
2437
+ // AsFvdemote initializes this instruction as an instruction with OpcodeFvdemote
2438
+ func (i *Instruction) AsFvdemote(x Value, lane VecLane) *Instruction {
2439
+ i.opcode = OpcodeFvdemote
2440
+ i.v = x
2441
+ i.u1 = uint64(lane)
2442
+ return i
2443
+ }
2444
+
2445
+ // AsSExtend initializes this instruction as a sign extension instruction with OpcodeSExtend.
2446
+ func (i *Instruction) AsSExtend(v Value, from, to byte) *Instruction {
2447
+ i.opcode = OpcodeSExtend
2448
+ i.v = v
2449
+ i.u1 = uint64(from)<<8 | uint64(to)
2450
+ if to == 64 {
2451
+ i.typ = TypeI64
2452
+ } else {
2453
+ i.typ = TypeI32
2454
+ }
2455
+ return i
2456
+ }
2457
+
2458
+ // AsUExtend initializes this instruction as an unsigned extension instruction with OpcodeUExtend.
2459
+ func (i *Instruction) AsUExtend(v Value, from, to byte) *Instruction {
2460
+ i.opcode = OpcodeUExtend
2461
+ i.v = v
2462
+ i.u1 = uint64(from)<<8 | uint64(to)
2463
+ if to == 64 {
2464
+ i.typ = TypeI64
2465
+ } else {
2466
+ i.typ = TypeI32
2467
+ }
2468
+ return i
2469
+ }
2470
+
2471
+ func (i *Instruction) ExtendData() (from, to byte, signed bool) {
2472
+ if i.opcode != OpcodeSExtend && i.opcode != OpcodeUExtend {
2473
+ panic("BUG: ExtendData only available for OpcodeSExtend and OpcodeUExtend")
2474
+ }
2475
+ from = byte(i.u1 >> 8)
2476
+ to = byte(i.u1)
2477
+ signed = i.opcode == OpcodeSExtend
2478
+ return
2479
+ }
2480
+
2481
+ // AsSelect initializes this instruction as an unsigned extension instruction with OpcodeSelect.
2482
+ func (i *Instruction) AsSelect(c, x, y Value) *Instruction {
2483
+ i.opcode = OpcodeSelect
2484
+ i.v = c
2485
+ i.v2 = x
2486
+ i.v3 = y
2487
+ i.typ = x.Type()
2488
+ return i
2489
+ }
2490
+
2491
+ // SelectData returns the select data for this instruction necessary for backends.
2492
+ func (i *Instruction) SelectData() (c, x, y Value) {
2493
+ c = i.v
2494
+ x = i.v2
2495
+ y = i.v3
2496
+ return
2497
+ }
2498
+
2499
+ // ExtendFromToBits returns the from and to bit size for the extension instruction.
2500
+ func (i *Instruction) ExtendFromToBits() (from, to byte) {
2501
+ from = byte(i.u1 >> 8)
2502
+ to = byte(i.u1)
2503
+ return
2504
+ }
2505
+
2506
+ // Format returns a string representation of this instruction with the given builder.
2507
+ // For debugging purposes only.
2508
+ func (i *Instruction) Format(b Builder) string {
2509
+ var instSuffix string
2510
+ switch i.opcode {
2511
+ case OpcodeExitWithCode:
2512
+ instSuffix = fmt.Sprintf(" %s, %s", i.v.Format(b), wazevoapi.ExitCode(i.u1))
2513
+ case OpcodeExitIfTrueWithCode:
2514
+ instSuffix = fmt.Sprintf(" %s, %s, %s", i.v2.Format(b), i.v.Format(b), wazevoapi.ExitCode(i.u1))
2515
+ case OpcodeIadd, OpcodeIsub, OpcodeImul, OpcodeFadd, OpcodeFsub, OpcodeFmin, OpcodeFmax, OpcodeFdiv, OpcodeFmul:
2516
+ instSuffix = fmt.Sprintf(" %s, %s", i.v.Format(b), i.v2.Format(b))
2517
+ case OpcodeIcmp:
2518
+ instSuffix = fmt.Sprintf(" %s, %s, %s", IntegerCmpCond(i.u1), i.v.Format(b), i.v2.Format(b))
2519
+ case OpcodeFcmp:
2520
+ instSuffix = fmt.Sprintf(" %s, %s, %s", FloatCmpCond(i.u1), i.v.Format(b), i.v2.Format(b))
2521
+ case OpcodeSExtend, OpcodeUExtend:
2522
+ instSuffix = fmt.Sprintf(" %s, %d->%d", i.v.Format(b), i.u1>>8, i.u1&0xff)
2523
+ case OpcodeCall, OpcodeCallIndirect:
2524
+ view := i.vs.View()
2525
+ vs := make([]string, len(view))
2526
+ for idx := range vs {
2527
+ vs[idx] = view[idx].Format(b)
2528
+ }
2529
+ if i.opcode == OpcodeCallIndirect {
2530
+ instSuffix = fmt.Sprintf(" %s:%s, %s", i.v.Format(b), SignatureID(i.u1), strings.Join(vs, ", "))
2531
+ } else {
2532
+ instSuffix = fmt.Sprintf(" %s:%s, %s", FuncRef(i.u1), SignatureID(i.u2), strings.Join(vs, ", "))
2533
+ }
2534
+ case OpcodeStore, OpcodeIstore8, OpcodeIstore16, OpcodeIstore32:
2535
+ instSuffix = fmt.Sprintf(" %s, %s, %#x", i.v.Format(b), i.v2.Format(b), uint32(i.u1))
2536
+ case OpcodeLoad, OpcodeVZeroExtLoad:
2537
+ instSuffix = fmt.Sprintf(" %s, %#x", i.v.Format(b), int32(i.u1))
2538
+ case OpcodeLoadSplat:
2539
+ instSuffix = fmt.Sprintf(".%s %s, %#x", VecLane(i.u2), i.v.Format(b), int32(i.u1))
2540
+ case OpcodeUload8, OpcodeUload16, OpcodeUload32, OpcodeSload8, OpcodeSload16, OpcodeSload32:
2541
+ instSuffix = fmt.Sprintf(" %s, %#x", i.v.Format(b), int32(i.u1))
2542
+ case OpcodeSelect, OpcodeVbitselect:
2543
+ instSuffix = fmt.Sprintf(" %s, %s, %s", i.v.Format(b), i.v2.Format(b), i.v3.Format(b))
2544
+ case OpcodeIconst:
2545
+ switch i.typ {
2546
+ case TypeI32:
2547
+ instSuffix = fmt.Sprintf("_32 %#x", uint32(i.u1))
2548
+ case TypeI64:
2549
+ instSuffix = fmt.Sprintf("_64 %#x", i.u1)
2550
+ }
2551
+ case OpcodeVconst:
2552
+ instSuffix = fmt.Sprintf(" %016x %016x", i.u1, i.u2)
2553
+ case OpcodeF32const:
2554
+ instSuffix = fmt.Sprintf(" %f", math.Float32frombits(uint32(i.u1)))
2555
+ case OpcodeF64const:
2556
+ instSuffix = fmt.Sprintf(" %f", math.Float64frombits(i.u1))
2557
+ case OpcodeReturn:
2558
+ view := i.vs.View()
2559
+ if len(view) == 0 {
2560
+ break
2561
+ }
2562
+ vs := make([]string, len(view))
2563
+ for idx := range vs {
2564
+ vs[idx] = view[idx].Format(b)
2565
+ }
2566
+ instSuffix = fmt.Sprintf(" %s", strings.Join(vs, ", "))
2567
+ case OpcodeJump:
2568
+ view := i.vs.View()
2569
+ vs := make([]string, len(view)+1)
2570
+ if i.IsFallthroughJump() {
2571
+ vs[0] = " fallthrough"
2572
+ } else {
2573
+ blockId := BasicBlockID(i.rValue)
2574
+ vs[0] = " " + b.BasicBlock(blockId).Name()
2575
+ }
2576
+ for idx := range view {
2577
+ vs[idx+1] = view[idx].Format(b)
2578
+ }
2579
+
2580
+ instSuffix = strings.Join(vs, ", ")
2581
+ case OpcodeBrz, OpcodeBrnz:
2582
+ view := i.vs.View()
2583
+ vs := make([]string, len(view)+2)
2584
+ vs[0] = " " + i.v.Format(b)
2585
+ blockId := BasicBlockID(i.rValue)
2586
+ vs[1] = b.BasicBlock(blockId).Name()
2587
+ for idx := range view {
2588
+ vs[idx+2] = view[idx].Format(b)
2589
+ }
2590
+ instSuffix = strings.Join(vs, ", ")
2591
+ case OpcodeBrTable:
2592
+ // `BrTable index, [label1, label2, ... labelN]`
2593
+ instSuffix = fmt.Sprintf(" %s", i.v.Format(b))
2594
+ instSuffix += ", ["
2595
+ for i, target := range i.rValues.View() {
2596
+ blk := b.BasicBlock(BasicBlockID(target))
2597
+ if i == 0 {
2598
+ instSuffix += blk.Name()
2599
+ } else {
2600
+ instSuffix += ", " + blk.Name()
2601
+ }
2602
+ }
2603
+ instSuffix += "]"
2604
+ case OpcodeBand, OpcodeBor, OpcodeBxor, OpcodeRotr, OpcodeRotl, OpcodeIshl, OpcodeSshr, OpcodeUshr,
2605
+ OpcodeSdiv, OpcodeUdiv, OpcodeFcopysign, OpcodeSrem, OpcodeUrem,
2606
+ OpcodeVbnot, OpcodeVbxor, OpcodeVbor, OpcodeVband, OpcodeVbandnot, OpcodeVIcmp, OpcodeVFcmp:
2607
+ instSuffix = fmt.Sprintf(" %s, %s", i.v.Format(b), i.v2.Format(b))
2608
+ case OpcodeUndefined:
2609
+ case OpcodeClz, OpcodeCtz, OpcodePopcnt, OpcodeFneg, OpcodeFcvtToSint, OpcodeFcvtToUint, OpcodeFcvtFromSint,
2610
+ OpcodeFcvtFromUint, OpcodeFcvtToSintSat, OpcodeFcvtToUintSat, OpcodeFdemote, OpcodeFpromote, OpcodeIreduce, OpcodeBitcast, OpcodeSqrt, OpcodeFabs,
2611
+ OpcodeCeil, OpcodeFloor, OpcodeTrunc, OpcodeNearest:
2612
+ instSuffix = " " + i.v.Format(b)
2613
+ case OpcodeVIadd, OpcodeExtIaddPairwise, OpcodeVSaddSat, OpcodeVUaddSat, OpcodeVIsub, OpcodeVSsubSat, OpcodeVUsubSat,
2614
+ OpcodeVImin, OpcodeVUmin, OpcodeVImax, OpcodeVUmax, OpcodeVImul, OpcodeVAvgRound,
2615
+ OpcodeVFadd, OpcodeVFsub, OpcodeVFmul, OpcodeVFdiv,
2616
+ OpcodeVIshl, OpcodeVSshr, OpcodeVUshr,
2617
+ OpcodeVFmin, OpcodeVFmax, OpcodeVMinPseudo, OpcodeVMaxPseudo,
2618
+ OpcodeSnarrow, OpcodeUnarrow, OpcodeSwizzle, OpcodeSqmulRoundSat:
2619
+ instSuffix = fmt.Sprintf(".%s %s, %s", VecLane(i.u1), i.v.Format(b), i.v2.Format(b))
2620
+ case OpcodeVIabs, OpcodeVIneg, OpcodeVIpopcnt, OpcodeVhighBits, OpcodeVallTrue, OpcodeVanyTrue,
2621
+ OpcodeVFabs, OpcodeVFneg, OpcodeVSqrt, OpcodeVCeil, OpcodeVFloor, OpcodeVTrunc, OpcodeVNearest,
2622
+ OpcodeVFcvtToUintSat, OpcodeVFcvtToSintSat, OpcodeVFcvtFromUint, OpcodeVFcvtFromSint,
2623
+ OpcodeFvpromoteLow, OpcodeFvdemote, OpcodeSwidenLow, OpcodeUwidenLow, OpcodeSwidenHigh, OpcodeUwidenHigh,
2624
+ OpcodeSplat:
2625
+ instSuffix = fmt.Sprintf(".%s %s", VecLane(i.u1), i.v.Format(b))
2626
+ case OpcodeExtractlane:
2627
+ var signedness string
2628
+ if i.u1 != 0 {
2629
+ signedness = "signed"
2630
+ } else {
2631
+ signedness = "unsigned"
2632
+ }
2633
+ instSuffix = fmt.Sprintf(".%s %d, %s (%s)", VecLane(i.u2), 0x0000FFFF&i.u1, i.v.Format(b), signedness)
2634
+ case OpcodeInsertlane:
2635
+ instSuffix = fmt.Sprintf(".%s %d, %s, %s", VecLane(i.u2), i.u1, i.v.Format(b), i.v2.Format(b))
2636
+ case OpcodeShuffle:
2637
+ lanes := make([]byte, 16)
2638
+ for idx := 0; idx < 8; idx++ {
2639
+ lanes[idx] = byte(i.u1 >> (8 * idx))
2640
+ }
2641
+ for idx := 0; idx < 8; idx++ {
2642
+ lanes[idx+8] = byte(i.u2 >> (8 * idx))
2643
+ }
2644
+ // Prints Shuffle.[0 1 2 3 4 5 6 7 ...] v2, v3
2645
+ instSuffix = fmt.Sprintf(".%v %s, %s", lanes, i.v.Format(b), i.v2.Format(b))
2646
+ case OpcodeAtomicRmw:
2647
+ instSuffix = fmt.Sprintf(" %s_%d, %s, %s", AtomicRmwOp(i.u1), 8*i.u2, i.v.Format(b), i.v2.Format(b))
2648
+ case OpcodeAtomicLoad:
2649
+ instSuffix = fmt.Sprintf("_%d, %s", 8*i.u1, i.v.Format(b))
2650
+ case OpcodeAtomicStore:
2651
+ instSuffix = fmt.Sprintf("_%d, %s, %s", 8*i.u1, i.v.Format(b), i.v2.Format(b))
2652
+ case OpcodeAtomicCas:
2653
+ instSuffix = fmt.Sprintf("_%d, %s, %s, %s", 8*i.u1, i.v.Format(b), i.v2.Format(b), i.v3.Format(b))
2654
+ case OpcodeFence:
2655
+ instSuffix = fmt.Sprintf(" %d", i.u1)
2656
+ case OpcodeTailCallReturnCall, OpcodeTailCallReturnCallIndirect:
2657
+ view := i.vs.View()
2658
+ vs := make([]string, len(view))
2659
+ for idx := range vs {
2660
+ vs[idx] = view[idx].Format(b)
2661
+ }
2662
+ if i.opcode == OpcodeCallIndirect {
2663
+ instSuffix = fmt.Sprintf(" %s:%s, %s", i.v.Format(b), SignatureID(i.u1), strings.Join(vs, ", "))
2664
+ } else {
2665
+ instSuffix = fmt.Sprintf(" %s:%s, %s", FuncRef(i.u1), SignatureID(i.u2), strings.Join(vs, ", "))
2666
+ }
2667
+ case OpcodeWideningPairwiseDotProductS:
2668
+ instSuffix = fmt.Sprintf(" %s, %s", i.v.Format(b), i.v2.Format(b))
2669
+ default:
2670
+ panic(fmt.Sprintf("TODO: format for %s", i.opcode))
2671
+ }
2672
+
2673
+ instr := i.opcode.String() + instSuffix
2674
+
2675
+ var rvs []string
2676
+ r1, rs := i.Returns()
2677
+ if r1.Valid() {
2678
+ rvs = append(rvs, r1.formatWithType(b))
2679
+ }
2680
+
2681
+ for _, v := range rs {
2682
+ rvs = append(rvs, v.formatWithType(b))
2683
+ }
2684
+
2685
+ if len(rvs) > 0 {
2686
+ return fmt.Sprintf("%s = %s", strings.Join(rvs, ", "), instr)
2687
+ } else {
2688
+ return instr
2689
+ }
2690
+ }
2691
+
2692
+ // addArgumentBranchInst adds an argument to this instruction.
2693
+ func (i *Instruction) addArgumentBranchInst(b *builder, v Value) {
2694
+ switch i.opcode {
2695
+ case OpcodeJump, OpcodeBrz, OpcodeBrnz:
2696
+ i.vs = i.vs.Append(&b.varLengthPool, v)
2697
+ default:
2698
+ panic("BUG: " + i.opcode.String())
2699
+ }
2700
+ }
2701
+
2702
+ // Constant returns true if this instruction is a constant instruction.
2703
+ func (i *Instruction) Constant() bool {
2704
+ switch i.opcode {
2705
+ case OpcodeIconst, OpcodeF32const, OpcodeF64const:
2706
+ return true
2707
+ }
2708
+ return false
2709
+ }
2710
+
2711
+ // ConstantVal returns the constant value of this instruction.
2712
+ // How to interpret the return value depends on the opcode.
2713
+ func (i *Instruction) ConstantVal() (ret uint64) {
2714
+ switch i.opcode {
2715
+ case OpcodeIconst, OpcodeF32const, OpcodeF64const:
2716
+ ret = i.u1
2717
+ default:
2718
+ panic("TODO")
2719
+ }
2720
+ return
2721
+ }
2722
+
2723
+ // String implements fmt.Stringer.
2724
+ func (o Opcode) String() (ret string) {
2725
+ switch o {
2726
+ case OpcodeInvalid:
2727
+ return "invalid"
2728
+ case OpcodeUndefined:
2729
+ return "Undefined"
2730
+ case OpcodeJump:
2731
+ return "Jump"
2732
+ case OpcodeBrz:
2733
+ return "Brz"
2734
+ case OpcodeBrnz:
2735
+ return "Brnz"
2736
+ case OpcodeBrTable:
2737
+ return "BrTable"
2738
+ case OpcodeExitWithCode:
2739
+ return "Exit"
2740
+ case OpcodeExitIfTrueWithCode:
2741
+ return "ExitIfTrue"
2742
+ case OpcodeReturn:
2743
+ return "Return"
2744
+ case OpcodeCall:
2745
+ return "Call"
2746
+ case OpcodeCallIndirect:
2747
+ return "CallIndirect"
2748
+ case OpcodeSplat:
2749
+ return "Splat"
2750
+ case OpcodeSwizzle:
2751
+ return "Swizzle"
2752
+ case OpcodeInsertlane:
2753
+ return "Insertlane"
2754
+ case OpcodeExtractlane:
2755
+ return "Extractlane"
2756
+ case OpcodeLoad:
2757
+ return "Load"
2758
+ case OpcodeLoadSplat:
2759
+ return "LoadSplat"
2760
+ case OpcodeStore:
2761
+ return "Store"
2762
+ case OpcodeUload8:
2763
+ return "Uload8"
2764
+ case OpcodeSload8:
2765
+ return "Sload8"
2766
+ case OpcodeIstore8:
2767
+ return "Istore8"
2768
+ case OpcodeUload16:
2769
+ return "Uload16"
2770
+ case OpcodeSload16:
2771
+ return "Sload16"
2772
+ case OpcodeIstore16:
2773
+ return "Istore16"
2774
+ case OpcodeUload32:
2775
+ return "Uload32"
2776
+ case OpcodeSload32:
2777
+ return "Sload32"
2778
+ case OpcodeIstore32:
2779
+ return "Istore32"
2780
+ case OpcodeIconst:
2781
+ return "Iconst"
2782
+ case OpcodeF32const:
2783
+ return "F32const"
2784
+ case OpcodeF64const:
2785
+ return "F64const"
2786
+ case OpcodeVconst:
2787
+ return "Vconst"
2788
+ case OpcodeShuffle:
2789
+ return "Shuffle"
2790
+ case OpcodeSelect:
2791
+ return "Select"
2792
+ case OpcodeVanyTrue:
2793
+ return "VanyTrue"
2794
+ case OpcodeVallTrue:
2795
+ return "VallTrue"
2796
+ case OpcodeVhighBits:
2797
+ return "VhighBits"
2798
+ case OpcodeIcmp:
2799
+ return "Icmp"
2800
+ case OpcodeIcmpImm:
2801
+ return "IcmpImm"
2802
+ case OpcodeVIcmp:
2803
+ return "VIcmp"
2804
+ case OpcodeIadd:
2805
+ return "Iadd"
2806
+ case OpcodeIsub:
2807
+ return "Isub"
2808
+ case OpcodeImul:
2809
+ return "Imul"
2810
+ case OpcodeUdiv:
2811
+ return "Udiv"
2812
+ case OpcodeSdiv:
2813
+ return "Sdiv"
2814
+ case OpcodeUrem:
2815
+ return "Urem"
2816
+ case OpcodeSrem:
2817
+ return "Srem"
2818
+ case OpcodeBand:
2819
+ return "Band"
2820
+ case OpcodeBor:
2821
+ return "Bor"
2822
+ case OpcodeBxor:
2823
+ return "Bxor"
2824
+ case OpcodeBnot:
2825
+ return "Bnot"
2826
+ case OpcodeRotl:
2827
+ return "Rotl"
2828
+ case OpcodeRotr:
2829
+ return "Rotr"
2830
+ case OpcodeIshl:
2831
+ return "Ishl"
2832
+ case OpcodeUshr:
2833
+ return "Ushr"
2834
+ case OpcodeSshr:
2835
+ return "Sshr"
2836
+ case OpcodeClz:
2837
+ return "Clz"
2838
+ case OpcodeCtz:
2839
+ return "Ctz"
2840
+ case OpcodePopcnt:
2841
+ return "Popcnt"
2842
+ case OpcodeFcmp:
2843
+ return "Fcmp"
2844
+ case OpcodeFadd:
2845
+ return "Fadd"
2846
+ case OpcodeFsub:
2847
+ return "Fsub"
2848
+ case OpcodeFmul:
2849
+ return "Fmul"
2850
+ case OpcodeFdiv:
2851
+ return "Fdiv"
2852
+ case OpcodeSqmulRoundSat:
2853
+ return "SqmulRoundSat"
2854
+ case OpcodeSqrt:
2855
+ return "Sqrt"
2856
+ case OpcodeFneg:
2857
+ return "Fneg"
2858
+ case OpcodeFabs:
2859
+ return "Fabs"
2860
+ case OpcodeFcopysign:
2861
+ return "Fcopysign"
2862
+ case OpcodeFmin:
2863
+ return "Fmin"
2864
+ case OpcodeFmax:
2865
+ return "Fmax"
2866
+ case OpcodeCeil:
2867
+ return "Ceil"
2868
+ case OpcodeFloor:
2869
+ return "Floor"
2870
+ case OpcodeTrunc:
2871
+ return "Trunc"
2872
+ case OpcodeNearest:
2873
+ return "Nearest"
2874
+ case OpcodeBitcast:
2875
+ return "Bitcast"
2876
+ case OpcodeIreduce:
2877
+ return "Ireduce"
2878
+ case OpcodeSnarrow:
2879
+ return "Snarrow"
2880
+ case OpcodeUnarrow:
2881
+ return "Unarrow"
2882
+ case OpcodeSwidenLow:
2883
+ return "SwidenLow"
2884
+ case OpcodeSwidenHigh:
2885
+ return "SwidenHigh"
2886
+ case OpcodeUwidenLow:
2887
+ return "UwidenLow"
2888
+ case OpcodeUwidenHigh:
2889
+ return "UwidenHigh"
2890
+ case OpcodeExtIaddPairwise:
2891
+ return "IaddPairwise"
2892
+ case OpcodeWideningPairwiseDotProductS:
2893
+ return "WideningPairwiseDotProductS"
2894
+ case OpcodeUExtend:
2895
+ return "UExtend"
2896
+ case OpcodeSExtend:
2897
+ return "SExtend"
2898
+ case OpcodeFpromote:
2899
+ return "Fpromote"
2900
+ case OpcodeFdemote:
2901
+ return "Fdemote"
2902
+ case OpcodeFvdemote:
2903
+ return "Fvdemote"
2904
+ case OpcodeFcvtToUint:
2905
+ return "FcvtToUint"
2906
+ case OpcodeFcvtToSint:
2907
+ return "FcvtToSint"
2908
+ case OpcodeFcvtToUintSat:
2909
+ return "FcvtToUintSat"
2910
+ case OpcodeFcvtToSintSat:
2911
+ return "FcvtToSintSat"
2912
+ case OpcodeFcvtFromUint:
2913
+ return "FcvtFromUint"
2914
+ case OpcodeFcvtFromSint:
2915
+ return "FcvtFromSint"
2916
+ case OpcodeAtomicRmw:
2917
+ return "AtomicRmw"
2918
+ case OpcodeAtomicCas:
2919
+ return "AtomicCas"
2920
+ case OpcodeAtomicLoad:
2921
+ return "AtomicLoad"
2922
+ case OpcodeAtomicStore:
2923
+ return "AtomicStore"
2924
+ case OpcodeFence:
2925
+ return "Fence"
2926
+ case OpcodeTailCallReturnCall:
2927
+ return "ReturnCall"
2928
+ case OpcodeTailCallReturnCallIndirect:
2929
+ return "ReturnCallIndirect"
2930
+ case OpcodeVbor:
2931
+ return "Vbor"
2932
+ case OpcodeVbxor:
2933
+ return "Vbxor"
2934
+ case OpcodeVband:
2935
+ return "Vband"
2936
+ case OpcodeVbandnot:
2937
+ return "Vbandnot"
2938
+ case OpcodeVbnot:
2939
+ return "Vbnot"
2940
+ case OpcodeVbitselect:
2941
+ return "Vbitselect"
2942
+ case OpcodeVIadd:
2943
+ return "VIadd"
2944
+ case OpcodeVSaddSat:
2945
+ return "VSaddSat"
2946
+ case OpcodeVUaddSat:
2947
+ return "VUaddSat"
2948
+ case OpcodeVSsubSat:
2949
+ return "VSsubSat"
2950
+ case OpcodeVUsubSat:
2951
+ return "VUsubSat"
2952
+ case OpcodeVAvgRound:
2953
+ return "OpcodeVAvgRound"
2954
+ case OpcodeVIsub:
2955
+ return "VIsub"
2956
+ case OpcodeVImin:
2957
+ return "VImin"
2958
+ case OpcodeVUmin:
2959
+ return "VUmin"
2960
+ case OpcodeVImax:
2961
+ return "VImax"
2962
+ case OpcodeVUmax:
2963
+ return "VUmax"
2964
+ case OpcodeVImul:
2965
+ return "VImul"
2966
+ case OpcodeVIabs:
2967
+ return "VIabs"
2968
+ case OpcodeVIneg:
2969
+ return "VIneg"
2970
+ case OpcodeVIpopcnt:
2971
+ return "VIpopcnt"
2972
+ case OpcodeVIshl:
2973
+ return "VIshl"
2974
+ case OpcodeVUshr:
2975
+ return "VUshr"
2976
+ case OpcodeVSshr:
2977
+ return "VSshr"
2978
+ case OpcodeVFabs:
2979
+ return "VFabs"
2980
+ case OpcodeVFmax:
2981
+ return "VFmax"
2982
+ case OpcodeVFmin:
2983
+ return "VFmin"
2984
+ case OpcodeVFneg:
2985
+ return "VFneg"
2986
+ case OpcodeVFadd:
2987
+ return "VFadd"
2988
+ case OpcodeVFsub:
2989
+ return "VFsub"
2990
+ case OpcodeVFmul:
2991
+ return "VFmul"
2992
+ case OpcodeVFdiv:
2993
+ return "VFdiv"
2994
+ case OpcodeVFcmp:
2995
+ return "VFcmp"
2996
+ case OpcodeVCeil:
2997
+ return "VCeil"
2998
+ case OpcodeVFloor:
2999
+ return "VFloor"
3000
+ case OpcodeVTrunc:
3001
+ return "VTrunc"
3002
+ case OpcodeVNearest:
3003
+ return "VNearest"
3004
+ case OpcodeVMaxPseudo:
3005
+ return "VMaxPseudo"
3006
+ case OpcodeVMinPseudo:
3007
+ return "VMinPseudo"
3008
+ case OpcodeVSqrt:
3009
+ return "VSqrt"
3010
+ case OpcodeVFcvtToUintSat:
3011
+ return "VFcvtToUintSat"
3012
+ case OpcodeVFcvtToSintSat:
3013
+ return "VFcvtToSintSat"
3014
+ case OpcodeVFcvtFromUint:
3015
+ return "VFcvtFromUint"
3016
+ case OpcodeVFcvtFromSint:
3017
+ return "VFcvtFromSint"
3018
+ case OpcodeFvpromoteLow:
3019
+ return "FvpromoteLow"
3020
+ case OpcodeVZeroExtLoad:
3021
+ return "VZeroExtLoad"
3022
+ }
3023
+ panic(fmt.Sprintf("unknown opcode %d", o))
3024
+ }