Blame SOURCES/gdb-rhbz1182151-ibm-z13-18of22.patch

2c2fa1
commit e6c693af14c0488998a784d560b8cfbcf15db99a
2c2fa1
Author: Andreas Arnez <arnez@linux.vnet.ibm.com>
2c2fa1
Date:   Wed Jun 17 11:17:07 2015 +0200
2c2fa1
2c2fa1
    Add vector ABI tests to gnu_vector.exp
2c2fa1
    
2c2fa1
    So far the gnu_vector test was limited to "static" aspects of GDB's
2c2fa1
    vector support, like evaluating vector-valued expressions.  This patch
2c2fa1
    enriches the test and adds checks for GDB's vector ABI support as well.
2c2fa1
    The new checks particularly verify inferior function calls with vector
2c2fa1
    arguments and GDB's handling of vector return values.
2c2fa1
    
2c2fa1
    The test now attempts to compile for the target's "native" architecture,
2c2fa1
    such that a hardware vector ABI is used if available.
2c2fa1
    
2c2fa1
    Since GDB has no vector ABI support for x86 and x86_64 targets, most of
2c2fa1
    the new checks are KFAILed there.
2c2fa1
    
2c2fa1
    gdb/testsuite/ChangeLog:
2c2fa1
    
2c2fa1
    	* gdb.base/gnu_vector.c: Include stdarg.h and stdio.h.
2c2fa1
    	(VECTOR): New macro.  Use it...
2c2fa1
    	(int4, uint4, char4, float4, int2, longlong2, float2, double2):
2c2fa1
    	...for these typedefs.
2c2fa1
    	(int8, char1, int1, double1): New typedefs.
2c2fa1
    	(struct just_int2, struct two_int2): New structures.
2c2fa1
    	(add_some_intvecs, add_many_charvecs, add_various_floatvecs)
2c2fa1
    	(add_structvecs, add_singlevecs): New functions.
2c2fa1
    	(main): Call add_some_intvecs twice.
2c2fa1
    	* gdb.base/gnu_vector.exp: Drop GCC version check; just attempt
2c2fa1
    	the compile and exit upon failure.  Try compiling for the "native"
2c2fa1
    	architecture.  Test inferior function calls with vector arguments
2c2fa1
    	and vector return value handling with "finish" and "return".
2c2fa1
2c2fa1
### a/gdb/testsuite/ChangeLog
2c2fa1
### b/gdb/testsuite/ChangeLog
2c2fa1
## -1,3 +1,19 @@
2c2fa1
+2015-06-17  Andreas Arnez  <arnez@linux.vnet.ibm.com>
2c2fa1
+
2c2fa1
+	* gdb.base/gnu_vector.c: Include stdarg.h and stdio.h.
2c2fa1
+	(VECTOR): New macro.  Use it...
2c2fa1
+	(int4, uint4, char4, float4, int2, longlong2, float2, double2):
2c2fa1
+	...for these typedefs.
2c2fa1
+	(int8, char1, int1, double1): New typedefs.
2c2fa1
+	(struct just_int2, struct two_int2): New structures.
2c2fa1
+	(add_some_intvecs, add_many_charvecs, add_various_floatvecs)
2c2fa1
+	(add_structvecs, add_singlevecs): New functions.
2c2fa1
+	(main): Call add_some_intvecs twice.
2c2fa1
+	* gdb.base/gnu_vector.exp: Drop GCC version check; just attempt
2c2fa1
+	the compile and exit upon failure.  Try compiling for the "native"
2c2fa1
+	architecture.  Test inferior function calls with vector arguments
2c2fa1
+	and vector return value handling with "finish" and "return".
2c2fa1
+
2c2fa1
 2015-06-10  Jon Turney  <jon.turney@dronecode.org.uk>
2c2fa1
 
2c2fa1
 	* gdb.base/sepdebug.exp: Add EXEEXT where needed.
