From 2f0a7153460acc3f21462236f470ec3471fa2ee1 Mon Sep 17 00:00:00 2001
From: Boris Ranto <branto@redhat.com>
Date: Mon, 31 Jul 2017 19:50:23 +0200
Subject: [PATCH] cmake: Support ppc64
The ppc64 support requires a couple of changes:
- adding the ppc64 support to cmake
- changing optimized crc32 code to compile on ppc64le only
- moving ifdef condition before crc32_align to avoid defined but not
used warning
Signed-off-by: Boris Ranto <branto@redhat.com>
---
cmake/modules/SIMDExt.cmake | 15 ++++++++++++++-
src/CMakeLists.txt | 4 +++-
src/arch/ppc.c | 8 ++++----
src/common/crc32c_ppc.c | 6 +++---
4 files changed, 24 insertions(+), 9 deletions(-)
diff --git a/cmake/modules/SIMDExt.cmake b/cmake/modules/SIMDExt.cmake
index 5330835..c47667d 100644
--- a/cmake/modules/SIMDExt.cmake
+++ b/cmake/modules/SIMDExt.cmake
@@ -109,7 +109,20 @@ elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "i386|i686|amd64|x86_64|AMD64")
endif(CMAKE_SYSTEM_PROCESSOR MATCHES "i686|amd64|x86_64|AMD64")
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "(powerpc|ppc)64le")
set(HAVE_PPC64LE 1)
- message(STATUS " we are ppc64le")
+ message(STATUS " we are ppc64")
+ CHECK_C_COMPILER_FLAG("-maltivec" HAS_ALTIVEC)
+ if(HAS_ALTIVEC)
+ message(STATUS " HAS_ALTIVEC yes")
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -maltivec")
+ set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -maltivec")
+ endif()
+ CHECK_C_COMPILER_FLAG("-mcpu=power8" HAVE_POWER8)
+ if(HAVE_POWER8)
+ message(STATUS " HAVE_POWER8 yes")
+ endif()
+elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "(power|ppc)64")
+ set(HAVE_PPC64 1)
+ message(STATUS " we are ppc64")
CHECK_C_COMPILER_FLAG("-maltivec" HAS_ALTIVEC)
if(HAS_ALTIVEC)
message(STATUS " HAS_ALTIVEC yes")
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 66f0c14..38d1913 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -568,7 +568,9 @@ if(HAVE_INTEL)
endif(HAVE_GOOD_YASM_ELF64)
elseif(HAVE_POWER8)
list(APPEND libcommon_files
- common/crc32c_ppc.c
+ common/crc32c_ppc.c)
+elseif(HAVE_PPC64LE)
+ list(APPEND libcommon_files
common/crc32c_ppc_asm.S
common/crc32c_ppc_fast_zero_asm.S)
endif(HAVE_INTEL)
diff --git a/src/arch/ppc.c b/src/arch/ppc.c
index f21e2fe..11d3a49 100644
--- a/src/arch/ppc.c
+++ b/src/arch/ppc.c
@@ -14,10 +14,10 @@ int ceph_arch_ppc_crc32 = 0;
#include <stdio.h>
-#if __linux__ && __powerpc64__
+#ifdef HAVE_PPC64LE
#include <sys/auxv.h>
#include <asm/cputable.h>
-#endif /* __linux__ && __powerpc64__ */
+#endif /* HAVE_PPC64LE */
#ifndef PPC_FEATURE2_VEC_CRYPTO
#define PPC_FEATURE2_VEC_CRYPTO 0x02000000
@@ -31,9 +31,9 @@ int ceph_arch_ppc_probe(void)
{
ceph_arch_ppc_crc32 = 0;
-#if __linux__ && __powerpc64__
+#ifdef HAVE_PPC64LE
if (getauxval(AT_HWCAP2) & PPC_FEATURE2_VEC_CRYPTO) ceph_arch_ppc_crc32 = 1;
-#endif /* __linux__ && __powerpc64__ */
+#endif /* HAVE_PPC64LE */
return 0;
}
diff --git a/src/common/crc32c_ppc.c b/src/common/crc32c_ppc.c
index 43756e2..52fd1c4 100644
--- a/src/common/crc32c_ppc.c
+++ b/src/common/crc32c_ppc.c
@@ -20,6 +20,7 @@
#define VMX_ALIGN 16
#define VMX_ALIGN_MASK (VMX_ALIGN-1)
+#ifdef HAVE_PPC64LE
#ifdef REFLECT
static unsigned int crc32_align(unsigned int crc, unsigned char const *p,
unsigned long len)
@@ -38,7 +39,6 @@ static unsigned int crc32_align(unsigned int crc, unsigned char const *p,
}
#endif
-#ifdef HAVE_POWER8
static inline unsigned long polynomial_multiply(unsigned int a, unsigned int b) {
vector unsigned int va = {a, 0, 0, 0};
vector unsigned int vb = {b, 0, 0, 0};
@@ -134,7 +134,7 @@ uint32_t ceph_crc32c_ppc(uint32_t crc, unsigned char const *data, unsigned len)
return crc;
}
-#else /* HAVE_POWER8 */
+#else /* HAVE_PPC64LE */
/* This symbol has to exist on non-ppc architectures (and on legacy
* ppc systems using power7 or below) in order to compile properly
@@ -145,4 +145,4 @@ uint32_t ceph_crc32c_ppc(uint32_t crc, unsigned char const *data, unsigned len)
return 0;
}
-#endif /* HAVE_POWER8 */
+#endif /* HAVE_PPC64LE */
--
2.9.4