Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(113)

Unified Diff: src/wasm/ast-decoder.cc

Issue 2294743003: [wasm] simd scalar lowering F32x4Add and I32x4Add (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: [wasm] simd scalar lowering F32x4Add and I32x4Add Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/v8.gyp ('k') | src/wasm/wasm-macro-gen.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/wasm/ast-decoder.cc
diff --git a/src/wasm/ast-decoder.cc b/src/wasm/ast-decoder.cc
index 86b5e4cac42858c84382393585ac66c55f4ce444..4e19d0f6b6a1894851890ffb5bedbac1790f9c99 100644
--- a/src/wasm/ast-decoder.cc
+++ b/src/wasm/ast-decoder.cc
@@ -150,6 +150,16 @@ struct Control {
(build() ? CheckForException(builder_->func(__VA_ARGS__)) : nullptr)
#define BUILD0(func) (build() ? CheckForException(builder_->func()) : nullptr)
+struct LaneOperand {
+ uint8_t lane;
+ unsigned length;
+
+ inline LaneOperand(Decoder* decoder, const byte* pc) {
+ lane = decoder->checked_read_u8(pc, 2, "lane");
+ length = 1;
+ }
+};
+
// Generic Wasm bytecode decoder with utilities for decoding operands,
// lengths, etc.
class WasmDecoder : public Decoder {
@@ -240,8 +250,17 @@ class WasmDecoder : public Decoder {
return true;
}
+ inline bool Validate(const byte* pc, LaneOperand& operand) {
+ if (operand.lane < 0 || operand.lane > 3) {
+ error(pc_, pc_ + 2, "invalid extract lane value");
+ return false;
+ } else {
+ return true;
+ }
+ }
+
unsigned OpcodeLength(const byte* pc) {
- switch (static_cast<WasmOpcode>(*pc)) {
+ switch (static_cast<byte>(*pc)) {
#define DECLARE_OPCODE_CASE(name, opcode, sig) case kExpr##name:
FOREACH_LOAD_MEM_OPCODE(DECLARE_OPCODE_CASE)
FOREACH_STORE_MEM_OPCODE(DECLARE_OPCODE_CASE)
@@ -304,6 +323,27 @@ class WasmDecoder : public Decoder {
return 5;
case kExprF64Const:
return 9;
+ case kSimdPrefix: {
+ byte simd_index = *(pc + 1);
+ WasmOpcode opcode =
+ static_cast<WasmOpcode>(kSimdPrefix << 8 | simd_index);
+ switch (opcode) {
+#define DECLARE_OPCODE_CASE(name, opcode, sig) case kExpr##name:
+ FOREACH_SIMD_0_OPERAND_OPCODE(DECLARE_OPCODE_CASE)
+#undef DECLARE_OPCODE_CASE
+ {
+ return 2;
+ }
+#define DECLARE_OPCODE_CASE(name, opcode, sig) case kExpr##name:
+ FOREACH_SIMD_1_OPERAND_OPCODE(DECLARE_OPCODE_CASE)
+#undef DECLARE_OPCODE_CASE
+ {
+ return 3;
+ }
+ default:
+ UNREACHABLE();
+ }
+ }
default:
return 1;
}
@@ -1249,18 +1289,25 @@ class WasmFullDecoder : public WasmDecoder {
return 1 + operand.length;
}
+ unsigned ExtractLane(WasmOpcode opcode, LocalType type) {
+ LaneOperand operand(this, pc_);
+ if (Validate(pc_, operand)) {
+ TFNode* input = Pop(0, LocalType::kSimd128).node;
+ TFNode* node = BUILD(SimdExtractLane, opcode, operand.lane, input);
+ Push(type, node);
+ }
+ return operand.length;
+ }
+
unsigned DecodeSimdOpcode(WasmOpcode opcode) {
unsigned len = 0;
switch (opcode) {
case kExprI32x4ExtractLane: {
- uint8_t lane = this->checked_read_u8(pc_, 2, "lane number");
- if (lane < 0 || lane > 3) {
- error(pc_, pc_ + 2, "invalid extract lane value");
- }
- TFNode* input = Pop(0, LocalType::kSimd128).node;
- TFNode* node = BUILD(SimdExtractLane, opcode, lane, input);
- Push(LocalType::kWord32, node);
- len++;
+ len = ExtractLane(opcode, LocalType::kWord32);
+ break;
+ }
+ case kExprF32x4ExtractLane: {
+ len = ExtractLane(opcode, LocalType::kFloat32);
break;
}
default: {
« no previous file with comments | « src/v8.gyp ('k') | src/wasm/wasm-macro-gen.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698