Patchwork Ping^5/update: contribute Synopsys Designware ARC port (7/7): testsuite

login
register
mail settings
Submitter Joern Rennecke
Date Sept. 5, 2013, 7:18 p.m.
Message ID <20130905151837.vo0fm3sj4ook8k0o-nzlynne@webmail.spamcop.net>
Download mbox | patch
Permalink /patch/272942/
State New
Headers show

Comments

Joern Rennecke - Sept. 5, 2013, 7:18 p.m.
OK to apply?

FWIW, my colleague Simon Cook is currently working on adding more  
target option /
builtin tests.
2013-08-31 Joern Rennecke <joern.rennecke@embecosm.com>
	   Vineet Gupta  <Vineet.Gupta@synopsys.com>

	* gcc.c-torture/execute/20101011-1.c [__arc__] (DO_TEST): Define as 0.
	* testsuite/gcc.target/arc: New directory.
	* gcc.dg/torture/pr37868.c: Also skip for arc*-*-*.
	* gcc.dg/stack-usage-1.c [__arc__] (SIZE): Define.
	* testsuite/gcc.dg/torture/stackalign/builtin-apply-2.c
	[__arc__] (STACK_ARGUMENTS_SIZE): Set to 0.
	* testsuite/gcc.dg/builtin-apply2.c
	[__arc__] (STACK_ARGUMENTS_SIZE): Set to 0.
Mike Stump - Sept. 5, 2013, 10:56 p.m.
On Sep 5, 2013, at 12:18 PM, Joern Rennecke <joern.rennecke@embecosm.com> wrote:
> OK to apply?

Ok.

Patch

diff --git a/gcc/testsuite/gcc.c-torture/execute/20101011-1.c b/gcc/testsuite/gcc.c-torture/execute/20101011-1.c
index 8d82183..bd54318 100644
--- a/gcc/testsuite/gcc.c-torture/execute/20101011-1.c
+++ b/gcc/testsuite/gcc.c-torture/execute/20101011-1.c
@@ -43,6 +43,9 @@ 
 #elif defined (__CRIS__)
   /* No SIGFPE for CRIS integer division.  */
 # define DO_TEST 0
+#elif defined (__arc__)
+  /* No SIGFPE for ARC integer division.  */
+# define DO_TEST 0
 #elif defined (__arm__) && defined (__ARM_EABI__)
 # ifdef __ARM_ARCH_EXT_IDIV__
   /* Hardware division instructions may not trap, and handle trapping
diff --git a/gcc/testsuite/gcc.dg/builtin-apply2.c b/gcc/testsuite/gcc.dg/builtin-apply2.c
index 9b73147..daaef47 100644
--- a/gcc/testsuite/gcc.dg/builtin-apply2.c
+++ b/gcc/testsuite/gcc.dg/builtin-apply2.c
@@ -17,7 +17,7 @@ 
    E, F and G are passed on stack.  So the size of the stack argument
    data is 20.  */
 #define STACK_ARGUMENTS_SIZE  20
-#elif defined __MMIX__
+#elif defined __MMIX__ || defined __arc__
 /* No parameters on stack for bar.  */
 #define STACK_ARGUMENTS_SIZE 0
 #else
diff --git a/gcc/testsuite/gcc.dg/stack-usage-1.c b/gcc/testsuite/gcc.dg/stack-usage-1.c
index fa299c4..ff9709a 100644
--- a/gcc/testsuite/gcc.dg/stack-usage-1.c
+++ b/gcc/testsuite/gcc.dg/stack-usage-1.c
@@ -9,6 +9,8 @@ 
 
 #if defined(__aarch64__)
 #  define SIZE 256 /* No frame pointer for leaf functions (default) */
+#elif defined(__arc__)
+#  define SIZE (256-4)
 #elif defined(__i386__)
 #  define SIZE 248
 #elif defined(__x86_64__)
diff --git a/gcc/testsuite/gcc.dg/torture/pr37868.c b/gcc/testsuite/gcc.dg/torture/pr37868.c
index 2b245eb..cc9c24f 100644
--- a/gcc/testsuite/gcc.dg/torture/pr37868.c
+++ b/gcc/testsuite/gcc.dg/torture/pr37868.c
@@ -1,6 +1,6 @@ 
 /* { dg-do run } */
 /* { dg-options "-fno-strict-aliasing" } */
