Module Name: src
Committed By: riastradh
Date: Mon Jul 15 13:51:10 UTC 2024
Modified Files:
src/sys/crypto/arch/x86: immintrin.h
Log Message:
sys/crypto: Fix gcc x86 load/store-unaligned intrinsics.
(Sure would be nice if someone wired up the kernel build to use
gcc/clang's own immintrin.h &c. so we don't have to maintain a copy!)
PR toolchain/58350
To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/crypto/arch/x86/immintrin.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/crypto/arch/x86/immintrin.h
diff -u src/sys/crypto/arch/x86/immintrin.h:1.1 src/sys/crypto/arch/x86/immintrin.h:1.2
--- src/sys/crypto/arch/x86/immintrin.h:1.1 Mon Aug 7 01:07:36 2023
+++ src/sys/crypto/arch/x86/immintrin.h Mon Jul 15 13:51:10 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: immintrin.h,v 1.1 2023/08/07 01:07:36 rin Exp $ */
+/* $NetBSD: immintrin.h,v 1.2 2024/07/15 13:51:10 riastradh Exp $ */
/*-
* Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -42,8 +42,16 @@
#define _INTRINSATTR \
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
-#define _PACKALIAS
+typedef short __m16 __attribute__((__vector_size__(2), __may_alias__));
+typedef short __m16_u
+ __attribute__((__vector_size__(2), __may_alias__, __aligned__(1)));
+typedef int __m32 __attribute__((__vector_size__(4), __may_alias__));
+typedef int __m32_u
+ __attribute__((__vector_size__(4), __may_alias__, __aligned__(1)));
+typedef int __m64 __attribute__((__vector_size__(8), __may_alias__));
+typedef int __m64_u
+ __attribute__((__vector_size__(8), __may_alias__, __aligned__(1)));
typedef float __m128 __attribute__((__vector_size__(16), __may_alias__));
typedef long long __m128i __attribute__((__vector_size__(16), __may_alias__));
typedef long long __m128i_u
@@ -113,14 +121,22 @@ _INTRINSATTR
static __inline __m128i
_mm_loadu_si128(const __m128i_u *__p)
{
+#if defined(__GNUC__) && !defined(__clang__)
+ return *__p;
+#else
return ((const struct { __m128i_u __v; } _PACKALIAS *)__p)->__v;
+#endif
}
_INTRINSATTR
static __inline __m128i
_mm_loadu_si32(const void *__p)
{
+#if defined(__GNUC__) && !defined(__clang__)
+ int32_t __v = (*(__m32_u *)__p)[0];
+#else
int32_t __v = ((const struct { int32_t __v; } _PACKALIAS *)__p)->__v;
+#endif
return __extension__ (__m128i)(__v4si){ __v, 0, 0, 0 };
}
@@ -128,7 +144,11 @@ _INTRINSATTR
static __inline __m128i
_mm_loadu_si64(const void *__p)
{
+#if defined(__GNUC__) && !defined(__clang__)
+ int64_t __v = (*(__m64_u *)__p)[0];
+#else
int64_t __v = ((const struct { int64_t __v; } _PACKALIAS *)__p)->__v;
+#endif
return __extension__ (__m128i)(__v2di){ __v, 0 };
}
@@ -278,21 +298,33 @@ _INTRINSATTR
static __inline void
_mm_storeu_si128(__m128i_u *__p, __m128i __v)
{
+#if defined(__GNUC__) && !defined(__clang__)
+ *__p = __v;
+#else
((struct { __m128i_u __v; } _PACKALIAS *)__p)->__v = __v;
+#endif
}
_INTRINSATTR
static __inline void
_mm_storeu_si32(void *__p, __m128i __v)
{
+#if defined(__GNUC__) && !defined(__clang__)
+ *(__m32_u *)__p = (__m32)((__v4si)__v)[0];
+#else
((struct { int32_t __v; } _PACKALIAS *)__p)->__v = ((__v4si)__v)[0];
+#endif
}
_INTRINSATTR
static __inline void
_mm_storeu_si64(void *__p, __m128i __v)
{
+#if defined(__GNUC__) && !defined(__clang__)
+ *(__m64_u *)__p = (__m64)((__v2di)__v)[0];
+#else
((struct { int64_t __v; } _PACKALIAS *)__p)->__v = ((__v2di)__v)[0];
+#endif
}
_INTRINSATTR