Skip to content

Commit 24fe3ab

Browse files
Add first support for neon 32 and 64 bit
1 parent 0576683 commit 24fe3ab

File tree

2 files changed

+116
-0
lines changed

2 files changed

+116
-0
lines changed

include/xsimd/arch/xsimd_neon.hpp

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2455,6 +2455,61 @@ namespace xsimd
24552455
return vshlq_s32(lhs, vnegq_s32(rhs));
24562456
}
24572457

2458+
// first
2459+
template <class A>
2460+
XSIMD_INLINE float first(batch<float, A> const& self, requires_arch<neon>) noexcept
2461+
{
2462+
return vget_lane_f32(self, 0);
2463+
}
2464+
2465+
template <class A, class T, detail::enable_sized_unsigned_t<T, 1> = 0>
2466+
XSIMD_INLINE T first(batch<T, A> val, requires_arch<neon>) noexcept
2467+
{
2468+
return vget_lane_u8(val, 0);
2469+
}
2470+
2471+
template <class A, class T, detail::enable_sized_signed_t<T, 1> = 0>
2472+
XSIMD_INLINE T first(batch<T, A> val, requires_arch<neon>) noexcept
2473+
{
2474+
return vget_lane_s8(val, 0);
2475+
}
2476+
2477+
template <class A, class T, detail::enable_sized_unsigned_t<T, 2> = 0>
2478+
XSIMD_INLINE T first(batch<T, A> val, requires_arch<neon>) noexcept
2479+
{
2480+
return vget_lane_u16(val, 0);
2481+
}
2482+
2483+
template <class A, class T, detail::enable_sized_signed_t<T, 2> = 0>
2484+
XSIMD_INLINE T first(batch<T, A> val, requires_arch<neon>) noexcept
2485+
{
2486+
return vget_lane_s16(val, 0);
2487+
}
2488+
2489+
template <class A, class T, detail::enable_sized_unsigned_t<T, 4> = 0>
2490+
XSIMD_INLINE T first(batch<T, A> val, requires_arch<neon>) noexcept
2491+
{
2492+
return vget_lane_u32(val, 0);
2493+
}
2494+
2495+
template <class A, class T, detail::enable_sized_signed_t<T, 4> = 0>
2496+
XSIMD_INLINE T first(batch<T, A> val, requires_arch<neon>) noexcept
2497+
{
2498+
return vget_lane_s32(val, 0);
2499+
}
2500+
2501+
template <class A, class T, detail::enable_sized_unsigned_t<T, 8> = 0>
2502+
XSIMD_INLINE T first(batch<T, A> val, requires_arch<neon>) noexcept
2503+
{
2504+
return vget_lane_u64(val, 0);
2505+
}
2506+
2507+
template <class A, class T, detail::enable_sized_signed_t<T, 8> = 0>
2508+
XSIMD_INLINE T first(batch<T, A> val, requires_arch<neon>) noexcept
2509+
{
2510+
return vget_lane_s64(val, 0);
2511+
}
2512+
24582513
// Overloads of bitwise shifts accepting two batches of uint64/int64 are not available with ARMv7
24592514

24602515
/*******

include/xsimd/arch/xsimd_neon64.hpp

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,67 @@ namespace xsimd
2828
{
2929
using namespace types;
3030

31+
// first
32+
template <class A>
33+
XSIMD_INLINE float first(batch<float, A> const& self, requires_arch<neon64>) noexcept
34+
{
35+
return vgetq_lane_f32(self, 0);
36+
}
37+
38+
template <class A>
39+
XSIMD_INLINE double first(batch<double, A> const& self, requires_arch<neon64>) noexcept
40+
{
41+
return vgetq_lane_f64(self, 0);
42+
}
43+
44+
template <class A, class T, detail::enable_sized_unsigned_t<T, 1> = 0>
45+
XSIMD_INLINE T first(batch<T, A> val, requires_arch<neon64>) noexcept
46+
{
47+
return vgetq_lane_u8(val, 0);
48+
}
49+
50+
template <class A, class T, detail::enable_sized_signed_t<T, 1> = 0>
51+
XSIMD_INLINE T first(batch<T, A> val, requires_arch<neon64>) noexcept
52+
{
53+
return vgetq_lane_s8(val, 0);
54+
}
55+
56+
template <class A, class T, detail::enable_sized_unsigned_t<T, 2> = 0>
57+
XSIMD_INLINE T first(batch<T, A> val, requires_arch<neon64>) noexcept
58+
{
59+
return vgetq_lane_u16(val, 0);
60+
}
61+
62+
template <class A, class T, detail::enable_sized_signed_t<T, 2> = 0>
63+
XSIMD_INLINE T first(batch<T, A> val, requires_arch<neon64>) noexcept
64+
{
65+
return vgetq_lane_s16(val, 0);
66+
}
67+
68+
template <class A, class T, detail::enable_sized_unsigned_t<T, 4> = 0>
69+
XSIMD_INLINE T first(batch<T, A> val, requires_arch<neon64>) noexcept
70+
{
71+
return vgetq_lane_u32(val, 0);
72+
}
73+
74+
template <class A, class T, detail::enable_sized_signed_t<T, 4> = 0>
75+
XSIMD_INLINE T first(batch<T, A> val, requires_arch<neon64>) noexcept
76+
{
77+
return vgetq_lane_s32(val, 0);
78+
}
79+
80+
template <class A, class T, detail::enable_sized_unsigned_t<T, 8> = 0>
81+
XSIMD_INLINE T first(batch<T, A> val, requires_arch<neon64>) noexcept
82+
{
83+
return vgetq_lane_u64(val, 0);
84+
}
85+
86+
template <class A, class T, detail::enable_sized_signed_t<T, 8> = 0>
87+
XSIMD_INLINE T first(batch<T, A> val, requires_arch<neon64>) noexcept
88+
{
89+
return vgetq_lane_s64(val, 0);
90+
}
91+
3192
/*******
3293
* all *
3394
*******/

0 commit comments

Comments
 (0)