-/* { dg-skip-if "unaligned access" { epiphany-*-* sparc*-*-* sh*-*-* tic6x-*-* } "*" "" } */
+/* { dg-skip-if "unaligned access" { arc*-*-* epiphany-*-* sparc*-*-* sh*-*-* tic6x-*-* } "*" "" } */
 
 extern void abort (void);
 #if (__SIZEOF_INT__ <= 2)
diff --git a/gcc/testsuite/gcc.dg/torture/stackalign/builtin-apply-2.c b/gcc/testsuite/gcc.dg/torture/stackalign/builtin-apply-2.c
index f683a2a..ed81e80 100644
--- a/gcc/testsuite/gcc.dg/torture/stackalign/builtin-apply-2.c
+++ b/gcc/testsuite/gcc.dg/torture/stackalign/builtin-apply-2.c
@@ -19,7 +19,7 @@ 
    E, F and G are passed on stack.  So the size of the stack argument
    data is 20.  */
 #define STACK_ARGUMENTS_SIZE  20
-#elif defined __aarch64__ || defined __MMIX__
+#elif defined __aarch64__ || defined __arc__ || defined __MMIX__
 /* No parameters on stack for bar.  */
 #define STACK_ARGUMENTS_SIZE 0
 #else
diff --git a/gcc/testsuite/gcc.target/arc/arc.exp b/gcc/testsuite/gcc.target/arc/arc.exp
new file mode 100644
index 0000000..83e2762
--- /dev/null
+++ b/gcc/testsuite/gcc.target/arc/arc.exp
@@ -0,0 +1,41 @@ 
+# Copyright (C) 2007, 2011, 2012 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+# 
+# You should have received a copy of the GNU General Public License
+# along with GCC; see the file COPYING3.  If not see
+# <http://www.gnu.org/licenses/>.
+
+# GCC testsuite that uses the `dg.exp' driver.
+
+# Exit immediately if this isn't an arc target.
+if ![istarget arc*-*-*] then {
+  return
+}
+
+# Load support procs.
+load_lib gcc-dg.exp
+
+# If a testcase doesn't have special options, use these.
+global DEFAULT_CFLAGS
+if ![info exists DEFAULT_CFLAGS] then {
+    set DEFAULT_CFLAGS " -ansi -pedantic-errors"
+}
+
+# Initialize `dg'.
+dg-init
+
+# Main loop.
+dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cS\]]] \
+	"" $DEFAULT_CFLAGS
+
+# All done.
+dg-finish
diff --git a/gcc/testsuite/gcc.target/arc/builtin_arc_aligned-1.c b/gcc/testsuite/gcc.target/arc/builtin_arc_aligned-1.c
new file mode 100644
index 0000000..b1990c6
--- /dev/null
+++ b/gcc/testsuite/gcc.target/arc/builtin_arc_aligned-1.c
@@ -0,0 +1,16 @@ 
+/* { dg-do run } */
+/* { dg-options "-O" } */
+
+extern void abort (void);
+
+/* In macros like optimized memset, we want to be able to decide what
+   alignment a passed pointer has.  */
+#define f(p) __builtin_arc_aligned (p, 4)
+
+int main (void)
+{
+  int i;
+  if (f (&i) == 0)
+    abort ();
+  return 0;
+}
diff --git a/gcc/testsuite/gcc.target/arc/builtin_arc_aligned-2.c b/gcc/testsuite/gcc.target/arc/builtin_arc_aligned-2.c
new file mode 100644
index 0000000..d48a915
--- /dev/null
+++ b/gcc/testsuite/gcc.target/arc/builtin_arc_aligned-2.c
@@ -0,0 +1,28 @@ 
+/* { dg-do run } */
+/* { dg-options "-O" } */
+
+extern void abort (void);
+
+typedef struct {
+  short x;
+} mytype_t;
+
+mytype_t *__attribute__  ((noinline,weak))
+some_func (void)
+{
+  static mytype_t s;
+  return &s;
+};
+
+int main (void)
+{
+  int y, y2;
+  mytype_t *shorter = some_func();
+  y = __builtin_arc_aligned (shorter, 2);
+  if (!y)
+    abort ();
+  y2 = __builtin_arc_aligned (shorter, 4);
+  if (y2)
+    abort ();
+  return 0;
+}
diff --git a/gcc/testsuite/gcc.target/arc/builtin_arc_aligned-3.c b/gcc/testsuite/gcc.target/arc/builtin_arc_aligned-3.c
new file mode 100644
index 0000000..23d80ed
--- /dev/null
+++ b/gcc/testsuite/gcc.target/arc/builtin_arc_aligned-3.c
@@ -0,0 +1,67 @@ 
+/* { dg-do run } */
+/* { dg-options "-O" } */
+
+extern void abort (void);
+
+typedef struct {
+  int b, c;
+}
+__attribute__((aligned(32))) inner_t; // data type is 32 byte aligned
+
+typedef struct {
+  inner_t *inner;
+  int a;
+} outer_t;
+
+void __attribute__  ((noinline,weak))
+somefunc (int a, int b, int c)
+{
+  if (!a || !b || c)
+    abort ();
+};
+
+__attribute__  ((noinline,weak))
+outer_t *
+some_alloc_1 ()
+{
+  static outer_t x;
+  return &x;
+}
+
+__attribute__  ((noinline,weak))
+inner_t *
+some_alloc_2 ()
+{
+  static inner_t x;
+  return &x;
+}
+
+int main (void)
+{
+  int y, y2, y3;
+  // @p_out is pointing to instance of outer_t, naturally aligned to 4+4 = 8
+  // and not gauranteed be 32 byte aligned.
+  outer_t *p_out = some_alloc_1( ); // returns 8 byte aligned ptr
+
+  // @ptr is pointing to instance of inner_t which is naturally aligned to 32.
+  // It is assigned to p_out->inner which is of type inner_t thus 32 byte
+  // aligned as well
+  // Note that gcc can deduce p_out->inner is 32b aligned, not at runtime,
+  // because it was assigned @ptr, but even at compile time, because it's data
+  // type is naturally 32 byte aligned.
+  inner_t *ptr = some_alloc_2(); // returns 32 byte aligned ptr
+  p_out->inner = ptr; // this ptr will also be 32 byte aligned
+
+  y = __builtin_arc_aligned(ptr, 32); // this shd return 1
+  y2 = __builtin_arc_aligned(p_out->inner, 32); // this also shd return 1
+  // Although p_out->inner ptr is 32 byte aligned,
+  // it's container &(p_out->inner) need not be.
+  // That is because the hoister has no relation to contents.
+  // p_out is not gauranteed to be 32 byte
+  // aligned, so it's member @inner in p_out need not be.
+  y3 = __builtin_arc_aligned(&(p_out->inner), 32);
+  // compiler not sure, so must return 0
+
+  somefunc(y, y2, y3);
+  return 0;
+}
diff --git a/gcc/testsuite/gcc.target/arc/interrupt-1.c b/gcc/testsuite/gcc.target/arc/interrupt-1.c
new file mode 100644
index 0000000..7051457
--- /dev/null
+++ b/gcc/testsuite/gcc.target/arc/interrupt-1.c
@@ -0,0 +1,5 @@ 
+void __attribute__ ((interrupt("ilink1")))
+handler1 (void)
+{
+}
+/* { dg-final { scan-assembler-times "j.*\[ilink1\]" 1 } } */
diff --git a/gcc/testsuite/gcc.target/arc/interrupt-2.c b/gcc/testsuite/gcc.target/arc/interrupt-2.c
new file mode 100644
index 0000000..ee8593b
--- /dev/null
+++ b/gcc/testsuite/gcc.target/arc/interrupt-2.c
@@ -0,0 +1,5 @@ 
+void __attribute__ ((interrupt("ilink2")))
+handler1 (void)
+{
+}
+/* { dg-final { scan-assembler-times "j.*\[ilink2\]" 1 } } */
diff --git a/gcc/testsuite/gcc.target/arc/interrupt-3.c b/gcc/testsuite/gcc.target/arc/interrupt-3.c
new file mode 100644
index 0000000..fa598d6
--- /dev/null
+++ b/gcc/testsuite/gcc.target/arc/interrupt-3.c
@@ -0,0 +1,14 @@ 
+void __attribute__ ((interrupt))
+handler0 (void)
+{ /* { dg-error "wrong number of arguments specified" } */
+}
+
+void __attribute__ ((interrupt("you load too")))
+handler1 (void)
+{ /* { dg-warning "is not \"ilink1\" or \"ilink2\"" } */
+}
+
+void __attribute__ ((interrupt(42)))
+hander2 (void)
+{ /* { dg-warning "is not a string constant" } */
+}
diff --git a/gcc/testsuite/gcc.target/arc/mulsi3_highpart-1.c b/gcc/testsuite/gcc.target/arc/mulsi3_highpart-1.c
new file mode 100644
index 0000000..398ecfe
--- /dev/null
+++ b/gcc/testsuite/gcc.target/arc/mulsi3_highpart-1.c
@@ -0,0 +1,28 @@ 
+/* { dg-do run } */
+/* { dg-options "-O2 -mARC700 --save-temps" } */
+
+#include <stdlib.h>
+
+/* Hide value propagation from the optimizers.  */
+static int
+id (int i)
+{
+  asm ("": "+Xr" (i));
+  return i;
+}
+
+static int
+mulhigh (unsigned a, unsigned b)
+{
+  return (unsigned long long) a * b >> 32;
+}
+
+int
+main (void)
+{
+  if (mulhigh (id (0x12345678), id (0x90abcdef)) != 0xa49a83e)
+    abort ();
+  return 0;
+}
+
+/* { dg-final { scan-assembler "mpyhu\[ \t\]" } } */
diff --git a/gcc/testsuite/gcc.target/arc/mulsi3_highpart-2.c b/gcc/testsuite/gcc.target/arc/mulsi3_highpart-2.c
new file mode 100644
index 0000000..ccc74e7
--- /dev/null
+++ b/gcc/testsuite/gcc.target/arc/mulsi3_highpart-2.c
@@ -0,0 +1,30 @@ 
+/* { dg-do run } */
+/* { dg-options "-O2 -mARC700 --save-temps -mno-mpy" } */
+
+#include <stdlib.h>
+
+/* Hide value propagation from the optimizers.  */
+static int
+id (int i)
+{
+  asm ("": "+Xr" (i));
+  return i;
+}
+
+static int
+mulhigh (unsigned a, unsigned b)
+{
+  return (unsigned long long) a * b >> 32;
+}
+
+int
+main (void)
+{
+  if (mulhigh (id (0x12345678), id (0x90abcdef)) != 0xa49a83e)
+    abort ();
+  return 0;
+}
+
+/* { dg-final { scan-assembler-not "mpyhu\[ \t\]" } } */
+/* { dg-final { scan-assembler-not "@__muldi3" } } */
+/* { dg-final { scan-assembler "@__umulsi3_highpart" } } */
diff --git a/gcc/testsuite/gcc.target/arc/nv-cache.c b/gcc/testsuite/gcc.target/arc/nv-cache.c
new file mode 100644
index 0000000..9687195
--- /dev/null
+++ b/gcc/testsuite/gcc.target/arc/nv-cache.c
@@ -0,0 +1,9 @@ 
+/* { dg-do compile } */
+/* { dg-options "-O2 -mno-volatile-cache" } */
+
+volatile int i;
+void f (void)
+{
+  i = 0;
+}
+/* { dg-final { scan-assembler "st\.di" } } */
diff --git a/gcc/testsuite/gcc.target/arc/sdata-1.c b/gcc/testsuite/gcc.target/arc/sdata-1.c
new file mode 100644
index 0000000..3d8366c
--- /dev/null
+++ b/gcc/testsuite/gcc.target/arc/sdata-1.c
@@ -0,0 +1,10 @@ 
+/* { dg-do compile } */
+/* { dg-options "-O2 -msdata" } */
+
+int i;
+
+int f (void)
+{
+  return i;
+}
+/* { dg-final { scan-assembler "@sda" } } */
diff --git a/gcc/testsuite/gcc.target/arc/sdata-2.c b/gcc/testsuite/gcc.target/arc/sdata-2.c
new file mode 100644
index 0000000..ebaa25e
--- /dev/null
+++ b/gcc/testsuite/gcc.target/arc/sdata-2.c
@@ -0,0 +1,10 @@ 
+/* { dg-do compile } */
+/* { dg-options "-O2 -mno-sdata" } */
+
+int i;
+
+int f (void)
+{
+  return i;
+}
+/* { dg-final { scan-assembler-not "@sda" } } */
diff --git a/gcc/testsuite/gcc.target/arc/v-cache.c b/gcc/testsuite/gcc.target/arc/v-cache.c
new file mode 100644
index 0000000..7722c43
--- /dev/null
+++ b/gcc/testsuite/gcc.target/arc/v-cache.c
@@ -0,0 +1,9 @@ 
+/* { dg-do compile } */
+/* { dg-options "-O2 -mvolatile-cache" } */
+
+volatile int i;
+void f (void)
+{
+  i = 0;
+}
+/* { dg-final { scan-assembler-not "st\.di" } } */