diff options
Diffstat (limited to 'src/wasm/literal.cpp')
-rw-r--r-- | src/wasm/literal.cpp | 25 |
1 files changed, 25 insertions, 0 deletions
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); } |