From 6a0b2ed0ca2b7628771ee450567c2c62c575db36 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Mon, 18 Mar 2019 20:05:15 -0700 Subject: Check compile-time support for SSE intrinsics --- CMakeLists.txt | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) (limited to 'CMakeLists.txt') diff --git a/CMakeLists.txt b/CMakeLists.txt index 67369d78..9f0dc8ed 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -386,6 +386,13 @@ IF(HAVE_MFPU_NEON_SWITCH) SET(FPU_NEON_SWITCH "-mfpu=neon") ENDIF() +CHECK_INCLUDE_FILE(xmmintrin.h HAVE_XMMINTRIN_H "${SSE2_SWITCH}") +CHECK_INCLUDE_FILE(emmintrin.h HAVE_EMMINTRIN_H "${SSE2_SWITCH}") +CHECK_INCLUDE_FILE(pmmintrin.h HAVE_PMMINTRIN_H "${SSE3_SWITCH}") +CHECK_INCLUDE_FILE(smmintrin.h HAVE_SMMINTRIN_H "${SSE4_1_SWITCH}") +CHECK_INCLUDE_FILE(arm_neon.h HAVE_ARM_NEON_H "${FPU_NEON_SWITCH}") + +SET(SSE_FLAGS ) SET(FPMATH_SET "0") IF(CMAKE_SIZEOF_VOID_P MATCHES "4") IF(SSE2_SWITCH OR MSVC) @@ -396,19 +403,33 @@ IF(CMAKE_SIZEOF_VOID_P MATCHES "4") IF(SSE2_SWITCH) CHECK_C_COMPILER_FLAG("${SSE2_SWITCH} -mfpmath=sse" HAVE_MFPMATH_SSE_2) IF(HAVE_MFPMATH_SSE_2) - SET(C_FLAGS ${C_FLAGS} ${SSE2_SWITCH} -mfpmath=sse) + SET(SSE_FLAGS ${SSE_FLAGS} ${SSE2_SWITCH} -mfpmath=sse) + SET(C_FLAGS ${C_FLAGS} ${SSE_FLAGS}) SET(FPMATH_SET 2) ENDIF() ELSEIF(MSVC) CHECK_C_COMPILER_FLAG("/arch:SSE2" HAVE_ARCH_SSE2) IF(HAVE_ARCH_SSE2) - SET(C_FLAGS ${C_FLAGS} "/arch:SSE2") + SET(SSE_FLAGS ${SSE_FLAGS} "/arch:SSE2") + SET(C_FLAGS ${C_FLAGS} ${SSE_FLAGS}) SET(FPMATH_SET 2) ENDIF() ENDIF() ENDIF() ENDIF() +IF(HAVE_EMMINTRIN_H) + SET(OLD_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS}) + FOREACH(flag_var ${SSE_FLAGS}) + SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} ${flag_var}") + ENDFOREACH() + + CHECK_C_SOURCE_COMPILES("#include + int main() {_mm_pause(); return 0;}" HAVE_SSE_INTRINSICS) + + SET(CMAKE_REQUIRED_FLAGS ${OLD_REQUIRED_FLAGS}) +ENDIF() + CHECK_C_SOURCE_COMPILES("int foo(const char *str, ...) __attribute__((format(printf, 1, 2))); int main() {return 0;}" HAVE_GCC_FORMAT) @@ -723,12 +744,6 @@ SET(HAVE_SSE3 0) SET(HAVE_SSE4_1 0) SET(HAVE_NEON 0) -CHECK_INCLUDE_FILE(xmmintrin.h HAVE_XMMINTRIN_H "${SSE2_SWITCH}") -CHECK_INCLUDE_FILE(emmintrin.h HAVE_EMMINTRIN_H "${SSE2_SWITCH}") -CHECK_INCLUDE_FILE(pmmintrin.h HAVE_PMMINTRIN_H "${SSE3_SWITCH}") -CHECK_INCLUDE_FILE(smmintrin.h HAVE_SMMINTRIN_H "${SSE4_1_SWITCH}") -CHECK_INCLUDE_FILE(arm_neon.h HAVE_ARM_NEON_H "${FPU_NEON_SWITCH}") - # Check for SSE+SSE2 support OPTION(ALSOFT_REQUIRE_SSE "Require SSE support" OFF) OPTION(ALSOFT_REQUIRE_SSE2 "Require SSE2 support" OFF) -- cgit v1.2.3