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

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