summaryrefslogtreecommitdiffstats
path: root/cmake/modules/SIMDExt.cmake
diff options
context:
space:
mode:
authorJosh Durgin <jdurgin@redhat.com>2018-10-05 01:10:18 +0200
committerGitHub <noreply@github.com>2018-10-05 01:10:18 +0200
commit8f826e146cb4f2d0881d5c41a49e2b733659898c (patch)
treeeaacc04f65fb3e692d5de0e7b824467706dde7ac /cmake/modules/SIMDExt.cmake
parentMerge pull request #24322 from votdev/improve_error_interceptor (diff)
parentcmake: detect armv8 crc and crypto feature using CHECK_C_COMPILER_FLAG (diff)
downloadceph-8f826e146cb4f2d0881d5c41a49e2b733659898c.tar.xz
ceph-8f826e146cb4f2d0881d5c41a49e2b733659898c.zip
Merge pull request #24168 from tchaikov/wip-17516
cmake: detect armv8 crc and crypto feature using CHECK_C_COMPILER_FLAG Reviewed-by: Josh Durgin <jdurgin@redhat.com>
Diffstat (limited to 'cmake/modules/SIMDExt.cmake')
-rw-r--r--cmake/modules/SIMDExt.cmake54
1 files changed, 13 insertions, 41 deletions
diff --git a/cmake/modules/SIMDExt.cmake b/cmake/modules/SIMDExt.cmake
index 4c019259ea9..2c36ac3736d 100644
--- a/cmake/modules/SIMDExt.cmake
+++ b/cmake/modules/SIMDExt.cmake
@@ -16,49 +16,21 @@
if(CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64|AARCH64")
set(HAVE_ARM 1)
- set(save_quiet ${CMAKE_REQUIRED_QUIET})
- set(CMAKE_REQUIRED_QUIET true)
- include(CheckCXXSourceCompiles)
-
- check_cxx_source_compiles("
- #define CRC32CX(crc, value) __asm__(\"crc32cx %w[c], %w[c], %x[v]\":[c]\"+r\"(crc):[v]\"r\"(value))
- asm(\".arch_extension crc\");
- unsigned int foo(unsigned int ret) {
- CRC32CX(ret, 0);
- return ret;
- }
- int main() { foo(0); }" HAVE_ARMV8_CRC)
- check_cxx_source_compiles("
- asm(\".arch_extension crypto\");
- unsigned int foo(unsigned int ret) {
- __asm__(\"pmull v2.1q, v2.1d, v1.1d\");
- return ret;
- }
- int main() { foo(0); }" HAVE_ARMV8_CRYPTO)
-
- set(CMAKE_REQUIRED_QUIET ${save_quiet})
- if(HAVE_ARMV8_CRC)
- message(STATUS " aarch64 crc extensions supported")
- endif()
-
- if(HAVE_ARMV8_CRYPTO)
- message(STATUS " aarch64 crypto extensions supported")
- endif()
- CHECK_C_COMPILER_FLAG(-march=armv8-a+crc+crypto HAVE_ARMV8_CRC_CRYPTO_MARCH)
-
- # don't believe only the -march support; gcc 4.8.5 on RHEL/CentOS says
- # it supports +crc but hasn't got the intrinsics or arm_acle.h. Test for
- # the actual presence of one of the intrinsic functions.
- if(HAVE_ARMV8_CRC_CRYPTO_MARCH)
- check_cxx_source_compiles("
- #include <inttypes.h>
- int main() { uint32_t a; uint8_t b; __builtin_aarch64_crc32b(a, b); }
- " HAVE_ARMV8_CRC_CRYPTO_INTRINSICS)
- endif()
+ include(CheckCCompilerFlag)
+ check_c_compiler_flag(-march=armv8-a+crc+crypto HAVE_ARMV8_CRC_CRYPTO_INTRINSICS)
if(HAVE_ARMV8_CRC_CRYPTO_INTRINSICS)
- message(STATUS " aarch64 crc+crypto intrinsics supported")
- set(ARMV8_CRC_COMPILE_FLAGS "${ARMV8_CRC_COMPILE_FLAGS} -march=armv8-a+crc+crypto")
+ set(ARMV8_CRC_COMPILE_FLAGS "-march=armv8-a+crc+crypto")
+ set(HAVE_ARMV8_CRC TRUE)
+ set(HAVE_ARMV8_CRYPTO TRUE)
+ else()
+ check_c_compiler_flag(-march=armv8-a+crc HAVE_ARMV8_CRC)
+ check_c_compiler_flag(-march=armv8-a+crypto HAVE_ARMV8_CRYPTO)
+ if(HAVE_ARMV8_CRC)
+ set(ARMV8_CRC_COMPILE_FLAGS "-march=armv8-a+crc")
+ elseif(HAVE_ARMV8_CRYPTO)
+ set(ARMV8_CRC_COMPILE_FLAGS "-march=armv8-a+crypto")
+ endif()
endif()
CHECK_C_COMPILER_FLAG(-march=armv8-a+simd HAVE_ARMV8_SIMD)