8ae002
From 29f8926b153d59ba18f67ce5445dce66bacc0cbf Mon Sep 17 00:00:00 2001
8ae002
From: Stefan Liebler <stli@linux.vnet.ibm.com>
8ae002
Date: Mon, 7 Nov 2016 15:25:04 +0100
8ae002
Subject: [PATCH 02/17] S390: Configure check for vector support in gcc.
8ae002
8ae002
Upstream commit 9b7f05599a92dead97d6683bc838a57bc63ac52b
8ae002
8ae002
The S390 specific test checks if the gcc has support for vector registers
8ae002
by compiling an inline assembly which clobbers vector registers.
8ae002
On success the macro HAVE_S390_VX_GCC_SUPPORT is defined.
8ae002
This macro can be used to determine if e.g. clobbering vector registers
8ae002
is allowed or not.
8ae002
8ae002
ChangeLog:
8ae002
8ae002
	* config.h.in (HAVE_S390_VX_GCC_SUPPORT): New macro undefine.
8ae002
	* sysdeps/s390/configure.in: Add test for S390 vector register
8ae002
	support in gcc.
8ae002
	* sysdeps/s390/configure: Regenerated.
8ae002
---
8ae002
 config.h.in               |  4 ++++
8ae002
 sysdeps/s390/configure    | 33 +++++++++++++++++++++++++++++++++
8ae002
 sysdeps/s390/configure.in | 22 ++++++++++++++++++++++
8ae002
 3 files changed, 59 insertions(+)
8ae002
8ae002
diff --git a/config.h.in b/config.h.in
8ae002
index f7f2388..62e04c7 100644
8ae002
--- a/config.h.in
8ae002
+++ b/config.h.in
8ae002
@@ -113,6 +113,10 @@
8ae002
 /* Define if assembler supports vector instructions on S390.  */
8ae002
 #undef  HAVE_S390_VX_ASM_SUPPORT
8ae002
 
8ae002
+/* Define if gcc supports vector registers as clobbers in inline assembly
8ae002
+   on S390.  */
8ae002
+#undef  HAVE_S390_VX_GCC_SUPPORT
8ae002
+
8ae002
 /* Define if gcc supports FMA4.  */
8ae002
 #undef	HAVE_FMA4_SUPPORT
8ae002
 
8ae002
diff --git a/sysdeps/s390/configure b/sysdeps/s390/configure
8ae002
index cc4c1e0..eb49a4c 100644
8ae002
--- a/sysdeps/s390/configure
8ae002
+++ b/sysdeps/s390/configure
8ae002
@@ -42,3 +42,36 @@ else
8ae002
   { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Use binutils with vector-support in order to use optimized implementations." >&5
8ae002
 $as_echo "$as_me: WARNING: Use binutils with vector-support in order to use optimized implementations." >&2;}
8ae002
 fi
8ae002
+
8ae002
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for S390 vector support in gcc" >&5
8ae002
+$as_echo_n "checking for S390 vector support in gcc... " >&6; }
8ae002
+if ${libc_cv_gcc_s390_vx+:} false; then :
8ae002
+  $as_echo_n "(cached) " >&6
8ae002
+else
8ae002
+  cat > conftest.c <<\EOF
8ae002
+void testvecclobber ()
8ae002
+{
8ae002
+  __asm__ ("" : : : "v16");
8ae002
+}
8ae002
+EOF
8ae002
+if { ac_try='${CC-cc} --shared conftest.c -o conftest.o &> /dev/null'
8ae002
+  { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
8ae002
+  (eval $ac_try) 2>&5
8ae002
+  ac_status=$?
8ae002
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
8ae002
+  test $ac_status = 0; }; } ;
8ae002
+then
8ae002
+  libc_cv_gcc_s390_vx=yes
8ae002
+else
8ae002
+  libc_cv_gcc_s390_vx=no
8ae002
+fi
8ae002
+rm -f conftest*
8ae002
+fi
8ae002
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libc_cv_gcc_s390_vx" >&5
8ae002
+$as_echo "$libc_cv_gcc_s390_vx" >&6; }
8ae002
+
8ae002
+if test "$libc_cv_gcc_s390_vx" = yes ;
8ae002
+then
8ae002
+  $as_echo "#define HAVE_S390_VX_GCC_SUPPORT 1" >>confdefs.h
8ae002
+
8ae002
+fi
8ae002
diff --git a/sysdeps/s390/configure.in b/sysdeps/s390/configure.in
8ae002
index 733e356..a3b1f25 100644
8ae002
--- a/sysdeps/s390/configure.in
8ae002
+++ b/sysdeps/s390/configure.in
8ae002
@@ -31,3 +31,25 @@ then
8ae002
 else
8ae002
   AC_MSG_WARN([Use binutils with vector-support in order to use optimized implementations.])
8ae002
 fi
8ae002
+
8ae002
+AC_CACHE_CHECK(for S390 vector support in gcc, libc_cv_gcc_s390_vx, [dnl
8ae002
+cat > conftest.c <<\EOF
8ae002
+void testvecclobber ()
8ae002
+{
8ae002
+  __asm__ ("" : : : "v16");
8ae002
+}
8ae002
+EOF
8ae002
+dnl
8ae002
+dnl test, if gcc supports S390 vector registers as clobber in inline assembly
8ae002
+if AC_TRY_COMMAND([${CC-cc} --shared conftest.c -o conftest.o &> /dev/null]) ;
8ae002
+then
8ae002
+  libc_cv_gcc_s390_vx=yes
8ae002
+else
8ae002
+  libc_cv_gcc_s390_vx=no
8ae002
+fi
8ae002
+rm -f conftest* ])
8ae002
+
8ae002
+if test "$libc_cv_gcc_s390_vx" = yes ;
8ae002
+then
8ae002
+  AC_DEFINE(HAVE_S390_VX_GCC_SUPPORT)
8ae002
+fi
8ae002
-- 
8ae002
1.8.3.1
8ae002