From fd2d2b07cba6ecdb76d272fddd9f738ae68c0dda Mon Sep 17 00:00:00 2001 From: Sinan Kaya Date: Sun, 24 Mar 2019 23:45:43 +0000 Subject: [PATCH] Unify clang with GNUC Enable SSE for GCC Commit migrated from https://github.com/dotnet/coreclr/commit/446393da44258d60aaa9c660602fb826c79fe6b3 --- .../src/classlibnative/bcltype/arraynative.inl | 12 ++++++------ src/coreclr/src/pal/inc/pal.h | 10 +++++++++- src/coreclr/src/pal/inc/rt/xmmintrin.h | 6 +++--- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/src/coreclr/src/classlibnative/bcltype/arraynative.inl b/src/coreclr/src/classlibnative/bcltype/arraynative.inl index 492d4fb3d8d..5928f9d6e0f 100644 --- a/src/coreclr/src/classlibnative/bcltype/arraynative.inl +++ b/src/coreclr/src/classlibnative/bcltype/arraynative.inl @@ -58,7 +58,7 @@ FORCEINLINE void InlinedForwardGCSafeCopyHelper(void *dest, const void *src, siz ++dptr; } -#if defined(_AMD64_) && (defined(_MSC_VER) || defined(__clang__)) +#if defined(_AMD64_) && (defined(_MSC_VER) || defined(__GNUC__)) if ((len & (2 * sizeof(SIZE_T))) != 0) { __m128 v = _mm_loadu_ps((float *)sptr); @@ -104,7 +104,7 @@ FORCEINLINE void InlinedForwardGCSafeCopyHelper(void *dest, const void *src, siz { return; } -#else // !(defined(_AMD64_) && (defined(_MSC_VER) || defined(__clang__))) +#else // !(defined(_AMD64_) && (defined(_MSC_VER) || defined(__GNUC__))) if ((len & (2 * sizeof(SIZE_T))) != 0) { // Read two values and write two values to hint the use of wide loads and stores @@ -144,7 +144,7 @@ FORCEINLINE void InlinedForwardGCSafeCopyHelper(void *dest, const void *src, siz sptr += 4; dptr += 4; } -#endif // defined(_AMD64_) && (defined(_MSC_VER) || defined(__clang__)) +#endif // defined(_AMD64_) && (defined(_MSC_VER) || defined(__GNUC__)) } } @@ -193,7 +193,7 @@ FORCEINLINE void InlinedBackwardGCSafeCopyHelper(void *dest, const void *src, si } } -#if defined(_AMD64_) && (defined(_MSC_VER) || defined(__clang__)) +#if defined(_AMD64_) && (defined(_MSC_VER) || defined(__GNUC__)) if ((len & (2 * sizeof(SIZE_T))) != 0) { sptr -= 2; @@ -242,7 +242,7 @@ FORCEINLINE void InlinedBackwardGCSafeCopyHelper(void *dest, const void *src, si { return; } -#else // !(defined(_AMD64_) && (defined(_MSC_VER) || defined(__clang__))) +#else // !(defined(_AMD64_) && (defined(_MSC_VER) || defined(__GNUC__))) if ((len & (2 * sizeof(SIZE_T))) != 0) { sptr -= 2; @@ -281,7 +281,7 @@ FORCEINLINE void InlinedBackwardGCSafeCopyHelper(void *dest, const void *src, si len -= 4 * sizeof(SIZE_T); } while (len != 0); return; -#endif // defined(_AMD64_) && (defined(_MSC_VER) || defined(__clang__)) +#endif // defined(_AMD64_) && (defined(_MSC_VER) || defined(__GNUC__)) } } diff --git a/src/coreclr/src/pal/inc/pal.h b/src/coreclr/src/pal/inc/pal.h index 38ef778d53a..66d83f1c421 100644 --- a/src/coreclr/src/pal/inc/pal.h +++ b/src/coreclr/src/pal/inc/pal.h @@ -192,11 +192,19 @@ typedef PVOID NATIVE_LIBRARY_HANDLE; #ifndef NOOPT_ATTRIBUTE #if defined(__llvm__) #define NOOPT_ATTRIBUTE optnone -#else +#elif defined(__GNUC__) #define NOOPT_ATTRIBUTE optimize("O0") #endif #endif +#ifndef NODEBUG_ATTRIBUTE +#if defined(__llvm__) +#define NODEBUG_ATTRIBUTE __nodebug__ +#elif defined(__GNUC__) +#define NODEBUG_ATTRIBUTE __artificial__ +#endif +#endif + #ifndef PAL_STDCPP_COMPAT #if __GNUC__ diff --git a/src/coreclr/src/pal/inc/rt/xmmintrin.h b/src/coreclr/src/pal/inc/rt/xmmintrin.h index 1a670bd75a0..33bc8b4b927 100644 --- a/src/coreclr/src/pal/inc/rt/xmmintrin.h +++ b/src/coreclr/src/pal/inc/rt/xmmintrin.h @@ -27,12 +27,12 @@ *===-----------------------------------------------------------------------=== */ -#ifdef __clang__ +#ifdef __GNUC__ typedef float __m128 __attribute__((__vector_size__(16))); /* Define the default attributes for the functions in this file. */ -#define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__)) +#define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, NODEBUG_ATTRIBUTE)) /// \brief Loads a 128-bit floating-point vector of [4 x float] from an aligned /// memory location. @@ -113,4 +113,4 @@ _mm_store_ps(float *__p, __m128 __a) *(__m128*)__p = __a; } -#endif // __clang__ +#endif // __GNUC__ -- GitLab