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