summaryrefslogtreecommitdiff
path: root/src/wasm
diff options
context:
space:
mode:
Diffstat (limited to 'src/wasm')
-rw-r--r--src/wasm/literal.cpp30
-rw-r--r--src/wasm/wasm-binary.cpp16
-rw-r--r--src/wasm/wasm-stack.cpp14
-rw-r--r--src/wasm/wasm-validator.cpp4
4 files changed, 56 insertions, 8 deletions
diff --git a/src/wasm/literal.cpp b/src/wasm/literal.cpp
index ea398acd3..fe763680e 100644
--- a/src/wasm/literal.cpp
+++ b/src/wasm/literal.cpp
@@ -2372,17 +2372,33 @@ Literal Literal::pmaxF64x2(const Literal& other) const {
return binary<2, &Literal::getLanesF64x2, &Literal::pmax>(*this, other);
}
-Literal Literal::dotSI16x8toI32x4(const Literal& other) const {
- LaneArray<8> lhs = getLanesSI16x8();
- LaneArray<8> rhs = other.getLanesSI16x8();
- LaneArray<4> result;
- for (size_t i = 0; i < 4; ++i) {
- result[i] = Literal(lhs[i * 2].geti32() * rhs[i * 2].geti32() +
- lhs[i * 2 + 1].geti32() * rhs[i * 2 + 1].geti32());
+template<size_t Lanes,
+ size_t Factor,
+ LaneArray<Lanes * Factor> (Literal::*IntoLanes)() const>
+static Literal dot(const Literal& left, const Literal& right) {
+ LaneArray<Lanes* Factor> lhs = (left.*IntoLanes)();
+ LaneArray<Lanes* Factor> rhs = (right.*IntoLanes)();
+ LaneArray<Lanes> result;
+ for (size_t i = 0; i < Lanes; ++i) {
+ result[i] = Literal(int32_t(0));
+ for (size_t j = 0; j < Factor; ++j) {
+ result[i] = Literal(result[i].geti32() + lhs[i * Factor + j].geti32() *
+ rhs[i * Factor + j].geti32());
+ }
}
return Literal(result);
}
+Literal Literal::dotSI8x16toI16x8(const Literal& other) const {
+ return dot<8, 2, &Literal::getLanesSI8x16>(*this, other);
+}
+Literal Literal::dotUI8x16toI16x8(const Literal& other) const {
+ return dot<8, 2, &Literal::getLanesUI8x16>(*this, other);
+}
+Literal Literal::dotSI16x8toI32x4(const Literal& other) const {
+ return dot<4, 2, &Literal::getLanesSI16x8>(*this, other);
+}
+
Literal Literal::bitselectV128(const Literal& left,
const Literal& right) const {
return andV128(left).orV128(notV128().andV128(right));
diff --git a/src/wasm/wasm-binary.cpp b/src/wasm/wasm-binary.cpp
index 026e277fb..52af3151f 100644
--- a/src/wasm/wasm-binary.cpp
+++ b/src/wasm/wasm-binary.cpp
@@ -5601,6 +5601,14 @@ bool WasmBinaryBuilder::maybeVisitSIMDBinary(Expression*& out, uint32_t code) {
curr = allocator.alloc<Binary>();
curr->op = RelaxedQ15MulrSVecI16x8;
break;
+ case BinaryConsts::I16x8DotI8x16I7x16S:
+ curr = allocator.alloc<Binary>();
+ curr->op = DotI8x16I7x16SToVecI16x8;
+ break;
+ case BinaryConsts::I16x8DotI8x16I7x16U:
+ curr = allocator.alloc<Binary>();
+ curr->op = DotI8x16I7x16UToVecI16x8;
+ break;
default:
return false;
}
@@ -6075,6 +6083,14 @@ bool WasmBinaryBuilder::maybeVisitSIMDTernary(Expression*& out, uint32_t code) {
curr = allocator.alloc<SIMDTernary>();
curr->op = RelaxedFmsVecF64x2;
break;
+ case BinaryConsts::I32x4DotI8x16I7x16AddS:
+ curr = allocator.alloc<SIMDTernary>();
+ curr->op = DotI8x16I7x16AddSToVecI32x4;
+ break;
+ case BinaryConsts::I32x4DotI8x16I7x16AddU:
+ curr = allocator.alloc<SIMDTernary>();
+ curr->op = DotI8x16I7x16AddUToVecI32x4;
+ break;
default:
return false;
}
diff --git a/src/wasm/wasm-stack.cpp b/src/wasm/wasm-stack.cpp
index 67104a8f1..176f2f53f 100644
--- a/src/wasm/wasm-stack.cpp
+++ b/src/wasm/wasm-stack.cpp
@@ -569,6 +569,12 @@ void BinaryInstWriter::visitSIMDTernary(SIMDTernary* curr) {
case RelaxedFmsVecF64x2:
o << U32LEB(BinaryConsts::F64x2RelaxedFms);
break;
+ case DotI8x16I7x16AddSToVecI32x4:
+ o << U32LEB(BinaryConsts::I32x4DotI8x16I7x16AddS);
+ break;
+ case DotI8x16I7x16AddUToVecI32x4:
+ o << U32LEB(BinaryConsts::I32x4DotI8x16I7x16AddU);
+ break;
}
}
@@ -1846,6 +1852,14 @@ void BinaryInstWriter::visitBinary(Binary* curr) {
o << int8_t(BinaryConsts::SIMDPrefix)
<< U32LEB(BinaryConsts::I16x8RelaxedQ15MulrS);
break;
+ case DotI8x16I7x16SToVecI16x8:
+ o << int8_t(BinaryConsts::SIMDPrefix)
+ << U32LEB(BinaryConsts::I16x8DotI8x16I7x16S);
+ break;
+ case DotI8x16I7x16UToVecI16x8:
+ o << int8_t(BinaryConsts::SIMDPrefix)
+ << U32LEB(BinaryConsts::I16x8DotI8x16I7x16U);
+ break;
case InvalidBinary:
WASM_UNREACHABLE("invalid binary op");
diff --git a/src/wasm/wasm-validator.cpp b/src/wasm/wasm-validator.cpp
index dd896e139..bebb3eabe 100644
--- a/src/wasm/wasm-validator.cpp
+++ b/src/wasm/wasm-validator.cpp
@@ -1635,7 +1635,9 @@ void FunctionValidator::visitBinary(Binary* curr) {
case NarrowUVecI32x4ToVecI16x8:
case SwizzleVecI8x16:
case RelaxedSwizzleVecI8x16:
- case RelaxedQ15MulrSVecI16x8: {
+ case RelaxedQ15MulrSVecI16x8:
+ case DotI8x16I7x16SToVecI16x8:
+ case DotI8x16I7x16UToVecI16x8: {
shouldBeEqualOrFirstIsUnreachable(
curr->left->type, Type(Type::v128), curr, "v128 op");
shouldBeEqualOrFirstIsUnreachable(