From 873b03f6618f4718523cf370b39c75ec2f4020a8 Mon Sep 17 00:00:00 2001 From: Hendiadyoin1 Date: Mon, 15 Apr 2024 20:28:57 +0200 Subject: [PATCH] AK: Add generic SIMD vector load/store functions (cherry picked from commit 27c386797df64b9c4dcbe6a27e57d9f54837e9b4) --- AK/SIMDExtras.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/AK/SIMDExtras.h b/AK/SIMDExtras.h index 78116ef53ac..1d4865e9800 100644 --- a/AK/SIMDExtras.h +++ b/AK/SIMDExtras.h @@ -101,6 +101,21 @@ ALWAYS_INLINE static int maskcount(i32x4 mask) // Load / Store +template +ALWAYS_INLINE static VectorType load_unaligned(void const* a) +{ + VectorType v; + __builtin_memcpy(&v, a, sizeof(VectorType)); + return v; +} + +template +ALWAYS_INLINE static void store_unaligned(void* a, VectorType const& v) +{ + // FIXME: Does this generate the right instructions? + __builtin_memcpy(a, &v, sizeof(VectorType)); +} + ALWAYS_INLINE static f32x4 load4(float const* a, float const* b, float const* c, float const* d) { return f32x4 { *a, *b, *c, *d };