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 #include "src/zone/zone-containers.h" | 10 #include "src/zone/zone-containers.h" |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 #define WASM_BR_TABLE(key, count, ...) \ | 133 #define WASM_BR_TABLE(key, count, ...) \ |
134 key, kExprBrTable, U32V_1(count), __VA_ARGS__ | 134 key, kExprBrTable, U32V_1(count), __VA_ARGS__ |
135 | 135 |
136 #define WASM_CASE(x) static_cast<byte>(x), static_cast<byte>(x >> 8) | 136 #define WASM_CASE(x) static_cast<byte>(x), static_cast<byte>(x >> 8) |
137 #define WASM_CASE_BR(x) static_cast<byte>(x), static_cast<byte>(0x80 | (x) >> 8) | 137 #define WASM_CASE_BR(x) static_cast<byte>(x), static_cast<byte>(0x80 | (x) >> 8) |
138 | 138 |
139 //------------------------------------------------------------------------------ | 139 //------------------------------------------------------------------------------ |
140 // Misc expressions. | 140 // Misc expressions. |
141 //------------------------------------------------------------------------------ | 141 //------------------------------------------------------------------------------ |
142 #define WASM_ID(...) __VA_ARGS__ | 142 #define WASM_ID(...) __VA_ARGS__ |
143 #define WASM_ZERO kExprI8Const, 0 | 143 #define WASM_ZERO kExprI32Const, 0 |
144 #define WASM_ONE kExprI8Const, 1 | 144 #define WASM_ONE kExprI32Const, 1 |
145 #define WASM_I8(val) kExprI8Const, static_cast<byte>(val) | |
146 | 145 |
147 #define I32V_MIN(length) -(1 << (6 + (7 * ((length) - 1)))) | 146 #define I32V_MIN(length) -(1 << (6 + (7 * ((length) - 1)))) |
148 #define I32V_MAX(length) ((1 << (6 + (7 * ((length) - 1)))) - 1) | 147 #define I32V_MAX(length) ((1 << (6 + (7 * ((length) - 1)))) - 1) |
149 #define I64V_MIN(length) -(1LL << (6 + (7 * ((length) - 1)))) | 148 #define I64V_MIN(length) -(1LL << (6 + (7 * ((length) - 1)))) |
150 #define I64V_MAX(length) ((1LL << (6 + 7 * ((length) - 1))) - 1) | 149 #define I64V_MAX(length) ((1LL << (6 + 7 * ((length) - 1))) - 1) |
151 | 150 |
152 #define I32V_IN_RANGE(value, length) \ | 151 #define I32V_IN_RANGE(value, length) \ |
153 ((value) >= I32V_MIN(length) && (value) <= I32V_MAX(length)) | 152 ((value) >= I32V_MIN(length) && (value) <= I32V_MAX(length)) |
154 #define I64V_IN_RANGE(value, length) \ | 153 #define I64V_IN_RANGE(value, length) \ |
155 ((value) >= I64V_MIN(length) && (value) <= I64V_MAX(length)) | 154 ((value) >= I64V_MIN(length) && (value) <= I64V_MAX(length)) |
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
440 | 439 |
441 #define WASM_NOT(x) x, kExprI32Eqz | 440 #define WASM_NOT(x) x, kExprI32Eqz |
442 #define WASM_SEQ(...) __VA_ARGS__ | 441 #define WASM_SEQ(...) __VA_ARGS__ |
443 | 442 |
444 //------------------------------------------------------------------------------ | 443 //------------------------------------------------------------------------------ |
445 // Constructs that are composed of multiple bytecodes. | 444 // Constructs that are composed of multiple bytecodes. |
446 //------------------------------------------------------------------------------ | 445 //------------------------------------------------------------------------------ |
447 #define WASM_WHILE(x, y) \ | 446 #define WASM_WHILE(x, y) \ |
448 kExprLoop, kLocalVoid, x, kExprIf, kLocalVoid, y, kExprBr, DEPTH_1, \ | 447 kExprLoop, kLocalVoid, x, kExprIf, kLocalVoid, y, kExprBr, DEPTH_1, \ |
449 kExprEnd, kExprEnd | 448 kExprEnd, kExprEnd |
450 #define WASM_INC_LOCAL(index) \ | 449 #define WASM_INC_LOCAL(index) \ |
451 kExprGetLocal, static_cast<byte>(index), kExprI8Const, 1, kExprI32Add, \ | 450 kExprGetLocal, static_cast<byte>(index), kExprI32Const, 1, kExprI32Add, \ |
452 kExprTeeLocal, static_cast<byte>(index) | 451 kExprTeeLocal, static_cast<byte>(index) |
453 #define WASM_INC_LOCAL_BYV(index, count) \ | 452 #define WASM_INC_LOCAL_BYV(index, count) \ |
454 kExprGetLocal, static_cast<byte>(index), kExprI8Const, \ | 453 kExprGetLocal, static_cast<byte>(index), kExprI32Const, \ |
455 static_cast<byte>(count), kExprI32Add, kExprTeeLocal, \ | 454 static_cast<byte>(count), kExprI32Add, kExprTeeLocal, \ |
456 static_cast<byte>(index) | 455 static_cast<byte>(index) |
457 #define WASM_INC_LOCAL_BY(index, count) \ | 456 #define WASM_INC_LOCAL_BY(index, count) \ |
458 kExprGetLocal, static_cast<byte>(index), kExprI8Const, \ | 457 kExprGetLocal, static_cast<byte>(index), kExprI32Const, \ |
459 static_cast<byte>(count), kExprI32Add, kExprSetLocal, \ | 458 static_cast<byte>(count), kExprI32Add, kExprSetLocal, \ |
460 static_cast<byte>(index) | 459 static_cast<byte>(index) |
461 #define WASM_UNOP(opcode, x) x, static_cast<byte>(opcode) | 460 #define WASM_UNOP(opcode, x) x, static_cast<byte>(opcode) |
462 #define WASM_BINOP(opcode, x, y) x, y, static_cast<byte>(opcode) | 461 #define WASM_BINOP(opcode, x, y) x, y, static_cast<byte>(opcode) |
463 #define WASM_SIMD_UNOP(opcode, x) x, kSimdPrefix, static_cast<byte>(opcode) | 462 #define WASM_SIMD_UNOP(opcode, x) x, kSimdPrefix, static_cast<byte>(opcode) |
464 #define WASM_SIMD_BINOP(opcode, x, y) \ | 463 #define WASM_SIMD_BINOP(opcode, x, y) \ |
465 x, y, kSimdPrefix, static_cast<byte>(opcode) | 464 x, y, kSimdPrefix, static_cast<byte>(opcode) |
466 | 465 |
467 //------------------------------------------------------------------------------ | 466 //------------------------------------------------------------------------------ |
468 // Int32 operations | 467 // Int32 operations |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
672 #define WASM_BRV(depth, val) val, kExprBr, static_cast<byte>(depth) | 671 #define WASM_BRV(depth, val) val, kExprBr, static_cast<byte>(depth) |
673 #define WASM_BRV_IF(depth, val, cond) \ | 672 #define WASM_BRV_IF(depth, val, cond) \ |
674 val, cond, kExprBrIf, static_cast<byte>(depth) | 673 val, cond, kExprBrIf, static_cast<byte>(depth) |
675 #define WASM_BRV_IFD(depth, val, cond) \ | 674 #define WASM_BRV_IFD(depth, val, cond) \ |
676 val, cond, kExprBrIf, static_cast<byte>(depth), kExprDrop | 675 val, cond, kExprBrIf, static_cast<byte>(depth), kExprDrop |
677 #define WASM_IFB(cond, ...) cond, kExprIf, kLocalVoid, __VA_ARGS__, kExprEnd | 676 #define WASM_IFB(cond, ...) cond, kExprIf, kLocalVoid, __VA_ARGS__, kExprEnd |
678 #define WASM_BR_TABLEV(val, key, count, ...) \ | 677 #define WASM_BR_TABLEV(val, key, count, ...) \ |
679 val, key, kExprBrTable, U32V_1(count), __VA_ARGS__ | 678 val, key, kExprBrTable, U32V_1(count), __VA_ARGS__ |
680 | 679 |
681 #endif // V8_WASM_MACRO_GEN_H_ | 680 #endif // V8_WASM_MACRO_GEN_H_ |
OLD | NEW |