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

Side by Side Diff: src/wasm/function-body-decoder.cc

Issue 2801183002: [WASM SIMD] Implement primitive shuffles. (Closed)
Patch Set: Add comments, remove S64x2Reverse, as it's redundant. 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 unified diff | Download patch
OLDNEW
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 #include "src/signature.h" 5 #include "src/signature.h"
6 6
7 #include "src/base/platform/elapsed-timer.h" 7 #include "src/base/platform/elapsed-timer.h"
8 #include "src/bit-vector.h" 8 #include "src/bit-vector.h"
9 #include "src/flags.h" 9 #include "src/flags.h"
10 #include "src/handles.h" 10 #include "src/handles.h"
(...skipping 392 matching lines...) Expand 10 before | Expand all | Expand 10 after
403 break; 403 break;
404 } 404 }
405 if (operand.shift < 0 || operand.shift >= max_shift) { 405 if (operand.shift < 0 || operand.shift >= max_shift) {
406 error(pc_ + 2, "invalid shift amount"); 406 error(pc_ + 2, "invalid shift amount");
407 return false; 407 return false;
408 } else { 408 } else {
409 return true; 409 return true;
410 } 410 }
411 } 411 }
412 412
413 inline bool Validate(const byte* pc, WasmOpcode opcode,
414 SimdConcatOperand<true>& operand) {
415 DCHECK_EQ(wasm::kExprS8x16Concat, opcode);
416 if (operand.bytes <= 0 || operand.bytes >= kSimd128Size) {
417 error(pc_ + 2, "invalid byte amount");
418 return false;
419 } else {
420 return true;
421 }
422 }
423
413 static unsigned OpcodeLength(Decoder* decoder, const byte* pc) { 424 static unsigned OpcodeLength(Decoder* decoder, const byte* pc) {
414 switch (static_cast<byte>(*pc)) { 425 switch (static_cast<byte>(*pc)) {
415 #define DECLARE_OPCODE_CASE(name, opcode, sig) case kExpr##name: 426 #define DECLARE_OPCODE_CASE(name, opcode, sig) case kExpr##name:
416 FOREACH_LOAD_MEM_OPCODE(DECLARE_OPCODE_CASE) 427 FOREACH_LOAD_MEM_OPCODE(DECLARE_OPCODE_CASE)
417 FOREACH_STORE_MEM_OPCODE(DECLARE_OPCODE_CASE) 428 FOREACH_STORE_MEM_OPCODE(DECLARE_OPCODE_CASE)
418 #undef DECLARE_OPCODE_CASE 429 #undef DECLARE_OPCODE_CASE
419 { 430 {
420 MemoryAccessOperand<true> operand(decoder, pc, UINT32_MAX); 431 MemoryAccessOperand<true> operand(decoder, pc, UINT32_MAX);
421 return 1 + operand.length; 432 return 1 + operand.length;
422 } 433 }
(...skipping 1044 matching lines...) Expand 10 before | Expand all | Expand 10 after
1467 SimdShiftOperand<true> operand(this, pc_); 1478 SimdShiftOperand<true> operand(this, pc_);
1468 if (Validate(pc_, opcode, operand)) { 1479 if (Validate(pc_, opcode, operand)) {
1469 compiler::NodeVector inputs(1, zone_); 1480 compiler::NodeVector inputs(1, zone_);
1470 inputs[0] = Pop(0, ValueType::kSimd128).node; 1481 inputs[0] = Pop(0, ValueType::kSimd128).node;
1471 TFNode* node = BUILD(SimdShiftOp, opcode, operand.shift, inputs); 1482 TFNode* node = BUILD(SimdShiftOp, opcode, operand.shift, inputs);
1472 Push(ValueType::kSimd128, node); 1483 Push(ValueType::kSimd128, node);
1473 } 1484 }
1474 return operand.length; 1485 return operand.length;
1475 } 1486 }
1476 1487
1488 unsigned SimdConcatOp(WasmOpcode opcode) {
1489 DCHECK_EQ(wasm::kExprS8x16Concat, opcode);
1490 SimdConcatOperand<true> operand(this, pc_);
1491 if (Validate(pc_, opcode, operand)) {
1492 compiler::NodeVector inputs(2, zone_);
1493 inputs[1] = Pop(1, ValueType::kSimd128).node;
1494 inputs[0] = Pop(0, ValueType::kSimd128).node;
1495 TFNode* node = BUILD(SimdConcatOp, operand.bytes, inputs);
1496 Push(ValueType::kSimd128, node);
1497 }
1498 return operand.length;
1499 }
1500
1477 unsigned DecodeSimdOpcode(WasmOpcode opcode) { 1501 unsigned DecodeSimdOpcode(WasmOpcode opcode) {
1478 unsigned len = 0; 1502 unsigned len = 0;
1479 switch (opcode) { 1503 switch (opcode) {
1480 case kExprF32x4ExtractLane: { 1504 case kExprF32x4ExtractLane: {
1481 len = SimdExtractLane(opcode, ValueType::kFloat32); 1505 len = SimdExtractLane(opcode, ValueType::kFloat32);
1482 break; 1506 break;
1483 } 1507 }
1484 case kExprI32x4ExtractLane: 1508 case kExprI32x4ExtractLane:
1485 case kExprI16x8ExtractLane: 1509 case kExprI16x8ExtractLane:
1486 case kExprI8x16ExtractLane: { 1510 case kExprI8x16ExtractLane: {
(...skipping 15 matching lines...) Expand all
1502 case kExprI32x4ShrU: 1526 case kExprI32x4ShrU:
1503 case kExprI16x8Shl: 1527 case kExprI16x8Shl:
1504 case kExprI16x8ShrS: 1528 case kExprI16x8ShrS:
1505 case kExprI16x8ShrU: 1529 case kExprI16x8ShrU:
1506 case kExprI8x16Shl: 1530 case kExprI8x16Shl:
1507 case kExprI8x16ShrS: 1531 case kExprI8x16ShrS:
1508 case kExprI8x16ShrU: { 1532 case kExprI8x16ShrU: {
1509 len = SimdShiftOp(opcode); 1533 len = SimdShiftOp(opcode);
1510 break; 1534 break;
1511 } 1535 }
1536 case kExprS8x16Concat: {
1537 len = SimdConcatOp(opcode);
1538 break;
1539 }
1512 default: { 1540 default: {
1513 FunctionSig* sig = WasmOpcodes::Signature(opcode); 1541 FunctionSig* sig = WasmOpcodes::Signature(opcode);
1514 if (sig != nullptr) { 1542 if (sig != nullptr) {
1515 compiler::NodeVector inputs(sig->parameter_count(), zone_); 1543 compiler::NodeVector inputs(sig->parameter_count(), zone_);
1516 for (size_t i = sig->parameter_count(); i > 0; i--) { 1544 for (size_t i = sig->parameter_count(); i > 0; i--) {
1517 Value val = Pop(static_cast<int>(i - 1), sig->GetParam(i - 1)); 1545 Value val = Pop(static_cast<int>(i - 1), sig->GetParam(i - 1));
1518 inputs[i - 1] = val.node; 1546 inputs[i - 1] = val.node;
1519 } 1547 }
1520 TFNode* node = BUILD(SimdOp, opcode, inputs); 1548 TFNode* node = BUILD(SimdOp, opcode, inputs);
1521 Push(GetReturnType(sig), node); 1549 Push(GetReturnType(sig), node);
(...skipping 652 matching lines...) Expand 10 before | Expand all | Expand 10 after
2174 BitVector* AnalyzeLoopAssignmentForTesting(Zone* zone, size_t num_locals, 2202 BitVector* AnalyzeLoopAssignmentForTesting(Zone* zone, size_t num_locals,
2175 const byte* start, const byte* end) { 2203 const byte* start, const byte* end) {
2176 Decoder decoder(start, end); 2204 Decoder decoder(start, end);
2177 return WasmDecoder::AnalyzeLoopAssignment(&decoder, start, 2205 return WasmDecoder::AnalyzeLoopAssignment(&decoder, start,
2178 static_cast<int>(num_locals), zone); 2206 static_cast<int>(num_locals), zone);
2179 } 2207 }
2180 2208
2181 } // namespace wasm 2209 } // namespace wasm
2182 } // namespace internal 2210 } // namespace internal
2183 } // namespace v8 2211 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698