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

Side by Side Diff: src/wasm/ast-decoder.cc

Issue 2385393002: [wasm] Implement I32x4ReplaceLane, I32x4Add, I32x4Sub. (Closed)
Patch Set: Bill's review 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 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/bit-vector.h" 7 #include "src/bit-vector.h"
8 #include "src/flags.h" 8 #include "src/flags.h"
9 #include "src/handles.h" 9 #include "src/handles.h"
10 #include "src/zone/zone-containers.h" 10 #include "src/zone/zone-containers.h"
(...skipping 1227 matching lines...) Expand 10 before | Expand all | Expand 10 after
1238 int DecodeStoreMem(LocalType type, MachineType mem_type) { 1238 int DecodeStoreMem(LocalType type, MachineType mem_type) {
1239 MemoryAccessOperand operand(this, pc_, 1239 MemoryAccessOperand operand(this, pc_,
1240 ElementSizeLog2Of(mem_type.representation())); 1240 ElementSizeLog2Of(mem_type.representation()));
1241 Value val = Pop(1, type); 1241 Value val = Pop(1, type);
1242 Value index = Pop(0, kAstI32); 1242 Value index = Pop(0, kAstI32);
1243 BUILD(StoreMem, mem_type, index.node, operand.offset, operand.alignment, 1243 BUILD(StoreMem, mem_type, index.node, operand.offset, operand.alignment,
1244 val.node, position()); 1244 val.node, position());
1245 return 1 + operand.length; 1245 return 1 + operand.length;
1246 } 1246 }
1247 1247
1248 uint8_t LaneValue(uint8_t max_lanes) {
titzer 2016/10/07 12:20:14 Maybe you should introduce a LaneOperand, since if
gdeepti 2016/11/22 01:15:20 LaneOperand introduced by ScalarLowering, merged t
1249 uint8_t lane = this->checked_read_u8(pc_, 2, "lane number");
1250 if (lane < 0 || lane > (max_lanes - 1)) {
1251 error(pc_, pc_ + 2, "invalid Simd128 lane value");
1252 }
1253 return lane;
1254 }
1255
1248 unsigned DecodeSimdOpcode(WasmOpcode opcode) { 1256 unsigned DecodeSimdOpcode(WasmOpcode opcode) {
1249 unsigned len = 0; 1257 unsigned len = 0;
1258 static const int kInt32x4MaxLanes = 4;
1250 switch (opcode) { 1259 switch (opcode) {
1260 case kExprI32x4ReplaceLane: {
1261 compiler::NodeVector inputs(3, zone_);
1262 inputs[2] = Pop(1, LocalType::kWord32).node;
1263 inputs[1] = builder_->Int32Constant(LaneValue(kInt32x4MaxLanes));
1264 inputs[0] = Pop(0, LocalType::kSimd128).node;
1265 TFNode* node = BUILD(SimdOp, opcode, inputs);
1266 Push(LocalType::kSimd128, node);
1267 len++;
1268 break;
1269 }
1251 case kExprI32x4ExtractLane: { 1270 case kExprI32x4ExtractLane: {
1252 uint8_t lane = this->checked_read_u8(pc_, 2, "lane number"); 1271 compiler::NodeVector inputs(2, zone_);
1253 if (lane < 0 || lane > 3) { 1272 inputs[1] = builder_->Int32Constant(LaneValue(kInt32x4MaxLanes));
1254 error(pc_, pc_ + 2, "invalid extract lane value"); 1273 inputs[0] = Pop(0, LocalType::kSimd128).node;
1255 } 1274 TFNode* node = BUILD(SimdOp, opcode, inputs);
1256 TFNode* input = Pop(0, LocalType::kSimd128).node;
1257 TFNode* node = BUILD(SimdExtractLane, opcode, lane, input);
1258 Push(LocalType::kWord32, node); 1275 Push(LocalType::kWord32, node);
1259 len++; 1276 len++;
1260 break; 1277 break;
1261 } 1278 }
1262 default: { 1279 default: {
1263 FunctionSig* sig = WasmOpcodes::Signature(opcode); 1280 FunctionSig* sig = WasmOpcodes::Signature(opcode);
1264 if (sig != nullptr) { 1281 if (sig != nullptr) {
1265 compiler::NodeVector inputs(sig->parameter_count(), zone_); 1282 compiler::NodeVector inputs(sig->parameter_count(), zone_);
1266 for (size_t i = sig->parameter_count(); i > 0; i--) { 1283 for (size_t i = sig->parameter_count(); i > 0; i--) {
1267 Value val = Pop(static_cast<int>(i - 1), sig->GetParam(i - 1)); 1284 Value val = Pop(static_cast<int>(i - 1), sig->GetParam(i - 1));
(...skipping 665 matching lines...) Expand 10 before | Expand all | Expand 10 after
1933 BitVector* AnalyzeLoopAssignmentForTesting(Zone* zone, size_t num_locals, 1950 BitVector* AnalyzeLoopAssignmentForTesting(Zone* zone, size_t num_locals,
1934 const byte* start, const byte* end) { 1951 const byte* start, const byte* end) {
1935 FunctionBody body = {nullptr, nullptr, nullptr, start, end}; 1952 FunctionBody body = {nullptr, nullptr, nullptr, start, end};
1936 WasmFullDecoder decoder(zone, nullptr, body); 1953 WasmFullDecoder decoder(zone, nullptr, body);
1937 return decoder.AnalyzeLoopAssignmentForTesting(start, num_locals); 1954 return decoder.AnalyzeLoopAssignmentForTesting(start, num_locals);
1938 } 1955 }
1939 1956
1940 } // namespace wasm 1957 } // namespace wasm
1941 } // namespace internal 1958 } // namespace internal
1942 } // namespace v8 1959 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698