This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] vector extension tests for gcc.dg/compat


This patch adds two new C binary compatibility tests.  The tests pass on
powerpc-unknown-linux-gnu, but everywhere else I've tried they result in
an interesting variety of internal compiler errors which, I'm sure, will
provide hours of entertainment to the people who fix them. :-)

My reading of the documentation about vector extensions implies that
these tests should work for any target.  I hope to suggest improvements
to the documentation soon, and to extend the tests based on what else I
learn about vector extensions.

2003-07-03  Janis Johnson  <janis187@us.ibm.com>

	* gcc.dg/compat/vector-defs.h: New file.
	* gcc.dg/compat/vector-setup.h: New file.
	* gcc.dg/compat/vector-check.h: New file.
	* gcc.dg/compat/vector-1_main.c: New file.
	* gcc.dg/compat/vector-1_x.c: New file.
	* gcc.dg/compat/vector-1_y.c: New file.
	* gcc.dg/compat/vector-2_main.c: New file.
	* gcc.dg/compat/vector-2_x.c: New file.
	* gcc.dg/compat/vector-2_y.c: New file.

--- /dev/null	Tue May 23 09:27:54 2000
+++ gcc.dg/compat/vector-defs.h	Thu Jul  3 13:21:18 2003
@@ -0,0 +1,46 @@
+/* This includes all of the vector modes that are recognized by
+   c_common_type_for_mode, grouped by base mode.  */
+
+typedef int __attribute__((mode(QI))) qi;
+typedef int __attribute__((mode(V8QI))) v8qi;
+typedef int __attribute__((mode(V16QI))) v16qi;
+
+typedef union U8QI { v8qi v; qi a[8]; } u8qi;
+typedef union U16QI { v16qi v; qi a[16]; } u16qi;
+
+typedef int __attribute__((mode(HI))) hi;
+typedef int __attribute__((mode(V2HI))) v2hi;
+typedef int __attribute__((mode(V4HI))) v4hi;
+typedef int __attribute__((mode(V8HI))) v8hi;
+
+typedef union U2HI { v2hi v; hi a[2]; } u2hi;
+typedef union U4HI { v4hi v; hi a[4]; } u4hi;
+typedef union U8HI { v8hi v; hi a[8]; } u8hi;
+
+typedef int __attribute__((mode(SI))) si;
+typedef int __attribute__((mode(V2SI))) v2si;
+typedef int __attribute__((mode(V4SI))) v4si;
+
+typedef union U2SI { v2si v; si a[2]; } u2si;
+typedef union U4SI { v4si v; si a[4]; } u4si;
+
+typedef int __attribute__((mode(DI))) di;
+typedef int __attribute__((mode(V1DI))) v1di;
+typedef int __attribute__((mode(V2DI))) v2di;
+
+typedef union U1DI { v1di v; di a[1]; } u1di;
+typedef union U2DI { v2di v; di a[2]; } u2di;
+
+typedef float __attribute__((mode(SF))) sf;
+typedef float __attribute__((mode(V2SF))) v2sf;
+typedef float __attribute__((mode(V4SF))) v4sf;
+typedef float __attribute__((mode(V16SF))) v16sf;
+
+typedef union U2SF { v2sf v; sf a[2]; } u2sf;
+typedef union U4SF { v4sf v; sf a[4]; } u4sf;
+typedef union U16SF { v16sf v; sf a[16]; } u16sf;
+
+typedef float __attribute__((mode(DF))) df;
+typedef float __attribute__((mode(V2DF))) v2df;
+
+typedef union U2DF { v2df v; df a[2]; } u2df;
--- /dev/null	Tue May 23 09:27:54 2000
+++ gcc.dg/compat/vector-setup.h	Thu Jul  3 13:17:37 2003
@@ -0,0 +1,28 @@
+#define SETUP(NUM,TMODE)				\
+v##NUM##TMODE g_v##NUM##TMODE;				\
+TMODE g_##TMODE;					\
+							\
+extern void test_v##NUM##TMODE (void);			\
+extern void checkp_##NUM##TMODE (TMODE *);		\
+							\
+void							\
+pass_v##NUM##TMODE (v##NUM##TMODE v)			\
+{							\
+  u##NUM##TMODE u;					\
+  int j;						\
+  TMODE a[NUM];						\
+  							\
+  u.v = v;						\
+  for (j = 0; j < NUM; j++)				\
+    a[j] = u.a[j];					\
+  checkp_##NUM##TMODE (a);				\
+}							\
+							\
+v##NUM##TMODE						\
+return_v##NUM##TMODE (void)				\
+{							\
+  return g_v##NUM##TMODE;				\
+}
+
+#define CHECK(NUM,TMODE)				\
+  test_v##NUM##TMODE()
--- /dev/null	Tue May 23 09:27:54 2000
+++ gcc.dg/compat/vector-check.h	Thu Jul  3 13:17:37 2003
@@ -0,0 +1,64 @@
+#define TEST(NUM,TMODE,VAL)				\
+extern v##NUM##TMODE g_v##NUM##TMODE;			\
+extern int g_##TMODE;					\
+							\
+extern void pass_v##NUM##TMODE (v##NUM##TMODE);		\
+extern v##NUM##TMODE return_v##NUM##TMODE (void);	\
+							\
+void							\
+checkp_##NUM##TMODE (TMODE *p)				\
+{							\
+  int i;						\
+  for (i = 0; i < NUM; i++)				\
+    {							\
+      if (p[i] != g_##TMODE + i)			\
+	DEBUG_CHECK;					\
+    }							\
+}							\
+							\
+void							\
+checkg_##NUM##TMODE (void)				\
+{							\
+  u##NUM##TMODE u;					\
+  TMODE *p = u.a;					\
+							\
+  u.v = g_v##NUM##TMODE;				\
+  checkp_##NUM##TMODE (p);				\
+}							\
+							\
+void							\
+init_##NUM##TMODE (void)				\
+{							\
+  int i;						\
+  u##NUM##TMODE u;					\
+  g_##TMODE = VAL;					\
+  for (i = 0; i < NUM; i++)				\
+    u.a[i] = VAL + i;					\
+  g_v##NUM##TMODE = u.v;				\
+}							\
+							\
+void							\
+test_v##NUM##TMODE (void)				\
+{							\
+  v##NUM##TMODE v;					\
+  u##NUM##TMODE u;					\
+  TMODE *p = u.a;					\
+							\
+  DEBUG_FPUTS ("v" #NUM #TMODE);			\
+  DEBUG_NL;						\
+  DEBUG_FPUTS ("  global variable:");			\
+  init_##NUM##TMODE ();					\
+  checkg_##NUM##TMODE ();				\
+  DEBUG_NL;						\
+  DEBUG_FPUTS ("  pass global variable:");		\
+  pass_v##NUM##TMODE (g_v##NUM##TMODE);			\
+  DEBUG_NL;						\
+  DEBUG_FPUTS ("  pass local variable:");		\
+  v = g_v##NUM##TMODE;					\
+  pass_v##NUM##TMODE (v);				\
+  DEBUG_NL;						\
+  DEBUG_FPUTS ("  function return:");			\
+  u.v = return_v##NUM##TMODE ();			\
+  checkp_##NUM##TMODE (p);				\
+  DEBUG_NL;						\
+}
--- /dev/null	Tue May 23 09:27:54 2000
+++ gcc.dg/compat/vector-1_main.c	Thu Jul  3 13:17:37 2003
@@ -0,0 +1,14 @@
+/* Test compatibility of vector types: layout between separately-compiled
+   modules, parameter passing, and function return.  This test uses
+   vectors of integer values.  */
+
+extern void vector_1_x (void);
+extern void exit (int);
+int fails;
+
+int
+main ()
+{
+  vector_1_x ();
+  exit (0);
+}
--- /dev/null	Tue May 23 09:27:54 2000
+++ gcc.dg/compat/vector-1_x.c	Thu Jul  3 13:17:37 2003
@@ -0,0 +1,34 @@
+#include "compat-common.h"
+#include "vector-defs.h"
+#include "vector-setup.h"
+
+SETUP (8, qi);
+SETUP (16, qi);
+SETUP (2, hi);
+SETUP (4, hi);
+SETUP (8, hi);
+SETUP (2, si);
+SETUP (4, si);
+SETUP (1, di);
+SETUP (2, di);
+
+void
+vector_1_x (void)
+{
+  DEBUG_INIT
+
+  CHECK (8, qi);
+  CHECK (16, qi);
+  CHECK (2, hi);
+  CHECK (4, hi);
+  CHECK (8, hi);
+  CHECK (2, si);
+  CHECK (4, si);
+  CHECK (1, di);
+  CHECK (2, di);
+
+  DEBUG_FINI
+
+  if (fails != 0)
+    abort ();
+}
--- /dev/null	Tue May 23 09:27:54 2000
+++ gcc.dg/compat/vector-1_y.c	Thu Jul  3 13:17:37 2003
@@ -0,0 +1,13 @@
+#include "compat-common.h"
+#include "vector-defs.h"
+#include "vector-check.h"
+
+TEST (8, qi, 101)
+TEST (16, qi, 101)
+TEST (2, hi, 201)
+TEST (4, hi, 202)
+TEST (8, hi, 203)
+TEST (2, si, 301)
+TEST (4, si, 302)
+TEST (1, di, 401)
+TEST (2, di, 402)
--- /dev/null	Tue May 23 09:27:54 2000
+++ gcc.dg/compat/vector-2_main.c	Thu Jul  3 13:17:37 2003
@@ -0,0 +1,14 @@
+/* Test compatibility of vector types: layout between separately-compiled
+   modules, parameter passing, and function return.  This test uses
+   vectors of floating points values.  */
+
+extern void vector_2_x (void);
+extern void exit (int);
+int fails;
+
+int
+main ()
+{
+  vector_2_x ();
+  exit (0);
+}
--- /dev/null	Tue May 23 09:27:54 2000
+++ gcc.dg/compat/vector-2_x.c	Thu Jul  3 13:17:37 2003
@@ -0,0 +1,24 @@
+#include "compat-common.h"
+#include "vector-defs.h"
+#include "vector-setup.h"
+
+SETUP (2, sf);
+SETUP (4, sf);
+SETUP (16, sf);
+SETUP (2, df);
+
+void
+vector_2_x (void)
+{
+  DEBUG_INIT
+
+  CHECK (2, sf);
+  CHECK (4, sf);
+  CHECK (16, sf);
+  CHECK (2, df);
+
+  DEBUG_FINI
+
+  if (fails != 0)
+    abort ();
+}
--- /dev/null	Tue May 23 09:27:54 2000
+++ gcc.dg/compat/vector-2_y.c	Thu Jul  3 13:17:37 2003
@@ -0,0 +1,8 @@
+#include "compat-common.h"
+#include "vector-defs.h"
+#include "vector-check.h"
+
+TEST (2, sf, 301.0)
+TEST (4, sf, 302.0)
+TEST (16, sf, 304.0)
+TEST (2, df, 402.0)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]