bca718
From b13a91507798183556d7e1891fe3d4cd3a947aa6 Mon Sep 17 00:00:00 2001
bca718
From: Stefan Liebler <stli@linux.vnet.ibm.com>
bca718
Date: Thu, 8 Oct 2015 10:48:13 +0200
bca718
Subject: [PATCH 09/30] S390: Ifunc resolver macro for vector instructions.
bca718
bca718
upstream-commit-id: fd484e057dd4d2813182df08584a4c48d6f1dd7a
bca718
https://www.sourceware.org/ml/libc-alpha/2015-07/msg00076.html
bca718
bca718
This patch introduces a s390 specific ifunc resolver macro for 32/64bit,
bca718
which chooses <func>_vx with vector instructions if HWCAP_S390_VX flag
bca718
in hwcaps is set or <func>_c if not.
bca718
bca718
ChangeLog:
bca718
bca718
	* sysdeps/s390/multiarch/ifunc-resolve.h (s390_vx_libc_ifunc,
bca718
	s390_vx_libc_ifunc2): New macro function.
bca718
---
bca718
 sysdeps/s390/multiarch/ifunc-resolve.h | 19 +++++++++++++++++++
bca718
 1 file changed, 19 insertions(+)
bca718
bca718
diff --git a/sysdeps/s390/multiarch/ifunc-resolve.h b/sysdeps/s390/multiarch/ifunc-resolve.h
bca718
index 491df68..e9fd90e 100644
bca718
--- a/sysdeps/s390/multiarch/ifunc-resolve.h
bca718
+++ b/sysdeps/s390/multiarch/ifunc-resolve.h
bca718
@@ -73,3 +73,22 @@
bca718
     else								\
bca718
       return &__##FUNC##_default;					\
bca718
   }
bca718
+
bca718
+#define s390_vx_libc_ifunc(FUNC)		\
bca718
+  s390_vx_libc_ifunc2(FUNC, FUNC)
bca718
+
bca718
+#define s390_vx_libc_ifunc2(RESOLVERFUNC, FUNC)				\
bca718
+  /* Make the declarations of the optimized functions hidden in order
bca718
+     to prevent GOT slots being generated for them.  */			\
bca718
+  extern __typeof (FUNC) RESOLVERFUNC##_vx attribute_hidden;		\
bca718
+  extern __typeof (FUNC) RESOLVERFUNC##_c attribute_hidden;		\
bca718
+  extern void *__resolve_##RESOLVERFUNC (unsigned long int) __asm__ (#FUNC); \
bca718
+									\
bca718
+  void *__resolve_##RESOLVERFUNC (unsigned long int dl_hwcap)		\
bca718
+  {									\
bca718
+    if (dl_hwcap & HWCAP_S390_VX)					\
bca718
+      return &RESOLVERFUNC##_vx;					\
bca718
+    else								\
bca718
+      return &RESOLVERFUNC##_c;						\
bca718
+  }									\
bca718
+ __asm__ (".type " #FUNC ", %gnu_indirect_function");
bca718
-- 
bca718
2.3.0
bca718