diff options
author | Thomas Lively <7121787+tlively@users.noreply.github.com> | 2019-10-03 18:07:02 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-10-03 18:07:02 -0700 |
commit | 3c78269032071490bc13dc5dbac02567d4d491e0 (patch) | |
tree | a00c874c18dd2e00fbb2d05aa104ee8131a7d1c5 /src/wasm/literal.cpp | |
parent | fc6d2df4eedfef53a0a29fed1ff3ce4707556700 (diff) | |
download | binaryen-3c78269032071490bc13dc5dbac02567d4d491e0.tar.gz binaryen-3c78269032071490bc13dc5dbac02567d4d491e0.tar.bz2 binaryen-3c78269032071490bc13dc5dbac02567d4d491e0.zip |
v8x16.swizzle (#2368)
As specified at
https://github.com/WebAssembly/simd/blob/master/proposals/simd/SIMD.md#swizzling-using-variable-indices.
Diffstat (limited to 'src/wasm/literal.cpp')
-rw-r--r-- | src/wasm/literal.cpp | 11 |
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 |