| 1 | /* |
| 2 | * Copyright (C) 2016-2017 Apple Inc. All rights reserved. |
| 3 | * |
| 4 | * Redistribution and use in source and binary forms, with or without |
| 5 | * modification, are permitted provided that the following conditions |
| 6 | * are met: |
| 7 | * |
| 8 | * 1. Redistributions of source code must retain the above copyright |
| 9 | * notice, this list of conditions and the following disclaimer. |
| 10 | * 2. Redistributions in binary form must reproduce the above copyright |
| 11 | * notice, this list of conditions and the following disclaimer in the |
| 12 | * documentation and/or other materials provided with the distribution. |
| 13 | * |
| 14 | * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY |
| 15 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
| 16 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| 17 | * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY |
| 18 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
| 19 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| 20 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
| 21 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 22 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
| 23 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 24 | */ |
| 25 | |
| 26 | // DO NO EDIT! - This file was generated by /home/ubuntu/webkit/Source/JavaScriptCore/wasm/generateWasmOpsHeader.py |
| 27 | |
| 28 | #pragma once |
| 29 | |
| 30 | #if ENABLE(WEBASSEMBLY) |
| 31 | |
| 32 | #include <cstdint> |
| 33 | |
| 34 | namespace JSC { namespace Wasm { |
| 35 | |
| 36 | static constexpr unsigned expectedVersionNumber = 1; |
| 37 | |
| 38 | static constexpr unsigned numTypes = 8; |
| 39 | |
| 40 | #define FOR_EACH_WASM_TYPE(macro) \ |
| 41 | macro(Anyfunc, -0x10, B3::Void, 0) \ |
| 42 | macro(I32, -0x1, B3::Int32, 1) \ |
| 43 | macro(Void, -0x40, B3::Void, 2) \ |
| 44 | macro(I64, -0x2, B3::Int64, 3) \ |
| 45 | macro(F32, -0x3, B3::Float, 4) \ |
| 46 | macro(Func, -0x20, B3::Void, 5) \ |
| 47 | macro(Anyref, -0x11, B3::Int64, 6) \ |
| 48 | macro(F64, -0x4, B3::Double, 7) |
| 49 | #define CREATE_ENUM_VALUE(name, id, b3type, inc) name = id, |
| 50 | enum Type : int8_t { |
| 51 | FOR_EACH_WASM_TYPE(CREATE_ENUM_VALUE) |
| 52 | }; |
| 53 | #undef CREATE_ENUM_VALUE |
| 54 | |
| 55 | #define CREATE_CASE(name, id, b3type, inc) case id: return true; |
| 56 | template <typename Int> |
| 57 | inline bool isValidType(Int i) |
| 58 | { |
| 59 | switch (i) { |
| 60 | default: return false; |
| 61 | FOR_EACH_WASM_TYPE(CREATE_CASE) |
| 62 | } |
| 63 | RELEASE_ASSERT_NOT_REACHED(); |
| 64 | return false; |
| 65 | } |
| 66 | #undef CREATE_CASE |
| 67 | |
| 68 | #define CREATE_CASE(name, id, b3type, inc) case name: return b3type; |
| 69 | inline B3::Type toB3Type(Type type) |
| 70 | { |
| 71 | switch (type) { |
| 72 | FOR_EACH_WASM_TYPE(CREATE_CASE) |
| 73 | } |
| 74 | RELEASE_ASSERT_NOT_REACHED(); |
| 75 | return B3::Void; |
| 76 | } |
| 77 | #undef CREATE_CASE |
| 78 | |
| 79 | #define CREATE_CASE(name, id, b3type, inc) case name: return #name; |
| 80 | inline const char* makeString(Type type) |
| 81 | { |
| 82 | switch (type) { |
| 83 | FOR_EACH_WASM_TYPE(CREATE_CASE) |
| 84 | } |
| 85 | RELEASE_ASSERT_NOT_REACHED(); |
| 86 | return nullptr; |
| 87 | } |
| 88 | #undef CREATE_CASE |
| 89 | |
| 90 | #define CREATE_CASE(name, id, b3type, inc) case id: return inc; |
| 91 | inline int linearizeType(Type type) |
| 92 | { |
| 93 | switch (type) { |
| 94 | FOR_EACH_WASM_TYPE(CREATE_CASE) |
| 95 | } |
| 96 | RELEASE_ASSERT_NOT_REACHED(); |
| 97 | return 0; |
| 98 | } |
| 99 | #undef CREATE_CASE |
| 100 | |
| 101 | #define CREATE_CASE(name, id, b3type, inc) case inc: return name; |
| 102 | inline Type linearizedToType(int i) |
| 103 | { |
| 104 | switch (i) { |
| 105 | FOR_EACH_WASM_TYPE(CREATE_CASE) |
| 106 | } |
| 107 | RELEASE_ASSERT_NOT_REACHED(); |
| 108 | return Void; |
| 109 | } |
| 110 | #undef CREATE_CASE |
| 111 | |
| 112 | |
| 113 | #define FOR_EACH_WASM_SPECIAL_OP(macro) \ |
| 114 | macro(F64Const, 0x44, Oops, 0) \ |
| 115 | macro(RefNull, 0xd0, Oops, 1) \ |
| 116 | macro(GrowMemory, 0x40, Oops, 2) \ |
| 117 | macro(I64Const, 0x42, Oops, 3) \ |
| 118 | macro(TeeLocal, 0x22, Oops, 4) \ |
| 119 | macro(SetLocal, 0x21, Oops, 5) \ |
| 120 | macro(I32Const, 0x41, Oops, 6) \ |
| 121 | macro(CurrentMemory, 0x3f, Oops, 7) \ |
| 122 | macro(F32Const, 0x43, Oops, 8) \ |
| 123 | macro(SetGlobal, 0x24, Oops, 9) \ |
| 124 | macro(GetGlobal, 0x23, Oops, 10) \ |
| 125 | macro(Call, 0x10, Oops, 11) \ |
| 126 | macro(RefIsNull, 0xd1, Oops, 12) \ |
| 127 | macro(GetLocal, 0x20, Oops, 13) \ |
| 128 | macro(CallIndirect, 0x11, Oops, 14) |
| 129 | |
| 130 | #define FOR_EACH_WASM_CONTROL_FLOW_OP(macro) \ |
| 131 | macro(Return, 0xf, Oops, 0) \ |
| 132 | macro(Nop, 0x1, Oops, 1) \ |
| 133 | macro(Drop, 0x1a, Oops, 2) \ |
| 134 | macro(BrIf, 0xd, Oops, 3) \ |
| 135 | macro(Br, 0xc, Oops, 4) \ |
| 136 | macro(Select, 0x1b, Oops, 5) \ |
| 137 | macro(Unreachable, 0x0, Oops, 6) \ |
| 138 | macro(Else, 0x5, Oops, 7) \ |
| 139 | macro(BrTable, 0xe, Oops, 8) \ |
| 140 | macro(Loop, 0x3, Oops, 9) \ |
| 141 | macro(If, 0x4, Oops, 10) \ |
| 142 | macro(End, 0xb, Oops, 11) \ |
| 143 | macro(Block, 0x2, Oops, 12) |
| 144 | |
| 145 | #define FOR_EACH_WASM_SIMPLE_UNARY_OP(macro) \ |
| 146 | macro(F32Ceil, 0x8d, Ceil, 0) \ |
| 147 | macro(F32DemoteF64, 0xb6, DoubleToFloat, 1) \ |
| 148 | macro(I32Clz, 0x67, Clz, 2) \ |
| 149 | macro(F64ConvertUI32, 0xb8, IToD(ZExt32(@0)), 3) \ |
| 150 | macro(F32ReinterpretI32, 0xbe, BitwiseCast, 4) \ |
| 151 | macro(F32Sqrt, 0x91, Sqrt, 5) \ |
| 152 | macro(I64Eqz, 0x50, Equal(i64(0), @0), 6) \ |
| 153 | macro(I64Clz, 0x79, Clz, 7) \ |
| 154 | macro(F32Neg, 0x8c, Neg, 8) \ |
| 155 | macro(F64Abs, 0x99, Abs, 9) \ |
| 156 | macro(F32ConvertSI64, 0xb4, IToF, 10) \ |
| 157 | macro(F64ConvertSI32, 0xb7, IToD, 11) \ |
| 158 | macro(F32ConvertUI32, 0xb3, IToF(ZExt32(@0)), 12) \ |
| 159 | macro(F64Ceil, 0x9b, Ceil, 13) \ |
| 160 | macro(F64Floor, 0x9c, Floor, 14) \ |
| 161 | macro(F32Abs, 0x8b, Abs, 15) \ |
| 162 | macro(I32ReinterpretF32, 0xbc, BitwiseCast, 16) \ |
| 163 | macro(F64ConvertSI64, 0xb9, IToD, 17) \ |
| 164 | macro(F64PromoteF32, 0xbb, FloatToDouble, 18) \ |
| 165 | macro(I64ExtendUI32, 0xad, ZExt32, 19) \ |
| 166 | macro(F64ReinterpretI64, 0xbf, BitwiseCast, 20) \ |
| 167 | macro(F32Floor, 0x8e, Floor, 21) \ |
| 168 | macro(F32ConvertSI32, 0xb2, IToF, 22) \ |
| 169 | macro(I32Eqz, 0x45, Equal(i32(0), @0), 23) \ |
| 170 | macro(I64ReinterpretF64, 0xbd, BitwiseCast, 24) \ |
| 171 | macro(F64Sqrt, 0x9f, Sqrt, 25) \ |
| 172 | macro(I32WrapI64, 0xa7, Trunc, 26) \ |
| 173 | macro(I64ExtendSI32, 0xac, SExt32, 27) \ |
| 174 | macro(F64Neg, 0x9a, Neg, 28) |
| 175 | |
| 176 | #define FOR_EACH_WASM_UNARY_OP(macro) \ |
| 177 | FOR_EACH_WASM_SIMPLE_UNARY_OP(macro) \ |
| 178 | macro(I64TruncSF32, 0xae, Oops, 0) \ |
| 179 | macro(F32ConvertUI64, 0xb5, Oops, 1) \ |
| 180 | macro(I32Ctz, 0x68, Oops, 2) \ |
| 181 | macro(I32TruncSF64, 0xaa, Oops, 3) \ |
| 182 | macro(I32TruncUF64, 0xab, Oops, 4) \ |
| 183 | macro(I32Popcnt, 0x69, Oops, 5) \ |
| 184 | macro(I64Popcnt, 0x7b, Oops, 6) \ |
| 185 | macro(I64Ctz, 0x7a, Oops, 7) \ |
| 186 | macro(I32TruncSF32, 0xa8, Oops, 8) \ |
| 187 | macro(I64TruncUF64, 0xb1, Oops, 9) \ |
| 188 | macro(I64TruncSF64, 0xb0, Oops, 10) \ |
| 189 | macro(F64ConvertUI64, 0xba, Oops, 11) \ |
| 190 | macro(F64Nearest, 0x9e, Oops, 12) \ |
| 191 | macro(F64Trunc, 0x9d, Oops, 13) \ |
| 192 | macro(F32Trunc, 0x8f, Oops, 14) \ |
| 193 | macro(I32TruncUF32, 0xa9, Oops, 15) \ |
| 194 | macro(I64TruncUF32, 0xaf, Oops, 16) \ |
| 195 | macro(F32Nearest, 0x90, Oops, 17) |
| 196 | |
| 197 | #define FOR_EACH_WASM_SIMPLE_BINARY_OP(macro) \ |
| 198 | macro(I32Mul, 0x6c, Mul, 0) \ |
| 199 | macro(I32Sub, 0x6b, Sub, 1) \ |
| 200 | macro(F64Le, 0x65, LessEqual, 2) \ |
| 201 | macro(F32Min, 0x96, Select(Equal(@0, @1), BitOr(@0, @1), Select(LessThan(@0, @1), @0, Select(GreaterThan(@0, @1), @1, Add(@0, @1)))), 3) \ |
| 202 | macro(F64Ne, 0x62, NotEqual, 4) \ |
| 203 | macro(F64Lt, 0x63, LessThan, 5) \ |
| 204 | macro(F32Max, 0x97, Select(Equal(@0, @1), BitAnd(@0, @1), Select(LessThan(@0, @1), @1, Select(GreaterThan(@0, @1), @0, Add(@0, @1)))), 6) \ |
| 205 | macro(F64Mul, 0xa2, Mul, 7) \ |
| 206 | macro(F32Div, 0x95, Div, 8) \ |
| 207 | macro(F32Copysign, 0x98, BitwiseCast(BitOr(BitAnd(BitwiseCast(@1), i32(0x80000000)), BitAnd(BitwiseCast(@0), i32(0x7fffffff)))), 9) \ |
| 208 | macro(I64And, 0x83, BitAnd, 10) \ |
| 209 | macro(F32Ne, 0x5c, NotEqual, 11) \ |
| 210 | macro(F64Gt, 0x64, GreaterThan, 12) \ |
| 211 | macro(F64Ge, 0x66, GreaterEqual, 13) \ |
| 212 | macro(I64GtS, 0x55, GreaterThan, 14) \ |
| 213 | macro(I64GtU, 0x56, Above, 15) \ |
| 214 | macro(F64Div, 0xa3, Div, 16) \ |
| 215 | macro(F32Add, 0x92, Add, 17) \ |
| 216 | macro(I64Or, 0x84, BitOr, 18) \ |
| 217 | macro(I32LeU, 0x4d, BelowEqual, 19) \ |
| 218 | macro(I32LeS, 0x4c, LessEqual, 20) \ |
| 219 | macro(I64Ne, 0x52, NotEqual, 21) \ |
| 220 | macro(I32And, 0x71, BitAnd, 22) \ |
| 221 | macro(I32LtU, 0x49, Below, 23) \ |
| 222 | macro(I64Rotr, 0x8a, RotR(@0, Trunc(@1)), 24) \ |
| 223 | macro(I32LtS, 0x48, LessThan, 25) \ |
| 224 | macro(I32Eq, 0x46, Equal, 26) \ |
| 225 | macro(F64Copysign, 0xa6, BitwiseCast(BitOr(BitAnd(BitwiseCast(@1), i64(0x8000000000000000)), BitAnd(BitwiseCast(@0), i64(0x7fffffffffffffff)))), 27) \ |
| 226 | macro(I64Rotl, 0x89, RotL(@0, Trunc(@1)), 28) \ |
| 227 | macro(F32Lt, 0x5d, LessThan, 29) \ |
| 228 | macro(F64Eq, 0x61, Equal, 30) \ |
| 229 | macro(F32Le, 0x5f, LessEqual, 31) \ |
| 230 | macro(F32Ge, 0x60, GreaterEqual, 32) \ |
| 231 | macro(I32ShrU, 0x76, ZShr, 33) \ |
| 232 | macro(I32ShrS, 0x75, SShr, 34) \ |
| 233 | macro(I32GeU, 0x4f, AboveEqual, 35) \ |
| 234 | macro(I32GeS, 0x4e, GreaterEqual, 36) \ |
| 235 | macro(I32Shl, 0x74, Shl, 37) \ |
| 236 | macro(I32Xor, 0x73, BitXor, 38) \ |
| 237 | macro(F64Min, 0xa4, Select(Equal(@0, @1), BitOr(@0, @1), Select(LessThan(@0, @1), @0, Select(GreaterThan(@0, @1), @1, Add(@0, @1)))), 39) \ |
| 238 | macro(F32Mul, 0x94, Mul, 40) \ |
| 239 | macro(I64Sub, 0x7d, Sub, 41) \ |
| 240 | macro(I32Add, 0x6a, Add, 42) \ |
| 241 | macro(F64Sub, 0xa1, Sub, 43) \ |
| 242 | macro(I32Or, 0x72, BitOr, 44) \ |
| 243 | macro(I64LtU, 0x54, Below, 45) \ |
| 244 | macro(I64LtS, 0x53, LessThan, 46) \ |
| 245 | macro(I64Xor, 0x85, BitXor, 47) \ |
| 246 | macro(I64GeU, 0x5a, AboveEqual, 48) \ |
| 247 | macro(I64Mul, 0x7e, Mul, 49) \ |
| 248 | macro(F32Sub, 0x93, Sub, 50) \ |
| 249 | macro(F64Add, 0xa0, Add, 51) \ |
| 250 | macro(I64GeS, 0x59, GreaterEqual, 52) \ |
| 251 | macro(I32Ne, 0x47, NotEqual, 53) \ |
| 252 | macro(F32Eq, 0x5b, Equal, 54) \ |
| 253 | macro(I64Eq, 0x51, Equal, 55) \ |
| 254 | macro(I64ShrS, 0x87, SShr(@0, Trunc(@1)), 56) \ |
| 255 | macro(I64ShrU, 0x88, ZShr(@0, Trunc(@1)), 57) \ |
| 256 | macro(I64Shl, 0x86, Shl(@0, Trunc(@1)), 58) \ |
| 257 | macro(F32Gt, 0x5e, GreaterThan, 59) \ |
| 258 | macro(I32Rotl, 0x77, RotL, 60) \ |
| 259 | macro(I32Rotr, 0x78, RotR, 61) \ |
| 260 | macro(I32GtU, 0x4b, Above, 62) \ |
| 261 | macro(I32GtS, 0x4a, GreaterThan, 63) \ |
| 262 | macro(F64Max, 0xa5, Select(Equal(@0, @1), BitAnd(@0, @1), Select(LessThan(@0, @1), @1, Select(GreaterThan(@0, @1), @0, Add(@0, @1)))), 64) \ |
| 263 | macro(I64LeU, 0x58, BelowEqual, 65) \ |
| 264 | macro(I64LeS, 0x57, LessEqual, 66) \ |
| 265 | macro(I64Add, 0x7c, Add, 67) |
| 266 | |
| 267 | #define FOR_EACH_WASM_BINARY_OP(macro) \ |
| 268 | FOR_EACH_WASM_SIMPLE_BINARY_OP(macro) \ |
| 269 | macro(I32DivU, 0x6e, Oops, 0) \ |
| 270 | macro(I32DivS, 0x6d, Oops, 1) \ |
| 271 | macro(I32RemU, 0x70, Oops, 2) \ |
| 272 | macro(I32RemS, 0x6f, Oops, 3) \ |
| 273 | macro(I64RemS, 0x81, Oops, 4) \ |
| 274 | macro(I64RemU, 0x82, Oops, 5) \ |
| 275 | macro(I64DivU, 0x80, Oops, 6) \ |
| 276 | macro(I64DivS, 0x7f, Oops, 7) |
| 277 | |
| 278 | #define FOR_EACH_WASM_MEMORY_LOAD_OP(macro) \ |
| 279 | macro(I64Load32U, 0x35, Oops, 0) \ |
| 280 | macro(I64Load32S, 0x34, Oops, 1) \ |
| 281 | macro(I32Load16S, 0x2e, Oops, 2) \ |
| 282 | macro(I32Load16U, 0x2f, Oops, 3) \ |
| 283 | macro(I64Load, 0x29, Oops, 4) \ |
| 284 | macro(F64Load, 0x2b, Oops, 5) \ |
| 285 | macro(I32Load8S, 0x2c, Oops, 6) \ |
| 286 | macro(I32Load8U, 0x2d, Oops, 7) \ |
| 287 | macro(I32Load, 0x28, Oops, 8) \ |
| 288 | macro(F32Load, 0x2a, Oops, 9) \ |
| 289 | macro(I64Load8U, 0x31, Oops, 10) \ |
| 290 | macro(I64Load8S, 0x30, Oops, 11) \ |
| 291 | macro(I64Load16S, 0x32, Oops, 12) \ |
| 292 | macro(I64Load16U, 0x33, Oops, 13) |
| 293 | |
| 294 | #define FOR_EACH_WASM_MEMORY_STORE_OP(macro) \ |
| 295 | macro(I64Store16, 0x3d, Oops, 0) \ |
| 296 | macro(I64Store8, 0x3c, Oops, 1) \ |
| 297 | macro(I32Store, 0x36, Oops, 2) \ |
| 298 | macro(I32Store16, 0x3b, Oops, 3) \ |
| 299 | macro(F32Store, 0x38, Oops, 4) \ |
| 300 | macro(I64Store, 0x37, Oops, 5) \ |
| 301 | macro(F64Store, 0x39, Oops, 6) \ |
| 302 | macro(I32Store8, 0x3a, Oops, 7) \ |
| 303 | macro(I64Store32, 0x3e, Oops, 8) |
| 304 | |
| 305 | |
| 306 | #define FOR_EACH_WASM_OP(macro) \ |
| 307 | FOR_EACH_WASM_SPECIAL_OP(macro) \ |
| 308 | FOR_EACH_WASM_CONTROL_FLOW_OP(macro) \ |
| 309 | FOR_EACH_WASM_UNARY_OP(macro) \ |
| 310 | FOR_EACH_WASM_BINARY_OP(macro) \ |
| 311 | FOR_EACH_WASM_MEMORY_LOAD_OP(macro) \ |
| 312 | FOR_EACH_WASM_MEMORY_STORE_OP(macro) |
| 313 | |
| 314 | #define CREATE_ENUM_VALUE(name, id, b3op, inc) name = id, |
| 315 | |
| 316 | enum OpType : uint8_t { |
| 317 | FOR_EACH_WASM_OP(CREATE_ENUM_VALUE) |
| 318 | }; |
| 319 | |
| 320 | template<typename Int> |
| 321 | inline bool isValidOpType(Int i) |
| 322 | { |
| 323 | // Bitset of valid ops. |
| 324 | static const uint8_t valid[] = { 0x3f, 0xf8, 0x3, 0xc, 0x1f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0, 0x0, 0x3 }; |
| 325 | return 0 <= i && i <= 209 && (valid[i / 8] & (1 << (i % 8))); |
| 326 | } |
| 327 | |
| 328 | enum class BinaryOpType : uint8_t { |
| 329 | FOR_EACH_WASM_BINARY_OP(CREATE_ENUM_VALUE) |
| 330 | }; |
| 331 | |
| 332 | enum class UnaryOpType : uint8_t { |
| 333 | FOR_EACH_WASM_UNARY_OP(CREATE_ENUM_VALUE) |
| 334 | }; |
| 335 | |
| 336 | enum class LoadOpType : uint8_t { |
| 337 | FOR_EACH_WASM_MEMORY_LOAD_OP(CREATE_ENUM_VALUE) |
| 338 | }; |
| 339 | |
| 340 | enum class StoreOpType : uint8_t { |
| 341 | FOR_EACH_WASM_MEMORY_STORE_OP(CREATE_ENUM_VALUE) |
| 342 | }; |
| 343 | |
| 344 | #undef CREATE_ENUM_VALUE |
| 345 | |
| 346 | inline bool isControlOp(OpType op) |
| 347 | { |
| 348 | switch (op) { |
| 349 | #define CREATE_CASE(name, id, b3op, inc) case OpType::name: |
| 350 | FOR_EACH_WASM_CONTROL_FLOW_OP(CREATE_CASE) |
| 351 | return true; |
| 352 | #undef CREATE_CASE |
| 353 | default: |
| 354 | break; |
| 355 | } |
| 356 | return false; |
| 357 | } |
| 358 | |
| 359 | inline bool isSimple(UnaryOpType op) |
| 360 | { |
| 361 | switch (op) { |
| 362 | #define CREATE_CASE(name, id, b3op, inc) case UnaryOpType::name: |
| 363 | FOR_EACH_WASM_SIMPLE_UNARY_OP(CREATE_CASE) |
| 364 | return true; |
| 365 | #undef CREATE_CASE |
| 366 | default: |
| 367 | break; |
| 368 | } |
| 369 | return false; |
| 370 | } |
| 371 | |
| 372 | inline bool isSimple(BinaryOpType op) |
| 373 | { |
| 374 | switch (op) { |
| 375 | #define CREATE_CASE(name, id, b3op, inc) case BinaryOpType::name: |
| 376 | FOR_EACH_WASM_SIMPLE_BINARY_OP(CREATE_CASE) |
| 377 | return true; |
| 378 | #undef CREATE_CASE |
| 379 | default: |
| 380 | break; |
| 381 | } |
| 382 | return false; |
| 383 | } |
| 384 | |
| 385 | inline uint32_t memoryLog2Alignment(OpType op) |
| 386 | { |
| 387 | switch (op) { |
| 388 | case I64Load32U: return 2; |
| 389 | case I64Load32S: return 2; |
| 390 | case I32Load16S: return 1; |
| 391 | case I32Load16U: return 1; |
| 392 | case I64Load: return 3; |
| 393 | case F64Load: return 3; |
| 394 | case I32Load8S: return 0; |
| 395 | case I32Load8U: return 0; |
| 396 | case I32Load: return 2; |
| 397 | case F32Load: return 2; |
| 398 | case I64Load8U: return 0; |
| 399 | case I64Load8S: return 0; |
| 400 | case I64Load16S: return 1; |
| 401 | case I64Load16U: return 1; |
| 402 | case I64Store16: return 1; |
| 403 | case I64Store8: return 0; |
| 404 | case I32Store: return 2; |
| 405 | case I32Store16: return 1; |
| 406 | case F32Store: return 2; |
| 407 | case I64Store: return 3; |
| 408 | case F64Store: return 3; |
| 409 | case I32Store8: return 0; |
| 410 | case I64Store32: return 2; |
| 411 | default: |
| 412 | break; |
| 413 | } |
| 414 | RELEASE_ASSERT_NOT_REACHED(); |
| 415 | return 0; |
| 416 | } |
| 417 | |
| 418 | #define CREATE_CASE(name, id, b3type, inc) case name: return #name; |
| 419 | inline const char* makeString(OpType op) |
| 420 | { |
| 421 | switch (op) { |
| 422 | FOR_EACH_WASM_OP(CREATE_CASE) |
| 423 | } |
| 424 | RELEASE_ASSERT_NOT_REACHED(); |
| 425 | return nullptr; |
| 426 | } |
| 427 | #undef CREATE_CASE |
| 428 | |
| 429 | } } // namespace JSC::Wasm |
| 430 | |
| 431 | #endif // ENABLE(WEBASSEMBLY) |
| 432 | |
| 433 | |