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