diff options
author | Michael Dickens <michael.dickens@ettus.com> | 2013-11-26 12:54:17 -0500 |
---|---|---|
committer | Tom Rondeau <tom@trondeau.com> | 2013-11-26 12:54:17 -0500 |
commit | 6bdec053259dfa1004b9403e039358a4046d309d (patch) | |
tree | 939c307f92a1d0e965bbade6f30cbfbd39062686 | |
parent | a04bb11b52ed1bc122af22b65fbdebf3afb6eb55 (diff) |
cmake: fixes for Apple (specifically; clang generically) to handle some missing AVX instructions.
-rw-r--r-- | volk/lib/CMakeLists.txt | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/volk/lib/CMakeLists.txt b/volk/lib/CMakeLists.txt index 2e5723cc06..eda3a1026b 100644 --- a/volk/lib/CMakeLists.txt +++ b/volk/lib/CMakeLists.txt @@ -122,6 +122,7 @@ endmacro(OVERRULE_ARCH) # the xgetbv instruction, or {if not cross-compiling and the xgetbv # executable does not function correctly}. ######################################################################## +set(HAVE_XGETBV 0) if(CPU_IS_x86) # check to see if the compiler/linker works with xgetb instruction file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/test_xgetbv.c "unsigned long long _xgetbv(unsigned int index) { unsigned int eax, edx; __asm__ __volatile__(\"xgetbv\" : \"=a\"(eax), \"=d\"(edx) : \"c\"(index)); return ((unsigned long long)edx << 32) | eax; } int main (void) { (void) _xgetbv(0); return (0); }") @@ -139,17 +140,41 @@ if(CPU_IS_x86) if(NOT ${avx_exe_result} EQUAL 0) OVERRULE_ARCH(avx "CPU missing xgetbv.") else() - add_definitions(-DHAVE_XGETBV) + set(HAVE_XGETBV 1) endif() else() # cross compiling and compiler/linker seems to work; assume working - add_definitions(-DHAVE_XGETBV) + set(HAVE_XGETBV 1) endif() file(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/test_xgetbv ${CMAKE_CURRENT_BINARY_DIR}/test_xgetbv.c) endif() ######################################################################## +# eliminate AVX if cvtpi32_ps intrinsic fails on Apple +######################################################################## + +if(${HAVE_XGETBV} AND APPLE) + # check to see if the compiler/linker works with cvtpi32_ps instrinsic + file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/test_cvtpi32_ps.c "#include <immintrin.h>\nint main (void) {__m128 __a; __m64 __b; __m128 foo = _mm_cvtpi32_ps(__a, __b); return (0); }") + execute_process(COMMAND ${CMAKE_C_COMPILER} -mavx -o + ${CMAKE_CURRENT_BINARY_DIR}/test_cvtpi32_ps + ${CMAKE_CURRENT_BINARY_DIR}/test_cvtpi32_ps.c + OUTPUT_QUIET ERROR_QUIET + RESULT_VARIABLE avx_compile_result) + if(NOT ${avx_compile_result} EQUAL 0) + OVERRULE_ARCH(avx "Compiler missing cvtpi32_ps instrinsic") + set(HAVE_XGETBV 0) + endif() + file(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/test_cvtpi32_ps + ${CMAKE_CURRENT_BINARY_DIR}/test_cvtpi32_ps.c) +endif() + +if(${HAVE_XGETBV}) + add_definitions(-DHAVE_XGETBV) +endif() + +######################################################################## # implement overruling in the ORC case, # since ORC always passes flag detection ######################################################################## |