Skip to content

Commit

Permalink
added support for bitwise_lshift operation
Browse files Browse the repository at this point in the history
  • Loading branch information
anutosh491 committed Oct 5, 2023
1 parent 6a78841 commit 83e57d2
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions include/xsimd/arch/xsimd_wasm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,33 @@ namespace xsimd
return wasm_v128_or(self, other);
}

// bitwise_lshift
template <class A, class T, class = typename std::enable_if<std::is_integral<T>::value, void>::type>
inline batch<T, A> bitwise_lshift(batch<T, A> const& self, int32_t other, requires_arch<wasm>) noexcept
{
XSIMD_IF_CONSTEXPR(sizeof(T) == 1)
{
return wasm_v128_and(wasm_i8x16_splat(0xFF << other), wasm_i32x4_shl(self, other));
}
else XSIMD_IF_CONSTEXPR(sizeof(T) == 2)
{
return wasm_i16x8_shl(self, other);
}
else XSIMD_IF_CONSTEXPR(sizeof(T) == 4)
{
return wasm_i32x4_shl(self, other);
}
else XSIMD_IF_CONSTEXPR(sizeof(T) == 8)
{
return wasm_i64x2_shl(self, other);
}
else
{
assert(false && "unsupported arch/op combination");
return {};
}
}

// bitwise_xor
template <class A, class T>
inline batch<T, A> bitwise_xor(batch<T, A> const& self, batch<T, A> const& other, requires_arch<wasm>) noexcept
Expand Down

0 comments on commit 83e57d2

Please sign in to comment.