Index: src/wasm/ast-decoder.cc |
diff --git a/src/wasm/ast-decoder.cc b/src/wasm/ast-decoder.cc |
index 02d1db5bdad3b38998b0fd5b11e75c6202c58eab..0088e111220617023991fce38e61c0014b90b774 100644 |
--- a/src/wasm/ast-decoder.cc |
+++ b/src/wasm/ast-decoder.cc |
@@ -1245,16 +1245,33 @@ class WasmFullDecoder : public WasmDecoder { |
return 1 + operand.length; |
} |
+ 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
|
+ uint8_t lane = this->checked_read_u8(pc_, 2, "lane number"); |
+ if (lane < 0 || lane > (max_lanes - 1)) { |
+ error(pc_, pc_ + 2, "invalid Simd128 lane value"); |
+ } |
+ return lane; |
+ } |
+ |
unsigned DecodeSimdOpcode(WasmOpcode opcode) { |
unsigned len = 0; |
+ static const int kInt32x4MaxLanes = 4; |
switch (opcode) { |
+ case kExprI32x4ReplaceLane: { |
+ compiler::NodeVector inputs(3, zone_); |
+ inputs[2] = Pop(1, LocalType::kWord32).node; |
+ inputs[1] = builder_->Int32Constant(LaneValue(kInt32x4MaxLanes)); |
+ inputs[0] = Pop(0, LocalType::kSimd128).node; |
+ TFNode* node = BUILD(SimdOp, opcode, inputs); |
+ Push(LocalType::kSimd128, node); |
+ len++; |
+ break; |
+ } |
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); |
+ compiler::NodeVector inputs(2, zone_); |
+ inputs[1] = builder_->Int32Constant(LaneValue(kInt32x4MaxLanes)); |
+ inputs[0] = Pop(0, LocalType::kSimd128).node; |
+ TFNode* node = BUILD(SimdOp, opcode, inputs); |
Push(LocalType::kWord32, node); |
len++; |
break; |