summaryrefslogtreecommitdiff
path: root/src/wasm/literal.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/wasm/literal.cpp')
-rw-r--r--src/wasm/literal.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/wasm/literal.cpp b/src/wasm/literal.cpp
index b382d1a3d..7f0c9fa6b 100644
--- a/src/wasm/literal.cpp
+++ b/src/wasm/literal.cpp
@@ -1867,4 +1867,15 @@ Literal Literal::widenHighUToVecI32x4() const {
return widen<4, &Literal::getLanesUI16x8, LaneOrder::High>(*this);
}
+Literal Literal::swizzleVec8x16(const Literal& other) const {
+ auto lanes = getLanesUI8x16();
+ auto indices = other.getLanesUI8x16();
+ LaneArray<16> result;
+ for (size_t i = 0; i < 16; ++i) {
+ size_t index = indices[i].geti32();
+ result[i] = index >= 16 ? Literal(int32_t(0)) : lanes[index];
+ }
+ return Literal(result);
+}
+
} // namespace wasm