2c2fa1
Index: gdb-7.6.1/gdb/testsuite/gdb.base/gnu_vector.c
2c2fa1
===================================================================
2c2fa1
--- gdb-7.6.1.orig/gdb/testsuite/gdb.base/gnu_vector.c	2016-02-24 17:31:37.147569951 +0100
2c2fa1
+++ gdb-7.6.1/gdb/testsuite/gdb.base/gnu_vector.c	2016-02-24 17:31:46.248638945 +0100
2c2fa1
@@ -17,15 +17,27 @@
2c2fa1
 
2c2fa1
    Contributed by Ken Werner <ken.werner@de.ibm.com>  */
2c2fa1
 
2c2fa1
-typedef int __attribute__ ((vector_size (4 * sizeof(int)))) int4;
2c2fa1
-typedef unsigned int __attribute__ ((vector_size (4 * sizeof(unsigned int)))) uint4;
2c2fa1
-typedef char __attribute__ ((vector_size (4 * sizeof(char)))) char4;
2c2fa1
-typedef float __attribute__ ((vector_size (4 * sizeof(float)))) float4;
2c2fa1
-
2c2fa1
-typedef int __attribute__ ((vector_size (2 * sizeof(int)))) int2;
2c2fa1
-typedef long long __attribute__ ((vector_size (2 * sizeof(long long)))) longlong2;
2c2fa1
-typedef float __attribute__ ((vector_size (2 * sizeof(float)))) float2;
2c2fa1
-typedef double __attribute__ ((vector_size (2 * sizeof(double)))) double2;
2c2fa1
+#include <stdarg.h>
2c2fa1
+#include <stdio.h>
2c2fa1
+
2c2fa1
+#define VECTOR(n, type)					\
2c2fa1
+  type __attribute__ ((vector_size (n * sizeof(type))))
2c2fa1
+
2c2fa1
+typedef VECTOR (8, int) int8;
2c2fa1
+
2c2fa1
+typedef VECTOR (4, int) int4;
2c2fa1
+typedef VECTOR (4, unsigned int) uint4;
2c2fa1
+typedef VECTOR (4, char) char4;
2c2fa1
+typedef VECTOR (4, float) float4;
2c2fa1
+
2c2fa1
+typedef VECTOR (2, int) int2;
2c2fa1
+typedef VECTOR (2, long long) longlong2;
2c2fa1
+typedef VECTOR (2, float) float2;
2c2fa1
+typedef VECTOR (2, double) double2;
2c2fa1
+
2c2fa1
+typedef VECTOR (1, char) char1;
2c2fa1
+typedef VECTOR (1, int) int1;
2c2fa1
+typedef VECTOR (1, double) double1;
2c2fa1
 
2c2fa1
 int ia = 2;
2c2fa1
 int ib = 1;
2c2fa1
@@ -46,18 +58,91 @@
2c2fa1
 union
2c2fa1
 {
2c2fa1
   int i;
2c2fa1
-  char cv __attribute__ ((vector_size (sizeof (int))));
2c2fa1
+  VECTOR (sizeof(int), char) cv;
2c2fa1
 } union_with_vector_1;
2c2fa1
 
2c2fa1
 struct
2c2fa1
 {
2c2fa1
   int i;
2c2fa1
-  char cv __attribute__ ((vector_size (sizeof (int))));
2c2fa1
+  VECTOR (sizeof(int), char) cv;
2c2fa1
   float4 f4;
2c2fa1
 } struct_with_vector_1;
2c2fa1
 
