未验证 提交 bdc5d79e 编写于 作者: A Andrii Kurdiumov 提交者: GitHub

Fix compilation errors if host does not support AVX2 (#50316)

* Fix compilation errors if host does not support AVX2

* Add comments to empty preprocessor branches

* Explicitly ask for architecture support

* Apply -march-native only on GCC

* Make sure if clang on x64 would be used
it actually pass -march=native, otherwise AVX2 would not be enabled.

* Ask test use AVX2 when run on Windows.
上级 aa558fa4
......@@ -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
......
......@@ -8,9 +8,15 @@
#if defined(TARGET_XARCH)
#include <immintrin.h>
#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 = { };
......
......@@ -8,9 +8,15 @@
#if defined(TARGET_XARCH)
#include <immintrin.h>
#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 = { };
......
......@@ -8,17 +8,21 @@
#if defined(TARGET_XARCH)
#include <immintrin.h>
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 = { };
......
......@@ -8,9 +8,15 @@
#if defined(TARGET_XARCH)
#include <immintrin.h>
#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 = { };
......
......@@ -8,17 +8,21 @@
#if defined(TARGET_XARCH)
#include <immintrin.h>
#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 = { };
......
......@@ -8,9 +8,15 @@
#if defined(TARGET_XARCH)
#include <immintrin.h>
#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 = { };
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册