summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/literal.h4
-rw-r--r--src/wasm-interpreter.h8
-rw-r--r--src/wasm/literal.cpp25
3 files changed, 33 insertions, 4 deletions
diff --git a/src/literal.h b/src/literal.h
index 28e6f03cf..3d4562f77 100644
--- a/src/literal.h
+++ b/src/literal.h
@@ -612,6 +612,10 @@ public:
Literal floorF64x2() const;
Literal truncF64x2() const;
Literal nearestF64x2() const;
+ Literal extAddPairwiseToSI16x8() const;
+ Literal extAddPairwiseToUI16x8() const;
+ Literal extAddPairwiseToSI32x4() const;
+ Literal extAddPairwiseToUI32x4() const;
Literal truncSatToSI32x4() const;
Literal truncSatToUI32x4() const;
Literal convertSToF32x4() const;
diff --git a/src/wasm-interpreter.h b/src/wasm-interpreter.h
index 872d90603..13a3f2876 100644
--- a/src/wasm-interpreter.h
+++ b/src/wasm-interpreter.h
@@ -530,13 +530,13 @@ public:
case NearestVecF64x2:
return value.nearestF64x2();
case ExtAddPairwiseSVecI8x16ToI16x8:
- WASM_UNREACHABLE("unimp");
+ return value.extAddPairwiseToSI16x8();
case ExtAddPairwiseUVecI8x16ToI16x8:
- WASM_UNREACHABLE("unimp");
+ return value.extAddPairwiseToUI16x8();
case ExtAddPairwiseSVecI16x8ToI32x4:
- WASM_UNREACHABLE("unimp");
+ return value.extAddPairwiseToSI32x4();
case ExtAddPairwiseUVecI16x8ToI32x4:
- WASM_UNREACHABLE("unimp");
+ return value.extAddPairwiseToUI32x4();
case TruncSatSVecF32x4ToVecI32x4:
return value.truncSatToSI32x4();
case TruncSatUVecF32x4ToVecI32x4:
diff --git a/src/wasm/literal.cpp b/src/wasm/literal.cpp
index 7e36097c2..9b2171a74 100644
--- a/src/wasm/literal.cpp
+++ b/src/wasm/literal.cpp
@@ -1809,6 +1809,31 @@ Literal Literal::truncF64x2() const {
Literal Literal::nearestF64x2() const {
return unary<2, &Literal::getLanesF64x2, &Literal::nearbyint>(*this);
}
+
+template<int Lanes, typename LaneFrom, typename LaneTo>
+static Literal extAddPairwise(const Literal& vec) {
+ LaneArray<Lanes* 2> lanes = getLanes<LaneFrom, Lanes * 2>(vec);
+ LaneArray<Lanes> result;
+ for (size_t i = 0; i < Lanes; i++) {
+ result[i] = Literal((LaneTo)(LaneFrom)lanes[i * 2 + 0].geti32() +
+ (LaneTo)(LaneFrom)lanes[i * 2 + 1].geti32());
+ }
+ return Literal(result);
+}
+
+Literal Literal::extAddPairwiseToSI16x8() const {
+ return extAddPairwise<8, int8_t, int16_t>(*this);
+}
+Literal Literal::extAddPairwiseToUI16x8() const {
+ return extAddPairwise<8, uint8_t, int16_t>(*this);
+}
+Literal Literal::extAddPairwiseToSI32x4() const {
+ return extAddPairwise<4, int16_t, int32_t>(*this);
+}
+Literal Literal::extAddPairwiseToUI32x4() const {
+ return extAddPairwise<4, uint16_t, uint32_t>(*this);
+}
+
Literal Literal::truncSatToSI32x4() const {
return unary<4, &Literal::getLanesF32x4, &Literal::truncSatToSI32>(*this);
}