@ttsc/win32-arm64 0.33.1 → 0.34.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 (1062) hide show
  1. package/bin/go/VERSION +2 -2
  2. package/bin/go/bin/go.exe +0 -0
  3. package/bin/go/bin/gofmt.exe +0 -0
  4. package/bin/go/lib/time/update.bash +2 -2
  5. package/bin/go/lib/time/zoneinfo.zip +0 -0
  6. package/bin/go/pkg/include/asm_ppc64x.h +0 -16
  7. package/bin/go/pkg/tool/windows_arm64/asm.exe +0 -0
  8. package/bin/go/pkg/tool/windows_arm64/cgo.exe +0 -0
  9. package/bin/go/pkg/tool/windows_arm64/compile.exe +0 -0
  10. package/bin/go/pkg/tool/windows_arm64/cover.exe +0 -0
  11. package/bin/go/pkg/tool/windows_arm64/fix.exe +0 -0
  12. package/bin/go/pkg/tool/windows_arm64/link.exe +0 -0
  13. package/bin/go/pkg/tool/windows_arm64/preprofile.exe +0 -0
  14. package/bin/go/pkg/tool/windows_arm64/vet.exe +0 -0
  15. package/bin/go/src/archive/tar/reader.go +2 -1
  16. package/bin/go/src/archive/zip/reader.go +5 -29
  17. package/bin/go/src/archive/zip/struct.go +5 -6
  18. package/bin/go/src/archive/zip/writer.go +120 -60
  19. package/bin/go/src/bufio/bufio.go +1 -1
  20. package/bin/go/src/bytes/buffer.go +3 -3
  21. package/bin/go/src/bytes/bytes.go +45 -25
  22. package/bin/go/src/compress/flate/deflate.go +512 -363
  23. package/bin/go/src/compress/flate/deflatefast.go +156 -262
  24. package/bin/go/src/compress/flate/dict_decoder.go +1 -4
  25. package/bin/go/src/compress/flate/huffman_bit_writer.go +673 -250
  26. package/bin/go/src/compress/flate/huffman_code.go +164 -92
  27. package/bin/go/src/compress/flate/level1.go +195 -0
  28. package/bin/go/src/compress/flate/level2.go +190 -0
  29. package/bin/go/src/compress/flate/level3.go +228 -0
  30. package/bin/go/src/compress/flate/level4.go +200 -0
  31. package/bin/go/src/compress/flate/level5.go +287 -0
  32. package/bin/go/src/compress/flate/level6.go +297 -0
  33. package/bin/go/src/compress/flate/load_store.go +43 -0
  34. package/bin/go/src/compress/flate/regmask_amd64.go +9 -0
  35. package/bin/go/src/compress/flate/regmask_other.go +11 -0
  36. package/bin/go/src/compress/flate/token.go +238 -26
  37. package/bin/go/src/compress/gzip/gzip.go +8 -0
  38. package/bin/go/src/compress/zlib/writer.go +12 -0
  39. package/bin/go/src/context/context.go +6 -5
  40. package/bin/go/src/crypto/cipher/gcm.go +0 -4
  41. package/bin/go/src/crypto/crypto.go +27 -4
  42. package/bin/go/src/crypto/des/const.go +1 -1
  43. package/bin/go/src/crypto/ecdsa/ecdsa.go +21 -4
  44. package/bin/go/src/crypto/ed25519/ed25519.go +13 -0
  45. package/bin/go/src/crypto/internal/boring/aes.go +2 -3
  46. package/bin/go/src/crypto/internal/cryptotest/aead.go +53 -0
  47. package/bin/go/src/crypto/internal/cryptotest/boundary.go +34 -0
  48. package/bin/go/src/crypto/internal/cryptotest/boundary_compat.go +16 -0
  49. package/bin/go/src/crypto/internal/cryptotest/fetchmodule.go +9 -3
  50. package/bin/go/src/crypto/internal/cryptotest/fips140.go +62 -3
  51. package/bin/go/src/crypto/internal/cryptotest/hash.go +14 -0
  52. package/bin/go/src/crypto/internal/cryptotest/wycheproof/_schema/go.mod +19 -0
  53. package/bin/go/src/crypto/internal/cryptotest/wycheproof/_schema/go.sum +27 -0
  54. package/bin/go/src/crypto/internal/cryptotest/wycheproof/_schema/schema_gen.go +151 -0
  55. package/bin/go/src/crypto/internal/cryptotest/wycheproof/schema.go +9792 -0
  56. package/bin/go/src/crypto/internal/cryptotest/wycheproof/schemaversion.go +11 -0
  57. package/bin/go/src/crypto/internal/cryptotest/wycheproof/wycheproof.go +165 -0
  58. package/bin/go/src/crypto/internal/cryptotest/x509limbo/_schema/go.mod +14 -0
  59. package/bin/go/src/crypto/internal/cryptotest/x509limbo/_schema/go.sum +25 -0
  60. package/bin/go/src/crypto/internal/cryptotest/x509limbo/_schema/schema_gen.go +125 -0
  61. package/bin/go/src/crypto/internal/cryptotest/x509limbo/schema.go +591 -0
  62. package/bin/go/src/crypto/internal/cryptotest/x509limbo/schemaversion.go +14 -0
  63. package/bin/go/src/crypto/internal/fips140/aes/_asm/ctr/go.mod +1 -1
  64. package/bin/go/src/crypto/internal/fips140/aes/_asm/standard/go.mod +1 -1
  65. package/bin/go/src/crypto/internal/fips140/aes/gcm/_asm/gcm/gcm_amd64_asm.go +36 -32
  66. package/bin/go/src/crypto/internal/fips140/aes/gcm/_asm/gcm/go.mod +5 -5
  67. package/bin/go/src/crypto/internal/fips140/aes/gcm/_asm/gcm/go.sum +8 -6
  68. package/bin/go/src/crypto/internal/fips140/aes/gcm/gcm_amd64.s +29 -17
  69. package/bin/go/src/crypto/internal/fips140/aes/gcm/gcm_arm64.s +73 -72
  70. package/bin/go/src/crypto/internal/fips140/aes/gcm/ghash.go +140 -124
  71. package/bin/go/src/crypto/internal/fips140/bigmod/nat.go +18 -0
  72. package/bin/go/src/crypto/internal/fips140/check/checktest/asm_loong64.s +23 -0
  73. package/bin/go/src/crypto/internal/fips140/check/checktest/asm_none.go +1 -1
  74. package/bin/go/src/crypto/internal/fips140/check/checktest/asm_stub.go +1 -1
  75. package/bin/go/src/crypto/internal/fips140/drbg/rand.go +12 -4
  76. package/bin/go/src/crypto/internal/fips140/ecdsa/ecdsa.go +17 -10
  77. package/bin/go/src/crypto/internal/fips140/edwards25519/field/_asm/fe_amd64_asm.go +0 -90
  78. package/bin/go/src/crypto/internal/fips140/edwards25519/field/fe.go +64 -97
  79. package/bin/go/src/crypto/internal/fips140/edwards25519/field/fe_amd64.go +0 -5
  80. package/bin/go/src/crypto/internal/fips140/edwards25519/field/fe_amd64.s +0 -167
  81. package/bin/go/src/crypto/internal/fips140/edwards25519/field/fe_amd64_noasm.go +0 -2
  82. package/bin/go/src/crypto/internal/fips140/edwards25519/field/fe_generic.go +57 -1
  83. package/bin/go/src/crypto/internal/fips140/edwards25519/scalarmult.go +3 -2
  84. package/bin/go/src/crypto/internal/fips140/mldsa/mldsa.go +31 -25
  85. package/bin/go/src/crypto/internal/fips140/mldsa/semiexpanded.go +2 -2
  86. package/bin/go/src/crypto/internal/fips140/nistec/_asm/go.mod +4 -4
  87. package/bin/go/src/crypto/internal/fips140/nistec/_asm/go.sum +6 -0
  88. package/bin/go/src/crypto/internal/fips140/nistec/_asm/p256_asm.go +1 -613
  89. package/bin/go/src/crypto/internal/fips140/nistec/p256.go +2 -2
  90. package/bin/go/src/crypto/internal/fips140/nistec/p256_asm.go +7 -6
  91. package/bin/go/src/crypto/internal/fips140/nistec/p256_asm_amd64.s +0 -503
  92. package/bin/go/src/crypto/internal/fips140/nistec/p256_asm_arm64.s +4 -429
  93. package/bin/go/src/crypto/internal/fips140/nistec/p256_ordinv.go +511 -47
  94. package/bin/go/src/crypto/internal/fips140/pbkdf2/pbkdf2.go +1 -1
  95. package/bin/go/src/crypto/internal/fips140/rsa/keygen.go +48 -46
  96. package/bin/go/src/crypto/internal/fips140/rsa/largeexponent.go +365 -0
  97. package/bin/go/src/crypto/internal/fips140/rsa/pkcs1v15.go +27 -0
  98. package/bin/go/src/crypto/internal/fips140/sha256/_asm/go.mod +1 -1
  99. package/bin/go/src/crypto/internal/fips140/sha3/_asm/go.mod +1 -1
  100. package/bin/go/src/crypto/internal/fips140/sha512/_asm/go.mod +1 -1
  101. package/bin/go/src/crypto/internal/fips140/subtle/constant_time.go +1 -1
  102. package/bin/go/src/crypto/internal/fips140/subtle/xor_asm.go +1 -1
  103. package/bin/go/src/crypto/internal/fips140/subtle/xor_riscv64.go +18 -0
  104. package/bin/go/src/crypto/internal/fips140/subtle/xor_riscv64.s +33 -2
  105. package/bin/go/src/crypto/internal/fips140deps/cpu/cpu.go +2 -0
  106. package/bin/go/src/crypto/internal/fips140deps/time/time.go +7 -4
  107. package/bin/go/src/crypto/internal/fips140only/fips140only.go +0 -7
  108. package/bin/go/src/crypto/internal/fips140only/random_fips140v1.0.go +17 -0
  109. package/bin/go/src/crypto/internal/fips140only/random_fips140v1.28.go +16 -0
  110. package/bin/go/src/crypto/internal/fips140test/acvp_capabilities_fips140v1.28.json +86 -0
  111. package/bin/go/src/crypto/internal/fips140test/acvp_test_fips140v1.28.config.json +58 -0
  112. package/bin/go/src/crypto/internal/rand/rand.go +14 -14
  113. package/bin/go/src/crypto/internal/rand/random_fips140v1.0.go +20 -0
  114. package/bin/go/src/crypto/internal/rand/random_fips140v1.28.go +19 -0
  115. package/bin/go/src/crypto/mldsa/mldsa.go +97 -0
  116. package/bin/go/src/crypto/mldsa/mldsa_fips140v1.0.go +116 -0
  117. package/bin/go/src/crypto/mldsa/mldsa_fips140v1.26.go +226 -0
  118. package/bin/go/src/crypto/mlkem/mlkem.go +8 -2
  119. package/bin/go/src/crypto/rsa/fips.go +26 -8
  120. package/bin/go/src/crypto/rsa/pkcs1v15.go +2 -2
  121. package/bin/go/src/crypto/rsa/rsa.go +25 -2
  122. package/bin/go/src/crypto/sha1/sha1block_decl.go +1 -1
  123. package/bin/go/src/crypto/sha1/sha1block_generic.go +1 -1
  124. package/bin/go/src/crypto/sha1/sha1block_loong64.s +24 -8
  125. package/bin/go/src/crypto/sha1/sha1block_riscv64.s +225 -0
  126. package/bin/go/src/crypto/sha3/sha3.go +3 -2
  127. package/bin/go/src/crypto/tls/alert.go +2 -0
  128. package/bin/go/src/crypto/tls/auth.go +31 -0
  129. package/bin/go/src/crypto/tls/bogo_config.json +12 -23
  130. package/bin/go/src/crypto/tls/cipher_suites.go +3 -11
  131. package/bin/go/src/crypto/tls/common.go +106 -59
  132. package/bin/go/src/crypto/tls/common_string.go +18 -5
  133. package/bin/go/src/crypto/tls/conn.go +33 -35
  134. package/bin/go/src/crypto/tls/defaults.go +26 -20
  135. package/bin/go/src/crypto/tls/defaults_fips140.go +9 -0
  136. package/bin/go/src/crypto/tls/ech.go +9 -4
  137. package/bin/go/src/crypto/tls/generate_cert.go +8 -2
  138. package/bin/go/src/crypto/tls/handshake_client.go +17 -17
  139. package/bin/go/src/crypto/tls/handshake_client_tls13.go +8 -3
  140. package/bin/go/src/crypto/tls/handshake_server.go +26 -19
  141. package/bin/go/src/crypto/tls/handshake_server_tls13.go +8 -5
  142. package/bin/go/src/crypto/tls/key_agreement.go +5 -1
  143. package/bin/go/src/crypto/tls/key_schedule.go +42 -17
  144. package/bin/go/src/crypto/tls/prf.go +1 -1
  145. package/bin/go/src/crypto/tls/quic.go +6 -7
  146. package/bin/go/src/crypto/tls/tls.go +25 -29
  147. package/bin/go/src/crypto/x509/cert_pool.go +8 -4
  148. package/bin/go/src/crypto/x509/constraints.go +5 -0
  149. package/bin/go/src/crypto/x509/parser.go +101 -15
  150. package/bin/go/src/crypto/x509/pkcs8.go +45 -4
  151. package/bin/go/src/crypto/x509/pkix/pkix.go +33 -9
  152. package/bin/go/src/crypto/x509/root.go +113 -0
  153. package/bin/go/src/crypto/x509/root_darwin.go +8 -4
  154. package/bin/go/src/crypto/x509/root_plan9.go +2 -23
  155. package/bin/go/src/crypto/x509/root_unix.go +0 -97
  156. package/bin/go/src/crypto/x509/root_windows.go +8 -3
  157. package/bin/go/src/crypto/x509/verify.go +43 -4
  158. package/bin/go/src/crypto/x509/x509.go +169 -30
  159. package/bin/go/src/database/sql/closemu.go +119 -0
  160. package/bin/go/src/database/sql/convert.go +63 -4
  161. package/bin/go/src/database/sql/driver/driver.go +26 -0
  162. package/bin/go/src/database/sql/driver/types.go +4 -0
  163. package/bin/go/src/database/sql/internal/sql.go +22 -0
  164. package/bin/go/src/database/sql/sql.go +89 -40
  165. package/bin/go/src/debug/buildinfo/buildinfo.go +0 -13
  166. package/bin/go/src/debug/dwarf/buf.go +7 -1
  167. package/bin/go/src/debug/dwarf/class_string.go +3 -2
  168. package/bin/go/src/debug/elf/file.go +80 -50
  169. package/bin/go/src/debug/elf/reader.go +1 -1
  170. package/bin/go/src/debug/gosym/symtab.go +26 -30
  171. package/bin/go/src/debug/macho/file.go +2 -2
  172. package/bin/go/src/debug/macho/reloctype_string.go +12 -8
  173. package/bin/go/src/debug/pe/file.go +6 -3
  174. package/bin/go/src/encoding/base32/base32.go +29 -31
  175. package/bin/go/src/encoding/base64/base64.go +24 -29
  176. package/bin/go/src/encoding/gob/decode.go +7 -1
  177. package/bin/go/src/encoding/gob/type.go +6 -6
  178. package/bin/go/src/encoding/hex/hex.go +6 -6
  179. package/bin/go/src/encoding/json/decode.go +4 -3
  180. package/bin/go/src/encoding/json/encode.go +1 -2
  181. package/bin/go/src/encoding/json/fold.go +1 -1
  182. package/bin/go/src/encoding/json/internal/internal.go +11 -1
  183. package/bin/go/src/encoding/json/internal/jsonflags/flags.go +17 -9
  184. package/bin/go/src/encoding/json/internal/jsonopts/options.go +52 -37
  185. package/bin/go/src/encoding/json/internal/jsonopts/options_format.go +124 -0
  186. package/bin/go/src/encoding/json/internal/jsontest/_embed/canada_geometry.json.zst +0 -0
  187. package/bin/go/src/encoding/json/internal/jsontest/_embed/citm_catalog.json.zst +0 -0
  188. package/bin/go/src/encoding/json/internal/jsontest/_embed/golang_source.json.zst +0 -0
  189. package/bin/go/src/encoding/json/internal/jsontest/_embed/string_escaped.json.zst +0 -0
  190. package/bin/go/src/encoding/json/internal/jsontest/_embed/string_unicode.json.zst +0 -0
  191. package/bin/go/src/encoding/json/internal/jsontest/_embed/synthea_fhir.json.zst +0 -0
  192. package/bin/go/src/encoding/json/internal/jsontest/_embed/twitter_status.json.zst +0 -0
  193. package/bin/go/src/encoding/json/internal/jsontest/testdata.go +10 -4
  194. package/bin/go/src/encoding/json/internal/jsonwire/decode.go +13 -36
  195. package/bin/go/src/encoding/json/internal/jsonwire/encode.go +7 -7
  196. package/bin/go/src/encoding/json/internal/jsonwire/wire.go +30 -38
  197. package/bin/go/src/encoding/json/jsontext/decode.go +49 -14
  198. package/bin/go/src/encoding/json/jsontext/doc.go +6 -11
  199. package/bin/go/src/encoding/json/jsontext/encode.go +55 -39
  200. package/bin/go/src/encoding/json/jsontext/errors.go +34 -3
  201. package/bin/go/src/encoding/json/jsontext/export.go +14 -0
  202. package/bin/go/src/encoding/json/jsontext/options.go +8 -8
  203. package/bin/go/src/encoding/json/jsontext/quote.go +2 -2
  204. package/bin/go/src/encoding/json/jsontext/state.go +14 -14
  205. package/bin/go/src/encoding/json/jsontext/token.go +246 -101
  206. package/bin/go/src/encoding/json/jsontext/value.go +31 -16
  207. package/bin/go/src/encoding/json/stream.go +14 -2
  208. package/bin/go/src/encoding/json/v2/arshal.go +100 -114
  209. package/bin/go/src/encoding/json/v2/arshal_any.go +6 -5
  210. package/bin/go/src/encoding/json/v2/arshal_default.go +292 -189
  211. package/bin/go/src/encoding/json/v2/{arshal_inlined.go → arshal_embedded.go} +14 -14
  212. package/bin/go/src/encoding/json/v2/arshal_funcs.go +28 -47
  213. package/bin/go/src/encoding/json/v2/arshal_methods.go +98 -29
  214. package/bin/go/src/encoding/json/v2/arshal_time.go +33 -13
  215. package/bin/go/src/encoding/json/v2/doc.go +40 -55
  216. package/bin/go/src/encoding/json/v2/errors.go +29 -9
  217. package/bin/go/src/encoding/json/v2/fields.go +83 -81
  218. package/bin/go/src/encoding/json/v2/intern.go +2 -2
  219. package/bin/go/src/encoding/json/v2/options.go +57 -41
  220. package/bin/go/src/encoding/json/v2_decode.go +21 -9
  221. package/bin/go/src/encoding/json/v2_encode.go +21 -10
  222. package/bin/go/src/encoding/json/v2_indent.go +2 -0
  223. package/bin/go/src/encoding/json/v2_inject.go +7 -4
  224. package/bin/go/src/encoding/json/v2_options.go +37 -30
  225. package/bin/go/src/encoding/json/v2_scanner.go +6 -1
  226. package/bin/go/src/encoding/json/v2_stream.go +49 -14
  227. package/bin/go/src/encoding/pem/pem.go +6 -2
  228. package/bin/go/src/fmt/doc.go +11 -1
  229. package/bin/go/src/fmt/print.go +69 -82
  230. package/bin/go/src/go/ast/ast.go +4 -4
  231. package/bin/go/src/go/ast/filter.go +1 -1
  232. package/bin/go/src/go/ast/scope.go +2 -2
  233. package/bin/go/src/go/build/build.go +1 -1
  234. package/bin/go/src/go/build/constraint/vers.go +4 -1
  235. package/bin/go/src/go/build/read.go +2 -2
  236. package/bin/go/src/go/constant/kind_string.go +3 -2
  237. package/bin/go/src/go/constant/value.go +26 -4
  238. package/bin/go/src/go/doc/comment/std.go +1 -0
  239. package/bin/go/src/go/importer/importer.go +4 -3
  240. package/bin/go/src/go/internal/gccgoimporter/parser.go +2 -0
  241. package/bin/go/src/go/internal/gcimporter/ureader.go +141 -56
  242. package/bin/go/src/go/parser/parser.go +11 -22
  243. package/bin/go/src/go/printer/math.go +28 -0
  244. package/bin/go/src/go/printer/nodes.go +28 -11
  245. package/bin/go/src/go/printer/printer.go +3 -1
  246. package/bin/go/src/go/scanner/errors.go +2 -0
  247. package/bin/go/src/go/scanner/scanner.go +40 -28
  248. package/bin/go/src/go/token/position.go +7 -16
  249. package/bin/go/src/go/types/alias.go +0 -18
  250. package/bin/go/src/go/types/api.go +4 -10
  251. package/bin/go/src/go/types/api_predicates.go +2 -2
  252. package/bin/go/src/go/types/assignments.go +44 -38
  253. package/bin/go/src/go/types/builtins.go +199 -168
  254. package/bin/go/src/go/types/call.go +155 -138
  255. package/bin/go/src/go/types/check.go +0 -83
  256. package/bin/go/src/go/types/const.go +22 -10
  257. package/bin/go/src/go/types/conversions.go +19 -19
  258. package/bin/go/src/go/types/cycles.go +29 -42
  259. package/bin/go/src/go/types/decl.go +33 -81
  260. package/bin/go/src/go/types/expr.go +191 -183
  261. package/bin/go/src/go/types/gotype.go +1 -0
  262. package/bin/go/src/go/types/hash.go +309 -0
  263. package/bin/go/src/go/types/index.go +91 -61
  264. package/bin/go/src/go/types/infer.go +11 -11
  265. package/bin/go/src/go/types/instantiate.go +27 -15
  266. package/bin/go/src/go/types/interface.go +2 -2
  267. package/bin/go/src/go/types/literals.go +56 -32
  268. package/bin/go/src/go/types/lookup.go +31 -14
  269. package/bin/go/src/go/types/named.go +58 -54
  270. package/bin/go/src/go/types/object.go +4 -3
  271. package/bin/go/src/go/types/operand.go +50 -34
  272. package/bin/go/src/go/types/range.go +19 -16
  273. package/bin/go/src/go/types/recording.go +24 -7
  274. package/bin/go/src/go/types/resolver.go +16 -18
  275. package/bin/go/src/go/types/scope.go +1 -15
  276. package/bin/go/src/go/types/selection.go +3 -1
  277. package/bin/go/src/go/types/signature.go +10 -11
  278. package/bin/go/src/go/types/stmt.go +34 -28
  279. package/bin/go/src/go/types/subst.go +82 -5
  280. package/bin/go/src/go/types/trie.go +93 -0
  281. package/bin/go/src/go/types/typelists.go +28 -0
  282. package/bin/go/src/go/types/typestring.go +5 -9
  283. package/bin/go/src/go/types/typexpr.go +17 -28
  284. package/bin/go/src/go/types/unify.go +12 -3
  285. package/bin/go/src/go/types/universe.go +12 -40
  286. package/bin/go/src/go/types/version.go +4 -0
  287. package/bin/go/src/go.mod +5 -5
  288. package/bin/go/src/go.sum +8 -8
  289. package/bin/go/src/hash/maphash/hasher.go +139 -0
  290. package/bin/go/src/hash/maphash/maphash.go +59 -4
  291. package/bin/go/src/html/template/attr_string.go +3 -2
  292. package/bin/go/src/html/template/delim_string.go +3 -2
  293. package/bin/go/src/html/template/element_string.go +3 -2
  294. package/bin/go/src/html/template/jsctx_string.go +3 -2
  295. package/bin/go/src/html/template/state_string.go +3 -2
  296. package/bin/go/src/html/template/template.go +7 -4
  297. package/bin/go/src/html/template/transition.go +1 -1
  298. package/bin/go/src/html/template/urlpart_string.go +3 -2
  299. package/bin/go/src/image/format.go +9 -0
  300. package/bin/go/src/image/gif/reader.go +18 -0
  301. package/bin/go/src/image/jpeg/huffman.go +22 -3
  302. package/bin/go/src/image/jpeg/reader.go +54 -29
  303. package/bin/go/src/image/jpeg/scan.go +68 -38
  304. package/bin/go/src/image/png/writer.go +8 -0
  305. package/bin/go/src/index/suffixarray/suffixarray.go +14 -6
  306. package/bin/go/src/internal/abi/abi_generic.go +1 -1
  307. package/bin/go/src/internal/abi/abi_s390x.go +0 -2
  308. package/bin/go/src/internal/abi/compiletype.go +30 -0
  309. package/bin/go/src/internal/abi/iface.go +13 -1
  310. package/bin/go/src/internal/abi/map.go +21 -3
  311. package/bin/go/src/internal/abi/type.go +136 -27
  312. package/bin/go/src/internal/buildcfg/exp.go +8 -8
  313. package/bin/go/src/internal/buildcfg/zbootstrap.go +1 -1
  314. package/bin/go/src/internal/bytealg/bytealg.go +16 -16
  315. package/bin/go/src/internal/bytealg/compare_s390x.s +0 -24
  316. package/bin/go/src/internal/bytealg/equal_s390x.s +0 -18
  317. package/bin/go/src/internal/bytealg/indexbyte_arm64.s +28 -0
  318. package/bin/go/src/internal/bytealg/indexbyte_s390x.s +0 -33
  319. package/bin/go/src/internal/coverage/encodemeta/encode.go +1 -1
  320. package/bin/go/src/internal/cpu/cpu.go +22 -7
  321. package/bin/go/src/internal/cpu/cpu_arm64.go +8 -1
  322. package/bin/go/src/internal/cpu/cpu_arm64.s +7 -0
  323. package/bin/go/src/internal/cpu/cpu_arm64_darwin.go +2 -0
  324. package/bin/go/src/internal/cpu/cpu_arm64_freebsd.go +2 -1
  325. package/bin/go/src/internal/cpu/cpu_arm64_hwcap.go +2 -0
  326. package/bin/go/src/internal/cpu/cpu_arm64_openbsd.go +6 -1
  327. package/bin/go/src/internal/cpu/cpu_arm64_other.go +1 -1
  328. package/bin/go/src/internal/cpu/cpu_arm64_windows.go +26 -0
  329. package/bin/go/src/internal/cpu/cpu_loong64.go +14 -2
  330. package/bin/go/src/internal/cpu/cpu_riscv64.go +10 -0
  331. package/bin/go/src/internal/cpu/cpu_riscv64_linux.go +21 -0
  332. package/bin/go/src/internal/cpu/cpu_windows.go +20 -0
  333. package/bin/go/src/internal/cpu/cpu_x86.go +2 -0
  334. package/bin/go/src/internal/filepathlite/path_windows.go +30 -17
  335. package/bin/go/src/internal/fuzz/fuzz.go +5 -1
  336. package/bin/go/src/internal/fuzz/mutator.go +2 -2
  337. package/bin/go/src/internal/fuzz/worker.go +1 -1
  338. package/bin/go/src/internal/gate/gate.go +76 -0
  339. package/bin/go/src/internal/godebugs/table.go +29 -10
  340. package/bin/go/src/internal/goexperiment/exp_mapsplitgroup_off.go +8 -0
  341. package/bin/go/src/internal/goexperiment/exp_mapsplitgroup_on.go +8 -0
  342. package/bin/go/src/internal/goexperiment/flags.go +5 -3
  343. package/bin/go/src/internal/goversion/goversion.go +1 -1
  344. package/bin/go/src/internal/lazyregexp/lazyre.go +4 -0
  345. package/bin/go/src/internal/nettest/conn.go +437 -0
  346. package/bin/go/src/internal/nettest/listener.go +148 -0
  347. package/bin/go/src/internal/nettest/packetconn.go +250 -0
  348. package/bin/go/src/internal/nettest/queue.go +33 -0
  349. package/bin/go/src/internal/pkgbits/syncmarker_string.go +4 -4
  350. package/bin/go/src/internal/pkgbits/version.go +27 -1
  351. package/bin/go/src/internal/platform/supported.go +8 -10
  352. package/bin/go/src/internal/platform/zosarch.go +1 -3
  353. package/bin/go/src/internal/poll/fd_mutex.go +49 -10
  354. package/bin/go/src/internal/poll/fd_unix.go +6 -1
  355. package/bin/go/src/internal/poll/fd_windows.go +175 -191
  356. package/bin/go/src/internal/poll/fd_writev_libc.go +1 -1
  357. package/bin/go/src/internal/poll/fd_writev_unix.go +1 -1
  358. package/bin/go/src/internal/poll/file_plan9.go +4 -4
  359. package/bin/go/src/internal/poll/sendfile_windows.go +1 -3
  360. package/bin/go/src/internal/poll/splice_linux.go +1 -1
  361. package/bin/go/src/internal/profile/encode.go +1 -1
  362. package/bin/go/src/internal/profile/profile.go +5 -3
  363. package/bin/go/src/internal/profilerecord/profilerecord.go +2 -2
  364. package/bin/go/src/internal/reflectlite/value.go +1 -15
  365. package/bin/go/src/internal/runtime/atomic/atomic_386.go +0 -6
  366. package/bin/go/src/internal/runtime/atomic/atomic_amd64.go +0 -6
  367. package/bin/go/src/internal/runtime/atomic/atomic_andor_generic.go +0 -11
  368. package/bin/go/src/internal/runtime/atomic/atomic_arm.go +0 -6
  369. package/bin/go/src/internal/runtime/atomic/atomic_loong64.go +2 -2
  370. package/bin/go/src/internal/runtime/atomic/atomic_loong64.s +22 -11
  371. package/bin/go/src/internal/runtime/atomic/atomic_mipsx.go +0 -10
  372. package/bin/go/src/internal/runtime/atomic/atomic_riscv64.s +4 -4
  373. package/bin/go/src/internal/runtime/atomic/atomic_s390x.go +0 -6
  374. package/bin/go/src/internal/runtime/atomic/atomic_wasm.go +0 -31
  375. package/bin/go/src/internal/runtime/atomic/linkname.go +34 -0
  376. package/bin/go/src/internal/runtime/exithook/hooks.go +0 -4
  377. package/bin/go/src/internal/runtime/gc/scan/expand_amd64.s +2285 -2285
  378. package/bin/go/src/internal/runtime/gc/scan/mkasm.go +1 -1
  379. package/bin/go/src/internal/runtime/gc/scan/scan_amd64.go +2 -1
  380. package/bin/go/src/internal/runtime/gc/scan/scan_amd64.s +4 -2
  381. package/bin/go/src/internal/runtime/maps/group.go +22 -13
  382. package/bin/go/src/internal/runtime/maps/map.go +35 -14
  383. package/bin/go/src/internal/runtime/maps/memhash_386.s +408 -0
  384. package/bin/go/src/internal/runtime/maps/memhash_aes.go +38 -0
  385. package/bin/go/src/internal/runtime/maps/memhash_aes_asm.go +24 -0
  386. package/bin/go/src/internal/runtime/maps/memhash_aes_simd.go +49 -0
  387. package/bin/go/src/internal/runtime/maps/memhash_align_check.go +10 -0
  388. package/bin/go/src/internal/runtime/maps/memhash_align_nocheck.go +16 -0
  389. package/bin/go/src/internal/runtime/maps/memhash_amd64.s +426 -0
  390. package/bin/go/src/internal/runtime/maps/memhash_arm64.s +366 -0
  391. package/bin/go/src/internal/runtime/maps/memhash_noaes.go +43 -0
  392. package/bin/go/src/internal/runtime/maps/memhash_nosimd_amd64.s +33 -0
  393. package/bin/go/src/internal/runtime/maps/runtime.go +37 -88
  394. package/bin/go/src/internal/runtime/maps/runtime_alg.go +93 -0
  395. package/bin/go/src/internal/runtime/maps/runtime_fast32.go +111 -97
  396. package/bin/go/src/internal/runtime/maps/runtime_fast64.go +137 -98
  397. package/bin/go/src/internal/runtime/maps/runtime_faststr.go +96 -89
  398. package/bin/go/src/{runtime/hash32.go → internal/runtime/maps/runtime_hash32.go} +8 -10
  399. package/bin/go/src/{runtime/hash64.go → internal/runtime/maps/runtime_hash64.go} +8 -8
  400. package/bin/go/src/internal/runtime/maps/table.go +66 -3
  401. package/bin/go/src/internal/runtime/math/math.go +0 -21
  402. package/bin/go/src/internal/runtime/startlinetest/func_amd64.s +2 -1
  403. package/bin/go/src/internal/runtime/sys/dit_arm64.go +3 -0
  404. package/bin/go/src/internal/runtime/sys/dit_arm64.s +16 -3
  405. package/bin/go/src/internal/runtime/syscall/linux/asm_linux_s390x.s +0 -23
  406. package/bin/go/src/internal/runtime/syscall/windows/asm_windows_386.s +7 -4
  407. package/bin/go/src/internal/runtime/syscall/windows/asm_windows_amd64.s +10 -8
  408. package/bin/go/src/internal/runtime/syscall/windows/asm_windows_arm64.s +0 -1
  409. package/bin/go/src/internal/runtime/syscall/windows/defs_windows.go +4 -0
  410. package/bin/go/src/internal/runtime/syscall/windows/syscall_windows.go +7 -9
  411. package/bin/go/src/internal/strconv/atof.go +69 -42
  412. package/bin/go/src/internal/strconv/atoi.go +1 -0
  413. package/bin/go/src/internal/strconv/ftoa.go +329 -357
  414. package/bin/go/src/internal/strconv/itoa.go +53 -59
  415. package/bin/go/src/internal/strconv/pow10gen.go +15 -3
  416. package/bin/go/src/internal/strconv/pow10tab.go +670 -670
  417. package/bin/go/src/internal/strconv/uscale.go +290 -0
  418. package/bin/go/src/internal/stringslite/strings.go +14 -42
  419. package/bin/go/src/internal/syscall/unix/asm_openbsd.s +0 -2
  420. package/bin/go/src/internal/syscall/unix/at.go +1 -1
  421. package/bin/go/src/internal/syscall/unix/at_fstatat.go +1 -1
  422. package/bin/go/src/internal/syscall/unix/at_libc2.go +1 -1
  423. package/bin/go/src/internal/syscall/unix/at_openbsd.go +0 -2
  424. package/bin/go/src/internal/syscall/unix/faccessat_bsd.go +1 -1
  425. package/bin/go/src/internal/syscall/unix/faccessat_openbsd.go +0 -2
  426. package/bin/go/src/internal/syscall/windows/at_windows.go +5 -5
  427. package/bin/go/src/internal/syscall/windows/net_windows.go +1 -0
  428. package/bin/go/src/internal/syscall/windows/string_windows.go +6 -3
  429. package/bin/go/src/internal/syscall/windows/syscall_windows.go +2 -0
  430. package/bin/go/src/internal/syscall/windows/types_windows.go +89 -4
  431. package/bin/go/src/internal/syscall/windows/zsyscall_windows.go +7 -0
  432. package/bin/go/src/internal/testenv/testenv.go +24 -1
  433. package/bin/go/src/internal/trace/event.go +1 -1
  434. package/bin/go/src/internal/trace/tracev2/events.go +2 -0
  435. package/bin/go/src/internal/trace/traceviewer/pprof.go +1 -0
  436. package/bin/go/src/internal/types/errors/generrordocs.go +1 -1
  437. package/bin/go/src/io/fs/fs.go +4 -1
  438. package/bin/go/src/io/fs/glob.go +1 -1
  439. package/bin/go/src/io/fs/readdir.go +3 -3
  440. package/bin/go/src/io/fs/readfile.go +3 -3
  441. package/bin/go/src/io/fs/stat.go +1 -1
  442. package/bin/go/src/io/fs/sub.go +4 -2
  443. package/bin/go/src/iter/iter.go +2 -2
  444. package/bin/go/src/log/slog/handler.go +0 -1
  445. package/bin/go/src/log/slog/json_handler.go +7 -1
  446. package/bin/go/src/log/slog/logger.go +16 -0
  447. package/bin/go/src/log/slog/text_handler.go +10 -1
  448. package/bin/go/src/log/slog/value.go +1 -1
  449. package/bin/go/src/log/syslog/doc.go +5 -0
  450. package/bin/go/src/math/abs.go +1 -1
  451. package/bin/go/src/math/big/accuracy_string.go +4 -4
  452. package/bin/go/src/math/big/arith.go +1 -1
  453. package/bin/go/src/math/big/arith_loong64.s +2 -4
  454. package/bin/go/src/math/big/float.go +2 -0
  455. package/bin/go/src/math/big/ftoa.go +11 -5
  456. package/bin/go/src/math/big/int.go +84 -1
  457. package/bin/go/src/math/big/intconv.go +19 -4
  458. package/bin/go/src/math/big/internal/asmgen/loong64.go +2 -0
  459. package/bin/go/src/math/big/nat.go +68 -17
  460. package/bin/go/src/math/big/natdiv.go +8 -5
  461. package/bin/go/src/math/big/roundingmode_string.go +3 -2
  462. package/bin/go/src/math/copysign.go +1 -2
  463. package/bin/go/src/math/exp2_asm.go +1 -1
  464. package/bin/go/src/math/exp2_noasm.go +1 -1
  465. package/bin/go/src/math/exp_asm.go +1 -1
  466. package/bin/go/src/math/exp_loong64.s +4 -12
  467. package/bin/go/src/math/exp_noasm.go +1 -1
  468. package/bin/go/src/math/exp_riscv64.s +236 -0
  469. package/bin/go/src/math/nextafter.go +4 -2
  470. package/bin/go/src/math/pow10.go +1 -1
  471. package/bin/go/src/math/rand/v2/rand.go +14 -4
  472. package/bin/go/src/mime/type.go +3 -2
  473. package/bin/go/src/net/dial.go +10 -6
  474. package/bin/go/src/net/dnsclient_unix.go +37 -8
  475. package/bin/go/src/net/dnsconfig.go +6 -0
  476. package/bin/go/src/net/fd_plan9.go +13 -6
  477. package/bin/go/src/net/fd_unix.go +3 -7
  478. package/bin/go/src/net/fd_windows.go +4 -9
  479. package/bin/go/src/net/file_plan9.go +1 -1
  480. package/bin/go/src/net/file_posix.go +1 -5
  481. package/bin/go/src/net/http/client.go +21 -4
  482. package/bin/go/src/net/http/clientconn.go +20 -1
  483. package/bin/go/src/net/http/clone.go +1 -10
  484. package/bin/go/src/net/http/cookie.go +5 -6
  485. package/bin/go/src/net/http/cookiejar/jar.go +6 -4
  486. package/bin/go/src/net/http/fcgi/fcgi.go +1 -2
  487. package/bin/go/src/net/http/fs.go +8 -1
  488. package/bin/go/src/net/http/http.go +29 -12
  489. package/bin/go/src/net/http/http2.go +561 -0
  490. package/bin/go/src/net/http/httptest/server.go +305 -60
  491. package/bin/go/src/net/http/httptrace/trace.go +78 -27
  492. package/bin/go/src/net/http/httputil/reverseproxy.go +0 -30
  493. package/bin/go/src/net/http/internal/common.go +14 -0
  494. package/bin/go/src/net/http/internal/http2/api.go +161 -0
  495. package/bin/go/src/net/http/internal/http2/ascii.go +53 -0
  496. package/bin/go/src/net/http/internal/http2/ciphers.go +641 -0
  497. package/bin/go/src/net/http/internal/http2/client_conn_pool.go +285 -0
  498. package/bin/go/src/net/http/internal/http2/config.go +118 -0
  499. package/bin/go/src/net/http/internal/http2/databuffer.go +146 -0
  500. package/bin/go/src/net/http/internal/http2/errors.go +173 -0
  501. package/bin/go/src/net/http/internal/http2/flow.go +175 -0
  502. package/bin/go/src/net/http/internal/http2/frame.go +1905 -0
  503. package/bin/go/src/net/http/internal/http2/gotrack.go +181 -0
  504. package/bin/go/src/net/http/internal/http2/http2.go +403 -0
  505. package/bin/go/src/net/http/internal/http2/pipe.go +184 -0
  506. package/bin/go/src/net/http/internal/http2/server.go +3238 -0
  507. package/bin/go/src/net/http/internal/http2/transport.go +3267 -0
  508. package/bin/go/src/net/http/internal/http2/write.go +380 -0
  509. package/bin/go/src/net/http/internal/http2/writesched.go +289 -0
  510. package/bin/go/src/net/http/internal/http2/writesched_priority_rfc9218.go +224 -0
  511. package/bin/go/src/net/http/internal/http2/writesched_roundrobin.go +119 -0
  512. package/bin/go/src/net/http/internal/httpcommon/httpcommon.go +8 -0
  513. package/bin/go/src/net/http/internal/httpsfv/httpsfv.go +666 -0
  514. package/bin/go/src/net/http/internal/sniff.go +304 -0
  515. package/bin/go/src/net/http/omithttp2.go +28 -49
  516. package/bin/go/src/net/http/pprof/pprof.go +11 -17
  517. package/bin/go/src/net/http/request.go +30 -3
  518. package/bin/go/src/net/http/response.go +6 -2
  519. package/bin/go/src/net/http/server.go +366 -144
  520. package/bin/go/src/net/http/sniff.go +2 -289
  521. package/bin/go/src/net/http/transfer.go +64 -21
  522. package/bin/go/src/net/http/transport.go +288 -83
  523. package/bin/go/src/net/ip.go +4 -0
  524. package/bin/go/src/net/ipsock_plan9.go +4 -4
  525. package/bin/go/src/net/ipsock_posix.go +8 -2
  526. package/bin/go/src/net/lookup.go +10 -0
  527. package/bin/go/src/net/lookup_windows.go +1 -1
  528. package/bin/go/src/net/mail/message.go +8 -3
  529. package/bin/go/src/net/net.go +2 -0
  530. package/bin/go/src/net/netip/netip.go +68 -61
  531. package/bin/go/src/net/sock_posix.go +1 -4
  532. package/bin/go/src/net/textproto/reader.go +11 -3
  533. package/bin/go/src/net/udpsock_plan9.go +2 -7
  534. package/bin/go/src/net/unixsock.go +11 -3
  535. package/bin/go/src/net/url/url.go +33 -0
  536. package/bin/go/src/os/dir_darwin.go +7 -0
  537. package/bin/go/src/os/exec/exec.go +16 -2
  538. package/bin/go/src/os/exec.go +1 -0
  539. package/bin/go/src/os/file.go +8 -1
  540. package/bin/go/src/os/root_windows.go +5 -1
  541. package/bin/go/src/os/signal/doc.go +3 -2
  542. package/bin/go/src/os/signal/signal.go +18 -6
  543. package/bin/go/src/os/statat_unix.go +5 -1
  544. package/bin/go/src/path/filepath/path.go +4 -0
  545. package/bin/go/src/reflect/asm_s390x.s +0 -10
  546. package/bin/go/src/reflect/iter.go +13 -13
  547. package/bin/go/src/reflect/makefunc.go +2 -1
  548. package/bin/go/src/reflect/map.go +61 -18
  549. package/bin/go/src/reflect/type.go +63 -46
  550. package/bin/go/src/reflect/value.go +59 -16
  551. package/bin/go/src/regexp/exec.go +5 -5
  552. package/bin/go/src/regexp/regexp.go +382 -319
  553. package/bin/go/src/regexp/syntax/parse.go +19 -10
  554. package/bin/go/src/runtime/HACKING.md +19 -0
  555. package/bin/go/src/runtime/_mkmalloc/constants.go +6 -4
  556. package/bin/go/src/runtime/_mkmalloc/go.mod +1 -1
  557. package/bin/go/src/runtime/_mkmalloc/mkmalloc.go +405 -64
  558. package/bin/go/src/runtime/alg.go +21 -53
  559. package/bin/go/src/runtime/asm_386.s +11 -461
  560. package/bin/go/src/runtime/asm_amd64.s +30 -537
  561. package/bin/go/src/runtime/asm_arm.s +4 -39
  562. package/bin/go/src/runtime/asm_arm64.s +15 -428
  563. package/bin/go/src/runtime/asm_loong64.s +37 -47
  564. package/bin/go/src/runtime/asm_mips64x.s +15 -15
  565. package/bin/go/src/runtime/asm_mipsx.s +0 -15
  566. package/bin/go/src/runtime/asm_ppc64x.h +0 -16
  567. package/bin/go/src/runtime/asm_ppc64x.s +13 -59
  568. package/bin/go/src/runtime/asm_riscv64.s +30 -91
  569. package/bin/go/src/runtime/asm_s390x.s +49 -49
  570. package/bin/go/src/runtime/asm_wasm.s +0 -15
  571. package/bin/go/src/runtime/atomic_riscv64.s +1 -1
  572. package/bin/go/src/runtime/cgo/abi_riscv64.h +72 -0
  573. package/bin/go/src/runtime/cgo/asm_riscv64.s +7 -48
  574. package/bin/go/src/runtime/cgo/callbacks.go +0 -42
  575. package/bin/go/src/runtime/cgo/callbacks_unix.go +58 -0
  576. package/bin/go/src/runtime/cgo/cgo.go +6 -3
  577. package/bin/go/src/runtime/cgo/gcc_aix_ppc64.S +21 -9
  578. package/bin/go/src/runtime/cgo/gcc_android.c +0 -26
  579. package/bin/go/src/runtime/cgo/gcc_clearenv.c +1 -1
  580. package/bin/go/src/runtime/cgo/gcc_fatalf.c +14 -3
  581. package/bin/go/src/runtime/cgo/{gcc_libinit.c → gcc_libinit_unix.c} +18 -65
  582. package/bin/go/src/runtime/cgo/gcc_libinit_windows.c +23 -35
  583. package/bin/go/src/runtime/cgo/gcc_linux_ppc64x.S +16 -7
  584. package/bin/go/src/runtime/cgo/gcc_netbsd.c +8 -56
  585. package/bin/go/src/runtime/cgo/gcc_s390x.S +13 -4
  586. package/bin/go/src/runtime/cgo/gcc_sigaction.c +1 -1
  587. package/bin/go/src/runtime/cgo/gcc_unix.c +63 -0
  588. package/bin/go/src/runtime/cgo/gcc_util.c +0 -19
  589. package/bin/go/src/runtime/cgo/handle.go +3 -0
  590. package/bin/go/src/runtime/cgo/libcgo.h +7 -10
  591. package/bin/go/src/runtime/cgo/libcgo_unix.h +2 -10
  592. package/bin/go/src/runtime/cgo/pthread_unix.c +138 -0
  593. package/bin/go/src/runtime/cgo/sigaction.go +1 -1
  594. package/bin/go/src/runtime/cgo/windows.go +18 -1
  595. package/bin/go/src/runtime/cgo_ppc64x.go +1 -1
  596. package/bin/go/src/runtime/cgo_sigaction.go +1 -1
  597. package/bin/go/src/runtime/cgocall.go +10 -2
  598. package/bin/go/src/runtime/chan.go +2 -16
  599. package/bin/go/src/runtime/coro.go +2 -2
  600. package/bin/go/src/runtime/cpuflags.go +4 -3
  601. package/bin/go/src/runtime/debug/garbage.go +6 -6
  602. package/bin/go/src/runtime/debug/mod.go +1 -1
  603. package/bin/go/src/runtime/debug/stack.go +1 -1
  604. package/bin/go/src/runtime/debugcall.go +0 -3
  605. package/bin/go/src/runtime/error.go +6 -0
  606. package/bin/go/src/runtime/extern.go +5 -3
  607. package/bin/go/src/runtime/heapdump.go +1 -1
  608. package/bin/go/src/runtime/iface.go +20 -10
  609. package/bin/go/src/runtime/libinit.go +48 -0
  610. package/bin/go/src/runtime/lock_js.go +4 -2
  611. package/bin/go/src/runtime/lock_spinbit.go +13 -12
  612. package/bin/go/src/runtime/lock_wasip1.go +4 -2
  613. package/bin/go/src/runtime/lockrank.go +24 -21
  614. package/bin/go/src/runtime/lockrank_off.go +5 -2
  615. package/bin/go/src/runtime/lockrank_on.go +8 -7
  616. package/bin/go/src/runtime/malloc.go +10 -26
  617. package/bin/go/src/runtime/malloc_generated.go +819 -8628
  618. package/bin/go/src/runtime/malloc_stubs.go +187 -197
  619. package/bin/go/src/runtime/malloc_tables_generated.go +16 -882
  620. package/bin/go/src/runtime/map.go +4 -4
  621. package/bin/go/src/runtime/mbitmap.go +3 -1
  622. package/bin/go/src/runtime/mem.go +2 -6
  623. package/bin/go/src/runtime/mem_sbrk.go +4 -0
  624. package/bin/go/src/runtime/memclr_s390x.s +0 -5
  625. package/bin/go/src/runtime/memmove_s390x.s +0 -7
  626. package/bin/go/src/runtime/metrics/doc.go +5 -29
  627. package/bin/go/src/runtime/metrics/sample.go +3 -0
  628. package/bin/go/src/runtime/metrics.go +3 -2
  629. package/bin/go/src/runtime/mgc.go +41 -25
  630. package/bin/go/src/runtime/mgcmark.go +5 -0
  631. package/bin/go/src/runtime/mgcmark_greenteagc.go +1 -1
  632. package/bin/go/src/runtime/mgcpacer.go +1 -3
  633. package/bin/go/src/runtime/mgcscavenge.go +1 -1
  634. package/bin/go/src/runtime/mheap.go +1 -10
  635. package/bin/go/src/runtime/mklockrank.go +6 -1
  636. package/bin/go/src/runtime/mkpreempt.go +7 -0
  637. package/bin/go/src/runtime/mprof.go +12 -23
  638. package/bin/go/src/runtime/os2_aix.go +3 -3
  639. package/bin/go/src/runtime/os3_solaris.go +10 -0
  640. package/bin/go/src/runtime/os_aix.go +9 -2
  641. package/bin/go/src/runtime/os_darwin.go +3 -8
  642. package/bin/go/src/runtime/os_dragonfly.go +10 -0
  643. package/bin/go/src/runtime/os_js.go +10 -0
  644. package/bin/go/src/runtime/os_linux32.go +19 -6
  645. package/bin/go/src/runtime/os_netbsd.go +10 -0
  646. package/bin/go/src/runtime/os_openbsd.go +10 -0
  647. package/bin/go/src/runtime/os_plan9.go +10 -0
  648. package/bin/go/src/runtime/os_wasip1.go +10 -0
  649. package/bin/go/src/runtime/os_windows.go +45 -12
  650. package/bin/go/src/runtime/os_workdir_ios_arm64.go +98 -0
  651. package/bin/go/src/runtime/os_workdir_stub.go +9 -0
  652. package/bin/go/src/runtime/panic.go +93 -8
  653. package/bin/go/src/runtime/plugin.go +1 -3
  654. package/bin/go/src/runtime/pprof/pprof.go +11 -14
  655. package/bin/go/src/runtime/pprof/protomem.go +8 -15
  656. package/bin/go/src/runtime/preempt_loong64.s +8 -4
  657. package/bin/go/src/runtime/preempt_noxreg.go +2 -0
  658. package/bin/go/src/runtime/preempt_xreg.go +29 -2
  659. package/bin/go/src/runtime/print.go +9 -1
  660. package/bin/go/src/runtime/proc.go +68 -17
  661. package/bin/go/src/runtime/race_riscv64.s +40 -83
  662. package/bin/go/src/runtime/race_s390x.s +0 -16
  663. package/bin/go/src/runtime/rand.go +40 -12
  664. package/bin/go/src/runtime/{rt0_linux_ppc64le.s → rt0_linux_ppc64x.s} +12 -2
  665. package/bin/go/src/runtime/runtime-gdb.py +13 -2
  666. package/bin/go/src/runtime/runtime1.go +69 -18
  667. package/bin/go/src/runtime/runtime2.go +23 -22
  668. package/bin/go/src/runtime/secret/secret.go +7 -2
  669. package/bin/go/src/runtime/secret.go +27 -9
  670. package/bin/go/src/runtime/secret_nosecret.go +1 -1
  671. package/bin/go/src/runtime/sigaction.go +1 -1
  672. package/bin/go/src/runtime/signal_unix.go +5 -3
  673. package/bin/go/src/runtime/softfloat64.go +7 -2
  674. package/bin/go/src/runtime/string.go +4 -1
  675. package/bin/go/src/runtime/stubs.go +14 -4
  676. package/bin/go/src/runtime/stubs_amd64.go +4 -0
  677. package/bin/go/src/runtime/stubs_arm.go +10 -1
  678. package/bin/go/src/runtime/stubs_arm64.go +13 -0
  679. package/bin/go/src/runtime/stubs_loong64.go +18 -0
  680. package/bin/go/src/runtime/stubs_mips64x.go +9 -0
  681. package/bin/go/src/runtime/stubs_mipsx.go +11 -0
  682. package/bin/go/src/runtime/stubs_ppc64x.go +15 -0
  683. package/bin/go/src/runtime/stubs_riscv64.go +13 -0
  684. package/bin/go/src/runtime/stubs_s390x.go +18 -0
  685. package/bin/go/src/runtime/symtab.go +15 -16
  686. package/bin/go/src/runtime/synctest.go +2 -4
  687. package/bin/go/src/runtime/sys_aix_ppc64.s +9 -0
  688. package/bin/go/src/runtime/sys_darwin.go +2 -20
  689. package/bin/go/src/runtime/sys_darwin_amd64.s +1 -4
  690. package/bin/go/src/runtime/sys_darwin_arm64.s +3 -6
  691. package/bin/go/src/runtime/sys_freebsd_riscv64.s +2 -2
  692. package/bin/go/src/runtime/sys_ios_arm64.go +151 -0
  693. package/bin/go/src/runtime/sys_ios_arm64.s +78 -0
  694. package/bin/go/src/runtime/sys_linux_amd64.s +7 -1
  695. package/bin/go/src/runtime/sys_linux_loong64.s +8 -14
  696. package/bin/go/src/runtime/sys_linux_ppc64x.s +0 -12
  697. package/bin/go/src/runtime/sys_linux_riscv64.s +2 -2
  698. package/bin/go/src/runtime/sys_openbsd.go +1 -1
  699. package/bin/go/src/runtime/sys_openbsd_riscv64.s +16 -16
  700. package/bin/go/src/runtime/syscall_windows.go +2 -6
  701. package/bin/go/src/runtime/time.go +19 -57
  702. package/bin/go/src/runtime/trace/subscribe.go +0 -3
  703. package/bin/go/src/runtime/traceback.go +90 -13
  704. package/bin/go/src/runtime/traceregion.go +3 -3
  705. package/bin/go/src/runtime/tracestring.go +5 -0
  706. package/bin/go/src/runtime/type.go +85 -15
  707. package/bin/go/src/runtime/utf8.go +2 -2
  708. package/bin/go/src/simd/archsimd/_gen/go.mod +2 -2
  709. package/bin/go/src/simd/archsimd/_gen/go.sum +2 -2
  710. package/bin/go/src/simd/archsimd/_gen/main.go +106 -15
  711. package/bin/go/src/simd/archsimd/_gen/midway/comments.yaml +151 -0
  712. package/bin/go/src/simd/archsimd/_gen/midway/intersect_simd_ops.go +836 -0
  713. package/bin/go/src/simd/archsimd/_gen/sgutil/asbits.go +139 -0
  714. package/bin/go/src/simd/archsimd/_gen/sgutil/compare_natural.go +73 -0
  715. package/bin/go/src/simd/archsimd/_gen/sgutil/formatted_files.go +66 -0
  716. package/bin/go/src/simd/archsimd/_gen/sgutil/insert_ordered_map.go +159 -0
  717. package/bin/go/src/simd/archsimd/_gen/sgutil/merge_generic_ops.go +245 -0
  718. package/bin/go/src/simd/archsimd/_gen/simdgen/arch.go +173 -0
  719. package/bin/go/src/simd/archsimd/_gen/simdgen/arm64/emit.go +166 -0
  720. package/bin/go/src/simd/archsimd/_gen/simdgen/arm64/instruction.go +642 -0
  721. package/bin/go/src/simd/archsimd/_gen/simdgen/arm64/load.go +54 -0
  722. package/bin/go/src/simd/archsimd/_gen/simdgen/arm64/operands.go +406 -0
  723. package/bin/go/src/simd/archsimd/_gen/simdgen/etetest.sh +1 -1
  724. package/bin/go/src/simd/archsimd/_gen/simdgen/gen_simdGenericOps.go +19 -52
  725. package/bin/go/src/simd/archsimd/_gen/simdgen/gen_simdIntrinsics.go +162 -98
  726. package/bin/go/src/simd/archsimd/_gen/simdgen/gen_simdMachineOps.go +50 -19
  727. package/bin/go/src/simd/archsimd/_gen/simdgen/gen_simdTypes.go +198 -140
  728. package/bin/go/src/simd/archsimd/_gen/simdgen/gen_simdrules.go +278 -57
  729. package/bin/go/src/simd/archsimd/_gen/simdgen/gen_simdssa.go +133 -68
  730. package/bin/go/src/simd/archsimd/_gen/simdgen/gen_utility.go +163 -30
  731. package/bin/go/src/simd/archsimd/_gen/simdgen/go_amd64.yaml +1 -0
  732. package/bin/go/src/simd/archsimd/_gen/simdgen/go_arm64.yaml +1 -0
  733. package/bin/go/src/simd/archsimd/_gen/simdgen/godefs.go +113 -15
  734. package/bin/go/src/simd/archsimd/_gen/simdgen/main.go +62 -17
  735. package/bin/go/src/simd/archsimd/_gen/simdgen/ops/AddSub/categories.yaml +12 -12
  736. package/bin/go/src/simd/archsimd/_gen/simdgen/ops/AddSub/{go.yaml → go_amd64.yaml} +12 -12
  737. package/bin/go/src/simd/archsimd/_gen/simdgen/ops/AddSub/go_arm64.yaml +91 -0
  738. package/bin/go/src/simd/archsimd/_gen/simdgen/ops/BitwiseLogic/categories.yaml +11 -3
  739. package/bin/go/src/simd/archsimd/_gen/simdgen/ops/BitwiseLogic/go_arm64.yaml +43 -0
  740. package/bin/go/src/simd/archsimd/_gen/simdgen/ops/Compares/go_arm64.yaml +81 -0
  741. package/bin/go/src/simd/archsimd/_gen/simdgen/ops/Converts/categories.yaml +11 -6
  742. package/bin/go/src/simd/archsimd/_gen/simdgen/ops/Converts/{go.yaml → go_amd64.yaml} +8 -8
  743. package/bin/go/src/simd/archsimd/_gen/simdgen/ops/Converts/go_arm64.yaml +358 -0
  744. package/bin/go/src/simd/archsimd/_gen/simdgen/ops/FPonlyArith/categories.yaml +5 -5
  745. package/bin/go/src/simd/archsimd/_gen/simdgen/ops/FPonlyArith/{go.yaml → go_amd64.yaml} +4 -4
  746. package/bin/go/src/simd/archsimd/_gen/simdgen/ops/FPonlyArith/go_arm64.yaml +52 -0
  747. package/bin/go/src/simd/archsimd/_gen/simdgen/ops/GaloisField/categories.yaml +29 -11
  748. package/bin/go/src/simd/archsimd/_gen/simdgen/ops/GaloisField/{go.yaml → go_amd64.yaml} +1 -0
  749. package/bin/go/src/simd/archsimd/_gen/simdgen/ops/GaloisField/go_arm64.yaml +10 -0
  750. package/bin/go/src/simd/archsimd/_gen/simdgen/ops/IntOnlyArith/categories.yaml +2 -5
  751. package/bin/go/src/simd/archsimd/_gen/simdgen/ops/IntOnlyArith/{go.yaml → go_amd64.yaml} +2 -3
  752. package/bin/go/src/simd/archsimd/_gen/simdgen/ops/IntOnlyArith/go_arm64.yaml +35 -0
  753. package/bin/go/src/simd/archsimd/_gen/simdgen/ops/MLOps/categories.yaml +5 -8
  754. package/bin/go/src/simd/archsimd/_gen/simdgen/ops/MLOps/{go.yaml → go_amd64.yaml} +7 -5
  755. package/bin/go/src/simd/archsimd/_gen/simdgen/ops/MLOps/go_arm64.yaml +31 -0
  756. package/bin/go/src/simd/archsimd/_gen/simdgen/ops/MinMax/go_arm64.yaml +61 -0
  757. package/bin/go/src/simd/archsimd/_gen/simdgen/ops/Moves/categories.yaml +79 -23
  758. package/bin/go/src/simd/archsimd/_gen/simdgen/ops/Moves/{go.yaml → go_amd64.yaml} +213 -104
  759. package/bin/go/src/simd/archsimd/_gen/simdgen/ops/Moves/go_arm64.yaml +264 -0
  760. package/bin/go/src/simd/archsimd/_gen/simdgen/ops/Mul/categories.yaml +6 -2
  761. package/bin/go/src/simd/archsimd/_gen/simdgen/ops/Mul/{go.yaml → go_amd64.yaml} +3 -3
  762. package/bin/go/src/simd/archsimd/_gen/simdgen/ops/Mul/go_arm64.yaml +38 -0
  763. package/bin/go/src/simd/archsimd/_gen/simdgen/ops/NegAbs/categories.yaml +7 -0
  764. package/bin/go/src/simd/archsimd/_gen/simdgen/ops/NegAbs/go_arm64.yaml +36 -0
  765. package/bin/go/src/simd/archsimd/_gen/simdgen/ops/Others/categories.yaml +5 -1
  766. package/bin/go/src/simd/archsimd/_gen/simdgen/ops/Others/go_arm64.yaml +19 -0
  767. package/bin/go/src/simd/archsimd/_gen/simdgen/ops/Reduce/categories.yaml +16 -0
  768. package/bin/go/src/simd/archsimd/_gen/simdgen/ops/Reduce/go_arm64.yaml +71 -0
  769. package/bin/go/src/simd/archsimd/_gen/simdgen/ops/ShiftRotate/categories.yaml +156 -41
  770. package/bin/go/src/simd/archsimd/_gen/simdgen/ops/ShiftRotate/go_amd64.yaml +299 -0
  771. package/bin/go/src/simd/archsimd/_gen/simdgen/ops/ShiftRotate/go_arm64.yaml +202 -0
  772. package/bin/go/src/simd/archsimd/_gen/simdgen/types.yaml +2 -0
  773. package/bin/go/src/simd/archsimd/_gen/simdgen/xed.go +44 -11
  774. package/bin/go/src/simd/archsimd/_gen/tmplgen/main.go +668 -123
  775. package/bin/go/src/simd/archsimd/_gen/unify/closure.go +1 -1
  776. package/bin/go/src/simd/archsimd/_gen/unify/env.go +35 -3
  777. package/bin/go/src/simd/archsimd/_gen/unify/yaml.go +4 -4
  778. package/bin/go/src/simd/archsimd/_gen/wasmgen/main.go +2064 -0
  779. package/bin/go/src/simd/archsimd/clmul_arm64.go +79 -0
  780. package/bin/go/src/simd/archsimd/clmul_emulated.go +103 -0
  781. package/bin/go/src/simd/archsimd/compare_gen_arm64.go +155 -0
  782. package/bin/go/src/simd/archsimd/cpu.go +1 -1
  783. package/bin/go/src/simd/archsimd/cpu_other.go +21 -0
  784. package/bin/go/src/simd/archsimd/doc.go +0 -2
  785. package/bin/go/src/simd/archsimd/dummy.s +1 -1
  786. package/bin/go/src/simd/archsimd/generate.go +1 -1
  787. package/bin/go/src/simd/archsimd/internal/test_helpers/checkslices.go +2 -2
  788. package/bin/go/src/simd/archsimd/maskmerge_gen_amd64.go +330 -0
  789. package/bin/go/src/simd/archsimd/maskmerge_gen_arm64.go +167 -0
  790. package/bin/go/src/simd/archsimd/ops_amd64.go +4210 -2475
  791. package/bin/go/src/simd/archsimd/ops_arm64.go +2186 -0
  792. package/bin/go/src/simd/archsimd/ops_emulated_amd64.go +205 -0
  793. package/bin/go/src/simd/archsimd/ops_emulated_wasm.go +212 -0
  794. package/bin/go/src/simd/archsimd/ops_internal_amd64.go +500 -56
  795. package/bin/go/src/simd/archsimd/ops_internal_arm64.go +234 -0
  796. package/bin/go/src/simd/archsimd/ops_wasm.go +1795 -0
  797. package/bin/go/src/simd/archsimd/other_gen_amd64.go +576 -72
  798. package/bin/go/src/simd/archsimd/other_gen_arm64.go +519 -0
  799. package/bin/go/src/simd/archsimd/shuffles_amd64.go +217 -76
  800. package/bin/go/src/simd/archsimd/slice_gen_amd64.go +594 -532
  801. package/bin/go/src/simd/archsimd/slice_gen_arm64.go +125 -0
  802. package/bin/go/src/simd/archsimd/slicepart_128.go +302 -0
  803. package/bin/go/src/simd/archsimd/slicepart_amd64.go +36 -235
  804. package/bin/go/src/simd/archsimd/slicepart_arm64.go +217 -0
  805. package/bin/go/src/simd/archsimd/slicepart_wasm.go +217 -0
  806. package/bin/go/src/simd/archsimd/string.go +1 -1
  807. package/bin/go/src/simd/archsimd/types_amd64.go +165 -341
  808. package/bin/go/src/simd/archsimd/types_arm64.go +224 -0
  809. package/bin/go/src/simd/archsimd/types_wasm.go +354 -0
  810. package/bin/go/src/simd/archsimd/unsafe_helpers.go +60 -0
  811. package/bin/go/src/simd/doc.go +91 -0
  812. package/bin/go/src/simd/dummy.s +7 -0
  813. package/bin/go/src/simd/internal/bridge/decls_amd64.go +4085 -0
  814. package/bin/go/src/simd/internal/bridge/decls_arm64.go +1369 -0
  815. package/bin/go/src/simd/internal/bridge/decls_wasm.go +1369 -0
  816. package/bin/go/src/simd/internal/bridge/import_hook.go +13 -0
  817. package/bin/go/src/simd/internal/bridge/simd_emulated.go +3275 -0
  818. package/bin/go/src/simd/internal/bridge/simd_types_emulated.go +95 -0
  819. package/bin/go/src/simd/internal/bridge/tofrom_128.go +65 -0
  820. package/bin/go/src/simd/internal/bridge/tofrom_amd64.go +123 -0
  821. package/bin/go/src/simd/internal/bridge/tofrom_emulated.go +63 -0
  822. package/bin/go/src/simd/midway_amd64.go +34 -0
  823. package/bin/go/src/simd/midway_arm64.go +22 -0
  824. package/bin/go/src/simd/midway_common.go +138 -0
  825. package/bin/go/src/simd/midway_wasm.go +13 -0
  826. package/bin/go/src/simd/simd_emulated.go +3275 -0
  827. package/bin/go/src/simd/simd_stubs.go +1041 -0
  828. package/bin/go/src/simd/simd_types.go +96 -0
  829. package/bin/go/src/simd/tofrom_amd64.go +374 -0
  830. package/bin/go/src/simd/tofrom_arm64.go +290 -0
  831. package/bin/go/src/simd/tofrom_wasm.go +290 -0
  832. package/bin/go/src/slices/slices.go +9 -7
  833. package/bin/go/src/strconv/isprint.go +81 -51
  834. package/bin/go/src/strings/builder.go +1 -1
  835. package/bin/go/src/strings/strings.go +44 -35
  836. package/bin/go/src/sync/atomic/doc.go +7 -0
  837. package/bin/go/src/sync/cond.go +4 -2
  838. package/bin/go/src/sync/pool.go +6 -15
  839. package/bin/go/src/sync/runtime2_lockrank.go +1 -2
  840. package/bin/go/src/syscall/exec_bsd.go +3 -3
  841. package/bin/go/src/syscall/exec_libc2.go +1 -1
  842. package/bin/go/src/syscall/exec_linux.go +7 -2
  843. package/bin/go/src/syscall/fs_js.go +9 -4
  844. package/bin/go/src/syscall/fs_wasip1.go +6 -0
  845. package/bin/go/src/syscall/js/js.go +2 -2
  846. package/bin/go/src/syscall/linkname_bsd.go +8 -0
  847. package/bin/go/src/syscall/linkname_libc.go +1 -1
  848. package/bin/go/src/syscall/linkname_openbsd.go +0 -2
  849. package/bin/go/src/syscall/mkall.sh +6 -17
  850. package/bin/go/src/syscall/syscall_aix.go +5 -0
  851. package/bin/go/src/syscall/syscall_linux_386.go +9 -0
  852. package/bin/go/src/syscall/syscall_linux_amd64.go +5 -0
  853. package/bin/go/src/syscall/syscall_linux_arm.go +4 -0
  854. package/bin/go/src/syscall/syscall_linux_arm64.go +3 -0
  855. package/bin/go/src/syscall/syscall_linux_loong64.go +3 -0
  856. package/bin/go/src/syscall/syscall_linux_mipsx.go +4 -0
  857. package/bin/go/src/syscall/syscall_linux_riscv64.go +3 -0
  858. package/bin/go/src/syscall/syscall_linux_s390x.go +5 -0
  859. package/bin/go/src/syscall/syscall_openbsd.go +77 -2
  860. package/bin/go/src/syscall/syscall_plan9.go +25 -0
  861. package/bin/go/src/syscall/syscall_solaris.go +11 -0
  862. package/bin/go/src/syscall/syscall_unix.go +19 -0
  863. package/bin/go/src/syscall/syscall_windows.go +1 -1
  864. package/bin/go/src/testing/synctest/synctest.go +21 -0
  865. package/bin/go/src/testing/testing.go +211 -52
  866. package/bin/go/src/text/template/parse/lex.go +6 -6
  867. package/bin/go/src/text/template/parse/node.go +21 -16
  868. package/bin/go/src/text/template/parse/parse.go +23 -6
  869. package/bin/go/src/text/template/template.go +5 -3
  870. package/bin/go/src/time/format.go +3 -0
  871. package/bin/go/src/time/sleep.go +0 -33
  872. package/bin/go/src/time/tick.go +3 -2
  873. package/bin/go/src/time/time.go +2 -2
  874. package/bin/go/src/time/tzdata/zzipdata.go +1 -1
  875. package/bin/go/src/time/zoneinfo.go +5 -4
  876. package/bin/go/src/time/zoneinfo_read.go +1 -1
  877. package/bin/go/src/unicode/tables.go +898 -417
  878. package/bin/go/src/uuid/uuid.go +273 -0
  879. package/bin/go/src/vendor/golang.org/x/crypto/chacha20poly1305/chacha20poly1305_amd64.go +3 -3
  880. package/bin/go/src/vendor/golang.org/x/crypto/chacha20poly1305/chacha20poly1305_amd64.s +2066 -6598
  881. package/bin/go/src/vendor/golang.org/x/crypto/hkdf/hkdf.go +100 -0
  882. package/bin/go/src/vendor/golang.org/x/net/dns/dnsmessage/message.go +5 -4
  883. package/bin/go/src/vendor/golang.org/x/net/http/httpproxy/proxy.go +4 -4
  884. package/bin/go/src/vendor/golang.org/x/net/http3/http3.go +46 -0
  885. package/bin/go/src/vendor/golang.org/x/net/idna/{idna10.0.0.go → idna.go} +133 -35
  886. package/bin/go/src/vendor/golang.org/x/net/idna/punycode.go +4 -1
  887. package/bin/go/src/vendor/golang.org/x/net/idna/tables15.0.0.go +1 -1
  888. package/bin/go/src/vendor/golang.org/x/net/idna/tables17.0.0.go +5302 -0
  889. package/bin/go/src/vendor/golang.org/x/net/internal/http3/body.go +231 -0
  890. package/bin/go/src/vendor/golang.org/x/net/internal/http3/conn.go +131 -0
  891. package/bin/go/src/vendor/golang.org/x/net/internal/http3/doc.go +10 -0
  892. package/bin/go/src/vendor/golang.org/x/net/internal/http3/errors.go +102 -0
  893. package/bin/go/src/vendor/golang.org/x/net/internal/http3/http3.go +95 -0
  894. package/bin/go/src/vendor/golang.org/x/net/internal/http3/qpack.go +356 -0
  895. package/bin/go/src/vendor/golang.org/x/net/internal/http3/qpack_decode.go +81 -0
  896. package/bin/go/src/vendor/golang.org/x/net/internal/http3/qpack_encode.go +61 -0
  897. package/bin/go/src/vendor/golang.org/x/net/internal/http3/qpack_static.go +142 -0
  898. package/bin/go/src/vendor/golang.org/x/net/internal/http3/quic.go +40 -0
  899. package/bin/go/src/vendor/golang.org/x/net/internal/http3/roundtrip.go +423 -0
  900. package/bin/go/src/vendor/golang.org/x/net/internal/http3/server.go +866 -0
  901. package/bin/go/src/vendor/golang.org/x/net/internal/http3/settings.go +66 -0
  902. package/bin/go/src/vendor/golang.org/x/net/internal/http3/stream.go +260 -0
  903. package/bin/go/src/vendor/golang.org/x/net/internal/http3/transport.go +333 -0
  904. package/bin/go/src/vendor/golang.org/x/net/internal/http3/varint.go +23 -0
  905. package/bin/go/src/vendor/golang.org/x/net/internal/httpcommon/ascii.go +53 -0
  906. package/bin/go/src/vendor/golang.org/x/net/internal/httpcommon/headermap.go +115 -0
  907. package/bin/go/src/vendor/golang.org/x/net/internal/httpcommon/request.go +475 -0
  908. package/bin/go/src/vendor/golang.org/x/net/internal/quic/quicwire/wire.go +150 -0
  909. package/bin/go/src/vendor/golang.org/x/net/quic/ack_delay.go +26 -0
  910. package/bin/go/src/vendor/golang.org/x/net/quic/acks.go +213 -0
  911. package/bin/go/src/vendor/golang.org/x/net/quic/atomic_bits.go +31 -0
  912. package/bin/go/src/vendor/golang.org/x/net/quic/config.go +158 -0
  913. package/bin/go/src/vendor/golang.org/x/net/quic/congestion_reno.go +306 -0
  914. package/bin/go/src/vendor/golang.org/x/net/quic/conn.go +434 -0
  915. package/bin/go/src/vendor/golang.org/x/net/quic/conn_close.go +340 -0
  916. package/bin/go/src/vendor/golang.org/x/net/quic/conn_flow.go +142 -0
  917. package/bin/go/src/vendor/golang.org/x/net/quic/conn_id.go +502 -0
  918. package/bin/go/src/vendor/golang.org/x/net/quic/conn_loss.go +85 -0
  919. package/bin/go/src/vendor/golang.org/x/net/quic/conn_recv.go +631 -0
  920. package/bin/go/src/vendor/golang.org/x/net/quic/conn_send.go +407 -0
  921. package/bin/go/src/vendor/golang.org/x/net/quic/conn_streams.go +483 -0
  922. package/bin/go/src/vendor/golang.org/x/net/quic/crypto_stream.go +157 -0
  923. package/bin/go/src/vendor/golang.org/x/net/quic/dgram.go +53 -0
  924. package/bin/go/src/vendor/golang.org/x/net/quic/doc.go +50 -0
  925. package/bin/go/src/vendor/golang.org/x/net/quic/endpoint.go +478 -0
  926. package/bin/go/src/vendor/golang.org/x/net/quic/errors.go +129 -0
  927. package/bin/go/src/vendor/golang.org/x/net/quic/frame_debug.go +730 -0
  928. package/bin/go/src/vendor/golang.org/x/net/quic/gate.go +86 -0
  929. package/bin/go/src/vendor/golang.org/x/net/quic/idle.go +168 -0
  930. package/bin/go/src/vendor/golang.org/x/net/quic/log.go +67 -0
  931. package/bin/go/src/vendor/golang.org/x/net/quic/loss.go +521 -0
  932. package/bin/go/src/{runtime/cgo/gcc_stack_windows.c → vendor/golang.org/x/net/quic/math.go} +7 -2
  933. package/bin/go/src/vendor/golang.org/x/net/quic/pacer.go +129 -0
  934. package/bin/go/src/vendor/golang.org/x/net/quic/packet.go +267 -0
  935. package/bin/go/src/vendor/golang.org/x/net/quic/packet_number.go +72 -0
  936. package/bin/go/src/vendor/golang.org/x/net/quic/packet_parser.go +519 -0
  937. package/bin/go/src/vendor/golang.org/x/net/quic/packet_protection.go +539 -0
  938. package/bin/go/src/vendor/golang.org/x/net/quic/packet_writer.go +566 -0
  939. package/bin/go/src/vendor/golang.org/x/net/quic/path.go +87 -0
  940. package/bin/go/src/vendor/golang.org/x/net/quic/ping.go +14 -0
  941. package/bin/go/src/vendor/golang.org/x/net/quic/pipe.go +173 -0
  942. package/bin/go/src/vendor/golang.org/x/net/quic/qlog.go +272 -0
  943. package/bin/go/src/vendor/golang.org/x/net/quic/queue.go +63 -0
  944. package/bin/go/src/vendor/golang.org/x/net/quic/quic.go +221 -0
  945. package/bin/go/src/vendor/golang.org/x/net/quic/race_disabled.go +10 -0
  946. package/bin/go/src/vendor/golang.org/x/net/quic/race_enabled.go +27 -0
  947. package/bin/go/src/vendor/golang.org/x/net/quic/rangeset.go +193 -0
  948. package/bin/go/src/vendor/golang.org/x/net/quic/retry.go +240 -0
  949. package/bin/go/src/vendor/golang.org/x/net/quic/rtt.go +71 -0
  950. package/bin/go/src/vendor/golang.org/x/net/quic/sent_packet.go +119 -0
  951. package/bin/go/src/vendor/golang.org/x/net/quic/sent_packet_list.go +93 -0
  952. package/bin/go/src/vendor/golang.org/x/net/quic/sent_val.go +103 -0
  953. package/bin/go/src/vendor/golang.org/x/net/quic/skip.go +62 -0
  954. package/bin/go/src/vendor/golang.org/x/net/quic/stateless_reset.go +59 -0
  955. package/bin/go/src/vendor/golang.org/x/net/quic/stream.go +1106 -0
  956. package/bin/go/src/vendor/golang.org/x/net/quic/stream_limits.go +138 -0
  957. package/bin/go/src/vendor/golang.org/x/net/quic/tls.go +123 -0
  958. package/bin/go/src/vendor/golang.org/x/net/quic/transport_params.go +283 -0
  959. package/bin/go/src/vendor/golang.org/x/net/quic/udp.go +28 -0
  960. package/bin/go/src/vendor/golang.org/x/net/quic/udp_darwin.go +45 -0
  961. package/bin/go/src/vendor/golang.org/x/net/quic/udp_linux.go +39 -0
  962. package/bin/go/src/vendor/golang.org/x/net/quic/udp_msg.go +245 -0
  963. package/bin/go/src/vendor/golang.org/x/net/quic/udp_other.go +62 -0
  964. package/bin/go/src/vendor/golang.org/x/net/quic/udp_packetconn.go +67 -0
  965. package/bin/go/src/vendor/golang.org/x/sys/cpu/asm_darwin_arm64_gc.s +12 -0
  966. package/bin/go/src/vendor/golang.org/x/sys/cpu/cpu.go +12 -7
  967. package/bin/go/src/vendor/golang.org/x/sys/cpu/cpu_arm64.go +3 -6
  968. package/bin/go/src/vendor/golang.org/x/sys/cpu/cpu_darwin_arm64.go +67 -0
  969. package/bin/go/src/vendor/golang.org/x/sys/cpu/cpu_darwin_arm64_other.go +31 -0
  970. package/bin/go/src/vendor/golang.org/x/sys/cpu/cpu_gccgo_arm64.go +1 -0
  971. package/bin/go/src/vendor/golang.org/x/sys/cpu/cpu_linux_riscv64.go +2 -0
  972. package/bin/go/src/vendor/golang.org/x/sys/cpu/cpu_loong64.go +14 -2
  973. package/bin/go/src/vendor/golang.org/x/sys/cpu/cpu_other_arm64.go +4 -2
  974. package/bin/go/src/vendor/golang.org/x/sys/cpu/cpu_riscv64.go +1 -0
  975. package/bin/go/src/vendor/golang.org/x/sys/cpu/cpu_windows.go +26 -0
  976. package/bin/go/src/vendor/golang.org/x/sys/cpu/cpu_windows_arm64.go +38 -0
  977. package/bin/go/src/vendor/golang.org/x/sys/cpu/cpu_x86.go +124 -50
  978. package/bin/go/src/vendor/golang.org/x/sys/cpu/syscall_darwin_arm64_gc.go +54 -0
  979. package/bin/go/src/vendor/golang.org/x/sys/cpu/zcpu_windows.go +48 -0
  980. package/bin/go/src/vendor/golang.org/x/text/secure/bidirule/bidirule.go +4 -0
  981. package/bin/go/src/vendor/golang.org/x/text/unicode/bidi/tables15.0.0.go +1 -1
  982. package/bin/go/src/vendor/golang.org/x/text/unicode/bidi/tables17.0.0.go +2135 -0
  983. package/bin/go/src/vendor/golang.org/x/text/unicode/norm/forminfo.go +18 -8
  984. package/bin/go/src/vendor/golang.org/x/text/unicode/norm/tables15.0.0.go +1410 -1410
  985. package/bin/go/src/vendor/golang.org/x/text/unicode/norm/{tables13.0.0.go → tables17.0.0.go} +3530 -3186
  986. package/bin/go/src/vendor/modules.txt +14 -8
  987. package/bin/ttsc-cache.exe +0 -0
  988. package/bin/ttsc.exe +0 -0
  989. package/bin/ttscserver.exe +0 -0
  990. package/package.json +1 -1
  991. package/bin/go/src/crypto/internal/fips140/nistec/p256_ordinv_noasm.go +0 -13
  992. package/bin/go/src/go/internal/scannerhooks/hooks.go +0 -11
  993. package/bin/go/src/hash/maphash/maphash_purego.go +0 -200
  994. package/bin/go/src/hash/maphash/maphash_runtime.go +0 -64
  995. package/bin/go/src/internal/goexperiment/exp_goroutineleakprofile_off.go +0 -8
  996. package/bin/go/src/internal/goexperiment/exp_goroutineleakprofile_on.go +0 -8
  997. package/bin/go/src/internal/strconv/atofeisel.go +0 -166
  998. package/bin/go/src/internal/strconv/ftoadbox.go +0 -349
  999. package/bin/go/src/internal/strconv/ftoafixed.go +0 -184
  1000. package/bin/go/src/internal/strconv/math.go +0 -179
  1001. package/bin/go/src/net/http/h2_bundle.go +0 -12371
  1002. package/bin/go/src/net/http/h2_error.go +0 -37
  1003. package/bin/go/src/runtime/cgo/gcc_darwin_amd64.c +0 -61
  1004. package/bin/go/src/runtime/cgo/gcc_darwin_arm64.c +0 -148
  1005. package/bin/go/src/runtime/cgo/gcc_dragonfly_amd64.c +0 -61
  1006. package/bin/go/src/runtime/cgo/gcc_freebsd.c +0 -72
  1007. package/bin/go/src/runtime/cgo/gcc_freebsd_amd64.c +0 -72
  1008. package/bin/go/src/runtime/cgo/gcc_linux.c +0 -67
  1009. package/bin/go/src/runtime/cgo/gcc_linux_amd64.c +0 -92
  1010. package/bin/go/src/runtime/cgo/gcc_linux_arm64.c +0 -88
  1011. package/bin/go/src/runtime/cgo/gcc_linux_s390x.c +0 -64
  1012. package/bin/go/src/runtime/cgo/gcc_openbsd.c +0 -62
  1013. package/bin/go/src/runtime/cgo/gcc_ppc64x.c +0 -68
  1014. package/bin/go/src/runtime/cgo/gcc_signal2_ios_arm64.c +0 -11
  1015. package/bin/go/src/runtime/cgo/gcc_signal_ios_arm64.c +0 -213
  1016. package/bin/go/src/runtime/cgo/gcc_signal_ios_nolldb.c +0 -10
  1017. package/bin/go/src/runtime/cgo/gcc_solaris_amd64.c +0 -83
  1018. package/bin/go/src/runtime/cgo/gcc_stack_darwin.c +0 -25
  1019. package/bin/go/src/runtime/cgo/gcc_stack_unix.c +0 -48
  1020. package/bin/go/src/runtime/cgo/gcc_windows_386.c +0 -55
  1021. package/bin/go/src/runtime/cgo/gcc_windows_amd64.c +0 -54
  1022. package/bin/go/src/runtime/cgo/gcc_windows_arm64.c +0 -42
  1023. package/bin/go/src/runtime/cgo/libcgo_windows.h +0 -6
  1024. package/bin/go/src/runtime/cgo/signal_ios_arm64.go +0 -10
  1025. package/bin/go/src/runtime/cgo/signal_ios_arm64.s +0 -56
  1026. package/bin/go/src/runtime/rt0_linux_ppc64.s +0 -28
  1027. package/bin/go/src/runtime/stubs_ppc64.go +0 -12
  1028. package/bin/go/src/simd/archsimd/_gen/simdgen/go.yaml +0 -1
  1029. package/bin/go/src/simd/archsimd/_gen/simdgen/ops/ShiftRotate/go.yaml +0 -172
  1030. package/bin/go/src/syscall/asm_openbsd_mips64.s +0 -129
  1031. package/bin/go/src/syscall/syscall_openbsd1.go +0 -12
  1032. package/bin/go/src/syscall/syscall_openbsd_libc.go +0 -84
  1033. package/bin/go/src/syscall/syscall_openbsd_mips64.go +0 -43
  1034. package/bin/go/src/syscall/zerrors_openbsd_mips64.go +0 -1682
  1035. package/bin/go/src/syscall/zsyscall_openbsd_mips64.go +0 -1289
  1036. package/bin/go/src/syscall/zsysnum_openbsd_mips64.go +0 -218
  1037. package/bin/go/src/syscall/ztypes_openbsd_mips64.go +0 -443
  1038. package/bin/go/src/vendor/golang.org/x/net/idna/go118.go +0 -13
  1039. package/bin/go/src/vendor/golang.org/x/net/idna/idna9.0.0.go +0 -717
  1040. package/bin/go/src/vendor/golang.org/x/net/idna/pre_go118.go +0 -11
  1041. package/bin/go/src/vendor/golang.org/x/net/idna/tables10.0.0.go +0 -4559
  1042. package/bin/go/src/vendor/golang.org/x/net/idna/tables11.0.0.go +0 -4653
  1043. package/bin/go/src/vendor/golang.org/x/net/idna/tables12.0.0.go +0 -4733
  1044. package/bin/go/src/vendor/golang.org/x/net/idna/tables13.0.0.go +0 -4959
  1045. package/bin/go/src/vendor/golang.org/x/net/idna/tables9.0.0.go +0 -4486
  1046. package/bin/go/src/vendor/golang.org/x/net/idna/trie12.0.0.go +0 -30
  1047. package/bin/go/src/vendor/golang.org/x/net/idna/trie13.0.0.go +0 -30
  1048. package/bin/go/src/vendor/golang.org/x/text/secure/bidirule/bidirule10.0.0.go +0 -11
  1049. package/bin/go/src/vendor/golang.org/x/text/secure/bidirule/bidirule9.0.0.go +0 -14
  1050. package/bin/go/src/vendor/golang.org/x/text/unicode/bidi/tables10.0.0.go +0 -1815
  1051. package/bin/go/src/vendor/golang.org/x/text/unicode/bidi/tables11.0.0.go +0 -1887
  1052. package/bin/go/src/vendor/golang.org/x/text/unicode/bidi/tables12.0.0.go +0 -1923
  1053. package/bin/go/src/vendor/golang.org/x/text/unicode/bidi/tables13.0.0.go +0 -1955
  1054. package/bin/go/src/vendor/golang.org/x/text/unicode/bidi/tables9.0.0.go +0 -1781
  1055. package/bin/go/src/vendor/golang.org/x/text/unicode/norm/tables10.0.0.go +0 -7657
  1056. package/bin/go/src/vendor/golang.org/x/text/unicode/norm/tables11.0.0.go +0 -7693
  1057. package/bin/go/src/vendor/golang.org/x/text/unicode/norm/tables12.0.0.go +0 -7710
  1058. package/bin/go/src/vendor/golang.org/x/text/unicode/norm/tables9.0.0.go +0 -7637
  1059. /package/bin/go/src/simd/archsimd/_gen/simdgen/ops/BitwiseLogic/{go.yaml → go_amd64.yaml} +0 -0
  1060. /package/bin/go/src/simd/archsimd/_gen/simdgen/ops/Compares/{go.yaml → go_amd64.yaml} +0 -0
  1061. /package/bin/go/src/simd/archsimd/_gen/simdgen/ops/MinMax/{go.yaml → go_amd64.yaml} +0 -0
  1062. /package/bin/go/src/simd/archsimd/_gen/simdgen/ops/Others/{go.yaml → go_amd64.yaml} +0 -0
