ce426f
From 2d04109858181ed8c7dc3e4ae42923a26c1d3591 Mon Sep 17 00:00:00 2001
ce426f
From: Stefan Liebler <stli@linux.vnet.ibm.com>
ce426f
Date: Thu, 8 Oct 2015 10:47:37 +0200
ce426f
Subject: [PATCH 08/30] S390: configure check for vector instruction support in
ce426f
 assembler.
ce426f
ce426f
upstream-commit-id: 4f0a1cea34c05fb2acc16f1a2d291f53230eb4fb
ce426f
https://www.sourceware.org/ml/libc-alpha/2015-07/msg00153.html
ce426f
ce426f
The S390 specific test checks if the assembler has support for the new z13
ce426f
vector instructions by compiling a vector instruction. The .machine and
ce426f
.machinemode directives are needed to compile the vector instruction without
ce426f
-march=z13 option on 31/64 bit.
ce426f
On success the macro HAVE_S390_VX_ASM_SUPPORT is defined. This macro is used
ce426f
to determine if the optimized functions can be build without compile errors.
ce426f
If the used assembler lacks vector support, then a warning is dumped while
ce426f
configuring and only the common code functions are build.
ce426f
ce426f
The z13 instruction support was introduced in
ce426f
"[Committed] S/390: Add support for IBM z13."
ce426f
(https://sourceware.org/ml/binutils/2015-01/msg00197.html)
ce426f
ce426f
ChangeLog:
ce426f
ce426f
	* config.h.in (HAVE_S390_VX_ASM_SUPPORT): New macro undefine.
ce426f
	* sysdeps/s390/configure.ac: Add test for S390 vector instruction
ce426f
	assembler support.
ce426f
	* sysdeps/s390/configure: Regenerated.
ce426f
---
ce426f
 config.h.in               |  3 +++
ce426f
 sysdeps/s390/configure    | 39 +++++++++++++++++++++++++++++++++++++++
ce426f
 sysdeps/s390/configure.in | 27 +++++++++++++++++++++++++++
ce426f
 3 files changed, 69 insertions(+)
ce426f
ce426f
diff --git a/config.h.in b/config.h.in
ce426f
index 68321d4..f7f2388 100644
ce426f
--- a/config.h.in
ce426f
+++ b/config.h.in
ce426f
@@ -110,6 +110,9 @@
ce426f
 /* Define if assembler supports Intel MPX.  */
ce426f
 #undef  HAVE_MPX_SUPPORT
ce426f
 
ce426f
+/* Define if assembler supports vector instructions on S390.  */
ce426f
+#undef  HAVE_S390_VX_ASM_SUPPORT
ce426f
+
ce426f
 /* Define if gcc supports FMA4.  */
ce426f
 #undef	HAVE_FMA4_SUPPORT
ce426f
 
ce426f
diff --git a/sysdeps/s390/configure b/sysdeps/s390/configure
ce426f
index 669bb9b..cc4c1e0 100644
ce426f
--- a/sysdeps/s390/configure
ce426f
+++ b/sysdeps/s390/configure
ce426f
@@ -3,3 +3,42 @@
ce426f
 
ce426f
 $as_echo "#define PI_STATIC_AND_HIDDEN 1" >>confdefs.h
ce426f
 
ce426f
+
ce426f
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for S390 vector instruction support" >&5
ce426f
+$as_echo_n "checking for S390 vector instruction support... " >&6; }
ce426f
+if ${libc_cv_asm_s390_vx+:} false; then :
ce426f
+  $as_echo_n "(cached) " >&6
ce426f
+else
ce426f
+  cat > conftest.c <<\EOF
ce426f
+void testvecinsn ()
ce426f
+{
ce426f
+    __asm__ (".machine \"z13\" \n\t"
ce426f
+	     ".machinemode \"zarch_nohighgprs\" \n\t"
ce426f
+	     "vistrbs %%v16,%%v17 \n\t"
ce426f
+	     "locghie %%r1,0" : :);
ce426f
+}
ce426f
+EOF
ce426f
+if { ac_try='${CC-cc} --shared conftest.c -o conftest.o &> /dev/null'
ce426f
+  { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
ce426f
+  (eval $ac_try) 2>&5
ce426f
+  ac_status=$?
ce426f
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
ce426f
+  test $ac_status = 0; }; } ;
ce426f
+then
ce426f
+  libc_cv_asm_s390_vx=yes
ce426f
+else
ce426f
+  libc_cv_asm_s390_vx=no
ce426f
+fi
ce426f
+rm -f conftest*
ce426f
+fi
ce426f
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libc_cv_asm_s390_vx" >&5
ce426f
+$as_echo "$libc_cv_asm_s390_vx" >&6; }
ce426f
+
ce426f
+if test "$libc_cv_asm_s390_vx" = yes ;
ce426f
+then
ce426f
+  $as_echo "#define HAVE_S390_VX_ASM_SUPPORT 1" >>confdefs.h
ce426f
+
ce426f
+else
ce426f
+  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Use binutils with vector-support in order to use optimized implementations." >&5
ce426f
+$as_echo "$as_me: WARNING: Use binutils with vector-support in order to use optimized implementations." >&2;}
ce426f
+fi
ce426f
diff --git a/sysdeps/s390/configure.in b/sysdeps/s390/configure.in
ce426f
index b5af4e1..733e356 100644
ce426f
--- a/sysdeps/s390/configure.in
ce426f
+++ b/sysdeps/s390/configure.in
ce426f
@@ -4,3 +4,30 @@ GLIBC_PROVIDES dnl See aclocal.m4 in the top level source directory.
ce426f
 dnl It is always possible to access static and hidden symbols in an
ce426f
 dnl position independent way.
ce426f
 AC_DEFINE(PI_STATIC_AND_HIDDEN)
ce426f
+
ce426f
+AC_CACHE_CHECK(for S390 vector instruction support, libc_cv_asm_s390_vx, [dnl
ce426f
+cat > conftest.c <<\EOF
ce426f
+void testvecinsn ()
ce426f
+{
ce426f
+    __asm__ (".machine \"z13\" \n\t"
ce426f
+	     ".machinemode \"zarch_nohighgprs\" \n\t"
ce426f
+	     "vistrbs %%v16,%%v17 \n\t"
ce426f
+	     "locghie %%r1,0" : :);
ce426f
+}
ce426f
+EOF
ce426f
+dnl
ce426f
+dnl test, if assembler supports S390 vector instructions
ce426f
+if AC_TRY_COMMAND([${CC-cc} --shared conftest.c -o conftest.o &> /dev/null]) ;
ce426f
+then
ce426f
+  libc_cv_asm_s390_vx=yes
ce426f
+else
ce426f
+  libc_cv_asm_s390_vx=no
ce426f
+fi
ce426f
+rm -f conftest* ])
ce426f
+
ce426f
+if test "$libc_cv_asm_s390_vx" = yes ;
ce426f
+then
ce426f
+  AC_DEFINE(HAVE_S390_VX_ASM_SUPPORT)
ce426f
+else
ce426f
+  AC_MSG_WARN([Use binutils with vector-support in order to use optimized implementations.])
ce426f
+fi
ce426f
-- 
ce426f
2.3.0
ce426f