summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMax Graey <maxgraey@gmail.com>2021-07-26 17:51:23 +0300
committerGitHub <noreply@github.com>2021-07-26 07:51:23 -0700
commitac05f9cef1085f62f40990e5fbbfdf32c0860409 (patch)
tree1c76a18a005520db3e38a7a41d7cd1705200a972 /src
parentccd0c966cbd6a9d94d57cd93a39de1aeb9feccc2 (diff)
downloadbinaryen-ac05f9cef1085f62f40990e5fbbfdf32c0860409.tar.gz
binaryen-ac05f9cef1085f62f40990e5fbbfdf32c0860409.tar.bz2
binaryen-ac05f9cef1085f62f40990e5fbbfdf32c0860409.zip
[SIMD] Add extend + mul simd operations to interpreter (#4021)
Diffstat (limited to 'src')
-rw-r--r--src/wasm/literal.cpp37
1 files changed, 25 insertions, 12 deletions
diff --git a/src/wasm/literal.cpp b/src/wasm/literal.cpp
index 5a8ec3df3..7e36097c2 100644
--- a/src/wasm/literal.cpp
+++ b/src/wasm/literal.cpp
@@ -2400,41 +2400,54 @@ Literal Literal::extendHighUToVecI64x2() const {
return extend<2, uint32_t, uint64_t, LaneOrder::High>(*this);
}
+template<size_t Lanes, typename LaneFrom, typename LaneTo, LaneOrder Side>
+Literal extMul(const Literal& a, const Literal& b) {
+ LaneArray<Lanes* 2> lhs = getLanes<LaneFrom, Lanes * 2>(a);
+ LaneArray<Lanes* 2> rhs = getLanes<LaneFrom, Lanes * 2>(b);
+ LaneArray<Lanes> result;
+ for (size_t i = 0; i < Lanes; ++i) {
+ size_t idx = (Side == LaneOrder::Low) ? i : i + Lanes;
+ result[i] = Literal((LaneTo)(LaneFrom)lhs[idx].geti32() *
+ (LaneTo)(LaneFrom)rhs[idx].geti32());
+ }
+ return Literal(result);
+}
+
Literal Literal::extMulLowSI16x8(const Literal& other) const {
- WASM_UNREACHABLE("TODO: implement SIMD extending multiplications");
+ return extMul<8, int8_t, int16_t, LaneOrder::Low>(*this, other);
}
Literal Literal::extMulHighSI16x8(const Literal& other) const {
- WASM_UNREACHABLE("TODO: implement SIMD extending multiplications");
+ return extMul<8, int8_t, int16_t, LaneOrder::High>(*this, other);
}
Literal Literal::extMulLowUI16x8(const Literal& other) const {
- WASM_UNREACHABLE("TODO: implement SIMD extending multiplications");
+ return extMul<8, uint8_t, uint16_t, LaneOrder::Low>(*this, other);
}
Literal Literal::extMulHighUI16x8(const Literal& other) const {
- WASM_UNREACHABLE("TODO: implement SIMD extending multiplications");
+ return extMul<8, uint8_t, uint16_t, LaneOrder::High>(*this, other);
}
Literal Literal::extMulLowSI32x4(const Literal& other) const {
- WASM_UNREACHABLE("TODO: implement SIMD extending multiplications");
+ return extMul<4, int16_t, int32_t, LaneOrder::Low>(*this, other);
}
Literal Literal::extMulHighSI32x4(const Literal& other) const {
- WASM_UNREACHABLE("TODO: implement SIMD extending multiplications");
+ return extMul<4, int16_t, int32_t, LaneOrder::High>(*this, other);
}
Literal Literal::extMulLowUI32x4(const Literal& other) const {
- WASM_UNREACHABLE("TODO: implement SIMD extending multiplications");
+ return extMul<4, uint16_t, uint32_t, LaneOrder::Low>(*this, other);
}
Literal Literal::extMulHighUI32x4(const Literal& other) const {
- WASM_UNREACHABLE("TODO: implement SIMD extending multiplications");
+ return extMul<4, uint16_t, uint32_t, LaneOrder::High>(*this, other);
}
Literal Literal::extMulLowSI64x2(const Literal& other) const {
- WASM_UNREACHABLE("TODO: implement SIMD extending multiplications");
+ return extMul<2, int32_t, int64_t, LaneOrder::Low>(*this, other);
}
Literal Literal::extMulHighSI64x2(const Literal& other) const {
- WASM_UNREACHABLE("TODO: implement SIMD extending multiplications");
+ return extMul<2, int32_t, int64_t, LaneOrder::High>(*this, other);
}
Literal Literal::extMulLowUI64x2(const Literal& other) const {
- WASM_UNREACHABLE("TODO: implement SIMD extending multiplications");
+ return extMul<2, uint32_t, uint64_t, LaneOrder::Low>(*this, other);
}
Literal Literal::extMulHighUI64x2(const Literal& other) const {
- WASM_UNREACHABLE("TODO: implement SIMD extending multiplications");
+ return extMul<2, uint32_t, uint64_t, LaneOrder::High>(*this, other);
}
Literal Literal::swizzleVec8x16(const Literal& other) const {