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

Unified Diff: src/wasm/function-body-decoder.cc

Issue 2801183002: [WASM SIMD] Implement primitive shuffles. (Closed)
Patch Set: Fix ARM release build. Created 3 years, 8 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
Index: src/wasm/function-body-decoder.cc
diff --git a/src/wasm/function-body-decoder.cc b/src/wasm/function-body-decoder.cc
index 74be6464e62d40a3b072c8ed89f4d658f39784fc..e56f8120a81d15a062878d4496b1e0789314d460 100644
--- a/src/wasm/function-body-decoder.cc
+++ b/src/wasm/function-body-decoder.cc
@@ -410,6 +410,17 @@ class WasmDecoder : public Decoder {
}
}
+ inline bool Validate(const byte* pc, WasmOpcode opcode,
+ SimdConcatOperand<true>& operand) {
+ DCHECK_EQ(wasm::kExprS8x16Concat, opcode);
+ if (operand.bytes <= 0 || operand.bytes >= kSimd128Size) {
+ error(pc_ + 2, "invalid byte amount");
+ return false;
+ } else {
+ return true;
+ }
+ }
+
static unsigned OpcodeLength(Decoder* decoder, const byte* pc) {
switch (static_cast<byte>(*pc)) {
#define DECLARE_OPCODE_CASE(name, opcode, sig) case kExpr##name:
@@ -1474,6 +1485,19 @@ class WasmFullDecoder : public WasmDecoder {
return operand.length;
}
+ unsigned SimdConcatOp(WasmOpcode opcode) {
+ DCHECK_EQ(wasm::kExprS8x16Concat, opcode);
+ SimdConcatOperand<true> operand(this, pc_);
+ if (Validate(pc_, opcode, operand)) {
+ compiler::NodeVector inputs(2, zone_);
+ inputs[1] = Pop(1, ValueType::kSimd128).node;
+ inputs[0] = Pop(0, ValueType::kSimd128).node;
+ TFNode* node = BUILD(SimdConcatOp, operand.bytes, inputs);
+ Push(ValueType::kSimd128, node);
+ }
+ return operand.length;
+ }
+
unsigned DecodeSimdOpcode(WasmOpcode opcode) {
unsigned len = 0;
switch (opcode) {
@@ -1509,6 +1533,10 @@ class WasmFullDecoder : public WasmDecoder {
len = SimdShiftOp(opcode);
break;
}
+ case kExprS8x16Concat: {
+ len = SimdConcatOp(opcode);
+ break;
+ }
default: {
FunctionSig* sig = WasmOpcodes::Signature(opcode);
if (sig != nullptr) {

Powered by Google App Engine
This is Rietveld 408576698