summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThomas Lively <7121787+tlively@users.noreply.github.com>2019-11-04 15:44:19 -0800
committerGitHub <noreply@github.com>2019-11-04 15:44:19 -0800
commit368f8a743c8322c3a01633f0cfa8ce205d58fb49 (patch)
tree3cf09812f83b13d6c7dd87cc0359fd7e024ad0a4 /src
parent74526f3effdab0d5bca9cb122989335b6527e76f (diff)
downloadbinaryen-368f8a743c8322c3a01633f0cfa8ce205d58fb49.tar.gz
binaryen-368f8a743c8322c3a01633f0cfa8ce205d58fb49.tar.bz2
binaryen-368f8a743c8322c3a01633f0cfa8ce205d58fb49.zip
Add i32x4.dot_i16x8_s (#2420)
This experimental instruction is specified in https://github.com/WebAssembly/simd/pull/127 and is being implemented to enable further investigation of its performance impact.
Diffstat (limited to 'src')
-rw-r--r--src/binaryen-c.cpp3
-rw-r--r--src/binaryen-c.h1
-rw-r--r--src/gen-s-parser.inc3
-rw-r--r--src/ir/cost.h3
-rw-r--r--src/js/binaryen.js-post.js4
-rw-r--r--src/literal.h1
-rw-r--r--src/passes/Print.cpp3
-rw-r--r--src/tools/fuzzing.h1
-rw-r--r--src/wasm-binary.h1
-rw-r--r--src/wasm-interpreter.h2
-rw-r--r--src/wasm.h1
-rw-r--r--src/wasm/literal.cpp11
-rw-r--r--src/wasm/wasm-binary.cpp4
-rw-r--r--src/wasm/wasm-stack.cpp4
-rw-r--r--src/wasm/wasm-validator.cpp1
15 files changed, 43 insertions, 0 deletions
diff --git a/src/binaryen-c.cpp b/src/binaryen-c.cpp
index 2b9b9d2ae..4e5ad22f1 100644
--- a/src/binaryen-c.cpp
+++ b/src/binaryen-c.cpp
@@ -842,6 +842,9 @@ BinaryenOp BinaryenMinSVecI32x4(void) { return MinSVecI32x4; }
BinaryenOp BinaryenMinUVecI32x4(void) { return MinUVecI32x4; }
BinaryenOp BinaryenMaxSVecI32x4(void) { return MaxSVecI32x4; }
BinaryenOp BinaryenMaxUVecI32x4(void) { return MaxUVecI32x4; }
+BinaryenOp BinaryenDotSVecI16x8ToVecI32x4(void) {
+ return DotSVecI16x8ToVecI32x4;
+}
BinaryenOp BinaryenNegVecI64x2(void) { return NegVecI64x2; }
BinaryenOp BinaryenAnyTrueVecI64x2(void) { return AnyTrueVecI64x2; }
BinaryenOp BinaryenAllTrueVecI64x2(void) { return AllTrueVecI64x2; }
diff --git a/src/binaryen-c.h b/src/binaryen-c.h
index 936cfb0f6..dd5acf325 100644
--- a/src/binaryen-c.h
+++ b/src/binaryen-c.h
@@ -504,6 +504,7 @@ BINARYEN_API BinaryenOp BinaryenMinSVecI32x4(void);
BINARYEN_API BinaryenOp BinaryenMinUVecI32x4(void);
BINARYEN_API BinaryenOp BinaryenMaxSVecI32x4(void);
BINARYEN_API BinaryenOp BinaryenMaxUVecI32x4(void);
+BINARYEN_API BinaryenOp BinaryenDotSVecI16x8ToVecI32x4(void);
BINARYEN_API BinaryenOp BinaryenNegVecI64x2(void);
BINARYEN_API BinaryenOp BinaryenAnyTrueVecI64x2(void);
BINARYEN_API BinaryenOp BinaryenAllTrueVecI64x2(void);
diff --git a/src/gen-s-parser.inc b/src/gen-s-parser.inc
index 9a8d9b88c..5e6e37f5a 100644
--- a/src/gen-s-parser.inc
+++ b/src/gen-s-parser.inc
@@ -1409,6 +1409,9 @@ switch (op[0]) {
default: goto parse_error;
}
}
+ case 'd':
+ if (strcmp(op, "i32x4.dot_i16x8_s") == 0) { return makeBinary(s, BinaryOp::DotSVecI16x8ToVecI32x4); }
+ goto parse_error;
case 'e': {
switch (op[7]) {
case 'q':
diff --git a/src/ir/cost.h b/src/ir/cost.h
index 26c120675..60eb84b08 100644
--- a/src/ir/cost.h
+++ b/src/ir/cost.h
@@ -648,6 +648,9 @@ struct CostAnalyzer : public Visitor<CostAnalyzer, Index> {
case MaxUVecI32x4:
ret = 1;
break;
+ case DotSVecI16x8ToVecI32x4:
+ ret = 1;
+ break;
case AddVecI64x2:
ret = 1;
break;
diff --git a/src/js/binaryen.js-post.js b/src/js/binaryen.js-post.js
index f2d679900..37d2432cb 100644
--- a/src/js/binaryen.js-post.js
+++ b/src/js/binaryen.js-post.js
@@ -357,6 +357,7 @@ Module['MinSVecI16x8'] = Module['_BinaryenMinSVecI16x8']();
Module['MinUVecI16x8'] = Module['_BinaryenMinUVecI16x8']();
Module['MaxSVecI16x8'] = Module['_BinaryenMaxSVecI16x8']();
Module['MaxUVecI16x8'] = Module['_BinaryenMaxUVecI16x8']();
+Module['DotSVecI16x8ToVecI32x4'] = Module['_BinaryenDotSVecI16x8ToVecI32x4']();
Module['NegVecI32x4'] = Module['_BinaryenNegVecI32x4']();
Module['AnyTrueVecI32x4'] = Module['_BinaryenAnyTrueVecI32x4']();
Module['AllTrueVecI32x4'] = Module['_BinaryenAllTrueVecI32x4']();
@@ -1676,6 +1677,9 @@ function wrapModule(module, self) {
'max_u': function(left, right) {
return Module['_BinaryenBinary'](module, Module['MaxUVecI32x4'], left, right);
},
+ 'dot_i16x8_s': function(left, right) {
+ return Module['_BinaryenBinary'](module, Module['DotSVecI16x8ToVecI32x4'], left, right);
+ },
'trunc_sat_f32x4_s': function(value) {
return Module['_BinaryenUnary'](module, Module['TruncSatSVecF32x4ToVecI32x4'], value);
},
diff --git a/src/literal.h b/src/literal.h
index 007a2cde8..1106d1c27 100644
--- a/src/literal.h
+++ b/src/literal.h
@@ -364,6 +364,7 @@ public:
Literal minUI32x4(const Literal& other) const;
Literal maxSI32x4(const Literal& other) const;
Literal maxUI32x4(const Literal& other) const;
+ Literal dotSI16x8toI32x4(const Literal& other) const;
Literal negI64x2() const;
Literal anyTrueI64x2() const;
Literal allTrueI64x2() const;
diff --git a/src/passes/Print.cpp b/src/passes/Print.cpp
index e383974d6..bfd12dc94 100644
--- a/src/passes/Print.cpp
+++ b/src/passes/Print.cpp
@@ -1222,6 +1222,9 @@ struct PrintExpressionContents
case MaxUVecI32x4:
o << "i32x4.max_u";
break;
+ case DotSVecI16x8ToVecI32x4:
+ o << "i32x4.dot_i16x8_s";
+ break;
case AddVecI64x2:
o << "i64x2.add";
break;
diff --git a/src/tools/fuzzing.h b/src/tools/fuzzing.h
index c6cce4427..c66795c11 100644
--- a/src/tools/fuzzing.h
+++ b/src/tools/fuzzing.h
@@ -2169,6 +2169,7 @@ private:
MinUVecI32x4,
MaxSVecI32x4,
MaxUVecI32x4,
+ DotSVecI16x8ToVecI32x4,
AddVecI64x2,
SubVecI64x2,
AddVecF32x4,
diff --git a/src/wasm-binary.h b/src/wasm-binary.h
index 2a457f5a7..7014fd875 100644
--- a/src/wasm-binary.h
+++ b/src/wasm-binary.h
@@ -831,6 +831,7 @@ enum ASTNodes {
I32x4MinU = 0x81,
I32x4MaxS = 0x82,
I32x4MaxU = 0x83,
+ I32x4DotSVecI16x8 = 0xd9,
I64x2Neg = 0x84,
I64x2AnyTrue = 0x85,
I64x2AllTrue = 0x86,
diff --git a/src/wasm-interpreter.h b/src/wasm-interpreter.h
index f8cf3ae42..dc2696716 100644
--- a/src/wasm-interpreter.h
+++ b/src/wasm-interpreter.h
@@ -801,6 +801,8 @@ public:
return left.maxSI32x4(right);
case MaxUVecI32x4:
return left.maxUI32x4(right);
+ case DotSVecI16x8ToVecI32x4:
+ return left.dotSI16x8toI32x4(right);
case AddVecI64x2:
return left.addI64x2(right);
case SubVecI64x2:
diff --git a/src/wasm.h b/src/wasm.h
index ca1114182..77eeea5d3 100644
--- a/src/wasm.h
+++ b/src/wasm.h
@@ -383,6 +383,7 @@ enum BinaryOp {
MinUVecI32x4,
MaxSVecI32x4,
MaxUVecI32x4,
+ DotSVecI16x8ToVecI32x4,
AddVecI64x2,
SubVecI64x2,
AddVecF32x4,
diff --git a/src/wasm/literal.cpp b/src/wasm/literal.cpp
index f4ddf69cc..41d98dea3 100644
--- a/src/wasm/literal.cpp
+++ b/src/wasm/literal.cpp
@@ -1829,6 +1829,17 @@ Literal Literal::maxF64x2(const Literal& other) const {
return binary<2, &Literal::getLanesF64x2, &Literal::max>(*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());
+ }
+ return Literal(result);
+}
+
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 cb67d1556..8d6721c9c 100644
--- a/src/wasm/wasm-binary.cpp
+++ b/src/wasm/wasm-binary.cpp
@@ -3939,6 +3939,10 @@ bool WasmBinaryBuilder::maybeVisitSIMDBinary(Expression*& out, uint32_t code) {
curr = allocator.alloc<Binary>();
curr->op = MaxUVecI32x4;
break;
+ case BinaryConsts::I32x4DotSVecI16x8:
+ curr = allocator.alloc<Binary>();
+ curr->op = DotSVecI16x8ToVecI32x4;
+ break;
case BinaryConsts::I64x2Add:
curr = allocator.alloc<Binary>();
curr->op = AddVecI64x2;
diff --git a/src/wasm/wasm-stack.cpp b/src/wasm/wasm-stack.cpp
index d4af126b7..c1d4f1222 100644
--- a/src/wasm/wasm-stack.cpp
+++ b/src/wasm/wasm-stack.cpp
@@ -1459,6 +1459,10 @@ void BinaryInstWriter::visitBinary(Binary* curr) {
case MaxUVecI32x4:
o << int8_t(BinaryConsts::SIMDPrefix) << U32LEB(BinaryConsts::I32x4MaxU);
break;
+ case DotSVecI16x8ToVecI32x4:
+ o << int8_t(BinaryConsts::SIMDPrefix)
+ << U32LEB(BinaryConsts::I32x4DotSVecI16x8);
+ break;
case AddVecI64x2:
o << int8_t(BinaryConsts::SIMDPrefix) << U32LEB(BinaryConsts::I64x2Add);
break;
diff --git a/src/wasm/wasm-validator.cpp b/src/wasm/wasm-validator.cpp
index ed54173ed..82cd6d6f0 100644
--- a/src/wasm/wasm-validator.cpp
+++ b/src/wasm/wasm-validator.cpp
@@ -1361,6 +1361,7 @@ void FunctionValidator::visitBinary(Binary* curr) {
case MinUVecI32x4:
case MaxSVecI32x4:
case MaxUVecI32x4:
+ case DotSVecI16x8ToVecI32x4:
case AddVecI64x2:
case SubVecI64x2:
case AddVecF32x4: