Patchwork C6X port 11/11: Testcases

login
register
mail settings
Submitter Bernd Schmidt
Date May 10, 2011, 3:51 p.m.
Message ID <4DC95F01.9020706@codesourcery.com>
Download mbox | patch
Permalink /patch/95062/
State New
Headers show

Comments

Bernd Schmidt - May 10, 2011, 3:51 p.m.
This contains the testsuite changes for the C6X port.


Bernd
* gcc.target/tic6x/weak-call.c: New test.
	* gcc.target/tic6x/fpcmp.c: New test.
	* gcc.target/tic6x/fpdiv.c: New test.
	* gcc.target/tic6x/rotdi16-scan.c: New test.
	* gcc.target/tic6x/ffssi.c: New test.
	* gcc.target/tic6x/fpdiv-lib.c: New test.
	* gcc.target/tic6x/cold-lc.c: New test.
	* gcc.target/tic6x/longcalls.c: New test.
	* gcc.target/tic6x/abi-align-1.c: New test.
	* gcc.target/tic6x/fpcmp-finite.c: New test.
	* gcc.target/tic6x/rotdi16.c: New test.
	* gcc.target/tic6x/bswapl.c: New test.
	* gcc.target/tic6x/ffsdi.c: New test.
	* gcc.target/tic6x/tic6x.exp: New file.
	* gcc.target/tic6x/builtin-math-7.c: New test, adapted from gcc.dg.
	* lib/target-supports.exp (chck_profiling_available): Not on tic6x.
	* gcc.c-torture/execute/20101011-1.c: Add a condition for
	__TMS320C6X__.
	* gcc.dg/20020312-2.c: Likewise.
	* gcc.dg/pr27095.c: Handle tic6x like hppa.
	* gcc.dg/torture/pr37868.c: Skip on tic6x.
	* gcc.dg/torture/builtin-math-7.c: Likewise.

Patch

