Printer.cpp 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829
  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/Printer/Printer.h>
  9. namespace Wasm {
  10. struct Names {
  11. static HashMap<OpCode, String> instruction_names;
  12. };
  13. String instruction_name(const OpCode& opcode)
  14. {
  15. return Names::instruction_names.get(opcode).value_or("<unknown>");
  16. }
  17. void Printer::print_indent()
  18. {
  19. for (size_t i = 0; i < m_indent; ++i)
  20. m_stream.write_or_error(" "sv.bytes());
  21. }
  22. void Printer::print(const Wasm::BlockType& type)
  23. {
  24. print_indent();
  25. print("(type block ");
  26. switch (type.kind()) {
  27. case Wasm::BlockType::Kind::Index:
  28. print("index {})\n", type.type_index().value());
  29. return;
  30. case Wasm::BlockType::Kind::Type: {
  31. print("type\n");
  32. {
  33. TemporaryChange change { m_indent, m_indent + 1 };
  34. print(type.value_type());
  35. }
  36. print_indent();
  37. print(")\n");
  38. return;
  39. }
  40. case Wasm::BlockType::Kind ::Empty:
  41. print("empty)\n");
  42. return;
  43. }
  44. VERIFY_NOT_REACHED();
  45. }
  46. void Printer::print(const Wasm::CodeSection& section)
  47. {
  48. print_indent();
  49. print("(section code\n");
  50. {
  51. TemporaryChange change { m_indent, m_indent + 1 };
  52. for (auto& code : section.functions())
  53. print(code);
  54. }
  55. print_indent();
  56. print(")\n");
  57. }
  58. void Printer::print(const Wasm::CodeSection::Code& code)
  59. {
  60. print(code.func());
  61. }
  62. void Printer::print(const Wasm::CustomSection& section)
  63. {
  64. print_indent();
  65. print("(section custom\n");
  66. {
  67. TemporaryChange change { m_indent, m_indent + 1 };
  68. print_indent();
  69. print("(name `{}')\n", section.name());
  70. print_indent();
  71. print("(contents {} bytes)\n", section.contents().size());
  72. }
  73. print_indent();
  74. print(")\n");
  75. }
  76. void Printer::print(const Wasm::DataCountSection& section)
  77. {
  78. print_indent();
  79. print("(section data count\n");
  80. if (section.count().has_value()) {
  81. TemporaryChange change { m_indent, m_indent + 1 };
  82. print_indent();
  83. print("(count `{}')\n", *section.count());
  84. }
  85. print_indent();
  86. print(")\n");
  87. }
  88. void Printer::print(const Wasm::DataSection& section)
  89. {
  90. print_indent();
  91. print("(section data\n");
  92. {
  93. TemporaryChange change { m_indent, m_indent + 1 };
  94. for (auto& entry : section.data())
  95. print(entry);
  96. }
  97. print_indent();
  98. print(")\n");
  99. }
  100. void Printer::print(const Wasm::DataSection::Data& data)
  101. {
  102. print_indent();
  103. print("(data with value\n");
  104. {
  105. TemporaryChange change { m_indent, m_indent + 1 };
  106. data.value().visit(
  107. [this](const DataSection::Data::Passive& value) {
  108. print_indent();
  109. print("(passive init {}xu8 (", value.init.size());
  110. bool first = true;
  111. for (auto v : value.init) {
  112. if (first)
  113. print("{:x}", v);
  114. else
  115. print(" {:x}", v);
  116. first = false;
  117. }
  118. print(")\n");
  119. },
  120. [this](const DataSection::Data::Active& value) {
  121. print_indent();
  122. print("(active init {}xu8 (", value.init.size());
  123. bool first = true;
  124. for (auto v : value.init) {
  125. if (first)
  126. print("{:x}", v);
  127. else
  128. print(" {:x}", v);
  129. first = false;
  130. }
  131. print("\n");
  132. {
  133. TemporaryChange change { m_indent, m_indent + 1 };
  134. print_indent();
  135. print("(offset\n");
  136. {
  137. TemporaryChange change { m_indent, m_indent + 1 };
  138. print(value.offset);
  139. }
  140. print_indent();
  141. print(")\n");
  142. }
  143. {
  144. TemporaryChange change { m_indent, m_indent + 1 };
  145. print_indent();
  146. print("(index {})\n", value.index.value());
  147. }
  148. });
  149. }
  150. print_indent();
  151. print(")\n");
  152. }
  153. void Printer::print(const Wasm::ElementSection& section)
  154. {
  155. print_indent();
  156. print("(section element\n");
  157. {
  158. TemporaryChange change { m_indent, m_indent + 1 };
  159. for (auto& entry : section.segments())
  160. entry.visit([this](auto& segment) { print(segment); });
  161. }
  162. print_indent();
  163. print(")\n");
  164. }
  165. void Printer::print(const Wasm::ElementSection::SegmentType0&)
  166. {
  167. }
  168. void Printer::print(const Wasm::ElementSection::SegmentType1& segment)
  169. {
  170. print_indent();
  171. print("(element segment kind 1\n");
  172. {
  173. TemporaryChange change { m_indent, m_indent + 1 };
  174. for (auto& index : segment.function_indices) {
  175. print_indent();
  176. print("(function index {})\n", index.value());
  177. }
  178. }
  179. print_indent();
  180. print(")\n");
  181. }
  182. void Printer::print(const Wasm::ElementSection::SegmentType2&)
  183. {
  184. }
  185. void Printer::print(const Wasm::ElementSection::SegmentType3&)
  186. {
  187. }
  188. void Printer::print(const Wasm::ElementSection::SegmentType4&)
  189. {
  190. }
  191. void Printer::print(const Wasm::ElementSection::SegmentType5&)
  192. {
  193. }
  194. void Printer::print(const Wasm::ElementSection::SegmentType6&)
  195. {
  196. }
  197. void Printer::print(const Wasm::ElementSection::SegmentType7&)
  198. {
  199. }
  200. void Printer::print(const Wasm::ExportSection& section)
  201. {
  202. print_indent();
  203. print("(section export\n");
  204. {
  205. TemporaryChange change { m_indent, m_indent + 1 };
  206. for (auto& entry : section.entries())
  207. print(entry);
  208. }
  209. print_indent();
  210. print(")\n");
  211. }
  212. void Printer::print(const Wasm::ExportSection::Export& entry)
  213. {
  214. print_indent();
  215. print("(export `{}' as\n", entry.name());
  216. {
  217. TemporaryChange change { m_indent, m_indent + 1 };
  218. print_indent();
  219. entry.description().visit(
  220. [this](const FunctionIndex& index) { print("(function index {})\n", index.value()); },
  221. [this](const TableIndex& index) { print("(table index {})\n", index.value()); },
  222. [this](const MemoryIndex& index) { print("(memory index {})\n", index.value()); },
  223. [this](const GlobalIndex& index) { print("(global index {})\n", index.value()); });
  224. }
  225. print_indent();
  226. print(")\n");
  227. }
  228. void Printer::print(const Wasm::Expression& expression)
  229. {
  230. TemporaryChange change { m_indent, m_indent + 1 };
  231. for (auto& instr : expression.instructions())
  232. print(instr);
  233. }
  234. void Printer::print(const Wasm::CodeSection::Func& func)
  235. {
  236. print_indent();
  237. print("(function\n");
  238. {
  239. TemporaryChange change { m_indent, m_indent + 1 };
  240. {
  241. print_indent();
  242. print("(locals\n");
  243. {
  244. TemporaryChange change { m_indent, m_indent + 1 };
  245. for (auto& locals : func.locals())
  246. print(locals);
  247. }
  248. print_indent();
  249. print(")\n");
  250. }
  251. print_indent();
  252. print("(body\n");
  253. print(func.body());
  254. print_indent();
  255. print(")\n");
  256. }
  257. print_indent();
  258. print(")\n");
  259. }
  260. void Printer::print(const Wasm::FunctionSection& section)
  261. {
  262. print_indent();
  263. print("(section function\n");
  264. {
  265. TemporaryChange change { m_indent, m_indent + 1 };
  266. for (auto& index : section.types()) {
  267. print_indent();
  268. print("(type index {})\n", index.value());
  269. }
  270. }
  271. print_indent();
  272. print(")\n");
  273. }
  274. void Printer::print(const Wasm::FunctionType& type)
  275. {
  276. print_indent();
  277. print("(type function\n");
  278. {
  279. TemporaryChange change { m_indent, m_indent + 1 };
  280. print_indent();
  281. print("(parameters\n");
  282. {
  283. TemporaryChange change { m_indent, m_indent + 1 };
  284. for (auto& param : type.parameters())
  285. print(param);
  286. }
  287. print_indent();
  288. print("\n");
  289. }
  290. {
  291. TemporaryChange change { m_indent, m_indent + 1 };
  292. print_indent();
  293. print("(results\n");
  294. {
  295. TemporaryChange change { m_indent, m_indent + 1 };
  296. for (auto& type : type.results())
  297. print(type);
  298. }
  299. print_indent();
  300. print(")\n");
  301. }
  302. print_indent();
  303. print(")\n");
  304. }
  305. void Printer::print(const Wasm::GlobalSection& section)
  306. {
  307. print_indent();
  308. print("(section global\n");
  309. {
  310. TemporaryChange change { m_indent, m_indent + 1 };
  311. for (auto& entry : section.entries())
  312. print(entry);
  313. }
  314. print_indent();
  315. print(")\n");
  316. }
  317. void Printer::print(const Wasm::GlobalSection::Global& entry)
  318. {
  319. print_indent();
  320. print("(global\n");
  321. {
  322. TemporaryChange change { m_indent, m_indent + 1 };
  323. print_indent();
  324. print("(type\n");
  325. {
  326. TemporaryChange change { m_indent, m_indent + 1 };
  327. print(entry.type());
  328. }
  329. print_indent();
  330. print(")\n");
  331. }
  332. {
  333. TemporaryChange change { m_indent, m_indent + 1 };
  334. print_indent();
  335. print("(init\n");
  336. {
  337. TemporaryChange change { m_indent, m_indent + 1 };
  338. print(entry.expression());
  339. }
  340. print_indent();
  341. print(")\n");
  342. }
  343. print_indent();
  344. print(")\n");
  345. }
  346. void Printer::print(const Wasm::GlobalType& type)
  347. {
  348. print_indent();
  349. print("(type global {}mutable\n", type.is_mutable() ? "" : "im");
  350. {
  351. TemporaryChange change { m_indent, m_indent + 1 };
  352. print(type.type());
  353. }
  354. print_indent();
  355. print(")\n");
  356. }
  357. void Printer::print(const Wasm::ImportSection& section)
  358. {
  359. print_indent();
  360. print("(section import\n");
  361. {
  362. TemporaryChange change { m_indent, m_indent + 1 };
  363. for (auto& import : section.imports())
  364. print(import);
  365. }
  366. print_indent();
  367. print(")\n");
  368. }
  369. void Printer::print(const Wasm::ImportSection::Import& import)
  370. {
  371. print_indent();
  372. print("(import `{}' from `{}' as\n", import.name(), import.module());
  373. {
  374. TemporaryChange change { m_indent, m_indent + 1 };
  375. import.description().visit(
  376. [this](const auto& type) { print(type); },
  377. [this](const TypeIndex& index) {
  378. print_indent();
  379. print("(type index {})\n", index.value());
  380. });
  381. }
  382. print_indent();
  383. print(")\n");
  384. }
  385. void Printer::print(const Wasm::Instruction& instruction)
  386. {
  387. print_indent();
  388. print("({}", instruction_name(instruction.opcode()));
  389. if (instruction.arguments().has<u8>()) {
  390. print(")\n");
  391. } else {
  392. print(" ");
  393. instruction.arguments().visit(
  394. [&](const BlockType& type) { print(type); },
  395. [&](const DataIndex& index) { print("(data index {})", index.value()); },
  396. [&](const ElementIndex& index) { print("(element index {})", index.value()); },
  397. [&](const FunctionIndex& index) { print("(function index {})", index.value()); },
  398. [&](const GlobalIndex& index) { print("(global index {})", index.value()); },
  399. [&](const LabelIndex& index) { print("(label index {})", index.value()); },
  400. [&](const LocalIndex& index) { print("(local index {})", index.value()); },
  401. [&](const TableIndex& index) { print("(table index {})", index.value()); },
  402. [&](const Instruction::IndirectCallArgs& args) { print("(indirect (type index {}) (table index {}))", args.type.value(), args.table.value()); },
  403. [&](const Instruction::MemoryArgument& args) { print("(memory (align {}) (offset {}))", args.align, args.offset); },
  404. [&](const Instruction::StructuredInstructionArgs& args) { print("(structured (else {}) (end {}))", args.else_ip.has_value() ? String::number(args.else_ip->value()) : "(none)", args.end_ip.value()); },
  405. [&](const Instruction::TableBranchArgs&) { print("(table_branch ...)"); },
  406. [&](const Instruction::TableElementArgs& args) { print("(table_element (table index {}) (element index {}))", args.table_index.value(), args.element_index.value()); },
  407. [&](const Instruction::TableTableArgs& args) { print("(table_table (table index {}) (table index {}))", args.lhs.value(), args.rhs.value()); },
  408. [&](const ValueType& type) { print(type); },
  409. [&](const Vector<ValueType>&) { print("(types...)"); },
  410. [&](const auto& value) { print("{}", value); });
  411. print(")\n");
  412. }
  413. }
  414. void Printer::print(const Wasm::Limits& limits)
  415. {
  416. print_indent();
  417. print("(limits min={}", limits.min());
  418. if (limits.max().has_value())
  419. print(" max={}", limits.max().value());
  420. else
  421. print(" unbounded");
  422. print(")\n");
  423. }
  424. void Printer::print(const Wasm::Locals& local)
  425. {
  426. print_indent();
  427. print("(local x{} of type\n", local.n());
  428. {
  429. TemporaryChange change { m_indent, m_indent + 1 };
  430. print(local.type());
  431. }
  432. print_indent();
  433. print(")\n");
  434. }
  435. void Printer::print(const Wasm::MemorySection& section)
  436. {
  437. print_indent();
  438. print("(section memory\n");
  439. {
  440. TemporaryChange change { m_indent, m_indent + 1 };
  441. for (auto& memory : section.memories())
  442. print(memory);
  443. }
  444. print_indent();
  445. print(")\n");
  446. }
  447. void Printer::print(const Wasm::MemorySection::Memory& memory)
  448. {
  449. print_indent();
  450. print("(memory\n");
  451. {
  452. TemporaryChange change { m_indent, m_indent + 1 };
  453. print(memory.type());
  454. }
  455. print_indent();
  456. print(")\n");
  457. }
  458. void Printer::print(const Wasm::MemoryType& type)
  459. {
  460. print_indent();
  461. print("(type memory\n");
  462. {
  463. TemporaryChange change { m_indent, m_indent + 1 };
  464. print(type.limits());
  465. }
  466. print_indent();
  467. print(")\n");
  468. }
  469. void Printer::print(const Wasm::Module& module)
  470. {
  471. print_indent();
  472. {
  473. TemporaryChange change { m_indent, m_indent + 1 };
  474. print("(module\n");
  475. for (auto& section : module.sections())
  476. section.visit([this](const auto& value) { print(value); });
  477. }
  478. print_indent();
  479. print(")\n");
  480. }
  481. void Printer::print(const Wasm::Module::Function& func)
  482. {
  483. print_indent();
  484. print("(function\n");
  485. {
  486. TemporaryChange change { m_indent, m_indent + 1 };
  487. {
  488. print_indent();
  489. print("(locals\n");
  490. {
  491. TemporaryChange change { m_indent, m_indent + 1 };
  492. for (auto& locals : func.locals())
  493. print(locals);
  494. }
  495. print_indent();
  496. print(")\n");
  497. }
  498. print_indent();
  499. print("(body\n");
  500. print(func.body());
  501. print_indent();
  502. print(")\n");
  503. }
  504. print_indent();
  505. print(")\n");
  506. }
  507. void Printer::print(const Wasm::StartSection& section)
  508. {
  509. print_indent();
  510. print("(section start\n");
  511. {
  512. TemporaryChange change { m_indent, m_indent + 1 };
  513. print(section.function());
  514. }
  515. print_indent();
  516. print(")\n");
  517. }
  518. void Printer::print(const Wasm::StartSection::StartFunction& function)
  519. {
  520. print_indent();
  521. print("(start function index {})\n", function.index().value());
  522. }
  523. void Printer::print(const Wasm::TableSection& section)
  524. {
  525. print_indent();
  526. print("(section table\n");
  527. {
  528. TemporaryChange change { m_indent, m_indent + 1 };
  529. for (auto& table : section.tables())
  530. print(table);
  531. }
  532. print_indent();
  533. print(")\n");
  534. }
  535. void Printer::print(const Wasm::TableSection::Table& table)
  536. {
  537. print_indent();
  538. print("(table\n");
  539. {
  540. TemporaryChange change { m_indent, m_indent + 1 };
  541. print(table.type());
  542. }
  543. print_indent();
  544. print(")\n");
  545. }
  546. void Printer::print(const Wasm::TableType& type)
  547. {
  548. print_indent();
  549. print("(type table min:{}", type.limits().min());
  550. if (type.limits().max().has_value())
  551. print(" max:{}", type.limits().max().value());
  552. print("\n");
  553. {
  554. TemporaryChange change { m_indent, m_indent + 1 };
  555. print(type.element_type());
  556. }
  557. print_indent();
  558. print(")\n");
  559. }
  560. void Printer::print(const Wasm::TypeSection& section)
  561. {
  562. print_indent();
  563. print("(section type\n");
  564. {
  565. TemporaryChange change { m_indent, m_indent + 1 };
  566. for (auto& type : section.types())
  567. print(type);
  568. }
  569. print_indent();
  570. print(")\n");
  571. }
  572. void Printer::print(const Wasm::ValueType& type)
  573. {
  574. print_indent();
  575. print("(type {})\n", ValueType::kind_name(type.kind()));
  576. }
  577. }
  578. HashMap<Wasm::OpCode, String> Wasm::Names::instruction_names {
  579. { Instructions::unreachable, "unreachable" },
  580. { Instructions::nop, "nop" },
  581. { Instructions::block, "block" },
  582. { Instructions::loop, "loop" },
  583. { Instructions::if_, "if" },
  584. { Instructions::br, "br" },
  585. { Instructions::br_if, "br.if" },
  586. { Instructions::br_table, "br.table" },
  587. { Instructions::return_, "return." },
  588. { Instructions::call, "call" },
  589. { Instructions::call_indirect, "call.indirect" },
  590. { Instructions::drop, "drop" },
  591. { Instructions::select, "select" },
  592. { Instructions::select_typed, "select.typed" },
  593. { Instructions::local_get, "local.get" },
  594. { Instructions::local_set, "local.set" },
  595. { Instructions::local_tee, "local.tee" },
  596. { Instructions::global_get, "global.get" },
  597. { Instructions::global_set, "global.set" },
  598. { Instructions::table_get, "table.get" },
  599. { Instructions::table_set, "table.set" },
  600. { Instructions::i32_load, "i32.load" },
  601. { Instructions::i64_load, "i64.load" },
  602. { Instructions::f32_load, "f32.load" },
  603. { Instructions::f64_load, "f64.load" },
  604. { Instructions::i32_load8_s, "i32.load8.s" },
  605. { Instructions::i32_load8_u, "i32.load8.u" },
  606. { Instructions::i32_load16_s, "i32.load16.s" },
  607. { Instructions::i32_load16_u, "i32.load16.u" },
  608. { Instructions::i64_load8_s, "i64.load8.s" },
  609. { Instructions::i64_load8_u, "i64.load8.u" },
  610. { Instructions::i64_load16_s, "i64.load16.s" },
  611. { Instructions::i64_load16_u, "i64.load16.u" },
  612. { Instructions::i64_load32_s, "i64.load32.s" },
  613. { Instructions::i64_load32_u, "i64.load32.u" },
  614. { Instructions::i32_store, "i32.store" },
  615. { Instructions::i64_store, "i64.store" },
  616. { Instructions::f32_store, "f32.store" },
  617. { Instructions::f64_store, "f64.store" },
  618. { Instructions::i32_store8, "i32.store8" },
  619. { Instructions::i32_store16, "i32.store16" },
  620. { Instructions::i64_store8, "i64.store8" },
  621. { Instructions::i64_store16, "i64.store16" },
  622. { Instructions::i64_store32, "i64.store32" },
  623. { Instructions::memory_size, "memory.size" },
  624. { Instructions::memory_grow, "memory.grow" },
  625. { Instructions::i32_const, "i32.const" },
  626. { Instructions::i64_const, "i64.const" },
  627. { Instructions::f32_const, "f32.const" },
  628. { Instructions::f64_const, "f64.const" },
  629. { Instructions::i32_eqz, "i32.eqz" },
  630. { Instructions::i32_eq, "i32.eq" },
  631. { Instructions::i32_ne, "i32.ne" },
  632. { Instructions::i32_lts, "i32.lts" },
  633. { Instructions::i32_ltu, "i32.ltu" },
  634. { Instructions::i32_gts, "i32.gts" },
  635. { Instructions::i32_gtu, "i32.gtu" },
  636. { Instructions::i32_les, "i32.les" },
  637. { Instructions::i32_leu, "i32.leu" },
  638. { Instructions::i32_ges, "i32.ges" },
  639. { Instructions::i32_geu, "i32.geu" },
  640. { Instructions::i64_eqz, "i64.eqz" },
  641. { Instructions::i64_eq, "i64.eq" },
  642. { Instructions::i64_ne, "i64.ne" },
  643. { Instructions::i64_lts, "i64.lts" },
  644. { Instructions::i64_ltu, "i64.ltu" },
  645. { Instructions::i64_gts, "i64.gts" },
  646. { Instructions::i64_gtu, "i64.gtu" },
  647. { Instructions::i64_les, "i64.les" },
  648. { Instructions::i64_leu, "i64.leu" },
  649. { Instructions::i64_ges, "i64.ges" },
  650. { Instructions::i64_geu, "i64.geu" },
  651. { Instructions::f32_eq, "f32.eq" },
  652. { Instructions::f32_ne, "f32.ne" },
  653. { Instructions::f32_lt, "f32.lt" },
  654. { Instructions::f32_gt, "f32.gt" },
  655. { Instructions::f32_le, "f32.le" },
  656. { Instructions::f32_ge, "f32.ge" },
  657. { Instructions::f64_eq, "f64.eq" },
  658. { Instructions::f64_ne, "f64.ne" },
  659. { Instructions::f64_lt, "f64.lt" },
  660. { Instructions::f64_gt, "f64.gt" },
  661. { Instructions::f64_le, "f64.le" },
  662. { Instructions::f64_ge, "f64.ge" },
  663. { Instructions::i32_clz, "i32.clz" },
  664. { Instructions::i32_ctz, "i32.ctz" },
  665. { Instructions::i32_popcnt, "i32.popcnt" },
  666. { Instructions::i32_add, "i32.add" },
  667. { Instructions::i32_sub, "i32.sub" },
  668. { Instructions::i32_mul, "i32.mul" },
  669. { Instructions::i32_divs, "i32.divs" },
  670. { Instructions::i32_divu, "i32.divu" },
  671. { Instructions::i32_rems, "i32.rems" },
  672. { Instructions::i32_remu, "i32.remu" },
  673. { Instructions::i32_and, "i32.and" },
  674. { Instructions::i32_or, "i32.or" },
  675. { Instructions::i32_xor, "i32.xor" },
  676. { Instructions::i32_shl, "i32.shl" },
  677. { Instructions::i32_shrs, "i32.shrs" },
  678. { Instructions::i32_shru, "i32.shru" },
  679. { Instructions::i32_rotl, "i32.rotl" },
  680. { Instructions::i32_rotr, "i32.rotr" },
  681. { Instructions::i64_clz, "i64.clz" },
  682. { Instructions::i64_ctz, "i64.ctz" },
  683. { Instructions::i64_popcnt, "i64.popcnt" },
  684. { Instructions::i64_add, "i64.add" },
  685. { Instructions::i64_sub, "i64.sub" },
  686. { Instructions::i64_mul, "i64.mul" },
  687. { Instructions::i64_divs, "i64.divs" },
  688. { Instructions::i64_divu, "i64.divu" },
  689. { Instructions::i64_rems, "i64.rems" },
  690. { Instructions::i64_remu, "i64.remu" },
  691. { Instructions::i64_and, "i64.and" },
  692. { Instructions::i64_or, "i64.or" },
  693. { Instructions::i64_xor, "i64.xor" },
  694. { Instructions::i64_shl, "i64.shl" },
  695. { Instructions::i64_shrs, "i64.shrs" },
  696. { Instructions::i64_shru, "i64.shru" },
  697. { Instructions::i64_rotl, "i64.rotl" },
  698. { Instructions::i64_rotr, "i64.rotr" },
  699. { Instructions::f32_abs, "f32.abs" },
  700. { Instructions::f32_neg, "f32.neg" },
  701. { Instructions::f32_ceil, "f32.ceil" },
  702. { Instructions::f32_floor, "f32.floor" },
  703. { Instructions::f32_trunc, "f32.trunc" },
  704. { Instructions::f32_nearest, "f32.nearest" },
  705. { Instructions::f32_sqrt, "f32.sqrt" },
  706. { Instructions::f32_add, "f32.add" },
  707. { Instructions::f32_sub, "f32.sub" },
  708. { Instructions::f32_mul, "f32.mul" },
  709. { Instructions::f32_div, "f32.div" },
  710. { Instructions::f32_min, "f32.min" },
  711. { Instructions::f32_max, "f32.max" },
  712. { Instructions::f32_copysign, "f32.copysign" },
  713. { Instructions::f64_abs, "f64.abs" },
  714. { Instructions::f64_neg, "f64.neg" },
  715. { Instructions::f64_ceil, "f64.ceil" },
  716. { Instructions::f64_floor, "f64.floor" },
  717. { Instructions::f64_trunc, "f64.trunc" },
  718. { Instructions::f64_nearest, "f64.nearest" },
  719. { Instructions::f64_sqrt, "f64.sqrt" },
  720. { Instructions::f64_add, "f64.add" },
  721. { Instructions::f64_sub, "f64.sub" },
  722. { Instructions::f64_mul, "f64.mul" },
  723. { Instructions::f64_div, "f64.div" },
  724. { Instructions::f64_min, "f64.min" },
  725. { Instructions::f64_max, "f64.max" },
  726. { Instructions::f64_copysign, "f64.copysign" },
  727. { Instructions::i32_wrap_i64, "i32.wrap.i64" },
  728. { Instructions::i32_trunc_sf32, "i32.trunc.sf32" },
  729. { Instructions::i32_trunc_uf32, "i32.trunc.uf32" },
  730. { Instructions::i32_trunc_sf64, "i32.trunc.sf64" },
  731. { Instructions::i32_trunc_uf64, "i32.trunc.uf64" },
  732. { Instructions::i64_extend_si32, "i64.extend.si32" },
  733. { Instructions::i64_extend_ui32, "i64.extend.ui32" },
  734. { Instructions::i64_trunc_sf32, "i64.trunc.sf32" },
  735. { Instructions::i64_trunc_uf32, "i64.trunc.uf32" },
  736. { Instructions::i64_trunc_sf64, "i64.trunc.sf64" },
  737. { Instructions::i64_trunc_uf64, "i64.trunc.uf64" },
  738. { Instructions::f32_convert_si32, "f32.convert.si32" },
  739. { Instructions::f32_convert_ui32, "f32.convert.ui32" },
  740. { Instructions::f32_convert_si64, "f32.convert.si64" },
  741. { Instructions::f32_convert_ui64, "f32.convert.ui64" },
  742. { Instructions::f32_demote_f64, "f32.demote.f64" },
  743. { Instructions::f64_convert_si32, "f64.convert.si32" },
  744. { Instructions::f64_convert_ui32, "f64.convert.ui32" },
  745. { Instructions::f64_convert_si64, "f64.convert.si64" },
  746. { Instructions::f64_convert_ui64, "f64.convert.ui64" },
  747. { Instructions::f64_promote_f32, "f64.promote.f32" },
  748. { Instructions::i32_reinterpret_f32, "i32.reinterpret.f32" },
  749. { Instructions::i64_reinterpret_f64, "i64.reinterpret.f64" },
  750. { Instructions::f32_reinterpret_i32, "f32.reinterpret.i32" },
  751. { Instructions::f64_reinterpret_i64, "f64.reinterpret.i64" },
  752. { Instructions::i32_extend8_s, "i32.extend8_s" },
  753. { Instructions::i32_extend16_s, "i32.extend16_s" },
  754. { Instructions::i64_extend8_s, "i64.extend8_s" },
  755. { Instructions::i64_extend16_s, "i64.extend16_s" },
  756. { Instructions::i64_extend32_s, "i64.extend32_s" },
  757. { Instructions::ref_null, "ref.null" },
  758. { Instructions::ref_is_null, "ref.is.null" },
  759. { Instructions::ref_func, "ref.func" },
  760. { Instructions::i32_trunc_sat_f32_s, "i32.trunc.sat.f32.s" },
  761. { Instructions::i32_trunc_sat_f32_u, "i32.trunc.sat.f32.u" },
  762. { Instructions::i32_trunc_sat_f64_s, "i32.trunc.sat.f64.s" },
  763. { Instructions::i32_trunc_sat_f64_u, "i32.trunc.sat.f64.u" },
  764. { Instructions::i64_trunc_sat_f32_s, "i64.trunc.sat.f32.s" },
  765. { Instructions::i64_trunc_sat_f32_u, "i64.trunc.sat.f32.u" },
  766. { Instructions::i64_trunc_sat_f64_s, "i64.trunc.sat.f64.s" },
  767. { Instructions::i64_trunc_sat_f64_u, "i64.trunc.sat.f64.u" },
  768. { Instructions::memory_init, "memory.init" },
  769. { Instructions::data_drop, "data.drop" },
  770. { Instructions::memory_copy, "memory.copy" },
  771. { Instructions::memory_fill, "memory.fill" },
  772. { Instructions::table_init, "table.init" },
  773. { Instructions::elem_drop, "elem.drop" },
  774. { Instructions::table_copy, "table.copy" },
  775. { Instructions::table_grow, "table.grow" },
  776. { Instructions::table_size, "table.size" },
  777. { Instructions::table_fill, "table.fill" },
  778. { Instructions::structured_else, "synthetic:else" },
  779. { Instructions::structured_end, "synthetic:end" },
  780. };