Printer.cpp 43 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144
  1. /*
  2. * Copyright (c) 2021, Ali Mohammad Pur <mpfard@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #include <AK/HashMap.h>
  7. #include <AK/TemporaryChange.h>
  8. #include <LibWasm/AbstractMachine/AbstractMachine.h>
  9. #include <LibWasm/Printer/Printer.h>
  10. namespace Wasm {
  11. struct Names {
  12. static HashMap<OpCode, ByteString> instruction_names;
  13. static HashMap<ByteString, OpCode> instructions_by_name;
  14. };
  15. ByteString instruction_name(OpCode const& opcode)
  16. {
  17. return Names::instruction_names.get(opcode).value_or("<unknown>");
  18. }
  19. Optional<OpCode> instruction_from_name(StringView name)
  20. {
  21. if (Names::instructions_by_name.is_empty()) {
  22. for (auto& entry : Names::instruction_names)
  23. Names::instructions_by_name.set(entry.value, entry.key);
  24. }
  25. return Names::instructions_by_name.get(name);
  26. }
  27. void Printer::print_indent()
  28. {
  29. for (size_t i = 0; i < m_indent; ++i)
  30. m_stream.write_until_depleted(" "sv.bytes()).release_value_but_fixme_should_propagate_errors();
  31. }
  32. void Printer::print(Wasm::BlockType const& type)
  33. {
  34. print_indent();
  35. print("(type block ");
  36. switch (type.kind()) {
  37. case Wasm::BlockType::Kind::Index:
  38. print("index {})\n", type.type_index().value());
  39. return;
  40. case Wasm::BlockType::Kind::Type: {
  41. print("type\n");
  42. {
  43. TemporaryChange change { m_indent, m_indent + 1 };
  44. print(type.value_type());
  45. }
  46. print_indent();
  47. print(")\n");
  48. return;
  49. }
  50. case Wasm::BlockType::Kind ::Empty:
  51. print("empty)\n");
  52. return;
  53. }
  54. VERIFY_NOT_REACHED();
  55. }
  56. void Printer::print(Wasm::CodeSection const& section)
  57. {
  58. if (section.functions().is_empty())
  59. return;
  60. print_indent();
  61. print("(section code\n");
  62. {
  63. TemporaryChange change { m_indent, m_indent + 1 };
  64. for (auto& code : section.functions())
  65. print(code);
  66. }
  67. print_indent();
  68. print(")\n");
  69. }
  70. void Printer::print(Wasm::CodeSection::Code const& code)
  71. {
  72. print(code.func());
  73. }
  74. void Printer::print(Wasm::CustomSection const& section)
  75. {
  76. print_indent();
  77. print("(section custom\n");
  78. {
  79. TemporaryChange change { m_indent, m_indent + 1 };
  80. print_indent();
  81. print("(name `{}')\n", section.name());
  82. print_indent();
  83. print("(contents {} bytes)\n", section.contents().size());
  84. }
  85. print_indent();
  86. print(")\n");
  87. }
  88. void Printer::print(Wasm::DataCountSection const& section)
  89. {
  90. if (!section.count().has_value())
  91. return;
  92. print_indent();
  93. print("(section data count\n");
  94. if (section.count().has_value()) {
  95. TemporaryChange change { m_indent, m_indent + 1 };
  96. print_indent();
  97. print("(count `{}')\n", *section.count());
  98. }
  99. print_indent();
  100. print(")\n");
  101. }
  102. void Printer::print(Wasm::DataSection const& section)
  103. {
  104. if (section.data().is_empty())
  105. return;
  106. print_indent();
  107. print("(section data\n");
  108. {
  109. TemporaryChange change { m_indent, m_indent + 1 };
  110. for (auto& entry : section.data())
  111. print(entry);
  112. }
  113. print_indent();
  114. print(")\n");
  115. }
  116. void Printer::print(Wasm::DataSection::Data const& data)
  117. {
  118. print_indent();
  119. print("(data with value\n");
  120. {
  121. TemporaryChange change { m_indent, m_indent + 1 };
  122. data.value().visit(
  123. [this](DataSection::Data::Passive const& value) {
  124. print_indent();
  125. print("(passive init {}xu8 (", value.init.size());
  126. print(ByteString::join(' ', value.init, "{:x}"sv));
  127. print(")\n");
  128. },
  129. [this](DataSection::Data::Active const& value) {
  130. print_indent();
  131. print("(active init {}xu8 (", value.init.size());
  132. print(ByteString::join(' ', value.init, "{:x}"sv));
  133. print("\n");
  134. {
  135. TemporaryChange change { m_indent, m_indent + 1 };
  136. print_indent();
  137. print("(offset\n");
  138. {
  139. TemporaryChange change { m_indent, m_indent + 1 };
  140. print(value.offset);
  141. }
  142. print_indent();
  143. print(")\n");
  144. }
  145. {
  146. TemporaryChange change { m_indent, m_indent + 1 };
  147. print_indent();
  148. print("(index {})\n", value.index.value());
  149. }
  150. });
  151. }
  152. print_indent();
  153. print(")\n");
  154. }
  155. void Printer::print(Wasm::ElementSection const& section)
  156. {
  157. if (section.segments().is_empty())
  158. return;
  159. print_indent();
  160. print("(section element\n");
  161. {
  162. TemporaryChange change { m_indent, m_indent + 1 };
  163. for (auto& entry : section.segments())
  164. print(entry);
  165. }
  166. print_indent();
  167. print(")\n");
  168. }
  169. void Printer::print(Wasm::ElementSection::Element const& element)
  170. {
  171. print_indent();
  172. print("(element ");
  173. {
  174. TemporaryChange<size_t> change { m_indent, 0 };
  175. print(element.type);
  176. }
  177. {
  178. TemporaryChange change { m_indent, m_indent + 1 };
  179. print_indent();
  180. print("(init\n");
  181. {
  182. TemporaryChange change { m_indent, m_indent + 1 };
  183. for (auto& entry : element.init)
  184. print(entry);
  185. }
  186. print_indent();
  187. print(")\n");
  188. print_indent();
  189. print("(mode ");
  190. element.mode.visit(
  191. [this](ElementSection::Active const& active) {
  192. print("\n");
  193. {
  194. TemporaryChange change { m_indent, m_indent + 1 };
  195. print_indent();
  196. print("(active index {}\n", active.index.value());
  197. {
  198. print(active.expression);
  199. }
  200. print_indent();
  201. print(")\n");
  202. }
  203. print_indent();
  204. },
  205. [this](ElementSection::Passive const&) { print("passive"); },
  206. [this](ElementSection::Declarative const&) { print("declarative"); });
  207. print(")\n");
  208. }
  209. }
  210. void Printer::print(Wasm::ExportSection const& section)
  211. {
  212. if (section.entries().is_empty())
  213. return;
  214. print_indent();
  215. print("(section export\n");
  216. {
  217. TemporaryChange change { m_indent, m_indent + 1 };
  218. for (auto& entry : section.entries())
  219. print(entry);
  220. }
  221. print_indent();
  222. print(")\n");
  223. }
  224. void Printer::print(Wasm::ExportSection::Export const& entry)
  225. {
  226. print_indent();
  227. print("(export `{}' as\n", entry.name());
  228. {
  229. TemporaryChange change { m_indent, m_indent + 1 };
  230. print_indent();
  231. entry.description().visit(
  232. [this](FunctionIndex const& index) { print("(function index {})\n", index.value()); },
  233. [this](TableIndex const& index) { print("(table index {})\n", index.value()); },
  234. [this](MemoryIndex const& index) { print("(memory index {})\n", index.value()); },
  235. [this](GlobalIndex const& index) { print("(global index {})\n", index.value()); });
  236. }
  237. print_indent();
  238. print(")\n");
  239. }
  240. void Printer::print(Wasm::Expression const& expression)
  241. {
  242. TemporaryChange change { m_indent, m_indent + 1 };
  243. for (auto& instr : expression.instructions())
  244. print(instr);
  245. }
  246. void Printer::print(Wasm::CodeSection::Func const& func)
  247. {
  248. print_indent();
  249. print("(function\n");
  250. {
  251. TemporaryChange change { m_indent, m_indent + 1 };
  252. {
  253. print_indent();
  254. print("(locals\n");
  255. {
  256. TemporaryChange change { m_indent, m_indent + 1 };
  257. for (auto& locals : func.locals())
  258. print(locals);
  259. }
  260. print_indent();
  261. print(")\n");
  262. }
  263. print_indent();
  264. print("(body\n");
  265. print(func.body());
  266. print_indent();
  267. print(")\n");
  268. }
  269. print_indent();
  270. print(")\n");
  271. }
  272. void Printer::print(Wasm::FunctionSection const& section)
  273. {
  274. if (section.types().is_empty())
  275. return;
  276. print_indent();
  277. print("(section function\n");
  278. {
  279. TemporaryChange change { m_indent, m_indent + 1 };
  280. for (auto& index : section.types()) {
  281. print_indent();
  282. print("(type index {})\n", index.value());
  283. }
  284. }
  285. print_indent();
  286. print(")\n");
  287. }
  288. void Printer::print(Wasm::FunctionType const& type)
  289. {
  290. print_indent();
  291. print("(type function\n");
  292. {
  293. TemporaryChange change { m_indent, m_indent + 1 };
  294. print_indent();
  295. print("(parameters\n");
  296. {
  297. TemporaryChange change { m_indent, m_indent + 1 };
  298. for (auto& param : type.parameters())
  299. print(param);
  300. }
  301. print_indent();
  302. print(")\n");
  303. }
  304. {
  305. TemporaryChange change { m_indent, m_indent + 1 };
  306. print_indent();
  307. print("(results\n");
  308. {
  309. TemporaryChange change { m_indent, m_indent + 1 };
  310. for (auto& type : type.results())
  311. print(type);
  312. }
  313. print_indent();
  314. print(")\n");
  315. }
  316. print_indent();
  317. print(")\n");
  318. }
  319. void Printer::print(Wasm::GlobalSection const& section)
  320. {
  321. if (section.entries().is_empty())
  322. return;
  323. print_indent();
  324. print("(section global\n");
  325. {
  326. TemporaryChange change { m_indent, m_indent + 1 };
  327. for (auto& entry : section.entries())
  328. print(entry);
  329. }
  330. print_indent();
  331. print(")\n");
  332. }
  333. void Printer::print(Wasm::GlobalSection::Global const& entry)
  334. {
  335. print_indent();
  336. print("(global\n");
  337. {
  338. TemporaryChange change { m_indent, m_indent + 1 };
  339. print_indent();
  340. print("(type\n");
  341. {
  342. TemporaryChange change { m_indent, m_indent + 1 };
  343. print(entry.type());
  344. }
  345. print_indent();
  346. print(")\n");
  347. }
  348. {
  349. TemporaryChange change { m_indent, m_indent + 1 };
  350. print_indent();
  351. print("(init\n");
  352. {
  353. TemporaryChange change { m_indent, m_indent + 1 };
  354. print(entry.expression());
  355. }
  356. print_indent();
  357. print(")\n");
  358. }
  359. print_indent();
  360. print(")\n");
  361. }
  362. void Printer::print(Wasm::GlobalType const& type)
  363. {
  364. print_indent();
  365. print("(type global {}mutable\n", type.is_mutable() ? "" : "im");
  366. {
  367. TemporaryChange change { m_indent, m_indent + 1 };
  368. print(type.type());
  369. }
  370. print_indent();
  371. print(")\n");
  372. }
  373. void Printer::print(Wasm::ImportSection const& section)
  374. {
  375. if (section.imports().is_empty())
  376. return;
  377. print_indent();
  378. print("(section import\n");
  379. {
  380. TemporaryChange change { m_indent, m_indent + 1 };
  381. for (auto& import : section.imports())
  382. print(import);
  383. }
  384. print_indent();
  385. print(")\n");
  386. }
  387. void Printer::print(Wasm::ImportSection::Import const& import)
  388. {
  389. print_indent();
  390. print("(import `{}' from `{}' as\n", import.name(), import.module());
  391. {
  392. TemporaryChange change { m_indent, m_indent + 1 };
  393. import.description().visit(
  394. [this](auto const& type) {
  395. print(type);
  396. },
  397. [this](TypeIndex const& index) {
  398. print_indent();
  399. print("(type index {})\n", index.value());
  400. });
  401. }
  402. print_indent();
  403. print(")\n");
  404. }
  405. void Printer::print(Wasm::Instruction const& instruction)
  406. {
  407. print_indent();
  408. print("({}", instruction_name(instruction.opcode()));
  409. if (instruction.arguments().has<u8>()) {
  410. print(")\n");
  411. } else {
  412. print(" ");
  413. instruction.arguments().visit(
  414. [&](BlockType const& type) { print(type); },
  415. [&](DataIndex const& index) { print("(data index {})", index.value()); },
  416. [&](ElementIndex const& index) { print("(element index {})", index.value()); },
  417. [&](FunctionIndex const& index) { print("(function index {})", index.value()); },
  418. [&](GlobalIndex const& index) { print("(global index {})", index.value()); },
  419. [&](LabelIndex const& index) { print("(label index {})", index.value()); },
  420. [&](LocalIndex const& index) { print("(local index {})", index.value()); },
  421. [&](TableIndex const& index) { print("(table index {})", index.value()); },
  422. [&](Instruction::IndirectCallArgs const& args) { print("(indirect (type index {}) (table index {}))", args.type.value(), args.table.value()); },
  423. [&](Instruction::MemoryArgument const& args) { print("(memory index {} (align {}) (offset {}))", args.memory_index.value(), args.align, args.offset); },
  424. [&](Instruction::MemoryAndLaneArgument const& args) { print("(memory index {} (align {}) (offset {})) (lane {})", args.memory.memory_index.value(), args.memory.align, args.memory.offset, args.lane); },
  425. [&](Instruction::MemoryInitArgs const& args) { print("(memory index {}) (data index {})", args.memory_index.value(), args.data_index.value()); },
  426. [&](Instruction::MemoryCopyArgs const& args) { print("(from (memory index {}) to (memory index {}))", args.src_index.value(), args.dst_index.value()); },
  427. [&](Instruction::MemoryIndexArgument const& args) { print("(memory index {})", args.memory_index.value()); },
  428. [&](Instruction::LaneIndex const& args) { print("(lane {})", args.lane); },
  429. [&](Instruction::ShuffleArgument const& args) {
  430. print("{{ {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {} }}",
  431. args.lanes[0], args.lanes[1], args.lanes[2], args.lanes[3],
  432. args.lanes[4], args.lanes[5], args.lanes[6], args.lanes[7],
  433. args.lanes[8], args.lanes[9], args.lanes[10], args.lanes[11],
  434. args.lanes[12], args.lanes[13], args.lanes[14], args.lanes[15]);
  435. },
  436. [&](Instruction::StructuredInstructionArgs const& args) {
  437. print("(structured\n");
  438. TemporaryChange change { m_indent, m_indent + 1 };
  439. print(args.block_type);
  440. print_indent();
  441. print("(else {}) (end {}))", args.else_ip.has_value() ? ByteString::number(args.else_ip->value()) : "(none)", args.end_ip.value());
  442. },
  443. [&](Instruction::TableBranchArgs const& args) {
  444. print("(table_branch");
  445. for (auto& label : args.labels)
  446. print(" (label {})", label.value());
  447. print(" (label {}))", args.default_.value());
  448. },
  449. [&](Instruction::TableElementArgs const& args) { print("(table_element (table index {}) (element index {}))", args.table_index.value(), args.element_index.value()); },
  450. [&](Instruction::TableTableArgs const& args) { print("(table_table (table index {}) (table index {}))", args.lhs.value(), args.rhs.value()); },
  451. [&](ValueType const& type) { print(type); },
  452. [&](Vector<ValueType> const&) { print("(types...)"); },
  453. [&](auto const& value) { print("{}", value); });
  454. print(")\n");
  455. }
  456. }
  457. void Printer::print(Wasm::Limits const& limits)
  458. {
  459. print_indent();
  460. print("(limits min={}", limits.min());
  461. if (limits.max().has_value())
  462. print(" max={}", limits.max().value());
  463. else
  464. print(" unbounded");
  465. print(")\n");
  466. }
  467. void Printer::print(Wasm::Locals const& local)
  468. {
  469. print_indent();
  470. print("(local x{} of type\n", local.n());
  471. {
  472. TemporaryChange change { m_indent, m_indent + 1 };
  473. print(local.type());
  474. }
  475. print_indent();
  476. print(")\n");
  477. }
  478. void Printer::print(Wasm::MemorySection const& section)
  479. {
  480. if (section.memories().is_empty())
  481. return;
  482. print_indent();
  483. print("(section memory\n");
  484. {
  485. TemporaryChange change { m_indent, m_indent + 1 };
  486. for (auto& memory : section.memories())
  487. print(memory);
  488. }
  489. print_indent();
  490. print(")\n");
  491. }
  492. void Printer::print(Wasm::MemorySection::Memory const& memory)
  493. {
  494. print_indent();
  495. print("(memory\n");
  496. {
  497. TemporaryChange change { m_indent, m_indent + 1 };
  498. print(memory.type());
  499. }
  500. print_indent();
  501. print(")\n");
  502. }
  503. void Printer::print(Wasm::MemoryType const& type)
  504. {
  505. print_indent();
  506. print("(type memory\n");
  507. {
  508. TemporaryChange change { m_indent, m_indent + 1 };
  509. print(type.limits());
  510. }
  511. print_indent();
  512. print(")\n");
  513. }
  514. void Printer::print(Wasm::Module const& module)
  515. {
  516. print_indent();
  517. {
  518. TemporaryChange change { m_indent, m_indent + 1 };
  519. print("(module\n");
  520. for (auto& custom_section : module.custom_sections())
  521. print(custom_section);
  522. print(module.type_section());
  523. print(module.import_section());
  524. print(module.function_section());
  525. print(module.table_section());
  526. print(module.memory_section());
  527. print(module.global_section());
  528. print(module.export_section());
  529. print(module.start_section());
  530. print(module.element_section());
  531. print(module.code_section());
  532. print(module.data_section());
  533. print(module.data_count_section());
  534. }
  535. print_indent();
  536. print(")\n");
  537. }
  538. void Printer::print(Wasm::StartSection const& section)
  539. {
  540. if (!section.function().has_value())
  541. return;
  542. print_indent();
  543. print("(section start\n");
  544. {
  545. TemporaryChange change { m_indent, m_indent + 1 };
  546. print(*section.function());
  547. }
  548. print_indent();
  549. print(")\n");
  550. }
  551. void Printer::print(Wasm::StartSection::StartFunction const& function)
  552. {
  553. print_indent();
  554. print("(start function index {})\n", function.index().value());
  555. }
  556. void Printer::print(Wasm::TableSection const& section)
  557. {
  558. if (section.tables().is_empty())
  559. return;
  560. print_indent();
  561. print("(section table\n");
  562. {
  563. TemporaryChange change { m_indent, m_indent + 1 };
  564. for (auto& table : section.tables())
  565. print(table);
  566. }
  567. print_indent();
  568. print(")\n");
  569. }
  570. void Printer::print(Wasm::TableSection::Table const& table)
  571. {
  572. print_indent();
  573. print("(table\n");
  574. {
  575. TemporaryChange change { m_indent, m_indent + 1 };
  576. print(table.type());
  577. }
  578. print_indent();
  579. print(")\n");
  580. }
  581. void Printer::print(Wasm::TableType const& type)
  582. {
  583. print_indent();
  584. print("(type table min:{}", type.limits().min());
  585. if (type.limits().max().has_value())
  586. print(" max:{}", type.limits().max().value());
  587. print("\n");
  588. {
  589. TemporaryChange change { m_indent, m_indent + 1 };
  590. print(type.element_type());
  591. }
  592. print_indent();
  593. print(")\n");
  594. }
  595. void Printer::print(Wasm::TypeSection const& section)
  596. {
  597. if (section.types().is_empty())
  598. return;
  599. print_indent();
  600. print("(section type\n");
  601. {
  602. TemporaryChange change { m_indent, m_indent + 1 };
  603. for (auto& type : section.types())
  604. print(type);
  605. }
  606. print_indent();
  607. print(")\n");
  608. }
  609. void Printer::print(Wasm::ValueType const& type)
  610. {
  611. print_indent();
  612. print("(type {})\n", ValueType::kind_name(type.kind()));
  613. }
  614. void Printer::print(Wasm::Value const& value, Wasm::ValueType const& type)
  615. {
  616. print_indent();
  617. switch (type.kind()) {
  618. case ValueType::I32:
  619. print(ByteString::formatted("{}", value.to<i32>()));
  620. break;
  621. case ValueType::I64:
  622. print(ByteString::formatted("{}", value.to<i64>()));
  623. break;
  624. case ValueType::F32:
  625. print(ByteString::formatted("{}", value.to<f32>()));
  626. break;
  627. case ValueType::F64:
  628. print(ByteString::formatted("{}", value.to<f64>()));
  629. break;
  630. case ValueType::V128:
  631. print(ByteString::formatted("v128({:x})", value.value()));
  632. break;
  633. case ValueType::FunctionReference:
  634. case ValueType::ExternReference:
  635. print(ByteString::formatted("addr({})",
  636. value.to<Reference>().ref().visit(
  637. [](Wasm::Reference::Null const&) { return ByteString("null"); },
  638. [](auto const& ref) { return ByteString::number(ref.address.value()); })));
  639. break;
  640. }
  641. TemporaryChange<size_t> change { m_indent, 0 };
  642. }
  643. void Printer::print(Wasm::Value const& value)
  644. {
  645. print_indent();
  646. print("{:x}", value.value());
  647. TemporaryChange<size_t> change { m_indent, 0 };
  648. }
  649. void Printer::print(Wasm::Reference const& value)
  650. {
  651. print_indent();
  652. print(
  653. "addr({})\n",
  654. value.ref().visit(
  655. [](Wasm::Reference::Null const&) { return ByteString("null"); },
  656. [](auto const& ref) { return ByteString::number(ref.address.value()); }));
  657. }
  658. }
  659. HashMap<Wasm::OpCode, ByteString> Wasm::Names::instruction_names {
  660. { Instructions::unreachable, "unreachable" },
  661. { Instructions::nop, "nop" },
  662. { Instructions::block, "block" },
  663. { Instructions::loop, "loop" },
  664. { Instructions::if_, "if" },
  665. { Instructions::br, "br" },
  666. { Instructions::br_if, "br.if" },
  667. { Instructions::br_table, "br.table" },
  668. { Instructions::return_, "return" },
  669. { Instructions::call, "call" },
  670. { Instructions::call_indirect, "call.indirect" },
  671. { Instructions::drop, "drop" },
  672. { Instructions::select, "select" },
  673. { Instructions::select_typed, "select.typed" },
  674. { Instructions::local_get, "local.get" },
  675. { Instructions::local_set, "local.set" },
  676. { Instructions::local_tee, "local.tee" },
  677. { Instructions::global_get, "global.get" },
  678. { Instructions::global_set, "global.set" },
  679. { Instructions::table_get, "table.get" },
  680. { Instructions::table_set, "table.set" },
  681. { Instructions::i32_load, "i32.load" },
  682. { Instructions::i64_load, "i64.load" },
  683. { Instructions::f32_load, "f32.load" },
  684. { Instructions::f64_load, "f64.load" },
  685. { Instructions::i32_load8_s, "i32.load8_s" },
  686. { Instructions::i32_load8_u, "i32.load8_u" },
  687. { Instructions::i32_load16_s, "i32.load16_s" },
  688. { Instructions::i32_load16_u, "i32.load16_u" },
  689. { Instructions::i64_load8_s, "i64.load8_s" },
  690. { Instructions::i64_load8_u, "i64.load8_u" },
  691. { Instructions::i64_load16_s, "i64.load16_s" },
  692. { Instructions::i64_load16_u, "i64.load16_u" },
  693. { Instructions::i64_load32_s, "i64.load32_s" },
  694. { Instructions::i64_load32_u, "i64.load32_u" },
  695. { Instructions::i32_store, "i32.store" },
  696. { Instructions::i64_store, "i64.store" },
  697. { Instructions::f32_store, "f32.store" },
  698. { Instructions::f64_store, "f64.store" },
  699. { Instructions::i32_store8, "i32.store8" },
  700. { Instructions::i32_store16, "i32.store16" },
  701. { Instructions::i64_store8, "i64.store8" },
  702. { Instructions::i64_store16, "i64.store16" },
  703. { Instructions::i64_store32, "i64.store32" },
  704. { Instructions::memory_size, "memory.size" },
  705. { Instructions::memory_grow, "memory.grow" },
  706. { Instructions::i32_const, "i32.const" },
  707. { Instructions::i64_const, "i64.const" },
  708. { Instructions::f32_const, "f32.const" },
  709. { Instructions::f64_const, "f64.const" },
  710. { Instructions::i32_eqz, "i32.eqz" },
  711. { Instructions::i32_eq, "i32.eq" },
  712. { Instructions::i32_ne, "i32.ne" },
  713. { Instructions::i32_lts, "i32.lts" },
  714. { Instructions::i32_ltu, "i32.ltu" },
  715. { Instructions::i32_gts, "i32.gts" },
  716. { Instructions::i32_gtu, "i32.gtu" },
  717. { Instructions::i32_les, "i32.les" },
  718. { Instructions::i32_leu, "i32.leu" },
  719. { Instructions::i32_ges, "i32.ges" },
  720. { Instructions::i32_geu, "i32.geu" },
  721. { Instructions::i64_eqz, "i64.eqz" },
  722. { Instructions::i64_eq, "i64.eq" },
  723. { Instructions::i64_ne, "i64.ne" },
  724. { Instructions::i64_lts, "i64.lts" },
  725. { Instructions::i64_ltu, "i64.ltu" },
  726. { Instructions::i64_gts, "i64.gts" },
  727. { Instructions::i64_gtu, "i64.gtu" },
  728. { Instructions::i64_les, "i64.les" },
  729. { Instructions::i64_leu, "i64.leu" },
  730. { Instructions::i64_ges, "i64.ges" },
  731. { Instructions::i64_geu, "i64.geu" },
  732. { Instructions::f32_eq, "f32.eq" },
  733. { Instructions::f32_ne, "f32.ne" },
  734. { Instructions::f32_lt, "f32.lt" },
  735. { Instructions::f32_gt, "f32.gt" },
  736. { Instructions::f32_le, "f32.le" },
  737. { Instructions::f32_ge, "f32.ge" },
  738. { Instructions::f64_eq, "f64.eq" },
  739. { Instructions::f64_ne, "f64.ne" },
  740. { Instructions::f64_lt, "f64.lt" },
  741. { Instructions::f64_gt, "f64.gt" },
  742. { Instructions::f64_le, "f64.le" },
  743. { Instructions::f64_ge, "f64.ge" },
  744. { Instructions::i32_clz, "i32.clz" },
  745. { Instructions::i32_ctz, "i32.ctz" },
  746. { Instructions::i32_popcnt, "i32.popcnt" },
  747. { Instructions::i32_add, "i32.add" },
  748. { Instructions::i32_sub, "i32.sub" },
  749. { Instructions::i32_mul, "i32.mul" },
  750. { Instructions::i32_divs, "i32.divs" },
  751. { Instructions::i32_divu, "i32.divu" },
  752. { Instructions::i32_rems, "i32.rems" },
  753. { Instructions::i32_remu, "i32.remu" },
  754. { Instructions::i32_and, "i32.and" },
  755. { Instructions::i32_or, "i32.or" },
  756. { Instructions::i32_xor, "i32.xor" },
  757. { Instructions::i32_shl, "i32.shl" },
  758. { Instructions::i32_shrs, "i32.shrs" },
  759. { Instructions::i32_shru, "i32.shru" },
  760. { Instructions::i32_rotl, "i32.rotl" },
  761. { Instructions::i32_rotr, "i32.rotr" },
  762. { Instructions::i64_clz, "i64.clz" },
  763. { Instructions::i64_ctz, "i64.ctz" },
  764. { Instructions::i64_popcnt, "i64.popcnt" },
  765. { Instructions::i64_add, "i64.add" },
  766. { Instructions::i64_sub, "i64.sub" },
  767. { Instructions::i64_mul, "i64.mul" },
  768. { Instructions::i64_divs, "i64.divs" },
  769. { Instructions::i64_divu, "i64.divu" },
  770. { Instructions::i64_rems, "i64.rems" },
  771. { Instructions::i64_remu, "i64.remu" },
  772. { Instructions::i64_and, "i64.and" },
  773. { Instructions::i64_or, "i64.or" },
  774. { Instructions::i64_xor, "i64.xor" },
  775. { Instructions::i64_shl, "i64.shl" },
  776. { Instructions::i64_shrs, "i64.shrs" },
  777. { Instructions::i64_shru, "i64.shru" },
  778. { Instructions::i64_rotl, "i64.rotl" },
  779. { Instructions::i64_rotr, "i64.rotr" },
  780. { Instructions::f32_abs, "f32.abs" },
  781. { Instructions::f32_neg, "f32.neg" },
  782. { Instructions::f32_ceil, "f32.ceil" },
  783. { Instructions::f32_floor, "f32.floor" },
  784. { Instructions::f32_trunc, "f32.trunc" },
  785. { Instructions::f32_nearest, "f32.nearest" },
  786. { Instructions::f32_sqrt, "f32.sqrt" },
  787. { Instructions::f32_add, "f32.add" },
  788. { Instructions::f32_sub, "f32.sub" },
  789. { Instructions::f32_mul, "f32.mul" },
  790. { Instructions::f32_div, "f32.div" },
  791. { Instructions::f32_min, "f32.min" },
  792. { Instructions::f32_max, "f32.max" },
  793. { Instructions::f32_copysign, "f32.copysign" },
  794. { Instructions::f64_abs, "f64.abs" },
  795. { Instructions::f64_neg, "f64.neg" },
  796. { Instructions::f64_ceil, "f64.ceil" },
  797. { Instructions::f64_floor, "f64.floor" },
  798. { Instructions::f64_trunc, "f64.trunc" },
  799. { Instructions::f64_nearest, "f64.nearest" },
  800. { Instructions::f64_sqrt, "f64.sqrt" },
  801. { Instructions::f64_add, "f64.add" },
  802. { Instructions::f64_sub, "f64.sub" },
  803. { Instructions::f64_mul, "f64.mul" },
  804. { Instructions::f64_div, "f64.div" },
  805. { Instructions::f64_min, "f64.min" },
  806. { Instructions::f64_max, "f64.max" },
  807. { Instructions::f64_copysign, "f64.copysign" },
  808. { Instructions::i32_wrap_i64, "i32.wrap_i64" },
  809. { Instructions::i32_trunc_sf32, "i32.trunc_sf32" },
  810. { Instructions::i32_trunc_uf32, "i32.trunc_uf32" },
  811. { Instructions::i32_trunc_sf64, "i32.trunc_sf64" },
  812. { Instructions::i32_trunc_uf64, "i32.trunc_uf64" },
  813. { Instructions::i64_extend_si32, "i64.extend_si32" },
  814. { Instructions::i64_extend_ui32, "i64.extend_ui32" },
  815. { Instructions::i64_trunc_sf32, "i64.trunc_sf32" },
  816. { Instructions::i64_trunc_uf32, "i64.trunc_uf32" },
  817. { Instructions::i64_trunc_sf64, "i64.trunc_sf64" },
  818. { Instructions::i64_trunc_uf64, "i64.trunc_uf64" },
  819. { Instructions::f32_convert_si32, "f32.convert_si32" },
  820. { Instructions::f32_convert_ui32, "f32.convert_ui32" },
  821. { Instructions::f32_convert_si64, "f32.convert_si64" },
  822. { Instructions::f32_convert_ui64, "f32.convert_ui64" },
  823. { Instructions::f32_demote_f64, "f32.demote_f64" },
  824. { Instructions::f64_convert_si32, "f64.convert_si32" },
  825. { Instructions::f64_convert_ui32, "f64.convert_ui32" },
  826. { Instructions::f64_convert_si64, "f64.convert_si64" },
  827. { Instructions::f64_convert_ui64, "f64.convert_ui64" },
  828. { Instructions::f64_promote_f32, "f64.promote_f32" },
  829. { Instructions::i32_reinterpret_f32, "i32.reinterpret_f32" },
  830. { Instructions::i64_reinterpret_f64, "i64.reinterpret_f64" },
  831. { Instructions::f32_reinterpret_i32, "f32.reinterpret_i32" },
  832. { Instructions::f64_reinterpret_i64, "f64.reinterpret_i64" },
  833. { Instructions::i32_extend8_s, "i32.extend8_s" },
  834. { Instructions::i32_extend16_s, "i32.extend16_s" },
  835. { Instructions::i64_extend8_s, "i64.extend8_s" },
  836. { Instructions::i64_extend16_s, "i64.extend16_s" },
  837. { Instructions::i64_extend32_s, "i64.extend32_s" },
  838. { Instructions::ref_null, "ref.null" },
  839. { Instructions::ref_is_null, "ref.is.null" },
  840. { Instructions::ref_func, "ref.func" },
  841. { Instructions::i32_trunc_sat_f32_s, "i32.trunc_sat_f32_s" },
  842. { Instructions::i32_trunc_sat_f32_u, "i32.trunc_sat_f32_u" },
  843. { Instructions::i32_trunc_sat_f64_s, "i32.trunc_sat_f64_s" },
  844. { Instructions::i32_trunc_sat_f64_u, "i32.trunc_sat_f64_u" },
  845. { Instructions::i64_trunc_sat_f32_s, "i64.trunc_sat_f32_s" },
  846. { Instructions::i64_trunc_sat_f32_u, "i64.trunc_sat_f32_u" },
  847. { Instructions::i64_trunc_sat_f64_s, "i64.trunc_sat_f64_s" },
  848. { Instructions::i64_trunc_sat_f64_u, "i64.trunc_sat_f64_u" },
  849. { Instructions::memory_init, "memory.init" },
  850. { Instructions::data_drop, "data.drop" },
  851. { Instructions::memory_copy, "memory.copy" },
  852. { Instructions::memory_fill, "memory.fill" },
  853. { Instructions::table_init, "table.init" },
  854. { Instructions::elem_drop, "elem.drop" },
  855. { Instructions::table_copy, "table.copy" },
  856. { Instructions::table_grow, "table.grow" },
  857. { Instructions::table_size, "table.size" },
  858. { Instructions::table_fill, "table.fill" },
  859. { Instructions::v128_load, "v128.load" },
  860. { Instructions::v128_load8x8_s, "v128.load8x8_s" },
  861. { Instructions::v128_load8x8_u, "v128.load8x8_u" },
  862. { Instructions::v128_load16x4_s, "v128.load16x4_s" },
  863. { Instructions::v128_load16x4_u, "v128.load16x4_u" },
  864. { Instructions::v128_load32x2_s, "v128.load32x2_s" },
  865. { Instructions::v128_load32x2_u, "v128.load32x2_u" },
  866. { Instructions::v128_load8_splat, "v128.load8_splat" },
  867. { Instructions::v128_load16_splat, "v128.load16_splat" },
  868. { Instructions::v128_load32_splat, "v128.load32_splat" },
  869. { Instructions::v128_load64_splat, "v128.load64_splat" },
  870. { Instructions::v128_store, "v128.store" },
  871. { Instructions::v128_const, "v128.const" },
  872. { Instructions::i8x16_shuffle, "i8x16.shuffle" },
  873. { Instructions::i8x16_swizzle, "i8x16.swizzle" },
  874. { Instructions::i8x16_splat, "i8x16.splat" },
  875. { Instructions::i16x8_splat, "i16x8.splat" },
  876. { Instructions::i32x4_splat, "i32x4.splat" },
  877. { Instructions::i64x2_splat, "i64x2.splat" },
  878. { Instructions::f32x4_splat, "f32x4.splat" },
  879. { Instructions::f64x2_splat, "f64x2.splat" },
  880. { Instructions::i8x16_extract_lane_s, "i8x16.extract_lane_s" },
  881. { Instructions::i8x16_extract_lane_u, "i8x16.extract_lane_u" },
  882. { Instructions::i8x16_replace_lane, "i8x16.replace_lane" },
  883. { Instructions::i16x8_extract_lane_s, "i16x8.extract_lane_s" },
  884. { Instructions::i16x8_extract_lane_u, "i16x8.extract_lane_u" },
  885. { Instructions::i16x8_replace_lane, "i16x8.replace_lane" },
  886. { Instructions::i32x4_extract_lane, "i32x4.extract_lane" },
  887. { Instructions::i32x4_replace_lane, "i32x4.replace_lane" },
  888. { Instructions::i64x2_extract_lane, "i64x2.extract_lane" },
  889. { Instructions::i64x2_replace_lane, "i64x2.replace_lane" },
  890. { Instructions::f32x4_extract_lane, "f32x4.extract_lane" },
  891. { Instructions::f32x4_replace_lane, "f32x4.replace_lane" },
  892. { Instructions::f64x2_extract_lane, "f64x2.extract_lane" },
  893. { Instructions::f64x2_replace_lane, "f64x2.replace_lane" },
  894. { Instructions::i8x16_eq, "i8x16.eq" },
  895. { Instructions::i8x16_ne, "i8x16.ne" },
  896. { Instructions::i8x16_lt_s, "i8x16.lt_s" },
  897. { Instructions::i8x16_lt_u, "i8x16.lt_u" },
  898. { Instructions::i8x16_gt_s, "i8x16.gt_s" },
  899. { Instructions::i8x16_gt_u, "i8x16.gt_u" },
  900. { Instructions::i8x16_le_s, "i8x16.le_s" },
  901. { Instructions::i8x16_le_u, "i8x16.le_u" },
  902. { Instructions::i8x16_ge_s, "i8x16.ge_s" },
  903. { Instructions::i8x16_ge_u, "i8x16.ge_u" },
  904. { Instructions::i16x8_eq, "i16x8.eq" },
  905. { Instructions::i16x8_ne, "i16x8.ne" },
  906. { Instructions::i16x8_lt_s, "i16x8.lt_s" },
  907. { Instructions::i16x8_lt_u, "i16x8.lt_u" },
  908. { Instructions::i16x8_gt_s, "i16x8.gt_s" },
  909. { Instructions::i16x8_gt_u, "i16x8.gt_u" },
  910. { Instructions::i16x8_le_s, "i16x8.le_s" },
  911. { Instructions::i16x8_le_u, "i16x8.le_u" },
  912. { Instructions::i16x8_ge_s, "i16x8.ge_s" },
  913. { Instructions::i16x8_ge_u, "i16x8.ge_u" },
  914. { Instructions::i32x4_eq, "i32x4.eq" },
  915. { Instructions::i32x4_ne, "i32x4.ne" },
  916. { Instructions::i32x4_lt_s, "i32x4.lt_s" },
  917. { Instructions::i32x4_lt_u, "i32x4.lt_u" },
  918. { Instructions::i32x4_gt_s, "i32x4.gt_s" },
  919. { Instructions::i32x4_gt_u, "i32x4.gt_u" },
  920. { Instructions::i32x4_le_s, "i32x4.le_s" },
  921. { Instructions::i32x4_le_u, "i32x4.le_u" },
  922. { Instructions::i32x4_ge_s, "i32x4.ge_s" },
  923. { Instructions::i32x4_ge_u, "i32x4.ge_u" },
  924. { Instructions::f32x4_eq, "f32x4.eq" },
  925. { Instructions::f32x4_ne, "f32x4.ne" },
  926. { Instructions::f32x4_lt, "f32x4.lt" },
  927. { Instructions::f32x4_gt, "f32x4.gt" },
  928. { Instructions::f32x4_le, "f32x4.le" },
  929. { Instructions::f32x4_ge, "f32x4.ge" },
  930. { Instructions::f64x2_eq, "f64x2.eq" },
  931. { Instructions::f64x2_ne, "f64x2.ne" },
  932. { Instructions::f64x2_lt, "f64x2.lt" },
  933. { Instructions::f64x2_gt, "f64x2.gt" },
  934. { Instructions::f64x2_le, "f64x2.le" },
  935. { Instructions::f64x2_ge, "f64x2.ge" },
  936. { Instructions::v128_not, "v128.not" },
  937. { Instructions::v128_and, "v128.and" },
  938. { Instructions::v128_andnot, "v128.andnot" },
  939. { Instructions::v128_or, "v128.or" },
  940. { Instructions::v128_xor, "v128.xor" },
  941. { Instructions::v128_bitselect, "v128.bitselect" },
  942. { Instructions::v128_any_true, "v128.any_true" },
  943. { Instructions::v128_load8_lane, "v128.load8_lane" },
  944. { Instructions::v128_load16_lane, "v128.load16_lane" },
  945. { Instructions::v128_load32_lane, "v128.load32_lane" },
  946. { Instructions::v128_load64_lane, "v128.load64_lane" },
  947. { Instructions::v128_store8_lane, "v128.store8_lane" },
  948. { Instructions::v128_store16_lane, "v128.store16_lane" },
  949. { Instructions::v128_store32_lane, "v128.store32_lane" },
  950. { Instructions::v128_store64_lane, "v128.store64_lane" },
  951. { Instructions::v128_load32_zero, "v128.load32_zero" },
  952. { Instructions::v128_load64_zero, "v128.load64_zero" },
  953. { Instructions::f32x4_demote_f64x2_zero, "f32x4.demote_f64x2_zero" },
  954. { Instructions::f64x2_promote_low_f32x4, "f64x2.promote_low_f32x4" },
  955. { Instructions::i8x16_abs, "i8x16.abs" },
  956. { Instructions::i8x16_neg, "i8x16.neg" },
  957. { Instructions::i8x16_popcnt, "i8x16.popcnt" },
  958. { Instructions::i8x16_all_true, "i8x16.all_true" },
  959. { Instructions::i8x16_bitmask, "i8x16.bitmask" },
  960. { Instructions::i8x16_narrow_i16x8_s, "i8x16.narrow_i16x8_s" },
  961. { Instructions::i8x16_narrow_i16x8_u, "i8x16.narrow_i16x8_u" },
  962. { Instructions::f32x4_ceil, "f32x4.ceil" },
  963. { Instructions::f32x4_floor, "f32x4.floor" },
  964. { Instructions::f32x4_trunc, "f32x4.trunc" },
  965. { Instructions::f32x4_nearest, "f32x4.nearest" },
  966. { Instructions::i8x16_shl, "i8x16.shl" },
  967. { Instructions::i8x16_shr_s, "i8x16.shr_s" },
  968. { Instructions::i8x16_shr_u, "i8x16.shr_u" },
  969. { Instructions::i8x16_add, "i8x16.add" },
  970. { Instructions::i8x16_add_sat_s, "i8x16.add_sat_s" },
  971. { Instructions::i8x16_add_sat_u, "i8x16.add_sat_u" },
  972. { Instructions::i8x16_sub, "i8x16.sub" },
  973. { Instructions::i8x16_sub_sat_s, "i8x16.sub_sat_s" },
  974. { Instructions::i8x16_sub_sat_u, "i8x16.sub_sat_u" },
  975. { Instructions::f64x2_ceil, "f64x2.ceil" },
  976. { Instructions::f64x2_floor, "f64x2.floor" },
  977. { Instructions::i8x16_min_s, "i8x16.min_s" },
  978. { Instructions::i8x16_min_u, "i8x16.min_u" },
  979. { Instructions::i8x16_max_s, "i8x16.max_s" },
  980. { Instructions::i8x16_max_u, "i8x16.max_u" },
  981. { Instructions::f64x2_trunc, "f64x2.trunc" },
  982. { Instructions::i8x16_avgr_u, "i8x16.avgr_u" },
  983. { Instructions::i16x8_extadd_pairwise_i8x16_s, "i16x8.extadd_pairwise_i8x16_s" },
  984. { Instructions::i16x8_extadd_pairwise_i8x16_u, "i16x8.extadd_pairwise_i8x16_u" },
  985. { Instructions::i32x4_extadd_pairwise_i16x8_s, "i32x4.extadd_pairwise_i16x8_s" },
  986. { Instructions::i32x4_extadd_pairwise_i16x8_u, "i32x4.extadd_pairwise_i16x8_u" },
  987. { Instructions::i16x8_abs, "i16x8.abs" },
  988. { Instructions::i16x8_neg, "i16x8.neg" },
  989. { Instructions::i16x8_q15mulr_sat_s, "i16x8.q15mulr_sat_s" },
  990. { Instructions::i16x8_all_true, "i16x8.all_true" },
  991. { Instructions::i16x8_bitmask, "i16x8.bitmask" },
  992. { Instructions::i16x8_narrow_i32x4_s, "i16x8.narrow_i32x4_s" },
  993. { Instructions::i16x8_narrow_i32x4_u, "i16x8.narrow_i32x4_u" },
  994. { Instructions::i16x8_extend_low_i8x16_s, "i16x8.extend_low_i8x16_s" },
  995. { Instructions::i16x8_extend_high_i8x16_s, "i16x8.extend_high_i8x16_s" },
  996. { Instructions::i16x8_extend_low_i8x16_u, "i16x8.extend_low_i8x16_u" },
  997. { Instructions::i16x8_extend_high_i8x16_u, "i16x8.extend_high_i8x16_u" },
  998. { Instructions::i16x8_shl, "i16x8.shl" },
  999. { Instructions::i16x8_shr_s, "i16x8.shr_s" },
  1000. { Instructions::i16x8_shr_u, "i16x8.shr_u" },
  1001. { Instructions::i16x8_add, "i16x8.add" },
  1002. { Instructions::i16x8_add_sat_s, "i16x8.add_sat_s" },
  1003. { Instructions::i16x8_add_sat_u, "i16x8.add_sat_u" },
  1004. { Instructions::i16x8_sub, "i16x8.sub" },
  1005. { Instructions::i16x8_sub_sat_s, "i16x8.sub_sat_s" },
  1006. { Instructions::i16x8_sub_sat_u, "i16x8.sub_sat_u" },
  1007. { Instructions::f64x2_nearest, "f64x2.nearest" },
  1008. { Instructions::i16x8_mul, "i16x8.mul" },
  1009. { Instructions::i16x8_min_s, "i16x8.min_s" },
  1010. { Instructions::i16x8_min_u, "i16x8.min_u" },
  1011. { Instructions::i16x8_max_s, "i16x8.max_s" },
  1012. { Instructions::i16x8_max_u, "i16x8.max_u" },
  1013. { Instructions::i16x8_avgr_u, "i16x8.avgr_u" },
  1014. { Instructions::i16x8_extmul_low_i8x16_s, "i16x8.extmul_low_i8x16_s" },
  1015. { Instructions::i16x8_extmul_high_i8x16_s, "i16x8.extmul_high_i8x16_s" },
  1016. { Instructions::i16x8_extmul_low_i8x16_u, "i16x8.extmul_low_i8x16_u" },
  1017. { Instructions::i16x8_extmul_high_i8x16_u, "i16x8.extmul_high_i8x16_u" },
  1018. { Instructions::i32x4_abs, "i32x4.abs" },
  1019. { Instructions::i32x4_neg, "i32x4.neg" },
  1020. { Instructions::i32x4_all_true, "i32x4.all_true" },
  1021. { Instructions::i32x4_bitmask, "i32x4.bitmask" },
  1022. { Instructions::i32x4_extend_low_i16x8_s, "i32x4.extend_low_i16x8_s" },
  1023. { Instructions::i32x4_extend_high_i16x8_s, "i32x4.extend_high_i16x8_s" },
  1024. { Instructions::i32x4_extend_low_i16x8_u, "i32x4.extend_low_i16x8_u" },
  1025. { Instructions::i32x4_extend_high_i16x8_u, "i32x4.extend_high_i16x8_u" },
  1026. { Instructions::i32x4_shl, "i32x4.shl" },
  1027. { Instructions::i32x4_shr_s, "i32x4.shr_s" },
  1028. { Instructions::i32x4_shr_u, "i32x4.shr_u" },
  1029. { Instructions::i32x4_add, "i32x4.add" },
  1030. { Instructions::i32x4_sub, "i32x4.sub" },
  1031. { Instructions::i32x4_mul, "i32x4.mul" },
  1032. { Instructions::i32x4_min_s, "i32x4.min_s" },
  1033. { Instructions::i32x4_min_u, "i32x4.min_u" },
  1034. { Instructions::i32x4_max_s, "i32x4.max_s" },
  1035. { Instructions::i32x4_max_u, "i32x4.max_u" },
  1036. { Instructions::i32x4_dot_i16x8_s, "i32x4.dot_i16x8_s" },
  1037. { Instructions::i32x4_extmul_low_i16x8_s, "i32x4.extmul_low_i16x8_s" },
  1038. { Instructions::i32x4_extmul_high_i16x8_s, "i32x4.extmul_high_i16x8_s" },
  1039. { Instructions::i32x4_extmul_low_i16x8_u, "i32x4.extmul_low_i16x8_u" },
  1040. { Instructions::i32x4_extmul_high_i16x8_u, "i32x4.extmul_high_i16x8_u" },
  1041. { Instructions::i64x2_abs, "i64x2.abs" },
  1042. { Instructions::i64x2_neg, "i64x2.neg" },
  1043. { Instructions::i64x2_all_true, "i64x2.all_true" },
  1044. { Instructions::i64x2_bitmask, "i64x2.bitmask" },
  1045. { Instructions::i64x2_extend_low_i32x4_s, "i64x2.extend_low_i32x4_s" },
  1046. { Instructions::i64x2_extend_high_i32x4_s, "i64x2.extend_high_i32x4_s" },
  1047. { Instructions::i64x2_extend_low_i32x4_u, "i64x2.extend_low_i32x4_u" },
  1048. { Instructions::i64x2_extend_high_i32x4_u, "i64x2.extend_high_i32x4_u" },
  1049. { Instructions::i64x2_shl, "i64x2.shl" },
  1050. { Instructions::i64x2_shr_s, "i64x2.shr_s" },
  1051. { Instructions::i64x2_shr_u, "i64x2.shr_u" },
  1052. { Instructions::i64x2_add, "i64x2.add" },
  1053. { Instructions::i64x2_sub, "i64x2.sub" },
  1054. { Instructions::i64x2_mul, "i64x2.mul" },
  1055. { Instructions::i64x2_eq, "i64x2.eq" },
  1056. { Instructions::i64x2_ne, "i64x2.ne" },
  1057. { Instructions::i64x2_lt_s, "i64x2.lt_s" },
  1058. { Instructions::i64x2_gt_s, "i64x2.gt_s" },
  1059. { Instructions::i64x2_le_s, "i64x2.le_s" },
  1060. { Instructions::i64x2_ge_s, "i64x2.ge_s" },
  1061. { Instructions::i64x2_extmul_low_i32x4_s, "i64x2.extmul_low_i32x4_s" },
  1062. { Instructions::i64x2_extmul_high_i32x4_s, "i64x2.extmul_high_i32x4_s" },
  1063. { Instructions::i64x2_extmul_low_i32x4_u, "i64x2.extmul_low_i32x4_u" },
  1064. { Instructions::i64x2_extmul_high_i32x4_u, "i64x2.extmul_high_i32x4_u" },
  1065. { Instructions::f32x4_abs, "f32x4.abs" },
  1066. { Instructions::f32x4_neg, "f32x4.neg" },
  1067. { Instructions::f32x4_sqrt, "f32x4.sqrt" },
  1068. { Instructions::f32x4_add, "f32x4.add" },
  1069. { Instructions::f32x4_sub, "f32x4.sub" },
  1070. { Instructions::f32x4_mul, "f32x4.mul" },
  1071. { Instructions::f32x4_div, "f32x4.div" },
  1072. { Instructions::f32x4_min, "f32x4.min" },
  1073. { Instructions::f32x4_max, "f32x4.max" },
  1074. { Instructions::f32x4_pmin, "f32x4.pmin" },
  1075. { Instructions::f32x4_pmax, "f32x4.pmax" },
  1076. { Instructions::f64x2_abs, "f64x2.abs" },
  1077. { Instructions::f64x2_neg, "f64x2.neg" },
  1078. { Instructions::f64x2_sqrt, "f64x2.sqrt" },
  1079. { Instructions::f64x2_add, "f64x2.add" },
  1080. { Instructions::f64x2_sub, "f64x2.sub" },
  1081. { Instructions::f64x2_mul, "f64x2.mul" },
  1082. { Instructions::f64x2_div, "f64x2.div" },
  1083. { Instructions::f64x2_min, "f64x2.min" },
  1084. { Instructions::f64x2_max, "f64x2.max" },
  1085. { Instructions::f64x2_pmin, "f64x2.pmin" },
  1086. { Instructions::f64x2_pmax, "f64x2.pmax" },
  1087. { Instructions::i32x4_trunc_sat_f32x4_s, "i32x4.trunc_sat_f32x4_s" },
  1088. { Instructions::i32x4_trunc_sat_f32x4_u, "i32x4.trunc_sat_f32x4_u" },
  1089. { Instructions::f32x4_convert_i32x4_s, "f32x4.convert_i32x4_s" },
  1090. { Instructions::f32x4_convert_i32x4_u, "f32x4.convert_i32x4_u" },
  1091. { Instructions::i32x4_trunc_sat_f64x2_s_zero, "i32x4.trunc_sat_f64x2_s_zero" },
  1092. { Instructions::i32x4_trunc_sat_f64x2_u_zero, "i32x4.trunc_sat_f64x2_u_zero" },
  1093. { Instructions::f64x2_convert_low_i32x4_s, "f64x2.convert_low_i32x4_s" },
  1094. { Instructions::f64x2_convert_low_i32x4_u, "f64x2.convert_low_i32x4_u" },
  1095. { Instructions::structured_else, "synthetic:else" },
  1096. { Instructions::structured_end, "synthetic:end" },
  1097. };
  1098. HashMap<ByteString, Wasm::OpCode> Wasm::Names::instructions_by_name;