Fix ARM NEON detection

This commit is contained in:
Carles Fernandez 2020-01-13 23:12:34 +01:00
parent 69e349d832
commit 931d69b76e
No known key found for this signature in database
GPG Key ID: 4C583C52B0C3877D
1 changed files with 7 additions and 7 deletions

View File

@ -151,7 +151,7 @@ set(HAVE_AVX_CVTPI32_PS 0)
if(CPU_IS_x86)
# check to see if the compiler/linker works with xgetb instruction
if(NOT MSVC)
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); }")
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/test_xgetbv.c "#include <volk_gnsssdr/volk_gnsssdr_common.h>\n unsigned long long _xgetbv(unsigned int index) { unsigned int eax, edx; __VOLK_ASM __volatile__(\"xgetbv\" : \"=a\"(eax), \"=d\"(edx) : \"c\"(index)); return ((unsigned long long)edx << 32) | eax; } int main (void) { (void) _xgetbv(0); return (0); }")
else()
# MSVC defines an intrinsic
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/test_xgetbv.c "#include <stdio.h> \n #include <intrin.h> \n int main() { int avxSupported = 0; \n#if (_MSC_FULL_VER >= 160040219) \nint cpuInfo[4]; __cpuid(cpuInfo, 1);\nif ((cpuInfo[2] & (1 << 27) || 0) && (cpuInfo[2] & (1 << 28) || 0)) \n{\nunsigned long long xcrFeatureMask = _xgetbv(_XCR_XFEATURE_ENABLED_MASK);\n avxSupported = (xcrFeatureMask & 0x6) == 6;}\n#endif \n return 1- avxSupported; }")
@ -276,17 +276,17 @@ check_c_source_compiles("#include <arm_neon.h>\nint main(){ uint8_t *dest; uint8
neon_compile_result)
if(neon_compile_result)
check_c_source_compiles("int main(){asm volatile(\"vrev32.8 q0, q0\");}"
check_c_source_compiles("#include <volk_gnsssdr/volk_gnsssdr_common.h>\n int main(){__VOLK_ASM volatile(\"vrev32.8 q0, q0\");}"
have_neonv7_result)
check_c_source_compiles("int main(){asm volatile(\"sub v1.4s,v1.4s,v1.4s\");}"
check_c_source_compiles("#include <volk_gnsssdr/volk_gnsssdr_common.h>\n int main(){__VOLK_ASM volatile(\"sub v1.4s,v1.4s,v1.4s\");}"
have_neonv8_result)
if(have_neonv7_result)
overrule_arch(neonv8 "CPU is armv7")
if(NOT have_neonv7_result)
overrule_arch(neonv7 "Compiler doesn't support neonv7")
endif()
if(have_neonv8_result)
overrule_arch(neonv7 "CPU is armv8")
if(NOT have_neonv8_result)
overrule_arch(neonv8 "Compiler doesn't support neonv8")
endif()
else()
overrule_arch(neon "Compiler doesn't support NEON")