2c2fa1
+struct just_int2
2c2fa1
+{
2c2fa1
+  int2 i;
2c2fa1
+};
2c2fa1
+
2c2fa1
+struct two_int2
2c2fa1
+{
2c2fa1
+  int2 i, j;
2c2fa1
+};
2c2fa1
+
2c2fa1
+
2c2fa1
+/* Simple vector-valued function with a few 16-byte vector
2c2fa1
+   arguments.  */
2c2fa1
+
2c2fa1
+int4
2c2fa1
+add_some_intvecs (int4 a, int4 b, int4 c)
2c2fa1
+{
2c2fa1
+  return a + b + c;
2c2fa1
+}
2c2fa1
+
2c2fa1
+/* Many small vector arguments, 4 bytes each.  */
2c2fa1
+
2c2fa1
+char4
2c2fa1
+add_many_charvecs (char4 a, char4 b, char4 c, char4 d, char4 e,
2c2fa1
+		   char4 f, char4 g, char4 h, char4 i, char4 j)
2c2fa1
+{
2c2fa1
+  return (a + b + c + d + e + f + g + h + i + j);
2c2fa1
+}
2c2fa1
+
2c2fa1
+/* Varargs: One fixed and N-1 variable vector arguments.  */
2c2fa1
+
2c2fa1
+float4
2c2fa1
+add_various_floatvecs (int n, float4 a, ...)
2c2fa1
+{
2c2fa1
+  int i;
2c2fa1
+  va_list argp;
2c2fa1
+
2c2fa1
+  va_start (argp, a);
2c2fa1
+  for (i = 1; i < n; i++)
2c2fa1
+    a += va_arg (argp, float4);
2c2fa1
+  va_end (argp);
2c2fa1
+
2c2fa1
+  return a;
2c2fa1
+}
2c2fa1
+
2c2fa1
+/* Struct-wrapped vectors (might be passed as if not wrapped).  */
2c2fa1
+
2c2fa1
+struct just_int2
2c2fa1
+add_structvecs (int2 a, struct just_int2 b, struct two_int2 c)
2c2fa1
+{
2c2fa1
+  struct just_int2 res;
2c2fa1
+
2c2fa1
+  res.i = a + b.i + c.i + c.j;
2c2fa1
+  return res;
2c2fa1
+}
2c2fa1
+
2c2fa1
+/* Single-element vectors (might be treated like scalars).  */
2c2fa1
+
2c2fa1
+double1
2c2fa1
+add_singlevecs (char1 a, int1 b, double1 c)
2c2fa1
+{
2c2fa1
+  return (double1) {a[0] + b[0] + c[0]};
2c2fa1
+}
2c2fa1
+
2c2fa1
+
2c2fa1
 int
2c2fa1
 main ()
2c2fa1
 {
2c2fa1
+  int4 res;
2c2fa1
+
2c2fa1
+  res = add_some_intvecs (i4a, i4a + i4b, i4b);
2c2fa1
+  printf ("%d %d %d %d\n", res[0], res[1], res[2], res[3]);
2c2fa1
+
2c2fa1
+  res = add_some_intvecs (i4a, i4a + i4b, i4b);
2c2fa1
+  printf ("%d %d %d %d\n", res[0], res[1], res[2], res[3]);
2c2fa1
+
2c2fa1
   return 0;
2c2fa1
 }
2c2fa1
Index: gdb-7.6.1/gdb/testsuite/gdb.base/gnu_vector.exp
2c2fa1
===================================================================
2c2fa1
--- gdb-7.6.1.orig/gdb/testsuite/gdb.base/gnu_vector.exp	2016-02-24 17:31:37.147569951 +0100
2c2fa1
+++ gdb-7.6.1/gdb/testsuite/gdb.base/gnu_vector.exp	2016-02-24 17:31:46.248638945 +0100
2c2fa1
@@ -22,20 +22,19 @@
2c2fa1
 set srcfile ${testfile}.c
2c2fa1
 set binfile ${objdir}/${subdir}/${testfile}
2c2fa1
 
2c2fa1
-if [get_compiler_info] {
2c2fa1
+# If supported by the compiler, "-mcpu=native" or "-march=native"
2c2fa1
+# should enable the highest available vector ABI.  Try both, then try
2c2fa1
+# without a CPU option.  If all variants fail, assume that the
2c2fa1
+# compiler can not handle GNU vectors.
2c2fa1
+
2c2fa1
+if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" ${binfile} executable {debug quiet additional_flags=-mcpu=native}] != ""
2c2fa1
+     && [gdb_compile "${srcdir}/${subdir}/${srcfile}" ${binfile} executable {debug quiet additional_flags=-march=native}] != ""
2c2fa1
+     && [gdb_compile "${srcdir}/${subdir}/${srcfile}" ${binfile} executable {debug quiet}] != ""} {
2c2fa1
+    untested "compiler can't handle the vector_size attribute?"
2c2fa1
     return -1
2c2fa1
 }
