diff --git a/src/tests/Interop/PInvoke/Generics/CMakeLists.txt b/src/tests/Interop/PInvoke/Generics/CMakeLists.txt index ebb09a85e7b04..9d6a3f34adc1b 100644 --- a/src/tests/Interop/PInvoke/Generics/CMakeLists.txt +++ b/src/tests/Interop/PInvoke/Generics/CMakeLists.txt @@ -1,5 +1,5 @@ -project (GenericsNative) -include ("${CLR_INTEROP_TEST_ROOT}/Interop.cmake") +project (GenericsNative) +include ("${CLR_INTEROP_TEST_ROOT}/Interop.cmake") if(CLR_CMAKE_TARGET_ARCH_I386) add_definitions(-DTARGET_X86) add_definitions(-DTARGET_XARCH) @@ -17,6 +17,16 @@ if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") # The ABI for passing parameters with 32-byte alignment has changed in GCC 4.6 add_compile_options(-Wno-psabi) endif() +if (MSVC) + # The MSVC require explicitly ask for AVX2 so define would be present. + add_compile_options(/arch:AVX2) +else() + if (NOT CLR_CMAKE_TARGET_ARCH_ARM64 AND NOT CLR_CMAKE_TARGET_ARCH_ARM) + # We need -march=native so we can detect if AVX2 is present. + # ARM does not like that option too and it make no sense to have this detection there. + add_compile_options(-march=native) + endif() +endif() set(SOURCES GenericsNative.IUnknown.cpp GenericsNative.NullableB.cpp @@ -87,4 +97,4 @@ set(SOURCES GenericsNative.VectorU.cpp ) add_library (GenericsNative SHARED ${SOURCES}) -install (TARGETS GenericsNative DESTINATION bin) +install (TARGETS GenericsNative DESTINATION bin) diff --git a/src/tests/Interop/PInvoke/Generics/GenericsNative.Vector256B.cpp b/src/tests/Interop/PInvoke/Generics/GenericsNative.Vector256B.cpp index 619067ab205d2..895d5d2a40372 100644 --- a/src/tests/Interop/PInvoke/Generics/GenericsNative.Vector256B.cpp +++ b/src/tests/Interop/PInvoke/Generics/GenericsNative.Vector256B.cpp @@ -8,9 +8,15 @@ #if defined(TARGET_XARCH) #include +#elif defined(TARGET_ARMARCH) + // Intentionally empty +#else + #error Unsupported target architecture +#endif +#if defined(__AVX2__) typedef __m256i Vector256B; -#elif defined(TARGET_ARMARCH) +#else typedef struct { bool e00; bool e01; @@ -45,8 +51,6 @@ bool e30; bool e31; } Vector256B; -#else - #error Unsupported target architecture #endif static Vector256B Vector256BValue = { }; diff --git a/src/tests/Interop/PInvoke/Generics/GenericsNative.Vector256C.cpp b/src/tests/Interop/PInvoke/Generics/GenericsNative.Vector256C.cpp index acb15d74e0e5f..e1b55e13dbe56 100644 --- a/src/tests/Interop/PInvoke/Generics/GenericsNative.Vector256C.cpp +++ b/src/tests/Interop/PInvoke/Generics/GenericsNative.Vector256C.cpp @@ -8,9 +8,15 @@ #if defined(TARGET_XARCH) #include +#elif defined(TARGET_ARMARCH) + // Intentionally empty +#else + #error Unsupported target architecture +#endif +#if defined(__AVX2__) typedef __m256i Vector256C; -#elif defined(TARGET_ARMARCH) +#else typedef struct { char16_t e00; char16_t e01; @@ -29,8 +35,6 @@ char16_t e14; char16_t e15; } Vector256C; -#else - #error Unsupported target architecture #endif static Vector256C Vector256CValue = { }; diff --git a/src/tests/Interop/PInvoke/Generics/GenericsNative.Vector256D.cpp b/src/tests/Interop/PInvoke/Generics/GenericsNative.Vector256D.cpp index 4fa3d0c6a0301..769004e10cb60 100644 --- a/src/tests/Interop/PInvoke/Generics/GenericsNative.Vector256D.cpp +++ b/src/tests/Interop/PInvoke/Generics/GenericsNative.Vector256D.cpp @@ -8,17 +8,21 @@ #if defined(TARGET_XARCH) #include - - typedef __m256d Vector256D; #elif defined(TARGET_ARMARCH) + // Intentionally empty +#else + #error Unsupported target architecture +#endif + +#if defined(__AVX2__) + typedef __m256 Vector256D; +#else typedef struct { double e00; double e01; double e02; double e03; } Vector256D; -#else - #error Unsupported target architecture #endif static Vector256D Vector256DValue = { }; diff --git a/src/tests/Interop/PInvoke/Generics/GenericsNative.Vector256F.cpp b/src/tests/Interop/PInvoke/Generics/GenericsNative.Vector256F.cpp index 966e1ab73d623..c261ca25ab7b5 100644 --- a/src/tests/Interop/PInvoke/Generics/GenericsNative.Vector256F.cpp +++ b/src/tests/Interop/PInvoke/Generics/GenericsNative.Vector256F.cpp @@ -8,9 +8,15 @@ #if defined(TARGET_XARCH) #include +#elif defined(TARGET_ARMARCH) + // Intentionally empty +#else + #error Unsupported target architecture +#endif +#if defined(__AVX2__) typedef __m256 Vector256F; -#elif defined(TARGET_ARMARCH) +#else typedef struct { float e00; float e01; @@ -21,8 +27,6 @@ float e06; float e07; } Vector256F; -#else - #error Unsupported target architecture #endif static Vector256F Vector256FValue = { }; diff --git a/src/tests/Interop/PInvoke/Generics/GenericsNative.Vector256L.cpp b/src/tests/Interop/PInvoke/Generics/GenericsNative.Vector256L.cpp index 7df630881a19b..62fc21a6d4eb8 100644 --- a/src/tests/Interop/PInvoke/Generics/GenericsNative.Vector256L.cpp +++ b/src/tests/Interop/PInvoke/Generics/GenericsNative.Vector256L.cpp @@ -8,17 +8,21 @@ #if defined(TARGET_XARCH) #include +#elif defined(TARGET_ARMARCH) + // Intentionally empty +#else + #error Unsupported target architecture +#endif +#if defined(__AVX2__) typedef __m256i Vector256L; -#elif defined(TARGET_ARMARCH) +#else typedef struct { int64_t e00; int64_t e01; int64_t e02; int64_t e03; } Vector256L; -#else - #error Unsupported target architecture #endif static Vector256L Vector256LValue = { }; diff --git a/src/tests/Interop/PInvoke/Generics/GenericsNative.Vector256U.cpp b/src/tests/Interop/PInvoke/Generics/GenericsNative.Vector256U.cpp index 9f4918843cb91..99fe029d3eefa 100644 --- a/src/tests/Interop/PInvoke/Generics/GenericsNative.Vector256U.cpp +++ b/src/tests/Interop/PInvoke/Generics/GenericsNative.Vector256U.cpp @@ -8,9 +8,15 @@ #if defined(TARGET_XARCH) #include +#elif defined(TARGET_ARMARCH) + // Intentionally empty +#else + #error Unsupported target architecture +#endif +#if defined(__AVX2__) typedef __m256i Vector256U; -#elif defined(TARGET_ARMARCH) +#else typedef struct { uint32_t e00; uint32_t e01; @@ -21,8 +27,6 @@ uint32_t e06; uint32_t e07; } Vector256U; -#else - #error Unsupported target architecture #endif static Vector256U Vector256UValue = { };