@@ -0,0 +1,2064 @@
1
+ // Copyright 2025 The Go Authors. All rights reserved.
2
+ // Use of this source code is governed by a BSD-style
3
+ // license that can be found in the LICENSE file.
4
+
5
+ package main
6
+
7
+ import (
8
+ "bytes"
9
+ "flag"
10
+ "fmt"
11
+ "log"
12
+ "os"
13
+ "path/filepath"
14
+ "slices"
15
+ "strings"
16
+ "text/template"
17
+ "unicode"
18
+
19
+ "simd/archsimd/_gen/sgutil"
20
+ )
21
+
22
+ var (
23
+ gorootsrc = flag.String("gorootsrc", "../../../../../src", "root of destination directory, normally GOROOT/src")
24
+
25
+ genTypesFile = flag.String("types", "GOROOTSRC/simd/archsimd/types_wasm.go", "output file for simd types (e.g. types_wasm.go)")
26
+ genOpsFile = flag.String("ops", "GOROOTSRC/simd/archsimd/ops_wasm.go", "output file for simd ops (e.g. ops_wasm.go)")
27
+ genSSAOpsFile = flag.String("ssaops", "GOROOTSRC/cmd/compile/internal/ssa/_gen/simdWasmops.go", "output file for ssa ops (e.g. simdWasmops.go)")
28
+ genGenOpsFile = flag.String("genops", "GOROOTSRC/cmd/compile/internal/ssa/_gen/simdgenericOps.go", "output file for generic ssa ops (e.g. simdgenericOps.go)")
29
+ genSSARulesFile = flag.String("ssarules", "GOROOTSRC/cmd/compile/internal/ssa/_gen/simdWasm.rules", "output file for ssa rules (e.g. simdWasm.rules)")
30
+ genWasmSSAFile = flag.String("wasmssa", "GOROOTSRC/cmd/compile/internal/wasm/simdssa.go", "output file for wasm ssa (e.g. simdssa.go)")
31
+ genIntrinsicsFile = flag.String("intrinsics", "GOROOTSRC/cmd/compile/internal/ssagen/simdWasmintrinsics.go", "output file for intrinsics (e.g. simdWasmintrinsics.go)")
32
+
33
+ list = flag.Bool("list", false, "list all the opcodes")
34
+ )
35
+
36
+ type simdType struct {
37
+ Name string // e.g. "Int8x16"
38
+ Elem string // e.g. "int8"
39
+ Count int // e.g. 2, 4, 8, 16
40
+ ElemSize int // e.g. 8, 16, 32, 64
41
+ Unsigned bool
42
+ Float bool
43
+ Methods map[string]*wasmOp
44
+ IntShaped *simdType // refers to the same-shape signed integer type
45
+ UintShaped *simdType // refers to the same-shape unsigned integer type
46
+ }
47
+
48
+ func (t *simdType) ElemBits() int {
49
+ return t.ElemSize
50
+ }
51
+
52
+ func (t *simdType) HalfCount() int {
53
+ return t.Count / 2
54
+ }
55
+
56
+ func (t *simdType) TwiceCount() int {
57
+ return t.Count * 2
58
+ }
59
+
60
+ func (t *simdType) Name_() string {
61
+ return t.Name
62
+ }
63
+
64
+ func (t *simdType) Article() string {
65
+ // uint => "you-int" => "a you-int"
66
+ if t.Elem[0] == 'i' {
67
+ return "an"
68
+ }
69
+ return "a"
70
+ }
71
+
72
+ func (a *simdType) Compare(b *simdType) int {
73
+ if a.Name == b.Name {
74
+ return 0
75
+ }
76
+ if d := a.ElemSize - b.ElemSize; d != 0 {
77
+ return d
78
+ }
79
+ if d := a.Count - b.Count; d != 0 {
80
+ // never happens for WASM
81
+ return d
82
+ }
83
+
84
+ ao := strings.Index("iIuUfFmM", a.Name[:1])
85
+ bo := strings.Index("iIuUfFmM", b.Name[:1])
86
+ if ao == -1 || bo == -1 {
87
+ panic(fmt.Errorf("a.Elem=%s, b.Elem=%s, unexpected first characters (should be in \"iIuUfFmM\")", a.Elem, b.Elem))
88
+ }
89
+ return ao - bo
90
+ }
91
+
92
+ // WasmUName returns the Capitalized wasm type name e.g. I64x2
93
+ func (s *simdType) WasmUName() string {
94
+ T := s.Name[:1]
95
+ if T == "U" {
96
+ T = "I"
97
+ }
98
+ return fmt.Sprintf("%s%dx%d", T, s.ElemSize, s.Count)
99
+ }
100
+
101
+ // WasmUName returns the uncapitalized wasm type name e.g. i64x2
102
+ func (s *simdType) WasmLName() string {
103
+ T := s.Elem[:1]
104
+ if T == "u" {
105
+ T = "i"
106
+ }
107
+ return fmt.Sprintf("%s%dx%d", T, s.ElemSize, s.Count)
108
+ }
109
+
110
+ func CapitalizeFirst(s string) string {
111
+ return strings.ToUpper(s[:1]) + s[1:]
112
+ }
113
+
114
+ func (s *simdType) MaskFor() *simdType {
115
+ return maskFor[s]
116
+ }
117
+
118
+ // WidenElements doubles the width of the elements, and changes the type
119
+ func (s *simdType) WidenElements(newStem string) string {
120
+ return fmt.Sprintf("%s%dx%d", newStem, s.ElemSize*2, s.Count/2)
121
+ }
122
+
123
+ // ShrinkElements halves the width of the elements, and changes their type
124
+ func (s *simdType) ShrinkElements(newStem string) string {
125
+ return fmt.Sprintf("%s%dx%d", newStem, s.ElemSize/2, s.Count*2)
126
+ }
127
+
128
+ func (s *simdType) IntFor() *simdType {
129
+ if s.IntShaped == nil {
130
+ return s
131
+ }
132
+ return s.IntShaped
133
+ }
134
+
135
+ func (s *simdType) UintFor() *simdType {
136
+ if s.UintShaped == nil {
137
+ return s
138
+ }
139
+ return s.UintShaped
140
+ }
141
+
142
+ func (s *simdType) String() string {
143
+ return s.Name
144
+ }
145
+
146
+ func (s *simdType) IsMask() bool {
147
+ return s.Name[0] == 'M'
148
+ }
149
+
150
+ func (u *simdType) setUintShaped(s *simdType) *simdType {
151
+ s.UintShaped = u
152
+ return u
153
+ }
154
+
155
+ const pkg = "simd/archsimd"
156
+
157
+ var (
158
+ vi8 = &simdType{"Int8x16", "int8", 16, 8, false, false, make(map[string]*wasmOp), nil, nil}
159
+ vi16 = &simdType{"Int16x8", "int16", 8, 16, false, false, make(map[string]*wasmOp), nil, nil}
160
+ vi32 = &simdType{"Int32x4", "int32", 4, 32, false, false, make(map[string]*wasmOp), nil, nil}
161
+ vi64 = &simdType{"Int64x2", "int64", 2, 64, false, false, make(map[string]*wasmOp), nil, nil}
162
+
163
+ vu8 = (&simdType{"Uint8x16", "uint8", 16, 8, true, false, make(map[string]*wasmOp), vi8, nil}).setUintShaped(vi8) // For sign-ignoring operations (add, sub), use these types
164
+ vu16 = (&simdType{"Uint16x8", "uint16", 8, 16, true, false, make(map[string]*wasmOp), vi16, nil}).setUintShaped(vi16)
165
+ vu32 = (&simdType{"Uint32x4", "uint32", 4, 32, true, false, make(map[string]*wasmOp), vi32, nil}).setUintShaped(vi32)
166
+ vu64 = (&simdType{"Uint64x2", "uint64", 2, 64, true, false, make(map[string]*wasmOp), vi64, nil}).setUintShaped(vi64)
167
+
168
+ vf32 = &simdType{"Float32x4", "float32", 4, 32, false, true, make(map[string]*wasmOp), vi32, vu32}
169
+ vf64 = &simdType{"Float64x2", "float64", 2, 64, false, true, make(map[string]*wasmOp), vi64, vu64}
170
+
171
+ vm8 = &simdType{"Mask8x16", "int8", 16, 8, false, false, make(map[string]*wasmOp), vi8, vu8} // for non-bitwise operations (eq, ne), use these types
172
+ vm16 = &simdType{"Mask16x8", "int16", 8, 16, false, false, make(map[string]*wasmOp), vi16, vu16}
173
+ vm32 = &simdType{"Mask32x4", "int32", 4, 32, false, false, make(map[string]*wasmOp), vi32, vu32}
174
+ vm64 = &simdType{"Mask64x2", "int64", 2, 64, false, false, make(map[string]*wasmOp), vi64, vu64}
175
+ )
176
+
177
+ var maskFor map[*simdType]*simdType = map[*simdType]*simdType{
178
+ vm8: vm8,
179
+ vi8: vm8,
180
+ vu8: vm8,
181
+ vm16: vm16,
182
+ vi16: vm16,
183
+ vu16: vm16,
184
+ vm32: vm32,
185
+ vi32: vm32,
186
+ vu32: vm32,
187
+ vf32: vm32,
188
+ vm64: vm64,
189
+ vi64: vm64,
190
+ vu64: vm64,
191
+ vf64: vm64,
192
+ }
193
+
194
+ type OpFlags uint16
195
+
196
+ const (
197
+ IsConst = OpFlags(1) << iota
198
+ IsLoad
199
+ IsStore
200
+ IsShift
201
+ IsSplat
202
+ IsBitwise
203
+ IsRelation
204
+ IsTest
205
+ IsExtract // Returns element type
206
+ IsCommutative
207
+ IsConversion // "Wasm type" is result type, "Go method type" is input time
208
+ NameHasFormat //
209
+ NonSigned // Same bitwise operation whether signed or unsigned. E.g. 2's complement addition.
210
+ EmulatedRule // Emulation occurs at rule expansion.
211
+ )
212
+
213
+ func (o OpFlags) OneString() string {
214
+ switch o {
215
+ case IsConst:
216
+ return "IsConst"
217
+ case IsLoad:
218
+ return "IsLoad"
219
+ case IsStore:
220
+ return "IsStore"
221
+ case IsShift:
222
+ return "IsShift"
223
+ case IsSplat:
224
+ return "IsSplat"
225
+ case IsBitwise:
226
+ return "IsBitwise"
227
+ case IsRelation:
228
+ return "IsRelation"
229
+ case IsTest:
230
+ return "IsTest"
231
+ case IsExtract:
232
+ return "IsExtract"
233
+ case IsCommutative:
234
+ return "IsCommutative"
235
+ case IsConversion:
236
+ return "IsConversion"
237
+ case NameHasFormat:
238
+ return "NameHasFormat"
239
+ case NonSigned:
240
+ return "NonSigned"
241
+ case EmulatedRule:
242
+ return "RmulatedRule"
243
+ }
244
+ return fmt.Sprintf("0x%x", o)
245
+ }
246
+
247
+ var allFlags = []OpFlags{
248
+ IsConst,
249
+ IsLoad,
250
+ IsStore,
251
+ IsShift,
252
+ IsSplat,
253
+ IsBitwise,
254
+ IsRelation,
255
+ IsTest,
256
+ IsExtract,
257
+ IsCommutative,
258
+ IsConversion,
259
+ NameHasFormat,
260
+ NonSigned,
261
+ EmulatedRule,
262
+ }
263
+
264
+ func (o OpFlags) String() string {
265
+ sep := ""
266
+ ret := ""
267
+
268
+ for _, x := range allFlags {
269
+ if x&o != 0 {
270
+ ret += sep + x.OneString()
271
+ sep = "+"
272
+ }
273
+ }
274
+ return ret
275
+ }
276
+
277
+ // wasmOp represents a WebAssembly SIMD instruction.
278
+ type wasmOp struct {
279
+ t *simdType // the receiver and default arg type
280
+ op string // the basic Op type, e.g. "load", "add"
281
+ argCount int // Number of arguments (inputs)
282
+ argType string // (Binary) arg type (e.g., "v128", "i32", "void") -- defaults to t
283
+ resultType string // Result type (e.g., "v128", "i32", "void") -- defaults to t
284
+ opFlags OpFlags
285
+ doc string
286
+
287
+ immRange uint8 // Max immediate value; for lane-oriented operations. 0 => no immediate.
288
+ immName string // The parameter name for an immediate operations
289
+ arg1Name string // The 1st (non-immediate) arg name. Arg1Name() defaults to "y"
290
+ arg2Name string // The 2nd (non-immediate) arg name. Arg2Name() defaults to "z"
291
+ }
292
+
293
+ func (o *wasmOp) String() string {
294
+ return fmt.Sprintf(
295
+ "t=%s, op=%s, arity=%d, Method=%s, ArgType=%s, ResultType=%s, GenOp=%s, SsaWasmOp=%s, AsmOp=%s, WasmInstruction=%s, ImmRange=%d, ImmName=%s, Flags=%s",
296
+ o.Type().Name, o.Op(), o.ArgCount(), o.Method(), o.ArgType(), o.ResultType(), o.SsaGenOp(),
297
+ o.SsaWasmOp(), o.AsmOp(), o.WasmInstruction(), o.ImmRange(), o.ImmName(), o.OpFlags())
298
+ }
299
+
300
+ func compareWasmOps(a, b *wasmOp) int {
301
+ am, bm := a.NUMethod(), b.NUMethod()
302
+ if cmp := strings.Compare(am, bm); cmp != 0 {
303
+ return cmp
304
+ }
305
+ if cmp := a.t.Compare(b.t); cmp != 0 {
306
+ return cmp
307
+ }
308
+ return strings.Compare(a.op, b.op)
309
+ }
310
+
311
+ func (o *wasmOp) Type() *simdType {
312
+ return o.t
313
+ }
314
+
315
+ func (o *wasmOp) ArgCount() int {
316
+ return o.argCount
317
+ }
318
+
319
+ func (o *wasmOp) OpFlags() OpFlags {
320
+ return o.opFlags
321
+ }
322
+
323
+ func (o *wasmOp) Flag(f OpFlags) bool {
324
+ return o.opFlags&f != 0
325
+ }
326
+
327
+ func (o *wasmOp) ImmRange() uint8 {
328
+ return o.immRange
329
+ }
330
+
331
+ func (o *wasmOp) ImmName() string {
332
+ if o.immName == "" {
333
+ return "_"
334
+ }
335
+ return o.immName
336
+ }
337
+
338
+ func snakeToCamel(s string) string {
339
+ capnext := true
340
+ result := ""
341
+ for _, c := range s {
342
+ if c == '_' {
343
+ capnext = true
344
+ continue
345
+ }
346
+ if '0' <= c && c <= '9' {
347
+ capnext = true
348
+ } else {
349
+ if capnext {
350
+ c = unicode.ToUpper(c)
351
+ capnext = false
352
+ }
353
+ }
354
+ result += string(c)
355
+ }
356
+ return result
357
+ }
358
+
359
+ // Op returns the snakeToCamel version of the WASM operation,
360
+ // e.g. return_call_indirect
361
+ func (o *wasmOp) Op() string {
362
+ return snakeToCamel(o.op)
363
+ }
364
+
365
+ func (o *wasmOp) T() *simdType {
366
+ return o.t
367
+ }
368
+
369
+ // Sub, AddSaturated
370
+ // this appears in the Go API declaration files and in the intrinsic registration files.
371
+ func (o *wasmOp) Method() string {
372
+ goname := gonames[o.op]
373
+ if o.Flag(NameHasFormat) {
374
+ // This is an extend method of the form Extend{Lo,Hi}%dTo%s
375
+ count := o.T().Count / 2
376
+ x := strings.Index(o.ResultType(), "x")
377
+ typ := o.ResultType()[:x]
378
+ return fmt.Sprintf(goname, count, typ)
379
+ }
380
+ if len(goname) >= 1 {
381
+ if len(goname) == 1 {
382
+ // it's something like "-" or "?" or "!"
383
+ return ""
384
+ }
385
+ return goname
386
+ }
387
+ return snakeToCamel(o.op)
388
+ }
389
+
390
+ func (o *wasmOp) NUMethod() string {
391
+ s := o.Method()
392
+ if s != "" && s[0] == '_' {
393
+ s = s[1:]
394
+ }
395
+ return s
396
+ }
397
+
398
+ func (o *wasmOp) SsaResultType() string {
399
+ if o.Flag(IsTest) {
400
+ return "Bool"
401
+ }
402
+ return "Vec128" // TODO this is not always right
403
+ }
404
+
405
+ func (o *wasmOp) RegInfo() string {
406
+ if o.argType == "" {
407
+ if o.resultType == "" {
408
+ switch o.argCount {
409
+ case 1:
410
+ return "v11"
411
+ case 2:
412
+ return "v21"
413
+ case 3:
414
+ return "v31"
415
+ }
416
+ } else if o.Flag(IsConversion) {
417
+ if o.argCount == 1 {
418
+ return "v11"
419
+ } else if o.argCount == 2 {
420
+ // widening multiplies
421
+ return "v21"
422
+ }
423
+ } else {
424
+ if o.argCount == 1 {
425
+ // extract lane
426
+ if o.resultType[0] == 'i' || o.resultType[0] == 'u' {
427
+ return "v11gp"
428
+ }
429
+ if o.resultType == "float32" {
430
+ return "v11fp32"
431
+ }
432
+ if o.resultType == "float64" {
433
+ return "v11fp64"
434
+ }
435
+ }
436
+ }
437
+ } else if o.argCount == 2 {
438
+ // replace lane
439
+ if o.argType[0] == 'i' || o.argType[0] == 'u' {
440
+ return "v1gpv"
441
+ } else if o.argType == "float32" {
442
+ return "v1fp32v"
443
+ } else if o.argType == "float64" {
444
+ return "v1fp64v"
445
+ }
446
+ } else if o.argCount == 3 {
447
+ // bitSelect
448
+ return "v31"
449
+ } else if o.Flag(IsSplat) {
450
+ if o.argType[0] == 'i' {
451
+ return "gpv"
452
+ } else if o.argType == "float32" {
453
+ return "fp32v"
454
+ } else {
455
+ return "fp64v"
456
+ }
457
+ }
458
+
459
+ panic("RegInfo not implemented for " + o.String())
460
+ }
461
+
462
+ func (o *wasmOp) DefinesGeneric() bool {
463
+ return o.Method() != "" && !o.T().IsMask() && !o.Flag(NonSigned)
464
+ }
465
+
466
+ // SubInt8x16
467
+ func (o *wasmOp) SsaGenOp() string {
468
+ m := o.Method()
469
+ if m == "" {
470
+ return ""
471
+ }
472
+ // if o.Flag(IsBitwise) {
473
+ // return m + "V128"
474
+ // }
475
+ if m[0] == '_' {
476
+ // strip leading underscore from name, for generics.
477
+ m = m[1:]
478
+ }
479
+ t := o.T()
480
+ if t.IsMask() || o.Flag(NonSigned) {
481
+ t = t.IntShaped
482
+ }
483
+ // Rotate instructions on amd 64 are single op + immediate.
484
+ if strings.HasPrefix(o.op, "RotateAll") {
485
+ m += "Var"
486
+ }
487
+ r := m + t.Name
488
+ return r
489
+ }
490
+
491
+ // conversionCorrectedOp separates the s/u suffix from the operation
492
+ // for example input "foo_s" -> returns "foo", "_s", "S"
493
+ func (o *wasmOp) conversionCorrectedOp() (op, lowerSuffix, upperSuffix string) {
494
+ op = o.op
495
+ if strings.HasSuffix(op, "_s") {
496
+ op = op[:len(op)-2]
497
+ upperSuffix = "S"
498
+ lowerSuffix = "_s"
499
+ } else if strings.HasSuffix(op, "_u") {
500
+ op = op[:len(op)-2]
501
+ upperSuffix = "U"
502
+ lowerSuffix = "_u"
503
+ }
504
+ return
505
+ }
506
+
507
+ // SsaWasmOp returns the name of the WASM-specific SSA Op
508
+ // examples: I8x16Sub, I64x2ExtendLowI32x4U
509
+ func (o *wasmOp) SsaWasmOp() string {
510
+ // Wasm puts the main input type first
511
+ // Except conversions start with their result type
512
+ oop := o.Op()
513
+ if oop == "BitSelect" {
514
+ // Good names for methods versus consistent names for ASM, resolved here.
515
+ // Snake_To_Camel => Bitselect but BitSelect is better and Go programmers are
516
+ // more important than the naming choices of (virtual) hardware designers.
517
+ oop = "Bitselect"
518
+ } else if oop == "Shuffle" {
519
+ oop += "16"
520
+ }
521
+
522
+ if o.Flag(IsBitwise) {
523
+ return "V128" + oop
524
+ }
525
+ if o.Flag(IsConversion) {
526
+ // I64x2ExtendLowI32x4U
527
+ op, _, suffix := o.conversionCorrectedOp()
528
+ op = snakeToCamel(op)
529
+ return CapitalizeFirst(wasmResultType(o.ResultType())) + op + o.T().WasmUName() + suffix
530
+ }
531
+ r := o.T().WasmUName() + oop
532
+ return r
533
+ }
534
+
535
+ func wasmResultType(s string) string {
536
+ ti := strings.Index(s, "t") // Uint, Int, Float
537
+ if s[ti-1] == 'n' { // Uint, Int
538
+ s = "i" + s[ti+1:]
539
+ } else {
540
+ s = "f" + s[ti+1:]
541
+ }
542
+ return s
543
+ }
544
+
545
+ // WasmInstruction returns the from-the-Wasm-spec assembler instruction
546
+ // examples: i8x16.sub, i64x2.extend_low.i32x4_u
547
+ func (o *wasmOp) WasmInstruction() string {
548
+ oop := o.op
549
+ if o.Flag(IsBitwise) {
550
+ return "v128" + "." + oop
551
+ }
552
+ if o.Flag(IsConversion) {
553
+ // i64x2.extend_low
554
+ op, suffix, _ := o.conversionCorrectedOp()
555
+ return wasmResultType(o.ResultType()) + "." + op + "_" + o.T().WasmLName() + suffix
556
+ }
557
+ r := o.T().WasmLName() + "." + oop
558
+ return r
559
+ }
560
+
561
+ func (o *wasmOp) RcvrType() string {
562
+ return o.T().Name
563
+ }
564
+
565
+ func (o *wasmOp) Arg2Name() string {
566
+ if n := o.arg2Name; n != "" {
567
+ return n
568
+ }
569
+ return "z"
570
+ }
571
+
572
+ func (o *wasmOp) Arg1Name() string {
573
+ if n := o.arg1Name; n != "" {
574
+ return n
575
+ }
576
+ return "y"
577
+ }
578
+
579
+ // v128
580
+ func (o *wasmOp) ResultType() string {
581
+ if o.Flag(IsRelation) {
582
+ return o.T().MaskFor().Name
583
+ }
584
+ if o.resultType == "" {
585
+ return o.T().Name
586
+ }
587
+ return o.resultType
588
+ }
589
+
590
+ func (o *wasmOp) ArgType() string {
591
+ if o.argType == "" {
592
+ return o.T().Name
593
+ }
594
+ return o.argType
595
+ }
596
+
597
+ // I8x16Sub -- no need to prefix the "A", that is handled by the SSA rules generator
598
+ func (o *wasmOp) AsmOp() string {
599
+ r := o.SsaWasmOp()
600
+ return r
601
+ }
602
+
603
+ var (
604
+ // Sets of types assocated with various (groups of) wasm instructions
605
+
606
+ allTypes = []*simdType{vi8, vi16, vi32, vi64, vu8, vu16, vu32, vu64, vf32, vf64}
607
+ signed = []*simdType{vi8, vi16, vi32, vi64}
608
+ unsigned = []*simdType{vu8, vu16, vu32, vu64}
609
+ ints = []*simdType{vi8, vi16, vi32, vi64, vu8, vu16, vu32, vu64}
610
+ floats = []*simdType{vf32, vf64}
611
+ sle16 = []*simdType{vi8, vi16} // signed LEQ 16 bits
612
+ ule16 = []*simdType{vu8, vu16} // unsigned LEQ 16 bits
613
+ ige16 = []*simdType{vi16, vi32, vi64, vu16, vu32, vu64} // signed GEQ 16 bits
614
+ nge32 = []*simdType{vi32, vi64, vu32, vu64, vf32, vf64} // numbers GEQ 32 bits
615
+ sle32 = []*simdType{vi8, vi16, vi32} // signed LEQ 32 bits
616
+ ule32 = []*simdType{vu8, vu16, vu32} // unsigned LEQ 32 bits
617
+ ieq32 = []*simdType{vi32, vu32} // integer EQ 32 bits (convert_lo)
618
+ masks = []*simdType{vm8, vm16, vm32, vm64}
619
+
620
+ // All these names are transcribed roughly directly from the WASM 3 list of vector instructions on page 22
621
+ // prefix_suffix translates to receivertype_category
622
+ //
623
+ // receiver type = i(int), s(signed), u(unsigned), f(float), n(number); w/ possible size restriction suffix.
624
+ //
625
+ // 1, 2, 3 = unary, binary, ternary; suffix in number indicates arg type(s)
626
+ // t = test (unary w/ signed scalar result);
627
+ // r = relation (binary w/ signed vector result);
628
+ // c = convert (unary w/ type change)
629
+ // Suffix "q" means "have not figured out what this operation does yet"
630
+
631
+ iv_1 = []string{"not"} // vector, unary -- but not float
632
+ iv_2 = []string{"and", "andnot", "or", "xor"} // vector, binary -- but not float
633
+ v_3 = []string{"bitSelect"} // vector, ternary
634
+
635
+ v_t = []string{"any_true"} // vector, test (scalar result)
636
+
637
+ s_1 = []string{"abs", "neg"} // integer, unary
638
+ f_1 = []string{"abs", "neg", "sqrt", "ceil", "floor", "trunc", "nearest"} // float, unary
639
+ i8_1 = []string{"popcnt"} // int8, unary
640
+
641
+ i_2 = []string{"add", "sub"} // integer, binary
642
+ sle16_2 = []string{"add_sat_s", "sub_sat_s"} // signed 8, 16, binary
643
+ ule16_2 = []string{"add_sat_u", "sub_sat_u", "avgr_u"} // unsigned 8, 16, binary
644
+ ige16_2 = []string{"mul"} // integer 16, 32, 64, binary
645
+ s16_2 = []string{"q15mulr_sat_s", "relaxed_q15mulr_s"}
646
+ sle32_2 = []string{"min_s", "max_s"}
647
+ ule32_2 = []string{"min_u", "max_u"}
648
+
649
+ f_2 = []string{"add", "sub", "mul", "div", "min", "max", "pmin", "pmax", "relaxed_min", "relaxed_max"}
650
+
651
+ i_3 = []string{"relaxed_laneselect"}
652
+
653
+ f_3 = []string{"relaxed_madd", "relaxed_nmadd"}
654
+
655
+ i_t = []string{"all_true"} // shape, test (scalar result)
656
+
657
+ // WASM SIMD relations return vectors of integer 0/1-valued lanes. To use these as bitwise masks,
658
+ // they need to be negated.
659
+
660
+ i_r = []string{"eq", "ne"}
661
+ s_r = []string{"lt_s", "gt_s", "le_s", "ge_s"}
662
+ ule32_r = []string{"lt_u", "gt_u", "le_u", "ge_u"}
663
+
664
+ f_r = []string{"eq", "ne", "lt", "gt", "le", "ge"}
665
+
666
+ // TODO see if semantics can be derived from spec.
667
+ i8_swiz = []string{"swizzle"} //, "relaxed_swizzle"}
668
+ i8_shuf = []string{"shuffle"}
669
+
670
+ // shift ops; integer arg, vector result
671
+ u_s = []string{"shl", "shr_u"}
672
+ s_s = []string{"shl", "shr_s"}
673
+
674
+ sle16_q1 = []string{"extadd_pairwise_s"}
675
+ ule16_q1 = []string{"extadd_pairwise_u"}
676
+
677
+ s_q2 = []string{"extmul_low_s", "extmul_high_s"}
678
+ u_q2 = []string{"extmul_low_u", "extmul_high_u"}
679
+ s16_q2 = []string{"dot_s"}
680
+ s8_q2 = []string{"relaxed_dot_s"}
681
+
682
+ s8_q3 = []string{"relaxed_dot_add_s"}
683
+
684
+ // extend_{u,s} widen integers x2; convert_halfs widen integers to floats x2
685
+ // naming, to match amd64, is
686
+ // ExtendLo<N>To<Type> where result type is <Type>x<N>
687
+ extend_u = []string{"extend_low_u", "extend_high_u"}
688
+ extend_s = []string{"extend_low_s", "extend_high_s"}
689
+ convert_low_u = []string{"convert_low_u"}
690
+ convert_low_s = []string{"convert_low_s"}
691
+
692
+ // In same size, 32 bit integer to float.
693
+ convert_s = []string{"convert_s"}
694
+ convert_u = []string{"convert_u"}
695
+
696
+ f_c = []string{"trunc_sat_s", "trunc_sat_u"} // f32 -> s/u 32 (2 choices)
697
+ f32_c = []string{"promote_low"} // produces f64 vector
698
+ f64_c = []string{"demote_zero"} // produces f32 vector
699
+
700
+ // these have an immediate operand, and return an element_type operand
701
+ nge32_x = []string{"extract_lane"}
702
+ sle16_x = []string{"extract_lane_s"}
703
+ ule16_x = []string{"extract_lane_u"}
704
+
705
+ // has an immediate operand, and an element type operand
706
+ n_x = []string{"replace_lane"}
707
+
708
+ rotates = []string{"RotateAllLeft", "RotateAllRight"}
709
+
710
+ // TODO, once the semantics are understood.
711
+ // N1xM1.narrow_N2xM2_{S,U}
712
+ // N1xM1 is the result type. There are two N2xM2 inputs, where N1 = N2/2 and M1 = M2*2
713
+ // Each N2-sized input element is narrow, saturating signed or unsigned in the process.
714
+
715
+ // Some operations are renamed, and some are not directly present as an intrinsic
716
+ // or generic SIMD operation. A name beginning "_" means the intrinsic begins with
717
+ // that underscore and there must be an emulation written in terms of that intrinsic.
718
+ gonames = map[string]string{
719
+ // not a direct intrinsic
720
+ "any_true": "-", // not IsZero()
721
+ // rename
722
+ "add_sat_s": "AddSaturated",
723
+ "add_sat_u": "AddSaturated",
724
+ "sub_sat_s": "SubSaturated",
725
+ "sub_sat_u": "SubSaturated",
726
+ "andnot": "AndNot",
727
+ "nearest": "Round",
728
+ "popcnt": "OnesCount",
729
+ "avgr_u": "Average",
730
+ "eq": "Equal",
731
+ "ne": "NotEqual",
732
+ "le": "LessEqual",
733
+ "ge": "GreaterEqual",
734
+ "lt": "Less",
735
+ "gt": "Greater",
736
+ "le_s": "LessEqual",
737
+ "ge_s": "GreaterEqual",
738
+ "lt_s": "Less",
739
+ "gt_s": "Greater",
740
+ "le_u": "LessEqual",
741
+ "ge_u": "GreaterEqual",
742
+ "lt_u": "Less",
743
+ "gt_u": "Greater",
744
+ "relaxed_madd": "-",
745
+ "shl": "ShiftAllLeft",
746
+
747
+ "extract_lane": "GetElem",
748
+ "extract_lane_s": "GetElem",
749
+ "extract_lane_u": "GetElem",
750
+
751
+ "replace_lane": "SetElem",
752
+
753
+ "bitselect": "BitSelect",
754
+
755
+ // remove sign/unsigned
756
+ "min_s": "Min",
757
+ "max_s": "Max",
758
+ "min_u": "Min",
759
+ "max_u": "Max",
760
+ "shr_u": "ShiftAllRight",
761
+ "shr_s": "ShiftAllRight",
762
+
763
+ // need to figure out what these are.
764
+ "q15mulr_sat_s": "?",
765
+ "relaxed_q15mulr_s": "?",
766
+ // not sure we need these
767
+ "pmin": "-",
768
+ "pmax": "-",
769
+ "relaxed_min": "-",
770
+ "relaxed_max": "-",
771
+ // rename
772
+ // available via optimization.
773
+ "relaxed_nmadd": "-",
774
+ // not sure of the exact name
775
+ "all_true": "?",
776
+ // need to verify semantics
777
+ "extadd_pairwise_s": "?",
778
+ "extadd_pairwise_u": "?",
779
+ "extmul_low_s": "MulWidenLo",
780
+ "extmul_low_u": "MulWidenLo",
781
+ "extmul_high_s": "MulWidenHi",
782
+ "extmul_high_u": "MulWidenHi",
783
+ "dot_s": "?",
784
+ "relaxed_dot_s": "?",
785
+
786
+ // widen integer types
787
+ "extend_low_s": "ExtendLo%dTo%s",
788
+ "extend_high_s": "ExtendHi%dTo%s",
789
+ "extend_low_u": "ExtendLo%dTo%s",
790
+ "extend_high_u": "ExtendHi%dTo%s",
791
+
792
+ // [u]int32x4 to float32x4
793
+ "convert_s": "ConvertToFloat32",
794
+ "convert_u": "ConvertToFloat32",
795
+
796
+ // [u]int32x4 to float32x4
797
+ "trunc_sat_s": "ConvertToInt32",
798
+ "trunc_sat_u": "ConvertToUint32",
799
+
800
+ // [u]int32x4 to float64x2
801
+ "convert_low_s": "ConvertLo2ToFloat64",
802
+ "convert_low_u": "ConvertLo2ToFloat64",
803
+
804
+ "swizzle": "LookupOrZero",
805
+ "splat": "Broadcast",
806
+ }
807
+ )
808
+
809
+ func initWasmOps() {
810
+ // Local flag-setting functions handle various special cases.
811
+ isBitwise := func(s string, _ *simdType) OpFlags {
812
+ return IsBitwise
813
+ }
814
+ isTest := func(s string, _ *simdType) OpFlags {
815
+ if s == "any_true" {
816
+ return IsBitwise | IsTest
817
+ }
818
+ return IsTest
819
+ }
820
+ binBitwise := func(s string, t *simdType) OpFlags {
821
+ if s == "andnot" {
822
+ return IsBitwise
823
+ }
824
+ return IsBitwise | IsCommutative
825
+ }
826
+ unShape := func(s string, t *simdType) OpFlags {
827
+ return 0
828
+ }
829
+ binShape := func(s string, t *simdType) OpFlags {
830
+ if !t.Float && t.IntShaped != nil {
831
+ if s == "add" {
832
+ return IsCommutative | NonSigned
833
+ }
834
+ if s == "sub" {
835
+ return NonSigned
836
+ }
837
+ }
838
+ if strings.HasPrefix(s, "sub") || s == "div" {
839
+ return 0
840
+ }
841
+ return IsCommutative
842
+ }
843
+ isMask := func(s string, t *simdType) OpFlags {
844
+ flags := IsRelation
845
+ if s == "eq" || s == "ne" {
846
+ flags |= NonSigned
847
+ } else {
848
+ flags |= IsBitwise
849
+ }
850
+ if s == "ne" || s == "eq" || s == "and" || s == "or" || s == "xor" {
851
+ flags |= IsCommutative
852
+ }
853
+ return flags
854
+ }
855
+
856
+ isRelation := func(s string, t *simdType) OpFlags {
857
+ flags := IsRelation
858
+
859
+ if s == "ne" || s == "eq" || s == "and" || s == "or" || s == "xor" {
860
+ flags |= IsCommutative
861
+ }
862
+ return flags
863
+ }
864
+
865
+ bitSelect := func(op *wasmOp) {
866
+ op.opFlags = IsBitwise
867
+ op.arg2Name = "cond"
868
+ }
869
+
870
+ addWasmOps(ints, iv_1, 1, isBitwise) // because reasons, not floats
871
+ addWasmOps(ints, iv_2, 2, binBitwise) // because reasons, not floats
872
+ addWasmOpsDetail(ints, v_3, 3, bitSelect)
873
+ addWasmOps(allTypes, v_t, 1, isTest)
874
+ addWasmOps(signed, s_1, 1, unShape)
875
+ addWasmOps(floats, f_1, 1, unShape)
876
+ addWasmOps([]*simdType{vi8}, i8_1, 1, nil)
877
+
878
+ addWasmOps(ints, i_2, 2, binShape)
879
+ addWasmOps(sle16, sle16_2, 2, binShape)
880
+ addWasmOps(ule16, ule16_2, 2, binShape)
881
+ addWasmOps(ige16, ige16_2, 2, binShape)
882
+
883
+ addWasmOps([]*simdType{vi16}, s16_2, 2, nil) // afaik not commutative
884
+
885
+ addWasmOps(sle32, sle32_2, 2, binShape)
886
+ addWasmOps(ule32, ule32_2, 2, binShape)
887
+
888
+ addWasmOps(floats, f_2, 2, binShape)
889
+
890
+ // addWasmOps(floats, f_3, 3, nil) // relaxed_madd does not work
891
+ // addWasmOps(ints, i_3, 3, nil)
892
+ addWasmOps(ints, i_t, 1, isTest)
893
+
894
+ addWasmOps(ints, i_r, 2, isRelation)
895
+ addWasmOps(signed, s_r, 2, isRelation)
896
+ addWasmOps(ule32, ule32_r, 2, isRelation)
897
+
898
+ addWasmOps(floats, f_r, 2, isRelation)
899
+
900
+ // Shuffle is a mess, it takes a 8x16 vector in and SIXTEEN immediates specifying the indices.
901
+ // addWasmOps([]*simdType{vi8}, i8_shuf, 1, nil)
902
+ addWasmOpsDetail([]*simdType{vi8}, i8_swiz, 2, func(op *wasmOp) { op.arg1Name = "i" })
903
+
904
+ // Masks have some operations.
905
+ addWasmOps(masks, iv_2, 2, isMask)
906
+
907
+ extractImmediate := func(op *wasmOp) {
908
+ op.resultType = op.t.Elem
909
+ op.immRange = uint8(op.t.Count)
910
+ op.immName = "index"
911
+ }
912
+
913
+ addWasmOpsDetail(nge32, nge32_x, 1, extractImmediate)
914
+ addWasmOpsDetail(sle16, sle16_x, 1, extractImmediate)
915
+ addWasmOpsDetail(ule16, ule16_x, 1, extractImmediate)
916
+
917
+ replaceImmediate := func(op *wasmOp) {
918
+ op.argType = op.t.Elem
919
+ op.immRange = uint8(op.t.Count)
920
+ op.immName = "index"
921
+ }
922
+ addWasmOpsDetail(allTypes, n_x, 2, replaceImmediate)
923
+
924
+ shift := func(op *wasmOp) {
925
+ op.argType = "uint64"
926
+ op.opFlags = IsShift
927
+ }
928
+ addWasmOpsDetail(signed, s_s, 2, shift)
929
+ addWasmOpsDetail(unsigned, u_s, 2, shift)
930
+
931
+ splat := func(op *wasmOp) {
932
+ op.opFlags = IsSplat
933
+ op.argType = op.t.Elem
934
+ op.resultType = op.t.Name
935
+ if op.argType[0] == 'u' {
936
+ op.opFlags |= NonSigned
937
+ }
938
+ }
939
+ addWasmOpsDetail(allTypes, []string{"splat"}, 1, splat)
940
+
941
+ // To match the extend patterns for amd64, signed extends to signed, unsigned extends to unsigned
942
+ extendHalf := func(op *wasmOp) {
943
+ t := op.t
944
+ op.opFlags = IsConversion | NameHasFormat
945
+ // result type is twice the width, signedness from the op, half the count
946
+ stem := "Int"
947
+ if op.op[len(op.op)-1] == 'u' {
948
+ stem = "Uint"
949
+ }
950
+ op.resultType = t.WidenElements(stem)
951
+ }
952
+ mulHalf := func(op *wasmOp) {
953
+ t := op.t
954
+ op.opFlags = IsConversion | IsCommutative // this is ALSO a conversion, with same naming conventions.
955
+ // result type is twice the width, signedness from the op, half the count
956
+ stem := "Int"
957
+ if op.op[len(op.op)-1] == 'u' {
958
+ stem = "Uint"
959
+ }
960
+ op.resultType = t.WidenElements(stem)
961
+ }
962
+ convertHalf := func(op *wasmOp) {
963
+ // amd64 has these instructions but we use the vector-register-widening ones,
964
+ // thus the generics are not defined by amd64.
965
+ op.opFlags = IsConversion
966
+ op.resultType = "Float64x2"
967
+ }
968
+ convert := func(op *wasmOp) {
969
+ op.opFlags = IsConversion
970
+ op.resultType = "Float32x4"
971
+ }
972
+ truncSat := func(op *wasmOp) {
973
+ op.opFlags = IsConversion
974
+ if op.op == "trunc_sat_s" {
975
+ op.resultType = "Int32x4"
976
+ } else {
977
+ op.resultType = "Uint32x4"
978
+ }
979
+ }
980
+
981
+ rotate := func(op *wasmOp) {
982
+ op.opFlags = EmulatedRule | IsShift
983
+ op.argType = "uint64"
984
+ op.arg1Name = "shift"
985
+ }
986
+
987
+ addWasmOpsDetail(ule32, extend_u, 1, extendHalf)
988
+ addWasmOpsDetail(sle32, extend_s, 1, extendHalf)
989
+ addWasmOpsDetail([]*simdType{vi32}, convert_low_s, 1, convertHalf)
990
+ addWasmOpsDetail([]*simdType{vu32}, convert_low_u, 1, convertHalf)
991
+ addWasmOpsDetail([]*simdType{vi32}, convert_s, 1, convert)
992
+ addWasmOpsDetail([]*simdType{vu32}, convert_u, 1, convert)
993
+
994
+ addWasmOpsDetail([]*simdType{vf32}, f_c, 1, truncSat)
995
+
996
+ addWasmOpsDetail(sle32, s_q2, 2, mulHalf)
997
+ addWasmOpsDetail(ule32, u_q2, 2, mulHalf)
998
+
999
+ addWasmOpsDetail(ints, rotates, 2, rotate)
1000
+
1001
+ slices.SortFunc(wasmOps, compareWasmOps)
1002
+
1003
+ for i := 1; i < len(wasmOps); i++ {
1004
+ c := compareWasmOps(wasmOps[i-1], wasmOps[i])
1005
+ if c >= 0 {
1006
+ d := compareWasmOps(wasmOps[i-1], wasmOps[i])
1007
+ fmt.Printf("Two wasm ops compared out of order, c=%d, \n%v\n%v\n", d, wasmOps[i-1], wasmOps[i])
1008
+ }
1009
+ }
1010
+ }
1011
+
1012
+ var wasmOps = []*wasmOp{}
1013
+
1014
+ // Given a slice of simd types and a slice of operations with the specified argCount,
1015
+ // add the resulting wasm operations to wasmOps. after is a function that applies
1016
+ // operation-specific customization to the generated wasmOp.
1017
+ func addWasmOpsDetail(types []*simdType, ops []string, argCount int, after func(op *wasmOp)) {
1018
+ for _, t := range types {
1019
+ for _, o := range ops {
1020
+ op := &wasmOp{t: t, op: o, argCount: argCount}
1021
+ after(op)
1022
+ if t.Methods[o] != nil {
1023
+ panic("Double addition of method " + o + " for " + t.Name)
1024
+ }
1025
+ t.Methods[o] = op
1026
+ wasmOps = append(wasmOps, op)
1027
+ }
1028
+ }
1029
+
1030
+ }
1031
+
1032
+ // Given a slice of simd types and a slice of operatinos with the specified argCount,
1033
+ // add the resulting wasm operations to wasmOps. flags is an optional function that
1034
+ // adjusts the flags of the WasmOp.
1035
+ func addWasmOps(types []*simdType, ops []string, argCount int, flags func(op string, ty *simdType) OpFlags) {
1036
+ addWasmOpsDetail(types, ops, argCount, func(op *wasmOp) {
1037
+ if flags == nil {
1038
+ return
1039
+ }
1040
+ op.opFlags = flags(op.op, op.T())
1041
+ })
1042
+ }
1043
+
1044
+ func must(err error) {
1045
+ if err != nil {
1046
+ panic(err)
1047
+ }
1048
+ }
1049
+
1050
+ func mustVal[T any](v T, err error) T {
1051
+ if err != nil {
1052
+ panic(err)
1053
+ }
1054
+ return v
1055
+ }
1056
+
1057
+ func main() {
1058
+
1059
+ flag.Parse()
1060
+
1061
+ initWasmOps()
1062
+
1063
+ if *list {
1064
+ // Helper to list opcodes for a.out.go
1065
+ for i := range wasmOps {
1066
+ fmt.Println(wasmOps[i])
1067
+ }
1068
+ return
1069
+ }
1070
+
1071
+ *genTypesFile = mustVal(filepath.Abs(strings.ReplaceAll(*genTypesFile, "GOROOTSRC", *gorootsrc)))
1072
+ *genOpsFile = mustVal(filepath.Abs(strings.ReplaceAll(*genOpsFile, "GOROOTSRC", *gorootsrc)))
1073
+ *genSSAOpsFile = mustVal(filepath.Abs(strings.ReplaceAll(*genSSAOpsFile, "GOROOTSRC", *gorootsrc)))
1074
+ *genGenOpsFile = mustVal(filepath.Abs(strings.ReplaceAll(*genGenOpsFile, "GOROOTSRC", *gorootsrc)))
1075
+ *genSSARulesFile = mustVal(filepath.Abs(strings.ReplaceAll(*genSSARulesFile, "GOROOTSRC", *gorootsrc)))
1076
+ *genWasmSSAFile = mustVal(filepath.Abs(strings.ReplaceAll(*genWasmSSAFile, "GOROOTSRC", *gorootsrc)))
1077
+ *genIntrinsicsFile = mustVal(filepath.Abs(strings.ReplaceAll(*genIntrinsicsFile, "GOROOTSRC", *gorootsrc)))
1078
+
1079
+ log.Println("types file =", *genTypesFile)
1080
+ log.Println("ops file =", *genOpsFile)
1081
+ log.Println("ssa ops file =", *genSSAOpsFile)
1082
+ log.Println("ssa generic ops file =", *genGenOpsFile)
1083
+ log.Println("ssa rules file =", *genSSARulesFile)
1084
+ log.Println("ssa wasm ops file =", *genWasmSSAFile)
1085
+ log.Println("intrinsics file =", *genIntrinsicsFile)
1086
+
1087
+ log.Println("Generating WASM SIMD files...")
1088
+
1089
+ sgutil.FormatWriteAndClose(genTypes(), *genTypesFile)
1090
+ sgutil.FormatWriteAndClose(genOps(), *genOpsFile)
1091
+ sgutil.FormatWriteAndClose(genSSAOps(), *genSSAOpsFile)
1092
+ sgutil.FormatWriteAndClose(genWasmSSA(), *genWasmSSAFile)
1093
+ sgutil.FormatWriteAndClose(genIntrinsics(), *genIntrinsicsFile)
1094
+ sgutil.FormatWriteAndClose(genGenerics(), *genGenOpsFile)
1095
+
1096
+ genSSARules()
1097
+
1098
+ }
1099
+
1100
+ func templateOf(name, text string) *template.Template {
1101
+ return template.Must(template.New(name).Parse(text))
1102
+ }
1103
+
1104
+ var loadDecl = templateOf("load from array", `
1105
+ // Load{{.Name}}Array loads {{.Article}} {{.Name}} from a [{{.Count}}]{{.Elem}}.
1106
+ //
1107
+ //go:noescape
1108
+ func Load{{.Name}}Array(y *[{{.Count}}]{{.Elem}}) {{.Name}}
1109
+
1110
+ // Load{{.Name}} loads {{.Article}} {{.Name}} from a slice of at least {{.Count}} {{.Elem}}s.
1111
+ func Load{{.Name}}(s []{{.Elem}}) {{.Name}} {
1112
+ return Load{{.Name}}Array((*[{{.Count}}]{{.Elem}})(s))
1113
+ }
1114
+ `)
1115
+
1116
+ var storeDecl = templateOf("store to array", `
1117
+ // StoreArray stores {{.Article}} {{.Name}} to a [{{.Count}}]{{.Elem}}.
1118
+ //
1119
+ //go:noescape
1120
+ func (x {{.Name}}) StoreArray(y *[{{.Count}}]{{.Elem}})
1121
+
1122
+ // Store stores x into a slice of at least {{.Count}} {{.Elem}}s.
1123
+ func (x {{.Name}}) Store(s []{{.Elem}}) {
1124
+ x.StoreArray((*[{{.Count}}]{{.Elem}})(s))
1125
+ }
1126
+ `)
1127
+
1128
+ var splatDecl = templateOf("broadcast an element", `
1129
+ // Broadcast{{.Name}} broadcasts {{.Article}} {{.Elem}} to all elements of {{.Article}} {{.Name}} vector.
1130
+ func Broadcast{{.Name}}(x {{.Elem}}) {{.Name}}
1131
+ `)
1132
+
1133
+ var typeDecl = templateOf("type decl", `
1134
+ // {{.Name}} is a 128-bit SIMD vector of {{.Count}} {{.Elem}}s.
1135
+ type {{.Name}} struct {
1136
+ {{.Elem}}x{{.Count}} v128
1137
+ vals [{{.Count}}]{{.Elem}}
1138
+ }
1139
+ `)
1140
+
1141
+ var maskTypeDecl = templateOf("type decl", `
1142
+ // {{.Name}} is a 128-bit SIMD mask of {{.Count}} {{.Elem}}s.
1143
+ type {{.Name}} struct {
1144
+ {{.Elem}}x{{.Count}} v128
1145
+ vals [{{.Count}}]{{.Elem}}
1146
+ }
1147
+ `)
1148
+
1149
+ var lenDecl = templateOf("len decl", `
1150
+ // Len returns the number of elements in {{.Article}} {{.Name}}.
1151
+ func (x {{.Name}}) Len() int { return {{.Count}} }
1152
+ `)
1153
+
1154
+ func genTypes() (f *bytes.Buffer) {
1155
+ f = new(bytes.Buffer)
1156
+ fmt.Fprintln(f, "// Code generated by 'wasmgen'; DO NOT EDIT.")
1157
+ fmt.Fprintln(f)
1158
+ fmt.Fprintln(f, "//go:build goexperiment.simd && wasm")
1159
+ fmt.Fprintln(f)
1160
+ fmt.Fprintln(f, "package archsimd")
1161
+ fmt.Fprintln(f)
1162
+ fmt.Fprintln(f, "// v128 is a tag type that tells the compiler that this is really 128-bit SIMD")
1163
+ fmt.Fprintln(f, "type v128 struct {")
1164
+ fmt.Fprintln(f, "\t_128 [0]func() // uncomparable")
1165
+ fmt.Fprintln(f, "}")
1166
+
1167
+ for _, t := range allTypes {
1168
+ typeDecl.Execute(f, t)
1169
+ lenDecl.Execute(f, t)
1170
+ loadDecl.Execute(f, t)
1171
+ storeDecl.Execute(f, t)
1172
+ splatDecl.Execute(f, t)
1173
+ }
1174
+ for _, t := range masks {
1175
+ maskTypeDecl.Execute(f, t)
1176
+ }
1177
+ return
1178
+ }
1179
+
1180
+ var docForOp map[string]string = map[string]string{
1181
+ "Add": " returns the result of adding x and y, elementwise.",
1182
+ "Sub": " returns the result of subtracting y from x, elementwise.",
1183
+ "Mul": " returns the result of multiplying x and y, elementwise.",
1184
+ "Div": " returns the result of dividing x by y, elementwise.",
1185
+ "Neg": " returns the elementwise negation of x.",
1186
+ "Abs": " returns the elementwise absolute value of x.",
1187
+ "Sqrt": " returns the elementwise square root of x.",
1188
+ "Not": " returns the bitwise NOT of x.",
1189
+ "And": " returns the bitwise AND of x and y.",
1190
+ "Or": " returns the bitwise OR of x and y.",
1191
+ "Xor": " returns the bitwise XOR of x and y.",
1192
+ "AndNot": " returns the bitwise AND NOT of x and y (x & ^y).",
1193
+ "Min": " returns the elementwise minimum of x and y.",
1194
+ "Max": " returns the elementwise maximum of x and y.",
1195
+ "Round": " returns the elementwise nearest integer, rounding ties to even.",
1196
+ "OnesCount": " returns the elementwise population count (number of bits set).",
1197
+ "Average": " returns the elementwise average of unsigned integers in x and y.",
1198
+ "Equal": " returns true if x equals y, elementwise.",
1199
+ "NotEqual": " returns true if x does not equal y, elementwise.",
1200
+ "Less": " returns true if x is less than y, elementwise.",
1201
+ "Greater": " returns true if x is greater than y, elementwise.",
1202
+ "LessEqual": " returns true if x is less than or equal to y, elementwise.",
1203
+ "GreaterEqual": " returns true if x is greater than or equal to y, elementwise.",
1204
+ "MulAdd": " returns the elementwise multiply-add of x, y, and z.",
1205
+ "ShiftAllLeft": " returns the elementwise left shift of x by y bits.",
1206
+ "ShiftAllRight": " returns the elementwise right shift of x by y bits.",
1207
+ "Ceil": " returns the elementwise ceiling of x.",
1208
+ "Floor": " returns the elementwise floor of x.",
1209
+ "Trunc": " returns the elementwise truncation of x.",
1210
+ "BitSelect": " returns the bitwise selection if mask[i] then x[i] else y[i]",
1211
+ "GetElem": " gets the lane value at the given index.",
1212
+ "SetElem": " sets the lane at the given index to y.",
1213
+ "TruncSatS": " returns the elementwise saturating signed conversion to integer.",
1214
+ "TruncSatU": " returns the elementwise saturating unsigned conversion to integer.",
1215
+ "PromoteLow": " promotes the lower half elements of x to double width values.",
1216
+ "DemoteZero": " demotes elements of x to half width values in lower elements of result, with zeroes in the upper elements",
1217
+ "ConvertToFloat32": " converts elements of x to Float32x4.",
1218
+ "ConvertToInt32": " converts elements of x to Int32x4.",
1219
+ "ConvertToUint32": " converts elements of x to Uint32x4.",
1220
+ "ConvertLo2ToFloat64": " converts the first two elements of x to Float64x2.",
1221
+ "MulWidenHi": ` returns the doubled-width product of respective elements of the upper halves of x and y.
1222
+ //
1223
+ // Result[i] = x[i+{{.Type.HalfCount}}] * y[i+{{.Type.HalfCount}}], for 0 <= i < {{.Type.HalfCount}} == |x|/2.`,
1224
+ "MulWidenLo": ` returns the doubled-width product of respective elements of the lower halves of x and y.
1225
+ //
1226
+ // Result[i] = x[i] * y[i], for 0 <= i < {{.Type.HalfCount}} == |x|/2.`,
1227
+ // Size-specific extend operations
1228
+ "ExtendLo8ToInt16": " extends the lower 8 elements of x to 16-bit integers.",
1229
+ "ExtendLo16ToInt32": " extends the lower 4 elements of x to 32-bit integers.",
1230
+ "ExtendLo32ToInt64": " extends the lower 2 elements of x to 64-bit integers.",
1231
+ "ExtendHi8ToInt16": " extends the higher 8 elements of x to 16-bit integers.",
1232
+ "ExtendHi16ToInt32": " extends the higher 4 elements of x to 32-bit integers.",
1233
+ "ExtendHi32ToInt64": " extends the higher 2 elements of x to 64-bit integers.",
1234
+ "ExtendLo8ToUint16": " extends the lower 8 elements of x to 16-bit unsigned integers.",
1235
+ "ExtendLo16ToUint32": " extends the lower 4 elements of x to 32-bit unsigned integers.",
1236
+ "ExtendLo32ToUint64": " extends the lower 2 elements of x to 64-bit unsigned integers.",
1237
+ "ExtendHi8ToUint16": " extends the higher 8 elements of x to 16-bit unsigned integers.",
1238
+ "ExtendHi16ToUint32": " extends the higher 4 elements of x to 32-bit unsigned integers.",
1239
+ "ExtendHi32ToUint64": " extends the higher 2 elements of x to 64-bit unsigned integers.",
1240
+ "AddSaturated": " returns the result of adding x and y, saturating instead of overflowing, elementwise.",
1241
+ "SubSaturated": " returns the result of subtracting x and y, saturating instead of overflowing, elementwise.",
1242
+ "Shuffle": " returns the elements of y concatenated with z that are selected by elements of x",
1243
+ "LookupOrZero": ` returns the elements of x as indexed by the elements of i. If an index is out of range, its result is 0.
1244
+ //
1245
+ // if 0 <= indices[i] && indices[i] < len(table) {
1246
+ // result[i] = table[indices[i]]
1247
+ // } else {
1248
+ // result[i] = 0
1249
+ // }`,
1250
+ "RelaxedSwizzle": "",
1251
+ "RelaxedLaneselect": "",
1252
+ }
1253
+
1254
+ func (w *wasmOp) DocRest() string {
1255
+ m := w.Method()
1256
+ d := docForOp[m]
1257
+ if d == "" {
1258
+ return ""
1259
+ }
1260
+
1261
+ var buf bytes.Buffer
1262
+ if e := templateOf(m, d).Execute(&buf, w); e != nil {
1263
+ panic(e)
1264
+ }
1265
+ return buf.String()
1266
+ }
1267
+
1268
+ var unOp = templateOf("unaryOp", `
1269
+ // {{.Method}}{{.DocRest}}
1270
+ //
1271
+ // Asm: {{.AsmOp}}
1272
+ func (x {{.RcvrType}}) {{.Method}}() {{.ResultType}}
1273
+ `)
1274
+
1275
+ var binOp = templateOf("binaryOp", `
1276
+ // {{.Method}}{{.DocRest}}
1277
+ //
1278
+ // Asm: {{.AsmOp}}
1279
+ func (x {{.RcvrType}}) {{.Method}}({{.Arg1Name}} {{.ArgType}}) {{.ResultType}}
1280
+ `)
1281
+
1282
+ var ternOp = templateOf("ternaryOp", `
1283
+ // {{.Method}}{{.DocRest}}
1284
+ //
1285
+ // Asm: {{.AsmOp}}
1286
+ func (x {{.RcvrType}}) {{.Method}}(y {{.RcvrType}}, {{.Arg2Name}} {{.ArgType}}) {{.ResultType}}
1287
+ `)
1288
+
1289
+ var unOpImm = templateOf("unaryOpImm", `
1290
+ // {{.Method}}{{.DocRest}}
1291
+ //
1292
+ // Asm: {{.AsmOp}}
1293
+ func (x {{.RcvrType}}) {{.Method}}({{.ImmName}} uint8) {{.ResultType}}
1294
+ `)
1295
+
1296
+ var binOpImm = templateOf("binaryOpImm", `
1297
+ // {{.Method}}{{.DocRest}}
1298
+ //
1299
+ // Asm: {{.AsmOp}}
1300
+ func (x {{.RcvrType}}) {{.Method}}({{.ImmName}} uint8, y {{.ArgType}}) {{.ResultType}}
1301
+ `)
1302
+
1303
+ var toMask = templateOf("toMask", `
1304
+ // ToMask translates {{.Article}} {{.From.Name}} vector to a {{.To.Name}} mask vector
1305
+ // zero becomes false, not-zero becomes true
1306
+ func (x {{.From.Name}}) ToMask() {{.To.Name}}
1307
+ `)
1308
+
1309
+ var fromMask = templateOf("fromMask", `
1310
+ // To{{.To.Name}} translates a {{.From.Name}} mask vector to {{.Article}} {{.To.Name}} int vector
1311
+ // false becomes zero, true becomes -1
1312
+ func (x {{.From.Name}}) To{{.To.Name}}() {{.To.Name}}
1313
+ `)
1314
+
1315
+ var maskMergeUnsigned = templateOf("maskMerge",
1316
+ `// Masked returns x but with elements zeroed where mask is false.
1317
+ func (x {{.Name}}) Masked(mask Mask{{.ElemSize}}x{{.Count}}) {{.Name}} {
1318
+ im := mask.ToInt{{.ElemSize}}x{{.Count}}().ToBits()
1319
+ return im.And(x)
1320
+ }
1321
+
1322
+ // IfElse returns x but with elements set to y where mask is false.
1323
+ func (x {{.Name}}) IfElse(mask Mask{{.ElemSize}}x{{.Count}}, y {{.Name}}) {{.Name}} {
1324
+ im := mask.ToInt{{.ElemSize}}x{{.Count}}().ToBits()
1325
+ return x.BitSelect(y, im)
1326
+ }
1327
+ `)
1328
+
1329
+ var maskMergeFloat = templateOf("maskMerge",
1330
+ `// Masked returns x but with elements zeroed where mask is false.
1331
+ func (x {{.Name}}) Masked(mask Mask{{.ElemSize}}x{{.Count}}) {{.Name}} {
1332
+ im := mask.ToInt{{.ElemSize}}x{{.Count}}().ToBits()
1333
+ return im.And(x.ToBits()).BitsToFloat{{.ElemSize}}()
1334
+ }
1335
+
1336
+ // IfElse returns x but with elements set to y where mask is false.
1337
+ func (x {{.Name}}) IfElse(mask Mask{{.ElemSize}}x{{.Count}}, y {{.Name}}) {{.Name}} {
1338
+ im := mask.ToInt{{.ElemSize}}x{{.Count}}().ToBits()
1339
+ ix := x.ToBits()
1340
+ iy := y.ToBits()
1341
+ return ix.BitSelect(iy, im).BitsToFloat{{.ElemSize}}()
1342
+ }
1343
+ `)
1344
+
1345
+ var maskMergeInt = templateOf("maskMergeInt",
1346
+ `// Masked returns x but with elements zeroed where mask is false.
1347
+ func (x {{.Name}}) Masked(mask Mask{{.ElemSize}}x{{.Count}}) {{.Name}} {
1348
+ im := mask.ToInt{{.ElemSize}}x{{.Count}}()
1349
+ return im.And(x)
1350
+ }
1351
+
1352
+ // IfElse returns x but with elements set to y where mask is false.
1353
+ func (x {{.Name}}) IfElse(mask Mask{{.ElemSize}}x{{.Count}}, y {{.Name}}) {{.Name}} {
1354
+ im := mask.ToInt{{.ElemSize}}x{{.Count}}()
1355
+ return x.BitSelect(y, im)
1356
+ }
1357
+ `)
1358
+
1359
+ var toString = templateOf("toString",
1360
+ `// String returns a string representation of SIMD vector x.
1361
+ func (x {{.Name}}) String() string {
1362
+ var s [{{.Count}}]{{.Elem}}
1363
+ x.StoreArray(&s)
1364
+ return sliceToString(s[:])
1365
+ }
1366
+ `)
1367
+
1368
+ var maskToString = templateOf("maskToString",
1369
+ `// String returns a string representation of SIMD mask x.
1370
+ func (x Mask{{.ElemSize}}x{{.Count}}) String() string {
1371
+ var s [{{.Count}}]{{.Elem}}
1372
+ x.ToInt{{.ElemSize}}x{{.Count}}().Neg().StoreArray(&s)
1373
+ return sliceToString(s[:])
1374
+ }
1375
+ `)
1376
+
1377
+ type asConversion struct {
1378
+ From, To *simdType
1379
+ Article string
1380
+ }
1381
+
1382
+ func forAllAsConversions(f func(from, to *simdType)) {
1383
+ for _, from := range allTypes {
1384
+ for _, to := range allTypes {
1385
+ if from == to {
1386
+ continue
1387
+ }
1388
+ f(from, to)
1389
+ }
1390
+ }
1391
+ }
1392
+
1393
+ func fromUnsignedToFloats(f func(from, to *simdType)) {
1394
+ for _, to := range floats {
1395
+ from := to.UintFor()
1396
+ f(from, to)
1397
+ }
1398
+ }
1399
+
1400
+ func fromUnsignedToInts(f func(from, to *simdType)) {
1401
+ for _, to := range signed {
1402
+ from := to.UintFor()
1403
+ f(from, to)
1404
+ }
1405
+ }
1406
+
1407
+ func forAllReshape(f func(from, to *simdType)) {
1408
+ for _, from := range unsigned {
1409
+ for _, to := range unsigned {
1410
+ if from == to {
1411
+ continue
1412
+ }
1413
+ f(from, to)
1414
+ }
1415
+ }
1416
+ }
1417
+
1418
+ func genOps() (f *bytes.Buffer) {
1419
+ f = new(bytes.Buffer)
1420
+ fmt.Fprintln(f, "// Code generated by 'wasmgen'; DO NOT EDIT.")
1421
+ fmt.Fprintln(f)
1422
+ fmt.Fprintln(f, "//go:build goexperiment.simd && wasm")
1423
+ fmt.Fprintln(f)
1424
+ fmt.Fprintln(f, "package archsimd")
1425
+ fmt.Fprintln(f)
1426
+
1427
+ // Basic operations
1428
+ for _, op := range wasmOps {
1429
+ if op.OpFlags()&(IsLoad|IsStore|IsSplat) != 0 {
1430
+ continue // Handled elsewhere or skipped for methods
1431
+ }
1432
+
1433
+ if op.Method() == "" {
1434
+ continue
1435
+ }
1436
+
1437
+ if op.ImmRange() > 0 {
1438
+ switch op.ArgCount() {
1439
+ case 1:
1440
+ unOpImm.Execute(f, op)
1441
+ case 2:
1442
+ binOpImm.Execute(f, op)
1443
+ default:
1444
+ panic(fmt.Errorf("Unexpected arg count %d for %v", op.ArgCount(), op))
1445
+ }
1446
+
1447
+ } else {
1448
+ switch op.ArgCount() {
1449
+ case 1:
1450
+ unOp.Execute(f, op)
1451
+ case 2:
1452
+ binOp.Execute(f, op)
1453
+ case 3:
1454
+ ternOp.Execute(f, op)
1455
+ default:
1456
+ panic(fmt.Errorf("Unexpected arg count %d for %v", op.ArgCount(), op))
1457
+ }
1458
+ }
1459
+ }
1460
+
1461
+ for _, t := range signed {
1462
+ // Conversions to/from mask types
1463
+ // func (x Int8x16) ToMask() Mask8x16
1464
+ // func (x Mask8x16) ToInt8x16() Int8x16
1465
+ toMask.Execute(f, &asConversion{t, t.MaskFor(), t.Article()})
1466
+ fromMask.Execute(f, &asConversion{t.MaskFor(), t, t.Article()})
1467
+ }
1468
+
1469
+ // Mask and Merge ops
1470
+ for _, t := range allTypes {
1471
+ if t.Name[0] == 'I' {
1472
+ maskMergeInt.Execute(f, t)
1473
+ } else if t.Name[0] == 'F' {
1474
+ maskMergeFloat.Execute(f, t)
1475
+ } else {
1476
+ maskMergeUnsigned.Execute(f, t)
1477
+ }
1478
+ }
1479
+
1480
+ // String
1481
+ for _, t := range allTypes {
1482
+ toString.Execute(f, t)
1483
+ }
1484
+
1485
+ // Mask to String
1486
+ for _, t := range signed {
1487
+ maskToString.Execute(f, t)
1488
+ }
1489
+
1490
+ fromUnsignedToFloats(func(from, to *simdType) {
1491
+ sgutil.ToFloatsDcl.Execute(f, sgutil.Conversion(from, to))
1492
+ sgutil.ToBitsDcl.Execute(f, sgutil.Conversion(to, from))
1493
+ })
1494
+
1495
+ fromUnsignedToInts(func(from, to *simdType) {
1496
+ sgutil.ToIntsDcl.Execute(f, sgutil.Conversion(from, to))
1497
+ sgutil.ToBitsDcl.Execute(f, sgutil.Conversion(to, from))
1498
+ })
1499
+
1500
+ forAllReshape(func(from, to *simdType) {
1501
+ sgutil.ReshapeDcl.Execute(f, sgutil.Conversion(from, to))
1502
+ })
1503
+ return
1504
+ }
1505
+
1506
+ // genSSARules generates the definitions for WASM-specific SIMD SSA operations.
1507
+ // The expected target directory is cmd/compile/internal/ssa/_gen
1508
+ func genSSAOps() (f *bytes.Buffer) {
1509
+ f = new(bytes.Buffer)
1510
+ fmt.Fprintln(f, "// Code generated by 'wasmgen'; DO NOT EDIT.")
1511
+ fmt.Fprintln(f)
1512
+ fmt.Fprintln(f, "package main")
1513
+ fmt.Fprintln(f)
1514
+
1515
+ fmt.Fprintln(f)
1516
+ fmt.Fprintln(f, "func simdWasmOps(vload, vstore, v11, v21, v31, v11gp, v11fp32, v11fp64, v1gpv, v1fp32v, v1fp64v, gpv, fp32v, fp64v regInfo) []opData {")
1517
+ fmt.Fprintln(f, "\treturn []opData{")
1518
+
1519
+ done := make(map[string]string)
1520
+
1521
+ for _, op := range wasmOps {
1522
+ if op.Flag(NonSigned | EmulatedRule) {
1523
+ // There's only one (signed input) version of the op, or no op at all.
1524
+ continue
1525
+ }
1526
+ var toPrint string
1527
+ ssaWasmOp := op.SsaWasmOp()
1528
+ // TODO also incorporate immediate operands.
1529
+ if op.ImmRange() > 0 {
1530
+ // These are currently not commutative
1531
+ toPrint = fmt.Sprintf("\t\t{name: \"%s\", argLength: %d, reg: %s, asm: \"%s\", aux: \"UInt8\", typ: \"%s\"},\n", ssaWasmOp, op.ArgCount(), op.RegInfo(), op.AsmOp(), op.SsaResultType())
1532
+ } else if op.Flag(IsCommutative) {
1533
+ toPrint = fmt.Sprintf("\t\t{name: \"%s\", argLength: %d, reg: %s, asm: \"%s\", commutative: true, typ: \"%s\"},\n", ssaWasmOp, op.ArgCount(), op.RegInfo(), op.AsmOp(), op.SsaResultType())
1534
+ } else {
1535
+ toPrint = fmt.Sprintf("\t\t{name: \"%s\", argLength: %d, reg: %s, asm: \"%s\", typ: \"%s\"},\n", ssaWasmOp, op.ArgCount(), op.RegInfo(), op.AsmOp(), op.SsaResultType())
1536
+ }
1537
+ if old := done[ssaWasmOp]; old != "" {
1538
+ if old != toPrint {
1539
+ panic(fmt.Errorf("Second definition of SSA WASM Op %s differed: \nold: %s\nnew: %s\n", ssaWasmOp, old, toPrint))
1540
+ }
1541
+ continue
1542
+ }
1543
+ done[ssaWasmOp] = toPrint
1544
+ fmt.Fprint(f, toPrint)
1545
+
1546
+ }
1547
+
1548
+ fmt.Fprintln(f, "\t}")
1549
+ fmt.Fprintln(f, "}")
1550
+ return
1551
+ }
1552
+
1553
+ // genSSARules generates the rules that convert SSA generic (SIMD) operations
1554
+ // into WASM-specific SIMD SSA operations.
1555
+ // The expected target directory is cmd/compile/internal/ssa/_gen
1556
+ func genSSARules() {
1557
+ f, err := os.Create(*genSSARulesFile)
1558
+ if err != nil {
1559
+ log.Fatal(err)
1560
+ }
1561
+ defer f.Close()
1562
+
1563
+ fmt.Fprintln(f, "// Code generated by 'wasmgen'; DO NOT EDIT.")
1564
+ fmt.Fprintln(f)
1565
+
1566
+ for _, op := range wasmOps {
1567
+ // (GoOp x y) => (WasmOp x y)
1568
+ if op.Flag(NonSigned) {
1569
+ // skip these generics
1570
+ continue
1571
+ }
1572
+ g := op.SsaGenOp()
1573
+ if g == "" {
1574
+ continue
1575
+ }
1576
+ if op.T().IsMask() {
1577
+ continue // mask ops use Int generics
1578
+ }
1579
+ switch op.ArgCount() {
1580
+ case 1, 2, 3:
1581
+ wasmOp := op.SsaWasmOp()
1582
+ if op.Flag(IsShift) {
1583
+ t := op.T()
1584
+ elemSize := t.ElemSize
1585
+ if op.Op()[0] == 'S' { // shifts, not rotates
1586
+ fmt.Fprintf(f, "(%s x d:(Const64 [c])) && uint64(c) < %d => (%s x (I64Const [c]))\n", g, elemSize, wasmOp)
1587
+ fmt.Fprintf(f, "(%s x d:(I64Const [c])) && uint64(c) < %d => (%s x d)\n", g, elemSize, wasmOp)
1588
+ if op.op != "shr_s" { // shift right signed
1589
+ fmt.Fprintf(f, "// TODO need to do 'shiftIsBounded' for WASM SIMD Shifts\n")
1590
+ fmt.Fprintf(f, "(%s x y) => (SelectV (%s x y) (%s x x) (I64LtU y (I64Const [%d])))\n", g, wasmOp, t.Methods["xor"].SsaWasmOp(), elemSize)
1591
+ } else {
1592
+ // Signed, smear the sign bit
1593
+ fmt.Fprintf(f, "// TODO need to do 'shiftIsBounded' for WASM SIMD Shifts\n")
1594
+ fmt.Fprintf(f, "(%s x y) => (SelectV (%s x y) (%s x (I64Const [%d])) (I64LtU y (I64Const [%d])))\n", g, wasmOp, wasmOp, elemSize-1, elemSize)
1595
+ }
1596
+ } else { // rotates are okay with the implicit WASM modulus
1597
+ shl := t.UintFor().Methods["shl"].SsaWasmOp()
1598
+ shr := t.UintFor().Methods["shr_u"].SsaWasmOp()
1599
+ or := t.UintFor().Methods["or"].SsaWasmOp()
1600
+ if strings.Contains(op.Op(), "Left") {
1601
+ fmt.Fprintf(f, "(%s x y) => (%s (%s x y) (%s x (I64Sub (I64Const [%d]) y)))\n", g, or, shl, shr, elemSize)
1602
+ } else {
1603
+ fmt.Fprintf(f, "(%s x y) => (%s (%s x y) (%s x (I64Sub (I64Const [%d]) y)))\n", g, or, shr, shl, elemSize)
1604
+ }
1605
+ }
1606
+ continue
1607
+ }
1608
+ if op.Flag(NonSigned) {
1609
+ // hop over to the non-signed version of the type and use that method.
1610
+ wasmOp = op.T().IntShaped.Methods[op.op].SsaWasmOp()
1611
+ }
1612
+ fmt.Fprintf(f, "(%s ...) => (%s ...)\n", g, wasmOp)
1613
+ continue
1614
+ default:
1615
+ panic("Haven't figured out SSA rule for " + op.String())
1616
+ }
1617
+
1618
+ }
1619
+ }
1620
+
1621
+ // genWasmSSA creates the file/function that converts SSA nodes for WASM SIMD operations
1622
+ // into the appropriate assembly language.
1623
+ // The expected target directory is cmd/compile/internal/wasm
1624
+ func genWasmSSA() (f *bytes.Buffer) {
1625
+ f = new(bytes.Buffer)
1626
+
1627
+ fmt.Fprintln(f, "// Code generated by 'wasmgen'; DO NOT EDIT.")
1628
+ fmt.Fprintln(f)
1629
+ fmt.Fprintln(f, "package wasm")
1630
+ fmt.Fprintln(f)
1631
+ fmt.Fprintln(f, "import (")
1632
+ fmt.Fprintln(f, "\t\"cmd/compile/internal/ssa\"")
1633
+ fmt.Fprintln(f, "\t\"cmd/compile/internal/ssagen\"")
1634
+ fmt.Fprintln(f, "\t\"cmd/internal/obj\"")
1635
+ fmt.Fprintln(f, "\t\"cmd/internal/obj/wasm\"")
1636
+ fmt.Fprintln(f, ")")
1637
+ fmt.Fprintln(f)
1638
+ fmt.Fprintln(f, "func ssaGenSIMDValue(s *ssagen.State, v *ssa.Value, extend bool) bool {")
1639
+ fmt.Fprintln(f, "\tswitch v.Op {")
1640
+
1641
+ const (
1642
+ NONE = iota
1643
+ IMM1_64
1644
+ IMM1_U
1645
+ IMM1_S
1646
+
1647
+ IMM2_32
1648
+ IMM2_64
1649
+
1650
+ // splat operations
1651
+ I32V
1652
+ I64V
1653
+ F32V
1654
+ F64V
1655
+
1656
+ V
1657
+ VV
1658
+ V32
1659
+ VVV
1660
+ OP
1661
+ DONE
1662
+ )
1663
+
1664
+ type classifiedOP struct {
1665
+ op *wasmOp
1666
+ class int
1667
+ }
1668
+ var ssagenWasmOps []classifiedOP
1669
+
1670
+ // Classify mimics the decision tree for how to convert
1671
+ // SSA HW-specific op into ASM, returning small integers
1672
+ // that can be sorted so that like operations are all
1673
+ // grouped together.
1674
+ classify := func(op *wasmOp) int {
1675
+ if op.ImmRange() > 0 {
1676
+ switch op.ArgCount() {
1677
+ case 1:
1678
+ if op.T().ElemSize < 64 {
1679
+ switch op.T().Elem[0] {
1680
+ case 'u':
1681
+ return IMM1_U
1682
+ case 'i':
1683
+ return IMM1_S
1684
+ }
1685
+ }
1686
+ return IMM1_64
1687
+ case 2:
1688
+ if op.T().ElemSize < 64 && !op.T().Float { // empirically, float32 is 64 bits wide.
1689
+ return IMM2_32
1690
+ }
1691
+ return IMM2_64
1692
+ }
1693
+ } else {
1694
+ switch op.ArgCount() {
1695
+ case 1:
1696
+ if op.Flag(IsSplat) {
1697
+ switch op.ArgType() {
1698
+ case "int8", "int16", "int32":
1699
+ return I32V
1700
+ case "int64":
1701
+ return I64V
1702
+ case "float32":
1703
+ return F32V
1704
+ case "float64":
1705
+ return F64V
1706
+ default:
1707
+ panic(fmt.Errorf("op %s has unexpected splat arg type", op.String()))
1708
+ }
1709
+ }
1710
+ return V
1711
+ case 2:
1712
+ if c := op.ArgType()[0]; c == 'i' || c == 'u' {
1713
+ return V32
1714
+ } else {
1715
+ return VV
1716
+ }
1717
+ case 3:
1718
+ return VVV
1719
+ default:
1720
+ return OP
1721
+ }
1722
+ }
1723
+ panic(fmt.Errorf("op %s has class NONE", op.String()))
1724
+ }
1725
+
1726
+ done := make(map[string]bool)
1727
+
1728
+ for _, op := range wasmOps {
1729
+ if op.Flag(NonSigned | EmulatedRule) {
1730
+ // no hardware-specific op to generate asm from
1731
+ continue
1732
+ }
1733
+ if done[op.SsaWasmOp()] {
1734
+ continue
1735
+ }
1736
+ done[op.SsaWasmOp()] = true
1737
+ ssagenWasmOps = append(ssagenWasmOps, classifiedOP{op, classify(op)})
1738
+ }
1739
+
1740
+ slices.SortFunc(ssagenWasmOps, func(a, b classifiedOP) int {
1741
+ if c := a.class - b.class; c != 0 {
1742
+ return c
1743
+ }
1744
+ return compareWasmOps(a.op, b.op)
1745
+ })
1746
+
1747
+ ssagenWasmOps = append(ssagenWasmOps, classifiedOP{nil, DONE})
1748
+
1749
+ lastClass := NONE
1750
+ lastCR := 0
1751
+ for i, op := range ssagenWasmOps {
1752
+ if op.class != lastClass {
1753
+ lastCR = i
1754
+ // Print the appropriate action for ssagen
1755
+ switch lastClass {
1756
+ case NONE:
1757
+ case IMM1_64:
1758
+ fmt.Fprintf(f,
1759
+ ` getValue128(s, v.Args[0])
1760
+ p := s.Prog(v.Op.Asm())
1761
+ p.To = obj.Addr{Type: obj.TYPE_CONST, Offset: v.AuxInt}
1762
+ `)
1763
+ case IMM1_U:
1764
+ fmt.Fprintf(f,
1765
+ ` getValue128(s, v.Args[0])
1766
+ p := s.Prog(v.Op.Asm())
1767
+ p.To = obj.Addr{Type: obj.TYPE_CONST, Offset: v.AuxInt}
1768
+ `)
1769
+ fmt.Fprintf(f, "\tif extend {\n\t\ts.Prog(wasm.AI64ExtendI32U)\n\t}\n")
1770
+
1771
+ case IMM1_S:
1772
+ fmt.Fprintf(f,
1773
+ ` getValue128(s, v.Args[0])
1774
+ p := s.Prog(v.Op.Asm())
1775
+ p.To = obj.Addr{Type: obj.TYPE_CONST, Offset: v.AuxInt}
1776
+ `)
1777
+ fmt.Fprintf(f, "\tif extend {\n\t\ts.Prog(wasm.AI64ExtendI32S)\n\t}\n")
1778
+
1779
+ case IMM2_32:
1780
+ fmt.Fprintf(f,
1781
+ ` getValue128(s, v.Args[0])
1782
+ getValue32(s, v.Args[1])
1783
+ p := s.Prog(v.Op.Asm())
1784
+ p.To = obj.Addr{Type: obj.TYPE_CONST, Offset: v.AuxInt}
1785
+ `)
1786
+ case IMM2_64:
1787
+ fmt.Fprintf(f,
1788
+ ` getValue128(s, v.Args[0])
1789
+ getValue64(s, v.Args[1])
1790
+ p := s.Prog(v.Op.Asm())
1791
+ p.To = obj.Addr{Type: obj.TYPE_CONST, Offset: v.AuxInt}
1792
+ `)
1793
+
1794
+ case I32V:
1795
+ fmt.Fprintf(f,
1796
+ ` getValue32(s, v.Args[0])
1797
+ s.Prog(v.Op.Asm())
1798
+ `)
1799
+ case I64V:
1800
+ fmt.Fprintf(f,
1801
+ ` getValue64(s, v.Args[0])
1802
+ s.Prog(v.Op.Asm())
1803
+ `)
1804
+ case F32V:
1805
+ fmt.Fprintf(f,
1806
+ ` getValueFxx(s, v.Args[0])
1807
+ s.Prog(v.Op.Asm())
1808
+ `)
1809
+ case F64V:
1810
+ fmt.Fprintf(f,
1811
+ ` getValueFxx(s, v.Args[0])
1812
+ s.Prog(v.Op.Asm())
1813
+ `)
1814
+
1815
+ case V:
1816
+ fmt.Fprintf(f,
1817
+ ` getValue128(s, v.Args[0])
1818
+ s.Prog(v.Op.Asm())
1819
+ `)
1820
+ case VV:
1821
+ fmt.Fprintf(f,
1822
+ ` getValue128(s, v.Args[0])
1823
+ getValue128(s, v.Args[1])
1824
+ s.Prog(v.Op.Asm())
1825
+ `)
1826
+ case V32:
1827
+ // shifts, 32-bit operand
1828
+ fmt.Fprintf(f,
1829
+ ` getValue128(s, v.Args[0])
1830
+ getValue32(s, v.Args[1])
1831
+ s.Prog(v.Op.Asm())
1832
+ `)
1833
+ case VVV:
1834
+ fmt.Fprintf(f,
1835
+ ` getValue128(s, v.Args[0])
1836
+ getValue128(s, v.Args[1])
1837
+ getValue128(s, v.Args[2])
1838
+ s.Prog(v.Op.Asm())
1839
+ `)
1840
+ case OP:
1841
+ fmt.Fprintf(f,
1842
+ ` s.Prog(v.Op.Asm())
1843
+ `)
1844
+ }
1845
+ if op.class == DONE {
1846
+ fmt.Fprintln(f, `
1847
+ default:
1848
+ return false
1849
+ }
1850
+ return true
1851
+ }`)
1852
+ return
1853
+ }
1854
+ // Otherwise begin the next case
1855
+ fmt.Fprint(f, "case ")
1856
+ lastCR = i - 1
1857
+ lastClass = op.class
1858
+ }
1859
+
1860
+ sep := ","
1861
+ if op.class != ssagenWasmOps[i+1].class {
1862
+ sep = ":"
1863
+ }
1864
+ fmt.Fprintf(f, "ssa.OpWasm%s%s", op.op.SsaWasmOp(), sep)
1865
+ if i >= lastCR+3 {
1866
+ fmt.Fprintln(f)
1867
+ lastCR = i
1868
+ }
1869
+ }
1870
+ return f
1871
+ }
1872
+
1873
+ // genGenerics creates SSA generic ops that are implied by WASM SIMD instructions
1874
+ // that were not previously implied by AMD64 SIMD instructions.
1875
+ // The expected target directory is cmd/compile/internal/ssa/_gen
1876
+ func genGenerics() *bytes.Buffer {
1877
+ var newOps []sgutil.GenericOpsData
1878
+
1879
+ for _, op := range wasmOps {
1880
+ if op.SsaGenOp() == "" {
1881
+ continue
1882
+ }
1883
+ if !op.DefinesGeneric() {
1884
+ continue
1885
+ }
1886
+ newOp := sgutil.GenericOpsData{
1887
+ OpName: op.SsaGenOp(),
1888
+ OpInLen: op.ArgCount(),
1889
+ Comm: op.Flag(IsCommutative),
1890
+ HasAux: op.ImmRange() > 0,
1891
+ }
1892
+ newOps = append(newOps, newOp)
1893
+ }
1894
+
1895
+ buf := sgutil.MergeSIMDGenericOps(newOps, *genGenOpsFile, "wasm")
1896
+
1897
+ return buf
1898
+ }
1899
+
1900
+ // genIntrinsics creates the function that registers all of the WASM SIMD intrinsics.
1901
+ // The expected target directory is cmd/compile/internal/ssagen
1902
+ func genIntrinsics() (f *bytes.Buffer) {
1903
+ f = new(bytes.Buffer)
1904
+
1905
+ fmt.Fprint(f, `// Code generated by 'wasmgen'; DO NOT EDIT.
1906
+
1907
+ package ssagen
1908
+
1909
+ import (
1910
+ "cmd/compile/internal/ir"
1911
+ "cmd/compile/internal/ssa"
1912
+ "cmd/compile/internal/types"
1913
+ "cmd/internal/sys"
1914
+ )
1915
+
1916
+ func initWasmSIMD() {
1917
+ makeSimdOp1 := func(op ssa.Op) func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value {
1918
+ return func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value {
1919
+ return s.newValue1(op, types.TypeVec128, args[0])
1920
+ }
1921
+ }
1922
+ makeSimdOp2 := func(op ssa.Op) func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value {
1923
+ return func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value {
1924
+ return s.newValue2(op, types.TypeVec128, args[0], args[1])
1925
+ }
1926
+ }
1927
+ makeSimdOp3 := func(op ssa.Op) func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value {
1928
+ return func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value {
1929
+ return s.newValue3(op, types.TypeVec128, args[0], args[1], args[2])
1930
+ }
1931
+ }
1932
+
1933
+ // "As" is a type pun, just return the bits
1934
+ makeAsOp := func() func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value {
1935
+ return func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value {
1936
+ return args[0]
1937
+ }
1938
+ }
1939
+
1940
+ // converting to a mask is an not-equals comparison with zero, zero obtained by x XOR x.
1941
+ makeToMask := func(op, xor ssa.Op) func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value {
1942
+ return func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value {
1943
+ return s.newValue2(op, types.TypeVec128, args[0], s.newValue2(xor, n.Type(), args[0], args[0]))
1944
+ }
1945
+ }
1946
+
1947
+ makeSimdOp1Imm8 := func(op ssa.Op, immLimit uint64) func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value {
1948
+ return func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value {
1949
+ t := n.Type()
1950
+ if args[1].Op == ssa.OpConst8 && uint64(args[1].AuxInt) < immLimit {
1951
+ return s.newValue1I(op, t, args[1].AuxInt, args[0])
1952
+ }
1953
+ return immJumpTableN(s, args[1], n, immLimit, func(sNew *state, idx int) {
1954
+ // Encode as int8 due to requirement of AuxInt, check its comment for details.
1955
+ s.vars[n] = sNew.newValue1I(op, t, int64(int8(idx)), args[0])
1956
+ })
1957
+ }
1958
+ }
1959
+
1960
+ makeSimdOp2Imm8 := func(op ssa.Op, immLimit uint64) func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value {
1961
+ return func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value {
1962
+ t := types.TypeVec128
1963
+ if args[1].Op == ssa.OpConst8 && uint64(args[1].AuxInt) < immLimit {
1964
+ return s.newValue2I(op, t, args[1].AuxInt, args[0], args[2])
1965
+ }
1966
+ return immJumpTableN(s, args[1], n, immLimit, func(sNew *state, idx int) {
1967
+ // Encode as int8 due to requirement of AuxInt, check its comment for details.
1968
+ s.vars[n] = sNew.newValue2I(op, t, int64(int8(idx)), args[0], args[2])
1969
+ })
1970
+ }
1971
+ }
1972
+
1973
+ addWasmSIMD := func(pkg, fn string, builder func(s *state, n *ir.CallExpr, args []*ssa.Value) *ssa.Value) {
1974
+ intrinsics.add(sys.ArchWasm, pkg, fn, builder)
1975
+ }
1976
+
1977
+ `)
1978
+
1979
+ for _, op := range wasmOps {
1980
+
1981
+ typeName := op.RcvrType()
1982
+ funcName := op.Method()
1983
+
1984
+ // We want <Type>.<Method>
1985
+ // The key in intrinsics map is pkg, name.
1986
+ // For methods, name is "Type.Method".
1987
+
1988
+ fullname := typeName + "." + funcName
1989
+
1990
+ g := op.SsaGenOp()
1991
+ if g == "" || op.Flag(IsSplat) {
1992
+ continue
1993
+ }
1994
+ genOp := "ssa.Op" + g
1995
+
1996
+ if op.ImmRange() > 0 {
1997
+ switch op.ArgCount() {
1998
+ case 1:
1999
+ fmt.Fprintf(f, "\taddWasmSIMD(\"%s\", \"%s\", makeSimdOp1Imm8(%s, %d))\n", pkg, fullname, genOp, op.ImmRange())
2000
+ case 2:
2001
+ fmt.Fprintf(f, "\taddWasmSIMD(\"%s\", \"%s\", makeSimdOp2Imm8(%s, %d))\n", pkg, fullname, genOp, op.ImmRange())
2002
+ default:
2003
+ panic("unexpected wasm simd intrinsic " + op.String())
2004
+ }
2005
+ } else {
2006
+ switch op.ArgCount() {
2007
+ case 1:
2008
+ fmt.Fprintf(f, "\taddWasmSIMD(\"%s\", \"%s\", makeSimdOp1(%s))\n", pkg, fullname, genOp)
2009
+ case 2:
2010
+ fmt.Fprintf(f, "\taddWasmSIMD(\"%s\", \"%s\", makeSimdOp2(%s))\n", pkg, fullname, genOp)
2011
+ case 3:
2012
+ fmt.Fprintf(f, "\taddWasmSIMD(\"%s\", \"%s\",makeSimdOp3(%s))\n", pkg, fullname, genOp)
2013
+ default:
2014
+ panic("unexpected wasm simd intrinsic " + op.String())
2015
+ }
2016
+ }
2017
+
2018
+ }
2019
+
2020
+ for _, t := range signed {
2021
+ // Conversions to/from mask types
2022
+ // func (x Int8x16) ToMask() Mask8x16 -> x.Ne(x xor x)
2023
+ // func (x Mask8x16) ToInt8x16() Int8x16 -> AsInt8x16 (just a pun, masks are negative)
2024
+ fmt.Fprintf(f, "\taddWasmSIMD(\"%s\", \"%s\", makeToMask(%s, %s))\n", pkg, t.Name+".ToMask", "ssa.Op"+t.Methods["ne"].SsaGenOp(), "ssa.Op"+t.Methods["xor"].SsaGenOp())
2025
+ fmt.Fprintf(f, "\taddWasmSIMD(\"%s\", \"%s\", makeAsOp())\n", pkg, t.MaskFor().Name+".To"+t.Name)
2026
+ }
2027
+
2028
+ // load and store intrinsics
2029
+ for _, t := range allTypes {
2030
+ u := t
2031
+ if t.Unsigned {
2032
+ u = t.IntShaped
2033
+ }
2034
+ fmt.Fprintf(f, "\taddWasmSIMD(\"%s\", \"%s\", simdLoad())\n", pkg, "Load"+t.Name+"Array")
2035
+ fmt.Fprintf(f, "\taddWasmSIMD(\"%s\", \"%s\", simdBroadcast(ssa.OpBroadcast%s))\n", pkg, "Broadcast"+t.Name, u.Name)
2036
+ fmt.Fprintf(f, "\taddWasmSIMD(\"%s\", \"%s\", simdStore())\n", pkg, t.Name+".StoreArray")
2037
+ }
2038
+
2039
+ // As conversions
2040
+ forAllAsConversions(func(from, to *simdType) {
2041
+ fullname := from.Name + ".As" + to.Name
2042
+ fmt.Fprintf(f, "\taddWasmSIMD(\"%s\", \"%s\",makeAsOp())\n", pkg, fullname)
2043
+ })
2044
+
2045
+ var WasmTypeDotMethodIntrinsic = templateOf("wasm bit pun intrinsic", `addWasmSIMD("`+pkg+`", "{{.TypeDotMethod}}", makeAsOp())
2046
+ `)
2047
+
2048
+ // Factored bitwise reinterpretation methods
2049
+ // these produces a much smaller API
2050
+ fromUnsignedToFloats(func(from, to *simdType) {
2051
+ sgutil.Conversion(from, to).ExecuteIntrinsicTemplateOfTypeDotMethod(f, WasmTypeDotMethodIntrinsic)
2052
+ })
2053
+
2054
+ fromUnsignedToInts(func(from, to *simdType) {
2055
+ sgutil.Conversion(from, to).ExecuteIntrinsicTemplateOfTypeDotMethod(f, WasmTypeDotMethodIntrinsic)
2056
+ })
2057
+
2058
+ forAllReshape(func(from, to *simdType) {
2059
+ sgutil.Conversion(from, to).ExecuteIntrinsicTemplateOfTypeDotMethod(f, WasmTypeDotMethodIntrinsic)
2060
+ })
2061
+
2062
+ fmt.Fprintln(f, "}")
2063
+ return
2064
+ }