OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8_WASM_MACRO_GEN_H_ | 5 #ifndef V8_WASM_MACRO_GEN_H_ |
6 #define V8_WASM_MACRO_GEN_H_ | 6 #define V8_WASM_MACRO_GEN_H_ |
7 | 7 |
8 #include "src/wasm/wasm-opcodes.h" | 8 #include "src/wasm/wasm-opcodes.h" |
9 | 9 |
10 #define U32_LE(v) \ | 10 #define U32_LE(v) \ |
11 static_cast<byte>(v), static_cast<byte>((v) >> 8), \ | 11 static_cast<byte>(v), static_cast<byte>((v) >> 8), \ |
12 static_cast<byte>((v) >> 16), static_cast<byte>((v) >> 24) | 12 static_cast<byte>((v) >> 16), static_cast<byte>((v) >> 24) |
13 | 13 |
14 #define U16_LE(v) static_cast<byte>(v), static_cast<byte>((v) >> 8) | 14 #define U16_LE(v) static_cast<byte>(v), static_cast<byte>((v) >> 8) |
15 | 15 |
16 #define WASM_MODULE_HEADER U32_LE(kWasmMagic), U32_LE(kWasmVersion) | 16 #define WASM_MODULE_HEADER U32_LE(kWasmMagic), U32_LE(kWasmVersion) |
17 | 17 |
18 #define SIG_INDEX(v) U16_LE(v) | 18 #define SIG_INDEX(v) U16_LE(v) |
19 #define FUNC_INDEX(v) U16_LE(v) | 19 #define FUNC_INDEX(v) U32V_1(v) |
20 #define NAME_OFFSET(v) U32_LE(v) | 20 #define NAME_OFFSET(v) U32_LE(v) |
21 #define BR_TARGET(v) U16_LE(v) | 21 |
| 22 #define BR_TARGET(v) U32V_1(v) |
22 | 23 |
23 #define MASK_7 ((1 << 7) - 1) | 24 #define MASK_7 ((1 << 7) - 1) |
24 #define MASK_14 ((1 << 14) - 1) | 25 #define MASK_14 ((1 << 14) - 1) |
25 #define MASK_21 ((1 << 21) - 1) | 26 #define MASK_21 ((1 << 21) - 1) |
26 #define MASK_28 ((1 << 28) - 1) | 27 #define MASK_28 ((1 << 28) - 1) |
27 | 28 |
28 #define U32V_1(x) static_cast<byte>((x)&MASK_7) | 29 #define U32V_1(x) static_cast<byte>((x)&MASK_7) |
29 #define U32V_2(x) \ | 30 #define U32V_2(x) \ |
30 static_cast<byte>(((x)&MASK_7) | 0x80), static_cast<byte>(((x) >> 7) & MASK_7) | 31 static_cast<byte>(((x)&MASK_7) | 0x80), static_cast<byte>(((x) >> 7) & MASK_7) |
31 #define U32V_3(x) \ | 32 #define U32V_3(x) \ |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 #define WASM_BRV_IF(depth, val, cond) \ | 65 #define WASM_BRV_IF(depth, val, cond) \ |
65 kExprBrIf, static_cast<byte>(depth), val, cond | 66 kExprBrIf, static_cast<byte>(depth), val, cond |
66 #define WASM_BREAK(depth) kExprBr, static_cast<byte>(depth + 1), kExprNop | 67 #define WASM_BREAK(depth) kExprBr, static_cast<byte>(depth + 1), kExprNop |
67 #define WASM_CONTINUE(depth) kExprBr, static_cast<byte>(depth), kExprNop | 68 #define WASM_CONTINUE(depth) kExprBr, static_cast<byte>(depth), kExprNop |
68 #define WASM_BREAKV(depth, val) kExprBr, static_cast<byte>(depth + 1), val | 69 #define WASM_BREAKV(depth, val) kExprBr, static_cast<byte>(depth + 1), val |
69 #define WASM_RETURN0 kExprReturn | 70 #define WASM_RETURN0 kExprReturn |
70 #define WASM_RETURN(...) kExprReturn, __VA_ARGS__ | 71 #define WASM_RETURN(...) kExprReturn, __VA_ARGS__ |
71 #define WASM_UNREACHABLE kExprUnreachable | 72 #define WASM_UNREACHABLE kExprUnreachable |
72 | 73 |
73 #define WASM_BR_TABLE(key, count, ...) \ | 74 #define WASM_BR_TABLE(key, count, ...) \ |
74 kExprBrTable, U16_LE(count), __VA_ARGS__, key | 75 kExprBrTable, U32V_1(count), __VA_ARGS__, key |
75 | 76 |
76 #define WASM_CASE(x) static_cast<byte>(x), static_cast<byte>(x >> 8) | 77 #define WASM_CASE(x) static_cast<byte>(x), static_cast<byte>(x >> 8) |
77 #define WASM_CASE_BR(x) static_cast<byte>(x), static_cast<byte>(0x80 | (x) >> 8) | 78 #define WASM_CASE_BR(x) static_cast<byte>(x), static_cast<byte>(0x80 | (x) >> 8) |
78 | 79 |
79 //------------------------------------------------------------------------------ | 80 //------------------------------------------------------------------------------ |
80 // Misc expressions. | 81 // Misc expressions. |
81 //------------------------------------------------------------------------------ | 82 //------------------------------------------------------------------------------ |
82 #define WASM_ID(...) __VA_ARGS__ | 83 #define WASM_ID(...) __VA_ARGS__ |
83 #define WASM_ZERO kExprI8Const, 0 | 84 #define WASM_ZERO kExprI8Const, 0 |
84 #define WASM_ONE kExprI8Const, 1 | 85 #define WASM_ONE kExprI8Const, 1 |
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
500 #define WASM_F64_SCONVERT_I32(x) kExprF64SConvertI32, x | 501 #define WASM_F64_SCONVERT_I32(x) kExprF64SConvertI32, x |
501 #define WASM_F64_UCONVERT_I32(x) kExprF64UConvertI32, x | 502 #define WASM_F64_UCONVERT_I32(x) kExprF64UConvertI32, x |
502 #define WASM_F64_SCONVERT_I64(x) kExprF64SConvertI64, x | 503 #define WASM_F64_SCONVERT_I64(x) kExprF64SConvertI64, x |
503 #define WASM_F64_UCONVERT_I64(x) kExprF64UConvertI64, x | 504 #define WASM_F64_UCONVERT_I64(x) kExprF64UConvertI64, x |
504 #define WASM_F64_CONVERT_F32(x) kExprF64ConvertF32, x | 505 #define WASM_F64_CONVERT_F32(x) kExprF64ConvertF32, x |
505 #define WASM_F64_REINTERPRET_I64(x) kExprF64ReinterpretI64, x | 506 #define WASM_F64_REINTERPRET_I64(x) kExprF64ReinterpretI64, x |
506 #define WASM_I32_REINTERPRET_F32(x) kExprI32ReinterpretF32, x | 507 #define WASM_I32_REINTERPRET_F32(x) kExprI32ReinterpretF32, x |
507 #define WASM_I64_REINTERPRET_F64(x) kExprI64ReinterpretF64, x | 508 #define WASM_I64_REINTERPRET_F64(x) kExprI64ReinterpretF64, x |
508 | 509 |
509 #endif // V8_WASM_MACRO_GEN_H_ | 510 #endif // V8_WASM_MACRO_GEN_H_ |
OLD | NEW |