2c2fa1
 
2c2fa1
-# Check if our compiler is a GCC that suppports the vector extension
2c2fa1
-if { ![test_compiler_info gcc-4-*] } {
2c2fa1
-    setup_xfail "*-*-*"
2c2fa1
-    fail "This compiler can not handle GNU vectors"
2c2fa1
-    return 0
2c2fa1
-}
2c2fa1
-
2c2fa1
-if { [prepare_for_testing ${testfile}.exp ${testfile} ${srcfile} {debug}] } {
2c2fa1
-    return -1
2c2fa1
-}
2c2fa1
+clean_restart ${binfile}
2c2fa1
 
2c2fa1
 if { ![runto main] } {
2c2fa1
     fail "runto main"
2c2fa1
@@ -177,3 +176,34 @@
2c2fa1
 
2c2fa1
 gdb_test "ptype union_with_vector_1" "type = union {\r\n\[\t \]+int i;\r\n\[\t \]+char cv __attribute__ \\(\\(vector_size\\(4\\)\\)\\);\r\n}"
2c2fa1
 gdb_test "ptype struct_with_vector_1" "type = struct {\r\n\[\t \]+int i;\r\n\[\t \]+char cv __attribute__ \\(\\(vector_size\\(4\\)\\)\\);\r\n\[\t \]+float4 f4;\r\n}"
2c2fa1
+
2c2fa1
+# Test inferior function calls with vector arguments and/or vector
2c2fa1
+# return values.
2c2fa1
+setup_kfail gdb/18537 "i?86-*-*" "x86_64-*-*"
2c2fa1
+gdb_test "print add_some_intvecs(i4a, i4b, 3 * i4a)" "= \\{17, 34, 72, 132\\}" \
2c2fa1
+    "call add_some_intvecs"
2c2fa1
+setup_kfail gdb/18537 "i?86-*-*" "x86_64-*-*"
2c2fa1
+gdb_test "print add_many_charvecs(c4, c4, c4, c4, c4, c4, c4, c4, c4, c4)" \
2c2fa1
+    "= \\{10, 20, 30, 40\\}" "call add_many_charvecs"
2c2fa1
+setup_kfail gdb/18537 "i?86-*-*" "x86_64-*-*"
2c2fa1
+gdb_test "print add_various_floatvecs(2, f4a, f4b)" "= \\{3, 6, 16, 20\\}" \
2c2fa1
+    "call add_various_floatvecs"
2c2fa1
+setup_kfail gdb/18537 "i?86-*-*" "x86_64-*-*"
2c2fa1
+gdb_test "print add_structvecs(i2, (struct just_int2)\{2*i2\}, (struct two_int2)\{3*i2, 4*i2\})" \
2c2fa1
+    "= \\{i = \\{10, 20\\}\\}" "call add_structvecs"
2c2fa1
+gdb_test "print add_singlevecs((char1) \{6\}, (int1) \{12\}, (double1) \{24\})" "= \\{42\\}" \
2c2fa1
+    "call add_singlevecs"
2c2fa1
+
2c2fa1
+# Test vector return value handling with "finish" and "return".
2c2fa1
+gdb_breakpoint "add_some_intvecs"
2c2fa1
+gdb_continue "add_some_intvecs"
2c2fa1
+setup_kfail gdb/18537 "i?86-*-*" "x86_64-*-*"
2c2fa1
+gdb_test "finish" "Value returned is .* = \\{10, 20, 48, 72\\}" \
2c2fa1
+    "finish shows vector return value"
2c2fa1
+gdb_continue "add_some_intvecs"
2c2fa1
+gdb_test "return (int4) \{4, 2, 7, 6\}" \
2c2fa1
+    "#0 .* main .*" \
2c2fa1
+    "set vector return value" \
2c2fa1
+    "Make add_some_intvecs return now. .y or n.*" "y"
2c2fa1
+setup_kfail gdb/18537 "i?86-*-*" "x86_64-*-*"
2c2fa1
+gdb_test "continue" "4 2 7 6\r\n.*" "verify vector return value"