[Base] Add ARM64 utility functions

Mostly element-accessors
This commit is contained in:
Wunkolo 2024-04-30 11:29:07 -07:00
parent 59bc265941
commit 2284ed417a
1 changed files with 20 additions and 0 deletions

View File

@ -31,6 +31,8 @@
#if XE_ARCH_AMD64
#include <xmmintrin.h>
#elif XE_ARCH_ARM64
#include <arm64_neon.h>
#endif
namespace xe {
@ -383,6 +385,24 @@ template <int N>
int64_t m128_i64(const __m128& v) {
return m128_i64<N>(_mm_castps_pd(v));
}
#elif XE_ARCH_ARM64
// Utilities for NEON values.
template <int N>
float m128_f32(const float32x4_t& v) {
return vgetq_lane_f32(v, N);
}
template <int N>
int32_t m128_i32(const int32x4_t& v) {
return vgetq_lane_s32(v, N);
}
template <int N>
double m128_f64(const float64x2_t& v) {
return vgetq_lane_f64(v, N);
}
template <int N>
int64_t m128_i64(const int64x2_t& v) {
return vgetq_lane_s64(v, N);
}
#endif
// Similar to the C++ implementation of XMConvertFloatToHalf and