summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cipher/chacha20-ppc.c5
-rw-r--r--cipher/rijndael-ppc.c4
-rw-r--r--cipher/rijndael-ppc9le.c4
-rw-r--r--cipher/sha256-ppc.c5
-rw-r--r--cipher/sha512-ppc.c13
-rw-r--r--configure.ac22
6 files changed, 41 insertions, 12 deletions
diff --git a/cipher/chacha20-ppc.c b/cipher/chacha20-ppc.c
index 3fe7bc8c..243c12ff 100644
--- a/cipher/chacha20-ppc.c
+++ b/cipher/chacha20-ppc.c
@@ -657,7 +657,10 @@ chacha20_poly1305_ppc_blocks4(u32 *state, byte *dst, const byte *src,
# define FUNC_ATTR_OPT_O2
#endif
-#ifdef HAVE_GCC_ATTRIBUTE_PPC_TARGET
+#if defined(__clang__) && defined(HAVE_CLANG_ATTRIBUTE_PPC_TARGET)
+# define FUNC_ATTR_TARGET_P8 __attribute__((target("arch=pwr8")))
+# define FUNC_ATTR_TARGET_P9 __attribute__((target("arch=pwr9")))
+#elif defined(HAVE_GCC_ATTRIBUTE_PPC_TARGET)
# define FUNC_ATTR_TARGET_P8 __attribute__((target("cpu=power8")))
# define FUNC_ATTR_TARGET_P9 __attribute__((target("cpu=power9")))
#else
diff --git a/cipher/rijndael-ppc.c b/cipher/rijndael-ppc.c
index f376e0f1..7530209d 100644
--- a/cipher/rijndael-ppc.c
+++ b/cipher/rijndael-ppc.c
@@ -40,7 +40,9 @@
# define FUNC_ATTR_OPT
#endif
-#ifdef HAVE_GCC_ATTRIBUTE_PPC_TARGET
+#if defined(__clang__) && defined(HAVE_CLANG_ATTRIBUTE_PPC_TARGET)
+# define PPC_OPT_ATTR __attribute__((target("arch=pwr8"))) FUNC_ATTR_OPT
+#elif defined(HAVE_GCC_ATTRIBUTE_PPC_TARGET)
# define PPC_OPT_ATTR __attribute__((target("cpu=power8"))) FUNC_ATTR_OPT
#else
# define PPC_OPT_ATTR FUNC_ATTR_OPT
diff --git a/cipher/rijndael-ppc9le.c b/cipher/rijndael-ppc9le.c
index e462befc..6a44bcf3 100644
--- a/cipher/rijndael-ppc9le.c
+++ b/cipher/rijndael-ppc9le.c
@@ -40,7 +40,9 @@
# define FUNC_ATTR_OPT
#endif
-#ifdef HAVE_GCC_ATTRIBUTE_PPC_TARGET
+#if defined(__clang__) && defined(HAVE_CLANG_ATTRIBUTE_PPC_TARGET)
+# define PPC_OPT_ATTR __attribute__((target("arch=pwr9"))) FUNC_ATTR_OPT
+#elif defined(HAVE_GCC_ATTRIBUTE_PPC_TARGET)
# define PPC_OPT_ATTR __attribute__((target("cpu=power9"))) FUNC_ATTR_OPT
#else
# define PPC_OPT_ATTR FUNC_ATTR_OPT
diff --git a/cipher/sha256-ppc.c b/cipher/sha256-ppc.c
index 7b17b943..fd69380f 100644
--- a/cipher/sha256-ppc.c
+++ b/cipher/sha256-ppc.c
@@ -48,7 +48,10 @@ typedef vector unsigned long long vector2x_u64;
# define FUNC_ATTR_OPT_O2
#endif
-#ifdef HAVE_GCC_ATTRIBUTE_PPC_TARGET
+#if defined(__clang__) && defined(HAVE_CLANG_ATTRIBUTE_PPC_TARGET)
+# define FUNC_ATTR_TARGET_P8 __attribute__((target("arch=pwr8")))
+# define FUNC_ATTR_TARGET_P9 __attribute__((target("arch=pwr9")))
+#elif defined(HAVE_GCC_ATTRIBUTE_PPC_TARGET)
# define FUNC_ATTR_TARGET_P8 __attribute__((target("cpu=power8")))
# define FUNC_ATTR_TARGET_P9 __attribute__((target("cpu=power9")))
#else
diff --git a/cipher/sha512-ppc.c b/cipher/sha512-ppc.c
index b03aa6aa..6e69ddb9 100644
--- a/cipher/sha512-ppc.c
+++ b/cipher/sha512-ppc.c
@@ -47,7 +47,11 @@ typedef vector unsigned long long vector2x_u64;
# define FUNC_ATTR_OPT_O2
#endif
-#ifdef HAVE_GCC_ATTRIBUTE_PPC_TARGET
+
+#if defined(__clang__) && defined(HAVE_CLANG_ATTRIBUTE_PPC_TARGET)
+# define FUNC_ATTR_TARGET_P8 __attribute__((target("arch=pwr8")))
+# define FUNC_ATTR_TARGET_P9 __attribute__((target("arch=pwr9")))
+#elif defined(HAVE_GCC_ATTRIBUTE_PPC_TARGET)
# define FUNC_ATTR_TARGET_P8 __attribute__((target("cpu=power8")))
# define FUNC_ATTR_TARGET_P9 __attribute__((target("cpu=power9")))
#else
@@ -101,13 +105,6 @@ static const vector2x_u64 K[80] =
};
-static ASM_FUNC_ATTR_INLINE u64
-ror64 (u64 v, u64 shift)
-{
- return (v >> (shift & 63)) ^ (v << ((64 - shift) & 63));
-}
-
-
static ASM_FUNC_ATTR_INLINE vector2x_u64
vec_rol_elems(vector2x_u64 v, unsigned int idx)
{
diff --git a/configure.ac b/configure.ac
index 63f705ea..b9ac99bb 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2292,6 +2292,28 @@ fi
#
+# Check whether compiler supports clang PowerPC target attributes
+#
+AC_CACHE_CHECK([whether compiler supports clang PowerPC target attributes],
+ [gcry_cv_clang_attribute_ppc_target],
+ [if test "$mpi_cpu_arch" != "ppc" ; then
+ gcry_cv_clang_attribute_ppc_target="n/a"
+ else
+ gcry_cv_clang_attribute_ppc_target=no
+ AC_LINK_IFELSE([AC_LANG_PROGRAM(
+ [[void __attribute__((target("arch=pwr8"))) testfn8(void) {}
+ void __attribute__((target("arch=pwr9"))) testfn9(void)
+ { testfn8(); }
+ ]], [ testfn9(); ])],
+ [gcry_cv_clang_attribute_ppc_target=yes])
+ fi])
+if test "$gcry_cv_clang_attribute_ppc_target" = "yes" ; then
+ AC_DEFINE(HAVE_CLANG_ATTRIBUTE_PPC_TARGET,1,
+ [Defined if compiler supports clang PowerPC target attributes])
+fi
+
+
+#
# Check whether GCC inline assembler supports zSeries instructions
#
AC_CACHE_CHECK([whether GCC inline assembler supports zSeries instructions],