Index: testsuite/gcc.target/tic6x/weak-call.c
===================================================================
--- /dev/null
+++ testsuite/gcc.target/tic6x/weak-call.c
@@ -0,0 +1,17 @@ 
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+/* { dg-final { scan-assembler-not "call\[\\t ]*.s.\[\\t ]*.f" } } */
+/* { dg-final { scan-assembler-not "call\[\\t ]*.s.\[\\t ]*.g" } } */
+
+extern void f () __attribute__ ((weak));
+extern void g () __attribute__ ((weak)) __attribute__ ((noinline));
+
+void g ()
+{
+}
+
+int main ()
+{
+  f ();
+  g ();
+}
Index: testsuite/gcc.target/tic6x/builtin-math-7.c
===================================================================
--- /dev/null
+++ testsuite/gcc.target/tic6x/builtin-math-7.c
@@ -0,0 +1,94 @@ 
+/* Copyright (C) 2009  Free Software Foundation.
+
+   Verify that folding of complex mul and div work correctly.
+   TI C6X specific version, reduced by two tests that fails due to the
+   use of implicit -freciprocal-math.
+
+   Origin: Kaveh R. Ghazi,  August 13, 2009.  */
+
+/* { dg-do run } */
+/* { dg-options "-O2" } */
+/* { dg-add-options ieee } */
+
+extern void link_error(int);
+
+/* Evaluate this expression at compile-time.  */
+#define COMPILETIME_TESTIT(TYPE,X,OP,Y,RES) do { \
+  if ((_Complex TYPE)(X) OP (_Complex TYPE)(Y) != (_Complex TYPE)(RES)) \
+    link_error(__LINE__); \
+} while (0)
+
+/* Use this error function for cases which only evaluate at
+   compile-time when optimizing.  */
+#ifdef __OPTIMIZE__
+# define ERROR_FUNC(X) link_error(X)
+#else
+# define ERROR_FUNC(X) __builtin_abort()
+#endif
+
+/* Evaluate this expression at compile-time using static initializers.  */
+#define STATICINIT_TESTIT(TYPE,X,OP,Y,RES) do { \
+  static const _Complex TYPE foo = (_Complex TYPE)(X) OP (_Complex TYPE)(Y); \
+  if (foo != (_Complex TYPE)(RES)) \
+    ERROR_FUNC (__LINE__); \
+} while (0)
+
+/* Evaluate this expression at runtime.  */
+#define RUNTIME_TESTIT(TYPE,X,OP,Y,RES) do { \
+  volatile _Complex TYPE foo; \
+  foo = (_Complex TYPE)(X); \
+  foo OP##= (_Complex TYPE)(Y); \
+  if (foo != (_Complex TYPE)(RES)) \
+    __builtin_abort(); \
+} while (0)
+
+/* Evaluate this expression at compile-time and runtime.  */
+#define TESTIT(TYPE,X,OP,Y,RES) do { \
+  STATICINIT_TESTIT(TYPE,X,OP,Y,RES); \
+  COMPILETIME_TESTIT(TYPE,X,OP,Y,RES); \
+  RUNTIME_TESTIT(TYPE,X,OP,Y,RES); \
+} while (0)
+
+/* Either the real or imaginary parts should be infinity.  */
+#define TEST_ONE_PART_INF(VAL) do { \
+  static const _Complex double foo = (VAL); \
+  if (! __builtin_isinf(__real foo) && ! __builtin_isinf(__imag foo)) \
+    ERROR_FUNC (__LINE__); \
+  if (! __builtin_isinf(__real (VAL)) && ! __builtin_isinf(__imag (VAL))) \
+    __builtin_abort(); \
+} while (0)
+
+int main()
+{
+  /* Test some regular finite values.  */
+  TESTIT (double, 3.+4.i, *, 2, 6+8i);
+  TESTIT (double, 3.+4.i, /, 2, 1.5+2i);
+  TESTIT (int, 3+4i, *, 2, 6+8i);
+  TESTIT (int, 3+4i, /, 2, 1+2i);
+
+  TESTIT (double, 3.+4.i, *, 2+5i, -14+23i);
+  TESTIT (int, 3+4i, *, 2+5i, -14+23i);
+  TESTIT (int, 30+40i, /, 5i, 8-6i);
+  TESTIT (int, 14+6i, /, 7+3i, 2);
+  TESTIT (int, 8+24i, /, 4+12i, 2);
+
+  /* Test for accuracy.  */
+  COMPILETIME_TESTIT (double,
+		      (1 + __DBL_EPSILON__ + 1i),
+		      *,
+		      (1 - __DBL_EPSILON__ + 1i),
+		      -4.93038065763132378382330353301741393545754021943139377981e-32+2i);
+
+  /* This becomes (NaN + iInf).  */
+#define VAL1 ((_Complex double)__builtin_inf() * 1i)
+
+  /* Test some C99 Annex G special cases.  */
+  TEST_ONE_PART_INF ((VAL1) * (VAL1));
+  TEST_ONE_PART_INF ((_Complex double)1 / (_Complex double)0);
+  TEST_ONE_PART_INF ((VAL1) / (_Complex double)1);
+
+  RUNTIME_TESTIT (double, 1, /, VAL1, 0);
+  STATICINIT_TESTIT (double, 1, /, VAL1, 0);
+
+  return 0;
+}
Index: testsuite/gcc.target/tic6x/fpcmp.c
===================================================================
--- /dev/null
+++ testsuite/gcc.target/tic6x/fpcmp.c
@@ -0,0 +1,23 @@ 
+/* { dg-do compile } */
+/* { dg-options "-O2 -march=c67x" } */
+/* { dg-final { scan-assembler-times "cmpeq.p" 4 } } */
+
+double gedf (double x, double y)
+{
+  return x >= y;
+}
+
+double ledf (double x, double y)
+{
+  return x <= y;
+}
+
+float gesf (float x, float y)
+{
+  return x >= y;
+}
+
+float lesf (float x, float y)
+{
+  return x <= y;
+}
Index: testsuite/gcc.target/tic6x/tic6x.exp
===================================================================
--- /dev/null
+++ testsuite/gcc.target/tic6x/tic6x.exp
@@ -0,0 +1,62 @@ 
+# Copyright (C) 2010 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.
+
+if ![istarget tic6x-*-*] then {
+  return
+}
+
+# Load support procs.
+load_lib gcc-dg.exp
+
+# Like dg-options, but treats certain C6X-specific options specially:
+#
+#    -march=*
+#	Select the target architecture. Skip the test if the multilib
+#	flags force a different arch.
+proc dg-c6x-options {args} {
+    upvar dg-extra-tool-flags extra_tool_flags
+    upvar dg-do-what do_what
+
+    set multilib_arch ""
+    set arch ""
+
+    foreach flag [target_info multilib_flags] {
+	regexp "^-march=(.*)" $flag dummy multilib_arch
+    }
+
+    set flags [lindex $args 1]
+
+    foreach flag $flags {
+	regexp "^-march=(.*)" $flag dummy arch
+    }
+
+    if {$multilib_arch == "" || $multilib_cpu == $arch} {
+	set extra_tool_flags $flags
+    } else {
+	set do_what [list [lindex $do_what 0] "N" "P"]
+    }
+}
+
+# Initialize `dg'.
+dg-init
+
+# Main loop.
+dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.\[cCS\]]]	"" ""
+
+# All done.
+dg-finish
Index: testsuite/gcc.target/tic6x/fpdiv.c
===================================================================
--- /dev/null
+++ testsuite/gcc.target/tic6x/fpdiv.c
@@ -0,0 +1,14 @@ 
+/* { dg-do compile } */
+/* { dg-options "-O2 -march=c67x" } */
+/* { dg-final { scan-assembler "rcpdp" } } */
+/* { dg-final { scan-assembler "rcpsp" } } */
+
+double f (double x, double y)
+{
+  return x / y;
+}
+
+float g (float x, float y)
+{
+  return x / y;
+}
Index: testsuite/gcc.target/tic6x/rotdi16-scan.c
===================================================================
--- /dev/null
+++ testsuite/gcc.target/tic6x/rotdi16-scan.c
@@ -0,0 +1,15 @@ 
+/* { dg-do compile } */
+/* { dg-options "-O2 -march=c64x+" } */
+/* { dg-final { scan-assembler "dpackx" } } */
+
+#include <stdlib.h>
+
+unsigned long long z = 0x012389ab4567cdefull;
+
+int main ()
+{
+  unsigned long long z2 = (z << 48) | (z >> 16);
+  if (z2 != 0xcdef012389ab4567ull)
+    abort ();
+  exit (0);
+}
Index: testsuite/gcc.target/tic6x/ffssi.c
===================================================================
--- /dev/null
+++ testsuite/gcc.target/tic6x/ffssi.c
@@ -0,0 +1,18 @@ 
+/* { dg-do compile } */
+/* { dg-options "-O2 -march=c64x+" } */
+/* { dg-final { scan-assembler-not "call" } } */
+
+int foo (int x)
+{
+  return __builtin_ffsl (x);
+}
+
+int bar (int x)
+{
+  return __builtin_clzl (x);
+}
+
+int baz (int x)
+{
+  return __builtin_ctzl (x);
+}
Index: testsuite/gcc.target/tic6x/fpdiv-lib.c
===================================================================
--- /dev/null
+++ testsuite/gcc.target/tic6x/fpdiv-lib.c
@@ -0,0 +1,14 @@ 
+/* { dg-do compile } */
+/* { dg-options "-O2 -march=c67x -fno-reciprocal-math" } */
+/* { dg-final { scan-assembler-not "rcpdp" } } */
+/* { dg-final { scan-assembler-not "rcpsp" } } */
+
+double f (double x, double y)
+{
+  return x / y;
+}
+
+float g (float x, float y)
+{
+  return x / y;
+}
Index: testsuite/gcc.target/tic6x/cold-lc.c
===================================================================
--- /dev/null
+++ testsuite/gcc.target/tic6x/cold-lc.c
@@ -0,0 +1,21 @@ 
+/* { dg-do compile } */
+/* { dg-options "-O2 -mlong-calls" } */
+
+extern void dump_stack (void) __attribute__ ((__cold__));
+struct thread_info {
+    struct task_struct *task;
+};
+extern struct thread_info *current_thread_info (void);
+
+void dump_stack (void)
+{
+    unsigned long stack;
+    show_stack ((current_thread_info ()->task), &stack);
+}
+
+void die (char *str, void *fp, int nr)
+{
+    dump_stack ();
+    while (1);
+}
+
Index: testsuite/gcc.target/tic6x/longcalls.c
===================================================================
--- /dev/null
+++ testsuite/gcc.target/tic6x/longcalls.c
@@ -0,0 +1,27 @@ 
+/* { dg-do compile } */
+/* { dg-options "-O2 -mlong-calls" } */
+/* { dg-final { scan-assembler-times "\\tcall\[p\]*\[\\t ]*.s" 3 } } */
+/* { dg-final { scan-assembler "call\[p\]*\[\\t ]*.s.\[\\t ]*.f" } } */
+/* { dg-final { scan-assembler-not "call\[p\]*\[\\t ]*.s.\[\\t ]*.g" } } */
+/* { dg-final { scan-assembler-not "call\[p\]*\[\\t ]*.s.\[\\t ]*.h" } } */
+
+int x;
+
+static __attribute__ ((noinline)) void f ()
+{
+  x = 5;
+}
+
+extern void g ();
+
+static __attribute__ ((noinline)) __attribute__((section(".init.text"))) void h ()
+{
+  x = 5;
+}
+
+int bar ()
+{
+  f ();
+  g ();
+  h ();
+}
Index: testsuite/gcc.target/tic6x/abi-align-1.c
===================================================================
--- /dev/null
+++ testsuite/gcc.target/tic6x/abi-align-1.c
@@ -0,0 +1,19 @@ 
+/* { dg-do run } */
+
+/* common */
+char c;
+/* arrays must be 8 byte aligned, regardless of size */
+char c_ary[1];
+
+/* data */
+char d = 1;
+char d_ary[1] = {1};
+
+int main ()
+{
+  if (((unsigned long)&c_ary[0] & 7) != 0)
+    return 1;
+  if (((unsigned long)&d_ary[0] & 7) != 0)
+    return 1;
+  return 0;
+}
Index: testsuite/gcc.target/tic6x/fpcmp-finite.c
===================================================================
--- /dev/null
+++ testsuite/gcc.target/tic6x/fpcmp-finite.c
@@ -0,0 +1,23 @@ 
+/* { dg-do compile } */
+/* { dg-options "-O2 -march=c67x -ffinite-math-only" } */
+/* { dg-final { scan-assembler-not "cmpeq" } } */
+
+double gedf (double x, double y)
+{
+  return x >= y;
+}
+
+double ledf (double x, double y)
+{
+  return x <= y;
+}
+
+float gesf (float x, float y)
+{
+  return x >= y;
+}
+
+float lesf (float x, float y)
+{
+  return x <= y;
+}
Index: testsuite/gcc.target/tic6x/rotdi16.c
===================================================================
--- /dev/null
+++ testsuite/gcc.target/tic6x/rotdi16.c
@@ -0,0 +1,14 @@ 
+/* { dg-do run } */
+/* { dg-options "-O2 -march=c64x+" } */
+
+#include <stdlib.h>
+
+unsigned long long z = 0x012389ab4567cdefull;
+
+int main ()
+{
+  unsigned long long z2 = (z << 48) | (z >> 16);
+  if (z2 != 0xcdef012389ab4567ull)
+    abort ();
+  exit (0);
+}
Index: testsuite/gcc.target/tic6x/bswapl.c
===================================================================
--- /dev/null
+++ testsuite/gcc.target/tic6x/bswapl.c
@@ -0,0 +1,13 @@ 
+/* { dg-do compile } */
+/* { dg-options "-O2 -march=c64x+" } */
+/* { dg-final { scan-assembler-not "call" } } */
+
+int foo (int x)
+{
+  return __builtin_bswap32 (x);
+}
+
+long long bar (long long x)
+{
+  return __builtin_bswap64 (x);
+}
Index: testsuite/gcc.target/tic6x/ffsdi.c
===================================================================
--- /dev/null
+++ testsuite/gcc.target/tic6x/ffsdi.c
@@ -0,0 +1,18 @@ 
+/* { dg-do compile } */
+/* { dg-options "-O2 -march=c64x+" } */
+/* { dg-final { scan-assembler-not "call" } } */
+
+long long foo (long long x)
+{
+  return __builtin_ffsll (x);
+}
+
+long long bar (long long x)
+{
+  return __builtin_clzll (x);
+}
+
+long long baz (long long x)
+{
+  return __builtin_ctzll (x);
+}
Index: testsuite/lib/target-supports.exp
===================================================================
--- testsuite/lib/target-supports.exp.orig
+++ testsuite/lib/target-supports.exp
@@ -564,6 +564,7 @@  proc check_profiling_available { test_wh
 	     || [istarget powerpc-*-eabi*]
 	     || [istarget powerpc-*-elf]
 	     || [istarget rx-*-*]	
+	     || [istarget tic6x-*-elf]
 	     || [istarget xstormy16-*]
 	     || [istarget xtensa*-*-elf]
 	     || [istarget *-*-netware*]
Index: testsuite/gcc.c-torture/execute/20101011-1.c
===================================================================
--- testsuite/gcc.c-torture/execute/20101011-1.c.orig
+++ testsuite/gcc.c-torture/execute/20101011-1.c
@@ -12,6 +12,9 @@ 
 #elif defined (__sh__)
   /* On SH division by zero does not trap.  */
 # define DO_TEST 0
+#elif defined (__TMS320C6X__)
+  /* On TI C6X division by zero does not trap.  */
+# define DO_TEST 0
 #elif defined (__mips__) && !defined(__linux__)
   /* MIPS divisions do trap by default, but libgloss targets do not
      intercept the trap and raise a SIGFPE.  The same is probably
Index: testsuite/gcc.dg/pr27095.c
===================================================================
--- testsuite/gcc.dg/pr27095.c.orig
+++ testsuite/gcc.dg/pr27095.c
@@ -16,10 +16,11 @@  main (int argc, char **argv)
   memset (x, argc, strlen (x));
   return 0;
 }
-/* { dg-final { scan-assembler-not "(?n)strlen\(.*\n\)+.*strlen" { target { ! { powerpc*-*-darwin* hppa*-*-hpux* ia64-*-hpux* alpha*-*-* spu-*-* } } } } } */
+/* { dg-final { scan-assembler-not "(?n)strlen\(.*\n\)+.*strlen" { target { ! { powerpc*-*-darwin* hppa*-*-hpux* ia64-*-hpux* alpha*-*-* spu-*-* tic6x-*-* } } } } } */
 /* hppa*-*-hpux* has an IMPORT statement for strlen (plus the branch). */
 /* *-*-darwin* has something similar. */
-/* { dg-final { scan-assembler-not "(?n)strlen\(.*\n\)+.*strlen\(.*\n\)+.*strlen" { target hppa*-*-hpux* } } } */
+/* tic6x emits a comment at the point where the delayed branch happens.  */
+/* { dg-final { scan-assembler-not "(?n)strlen\(.*\n\)+.*strlen\(.*\n\)+.*strlen" { target hppa*-*-hpux* tic6x-*-* } } } */
 /* { dg-final { scan-assembler-not "(?n)bl L_strlen\(.*\n\)+.*bl L_strlen" { target powerpc*-*-darwin* } } } */
 /* ia64-*-hpux* has a global statement, a type statement, and the branch. */
 /* { dg-final { scan-assembler-not "(?n)strlen\(.*\n\)+.*strlen\(.*\n\)+.*strlen\(.*\n\)+.*strlen" { target ia64-*-hpux* } } } */
Index: testsuite/gcc.dg/torture/pr37868.c
===================================================================
--- testsuite/gcc.dg/torture/pr37868.c.orig
+++ testsuite/gcc.dg/torture/pr37868.c
@@ -1,6 +1,6 @@ 
 /* { dg-do run } */
 /* { dg-options "-fno-strict-aliasing" } */
-/* { dg-skip-if "unaligned access" { sparc*-*-* sh*-*-* } "*" "" } */
+/* { dg-skip-if "unaligned access" { sparc*-*-* sh*-*-* tic6x-*-* } "*" "" } */
 
 extern void abort (void);
 #if (__SIZEOF_INT__ <= 2)
Index: testsuite/gcc.dg/torture/builtin-math-7.c
===================================================================
--- testsuite/gcc.dg/torture/builtin-math-7.c.orig
+++ testsuite/gcc.dg/torture/builtin-math-7.c
@@ -5,6 +5,7 @@ 
    Origin: Kaveh R. Ghazi,  August 13, 2009.  */
 
 /* { dg-do run } */
+/* { dg-skip-if "" { tic6x-*-* } "*" "" } */
 /* { dg-add-options ieee } */
 
 extern void link_error(int);
Index: testsuite/gcc.dg/20020312-2.c
===================================================================
--- testsuite/gcc.dg/20020312-2.c.orig
+++ testsuite/gcc.dg/20020312-2.c
@@ -64,6 +64,8 @@  extern void abort (void);
 # define PIC_REG  "12"
 #elif defined(__sparc__)
 # define PIC_REG  "l7"
+#elif defined(__TMS320C6X__)
+# define PIC_REG "B14"
 #elif defined(__v850)
 /* No pic register.  */
 #elif defined(__vax__)