Skip to content

Commit 27e7284

Browse files
WIP
1 parent e52635f commit 27e7284

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

include/xsimd/arch/xsimd_wasm.hpp

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -531,6 +531,43 @@ namespace xsimd
531531
static_cast<int32_t>(wasm_f32x4_extract_lane(self, 3)));
532532
}
533533
}
534+
// first
535+
template <class A>
536+
XSIMD_INLINE float first(batch<float, A> const& self, requires_arch<wasm>) noexcept
537+
{
538+
return wasm_f32x4_extract_lane(self, 0);
539+
}
540+
template <class A, class T, class = typename std::enable_if<std::is_integral<T>::value, void>::type>
541+
XSIMD_INLINE T first(batch<T, A> const& self, requires_arch<wasm>) noexcept
542+
{
543+
XSIMD_IF_CONSTEXPR(sizeof(T) == 1)
544+
{
545+
return wasm_i8x16_extract_lane(self, 0);
546+
}
547+
else XSIMD_IF_CONSTEXPR(sizeof(T) == 2)
548+
{
549+
return wasm_i16x8_extract_lane(self, 0);
550+
}
551+
else XSIMD_IF_CONSTEXPR(sizeof(T) == 4)
552+
{
553+
return wasm_i32x4_extract_lane(self, 0);
554+
}
555+
else XSIMD_IF_CONSTEXPR(sizeof(T) == 8)
556+
{
557+
return wasm_i64x2_extract_lane(self, 0);
558+
}
559+
else
560+
{
561+
assert(false && "unsupported arch/op combination");
562+
return {};
563+
}
564+
}
565+
template <class A>
566+
XSIMD_INLINE double first(batch<double, A> const& self, requires_arch<wasm>) noexcept
567+
{
568+
return wasm_f64x2_extract_lane(self, 0);
569+
}
570+
534571

535572
// floor
536573
template <class A>

0 commit comments

Comments
 (0)