From c02b5e22a38dba429b1f058b305b6ddfdd7246b0 Mon Sep 17 00:00:00 2001 From: Stefan Reinauer Date: Sun, 25 Jun 2017 03:39:18 +0200 Subject: vendorcode/amd: Make compiler intrinsics clang friendly MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: Ibff31a9960a23f03facbb09e76d6a5d6fbfb5e94 Signed-off-by: Stefan Reinauer Reviewed-on: https://review.coreboot.org/20381 Tested-by: build bot (Jenkins) Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Patrick Georgi --- src/vendorcode/amd/include/gcc-intrin.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/vendorcode/amd') diff --git a/src/vendorcode/amd/include/gcc-intrin.h b/src/vendorcode/amd/include/gcc-intrin.h index 5d77c4de4d..8b31530a8a 100644 --- a/src/vendorcode/amd/include/gcc-intrin.h +++ b/src/vendorcode/amd/include/gcc-intrin.h @@ -467,6 +467,7 @@ static __inline__ __attribute__((always_inline)) void __writemsr (UINT32 msr, UI ); } +#if !defined(__clang__) static __inline__ __attribute__((always_inline)) UINT64 __rdtsc(void) { UINT64 retval; @@ -475,6 +476,7 @@ static __inline__ __attribute__((always_inline)) UINT64 __rdtsc(void) : "=A" (retval)); return retval; } +#endif static __inline__ __attribute__((always_inline)) void __cpuid(int CPUInfo[], const int InfoType) { @@ -585,7 +587,11 @@ typedef long long __m128i __attribute__ ((__vector_size__ (16), __may_alias__)); static __inline__ __attribute__((always_inline)) void _mm_stream_si128_fs2 (void *__A, __m128i __B) { __asm__(".byte 0x64"); // fs prefix +#if defined(__clang__) + __builtin_nontemporal_store((__v2di)__B, (__v2di *)__A); +#else __builtin_ia32_movntdq ((__v2di *)__A, (__v2di)__B); +#endif } static __inline__ __attribute__((always_inline)) void _mm_stream_si128_fs (void *__A, void *__B) @@ -601,15 +607,23 @@ static __inline__ __attribute__((always_inline)) void _mm_clflush_fs (void *__A) __builtin_ia32_clflush (__A); } +#if !defined(__clang__) static __inline __attribute__(( __always_inline__)) void _mm_mfence (void) { __builtin_ia32_mfence (); } +#else +void _mm_mfence(void); +#endif +#if !defined(__clang__) static __inline __attribute__(( __always_inline__)) void _mm_sfence (void) { __builtin_ia32_sfence (); } +#else +void _mm_sfence(void); +#endif #endif /* __SSE3__ */ #endif /* defined (__GNUC__) */ -- cgit v1.2.3