1 1.1 christos # check if we compile for IBM s390x 2 1.1 christos # 3 1.1 christos CHECK_C_SOURCE_COMPILES(" 4 1.1 christos #ifndef __s390x__ 5 1.1 christos #error 6 1.1 christos #endif 7 1.1 christos int main() {return 0;} 8 1.1 christos " HAS_S390X_SUPPORT) 9 1.1 christos 10 1.1 christos # 11 1.1 christos # Check for IBM S390X - VX extensions 12 1.1 christos # 13 1.1 christos if(ZLIB_WITH_CRC32VX AND HAS_S390X_SUPPORT) 14 1.1 christos # preset the compiler specific flags 15 1.1 christos if (CMAKE_C_COMPILER_ID STREQUAL "Clang") 16 1.1 christos set(VGFMAFLAG "-fzvector") 17 1.1 christos else() 18 1.1 christos set(VGFMAFLAG "-mzarch") 19 1.1 christos endif(CMAKE_C_COMPILER_ID STREQUAL "Clang") 20 1.1 christos 21 1.1 christos set(S390X_VX_TEST 22 1.1 christos "#ifndef __s390x__ \n\ 23 1.1 christos #error \n\ 24 1.1 christos #endif \n\ 25 1.1 christos #include <vecintrin.h> \n\ 26 1.1 christos int main(void) { \ 27 1.1 christos unsigned long long a __attribute__((vector_size(16))) = { 0 }; \ 28 1.1 christos unsigned long long b __attribute__((vector_size(16))) = { 0 }; \ 29 1.1 christos unsigned char c __attribute__((vector_size(16))) = { 0 }; \ 30 1.1 christos c = vec_gfmsum_accum_128(a, b, c); \ 31 1.1 christos return c[0]; \ 32 1.1 christos }") 33 1.1 christos 34 1.1 christos # cflags already contains a valid march 35 1.1 christos set(CMAKE_REQUIRED_FLAGS "${VGFMAFLAG}") 36 1.1 christos check_c_source_compiles("${S390X_VX_TEST}" HAS_S390X_VX_SUPPORT) 37 1.1 christos unset(CMAKE_REQUIRED_FLAGS) 38 1.1 christos 39 1.1 christos # or set march for our compile units 40 1.1 christos if(NOT HAS_S390X_VX_SUPPORT) 41 1.1 christos set(CMAKE_REQUIRED_FLAGS "${VGFMAFLAG} -march=z13") 42 1.1 christos check_c_source_compiles("${S390X_VX_TEST}" HAS_Z13_S390X_VX_SUPPORT) 43 1.1 christos unset(CMAKE_REQUIRED_FLAGS ) 44 1.1 christos list(APPEND VGFMAFLAG "-march=z13") 45 1.1 christos endif(NOT HAS_S390X_VX_SUPPORT) 46 1.1 christos 47 1.1 christos # prepare compiling for s390x 48 1.1 christos if(HAS_S390X_VX_SUPPORT OR HAS_Z13_S390X_VX_SUPPORT) 49 1.1 christos if(ZLIB_BUILD_SHARED) 50 1.1 christos target_sources(zlib 51 1.1 christos PRIVATE 52 1.1 christos crc32_vx.c 53 1.1 christos crc32_vx_hooks.h) 54 1.1 christos target_compile_definitions(zlib PUBLIC -DHAVE_S390X_VX=1) 55 1.1 christos endif(ZLIB_BUILD_SHARED) 56 1.1 christos if(ZLIB_BUILD_STATIC) 57 1.1 christos target_sources(zlibstatic 58 1.1 christos PRIVATE 59 1.1 christos crc32_vx.c 60 1.1 christos crc32_vx_hooks.h) 61 1.1 christos target_compile_definitions(zlibstatic PUBLIC -DHAVE_S390X_VX=1) 62 1.1 christos endif(ZLIB_BUILD_STATIC) 63 1.1 christos set_source_files_properties( 64 1.1 christos crc32_vx.c 65 1.1 christos PROPERTIES COMPILE_OPTIONS "${VGFMAFLAG}") 66 1.1 christos endif(HAS_S390X_VX_SUPPORT OR HAS_Z13_S390X_VX_SUPPORT) 67 1.1 christos endif(ZLIB_WITH_CRC32VX AND HAS_S390X_SUPPORT) 68