Skip to content

Commit 95fbc18

Browse files
lforg37Ferdinand LemaireJessica PaquetteLuc Forget
authored
[MLIR][Wasm] Extending Wasm binary to WasmSSA dialect importer (#154452)
This is a cherry pick of #154053 with a fix for bad handling of endianess when loading float and double litteral from the binary. --------- Co-authored-by: Ferdinand Lemaire <ferdinand.lemaire@woven-planet.global> Co-authored-by: Jessica Paquette <jessica.paquette@woven-planet.global> Co-authored-by: Luc Forget <luc.forget@woven.toyota>
1 parent c34cba0 commit 95fbc18

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+2086
-23
lines changed

mlir/include/mlir/Target/Wasm/WasmBinaryEncoding.h

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,79 @@ struct WasmBinaryEncoding {
2020
/// Byte encodings for Wasm instructions.
2121
struct OpCode {
2222
// Locals, globals, constants.
23+
static constexpr std::byte localGet{0x20};
24+
static constexpr std::byte localSet{0x21};
25+
static constexpr std::byte localTee{0x22};
26+
static constexpr std::byte globalGet{0x23};
2327
static constexpr std::byte constI32{0x41};
2428
static constexpr std::byte constI64{0x42};
2529
static constexpr std::byte constFP32{0x43};
2630
static constexpr std::byte constFP64{0x44};
31+
32+
// Numeric operations.
33+
static constexpr std::byte clzI32{0x67};
34+
static constexpr std::byte ctzI32{0x68};
35+
static constexpr std::byte popcntI32{0x69};
36+
static constexpr std::byte addI32{0x6A};
37+
static constexpr std::byte subI32{0x6B};
38+
static constexpr std::byte mulI32{0x6C};
39+
static constexpr std::byte divSI32{0x6d};
40+
static constexpr std::byte divUI32{0x6e};
41+
static constexpr std::byte remSI32{0x6f};
42+
static constexpr std::byte remUI32{0x70};
43+
static constexpr std::byte andI32{0x71};
44+
static constexpr std::byte orI32{0x72};
45+
static constexpr std::byte xorI32{0x73};
46+
static constexpr std::byte shlI32{0x74};
47+
static constexpr std::byte shrSI32{0x75};
48+
static constexpr std::byte shrUI32{0x76};
49+
static constexpr std::byte rotlI32{0x77};
50+
static constexpr std::byte rotrI32{0x78};
51+
static constexpr std::byte clzI64{0x79};
52+
static constexpr std::byte ctzI64{0x7A};
53+
static constexpr std::byte popcntI64{0x7B};
54+
static constexpr std::byte addI64{0x7C};
55+
static constexpr std::byte subI64{0x7D};
56+
static constexpr std::byte mulI64{0x7E};
57+
static constexpr std::byte divSI64{0x7F};
58+
static constexpr std::byte divUI64{0x80};
59+
static constexpr std::byte remSI64{0x81};
60+
static constexpr std::byte remUI64{0x82};
61+
static constexpr std::byte andI64{0x83};
62+
static constexpr std::byte orI64{0x84};
63+
static constexpr std::byte xorI64{0x85};
64+
static constexpr std::byte shlI64{0x86};
65+
static constexpr std::byte shrSI64{0x87};
66+
static constexpr std::byte shrUI64{0x88};
67+
static constexpr std::byte rotlI64{0x89};
68+
static constexpr std::byte rotrI64{0x8A};
69+
static constexpr std::byte absF32{0x8B};
70+
static constexpr std::byte negF32{0x8C};
71+
static constexpr std::byte ceilF32{0x8D};
72+
static constexpr std::byte floorF32{0x8E};
73+
static constexpr std::byte truncF32{0x8F};
74+
static constexpr std::byte sqrtF32{0x91};
75+
static constexpr std::byte addF32{0x92};
76+
static constexpr std::byte subF32{0x93};
77+
static constexpr std::byte mulF32{0x94};
78+
static constexpr std::byte divF32{0x95};
79+
static constexpr std::byte minF32{0x96};
80+
static constexpr std::byte maxF32{0x97};
81+
static constexpr std::byte copysignF32{0x98};
82+
static constexpr std::byte absF64{0x99};
83+
static constexpr std::byte negF64{0x9A};
84+
static constexpr std::byte ceilF64{0x9B};
85+
static constexpr std::byte floorF64{0x9C};
86+
static constexpr std::byte truncF64{0x9D};
87+
static constexpr std::byte sqrtF64{0x9F};
88+
static constexpr std::byte addF64{0xA0};
89+
static constexpr std::byte subF64{0xA1};
90+
static constexpr std::byte mulF64{0xA2};
91+
static constexpr std::byte divF64{0xA3};
92+
static constexpr std::byte minF64{0xA4};
93+
static constexpr std::byte maxF64{0xA5};
94+
static constexpr std::byte copysignF64{0xA6};
95+
static constexpr std::byte wrap{0xA7};
2796
};
2897

2998
/// Byte encodings of types in Wasm binaries

0 commit comments

Comments
 (0)