diff mbox

C6X port 11/11: Testcases

Message ID 4E200BED.9080606@codesourcery.com
State New
Headers show

Commit Message

Bernd Schmidt July 15, 2011, 9:44 a.m. UTC
On 05/10/11 17:51, Bernd Schmidt wrote:
> This contains the testsuite changes for the C6X port.

Committed this version. No one commented about the changes outside
gcc.target/tic6x, but I think they are reasonably obvious. I'm open to
suggestions for other names for the check_effective_target functions.


Bernd

Comments

H.J. Lu July 15, 2011, 12:06 p.m. UTC | #1
On Fri, Jul 15, 2011 at 2:44 AM, Bernd Schmidt <bernds@codesourcery.com> wrote:
> On 05/10/11 17:51, Bernd Schmidt wrote:
>> This contains the testsuite changes for the C6X port.
>
> Committed this version. No one commented about the changes outside
> gcc.target/tic6x, but I think they are reasonably obvious. I'm open to
> suggestions for other names for the check_effective_target functions.
>
>

I think this caused:

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49757
Mike Stump July 15, 2011, 5:37 p.m. UTC | #2
On Jul 15, 2011, at 2:44 AM, Bernd Schmidt wrote:
> Committed this version. No one commented about the changes outside
> gcc.target/tic6x, but I think they are reasonably obvious. I'm open to
> suggestions for other names for the check_effective_target functions.

They look fine.  For gcc.dg/torture/builtin-math-7.c, I'd prefer a 1 line comment on why skipping it.  Something short and sweet, "no denorms" or some such.  This lets people that fall into the same conceptual category as you quickly discover that and also skip.
diff mbox

Patch

Index: gcc/testsuite/gcc.target/tic6x/weak-call.c
===================================================================
--- gcc/testsuite/gcc.target/tic6x/weak-call.c	(revision 0)
+++ gcc/testsuite/gcc.target/tic6x/weak-call.c	(revision 0)
@@ -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: gcc/testsuite/gcc.target/tic6x/builtin-math-7.c
===================================================================
--- gcc/testsuite/gcc.target/tic6x/builtin-math-7.c	(revision 0)
+++ gcc/testsuite/gcc.target/tic6x/builtin-math-7.c	(revision 0)
@@ -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: gcc/testsuite/gcc.target/tic6x/fpcmp.c
===================================================================
--- gcc/testsuite/gcc.target/tic6x/fpcmp.c	(revision 0)
+++ gcc/testsuite/gcc.target/tic6x/fpcmp.c	(revision 0)
@@ -0,0 +1,24 @@ 
+/* { dg-do compile } */
+/* { dg-require-effective-target ti_c67x } */
+/* { dg-options "-O2" } */
+/* { 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: gcc/testsuite/gcc.target/tic6x/tic6x.exp
===================================================================
--- gcc/testsuite/gcc.target/tic6x/tic6x.exp	(revision 0)
+++ gcc/testsuite/gcc.target/tic6x/tic6x.exp	(revision 0)
@@ -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: gcc/testsuite/gcc.target/tic6x/fpdiv.c
===================================================================
--- gcc/testsuite/gcc.target/tic6x/fpdiv.c	(revision 0)
+++ gcc/testsuite/gcc.target/tic6x/fpdiv.c	(revision 0)
@@ -0,0 +1,15 @@ 
+/* { dg-do compile } */
+/* { dg-require-effective-target ti_c67x } */
+/* { dg-options "-O2" } */
+/* { 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: gcc/testsuite/gcc.target/tic6x/builtins/smpyh.c
===================================================================
--- gcc/testsuite/gcc.target/tic6x/builtins/smpyh.c	(revision 0)
+++ gcc/testsuite/gcc.target/tic6x/builtins/smpyh.c	(revision 0)
@@ -0,0 +1,19 @@ 
+#include <c6x_intrinsics.h>
+extern void abort (void);
+
+int a1 = 0x50000000;
+int b1 = 0xc0000000;
+int a2 = 0xd0000000;
+int b2 = 0x20000000;
+int c = 0x80000000;
+int main ()
+{
+  if (_smpyh (a1, b1) != 0xd8000000)
+    abort ();
+  if (_smpyh (a2, b2) != 0xf4000000)
+    abort ();
+  if (_smpyh (c, c) != 0x7fffffff)
+    abort ();
+
+  return 0;
+}
Index: gcc/testsuite/gcc.target/tic6x/builtins/c6x-builtins.exp
===================================================================
--- gcc/testsuite/gcc.target/tic6x/builtins/c6x-builtins.exp	(revision 0)
+++ gcc/testsuite/gcc.target/tic6x/builtins/c6x-builtins.exp	(revision 0)
@@ -0,0 +1,25 @@ 
+# Copyright (C) 2009 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 `c-torture.exp' driver, looping over
+# optimization options.
+
+load_lib gcc-dg.exp
+
+dg-init
+gcc-dg-runtest [lsort [glob $srcdir/$subdir/*.c]] ""
+dg-finish
+
Index: gcc/testsuite/gcc.target/tic6x/builtins/extclr.c
===================================================================
--- gcc/testsuite/gcc.target/tic6x/builtins/extclr.c	(revision 0)
+++ gcc/testsuite/gcc.target/tic6x/builtins/extclr.c	(revision 0)
@@ -0,0 +1,36 @@ 
+#include <c6x_intrinsics.h>
+
+extern void abort (void);
+
+#define N 4
+
+int vals[N] = { 0, 0xffffffff, 0x89abcdef, 0xdeadbeef };
+
+int main ()
+{
+  int i;
+  for (i = 0; i < N; i++)
+    {
+      int shf1, shf2;
+      int v = vals[i];
+      unsigned int uv = v;
+
+      for (shf1 = 0; shf1 < 32; shf1++)
+	for (shf2 = 0; shf2 < 32; shf2++)
+	  {
+	    int r = (shf1 << 5) | shf2;
+	    if (shf2 > shf1)
+	      {
+		unsigned int mask = (1u << (shf2 - shf1) << 1) - 1;
+		mask <<= shf1;
+		if (_clrr (v, r) != (v & ~mask))
+		  abort ();
+	      }
+	    if (_extr (v, r) != v << shf1 >> shf2)
+	      abort ();
+	    if (_extru (v, r) != uv << shf1 >> shf2)
+	      abort ();
+	  }
+    }
+  return 0;
+}
Index: gcc/testsuite/gcc.target/tic6x/builtins/smpy.c
===================================================================
--- gcc/testsuite/gcc.target/tic6x/builtins/smpy.c	(revision 0)
+++ gcc/testsuite/gcc.target/tic6x/builtins/smpy.c	(revision 0)
@@ -0,0 +1,20 @@ 
+#include <c6x_intrinsics.h>
+
+extern void abort (void);
+
+int a1 = 0x5000;
+int b1 = 0xc000;
+int a2 = 0xd000;
+int b2 = 0x2000;
+int c = 0x8000;
+int main ()
+{
+  if (_smpy (a1, b1) != 0xd8000000)
+    abort ();
+  if (_smpy (a2, b2) != 0xf4000000)
+    abort ();
+  if (_smpy (c, c) != 0x7fffffff)
+    abort ();
+
+  return 0;
+}
Index: gcc/testsuite/gcc.target/tic6x/builtins/sarith1.c
===================================================================
--- gcc/testsuite/gcc.target/tic6x/builtins/sarith1.c	(revision 0)
+++ gcc/testsuite/gcc.target/tic6x/builtins/sarith1.c	(revision 0)
@@ -0,0 +1,47 @@ 
+#include <c6x_intrinsics.h>
+
+extern void abort (void);
+
+int a1 = 0x50000000;
+int b1 = 0xc0000000;
+int c1 = 0x40000000;
+int a2 = 0xd0000000;
+int b2 = 0x20000000;
+int c2 = 0x90000000;
+int d = 0x80000000;
+
+int main ()
+{
+  if (_sadd (a1, b1) != 0x10000000)
+    abort ();
+  if (_sadd (a2, b2) != 0xf0000000)
+    abort ();
+  if (_sadd (a1, c1) != 0x7fffffff)
+    abort ();
+  if (_sadd (a2, c2) != 0x80000000)
+    abort ();
+
+  if (_ssub (a1, b1) != 0x7fffffff)
+    abort ();
+  if (_ssub (a2, b2) != 0xb0000000)
+    abort ();
+  if (_ssub (b1, a1) != 0x80000000)
+    abort ();
+  if (_ssub (b2, a2) != 0x50000000)
+    abort ();
+
+  if (_abs (a1) != 0x50000000)
+    abort ();
+  if (_abs (b1) != 0x40000000)
+    abort ();
+  if (_abs (d) != 0x7fffffff)
+    abort ();
+
+  if (_sshl (a1, 1) != 0x7fffffff
+      || _sshl (b2, 1) != 0x40000000
+      || _sshl (a2, 1) != 0xa0000000
+      || _sshl (a2, 4) != 0x80000000)
+    abort ();
+
+  return 0;
+}
Index: gcc/testsuite/gcc.target/tic6x/builtins/smpylh.c
===================================================================
--- gcc/testsuite/gcc.target/tic6x/builtins/smpylh.c	(revision 0)
+++ gcc/testsuite/gcc.target/tic6x/builtins/smpylh.c	(revision 0)
@@ -0,0 +1,26 @@ 
+#include <c6x_intrinsics.h>
+
+extern void abort (void);
+
+int a1 = 0x5000;
+int b1 = 0xc0000000;
+int a2 = 0xd000;
+int b2 = 0x20000000;
+int c = 0x8000;
+int main ()
+{
+  if (_smpylh (a1, b1) != 0xd8000000)
+    abort ();
+  if (_smpylh (a2, b2) != 0xf4000000)
+    abort ();
+  if (_smpylh (c, 0x80000000) != 0x7fffffff)
+    abort ();
+  if (_smpyhl (b1, a1) != 0xd8000000)
+    abort ();
+  if (_smpyhl (b2, a2) != 0xf4000000)
+    abort ();
+  if (_smpyhl (0x80000000, c) != 0x7fffffff)
+    abort ();
+
+  return 0;
+}
Index: gcc/testsuite/gcc.target/tic6x/builtins/arith24.c
===================================================================
--- gcc/testsuite/gcc.target/tic6x/builtins/arith24.c	(revision 0)
+++ gcc/testsuite/gcc.target/tic6x/builtins/arith24.c	(revision 0)
@@ -0,0 +1,83 @@ 
+/* { dg-require-effective-target ti_c64xp } */
+
+#include <c6x_intrinsics.h>
+
+extern void abort (void);
+
+typedef short  __v2hi __attribute ((vector_size(4)));
+
+int a = 0x5000d000;
+int b = 0xc0002000;
+int c = 0x40009000;
+int d = 0x80000001;
+int e = 0x50002001;
+int f = 0xc0008000;
+
+int a4 = 0x50d03080;
+int b4 = 0xc020f080;
+int c4 = 0xc0202080;
+int d4 = 0x50003080;
+int e4 = 0xc0202180;
+
+int main ()
+{
+  int v;
+  long long vll;
+
+  v = _add2 (a, b);
+  if (v != 0x1000f000)
+    abort ();
+  v = _sub2 (a, b);
+  if (v != 0x9000b000)
+    abort ();
+  v = _sub2 (b, a);
+  if (v != 0x70005000)
+    abort ();
+
+  v = _add4 (a4, b4);
+  if (v != 0x10f02000)
+    abort ();
+  v = _sub4 (a4, b4);
+  if (v != 0x90b04000)
+    abort ();
+  v = _saddu4 (a4, c4);
+  if (v != 0xfff050ff)
+    abort ();
+
+  v = _sadd2 (a, b);
+  if (v != 0x1000f000)
+    abort ();
+  v = _sadd2 (a, c);
+  if (v != 0x7fff8000)
+    abort ();
+
+  v = _ssub2 (a, b);
+  if (v != 0x7fffb000)
+    abort ();
+  v = _ssub2 (b, a);
+  if (v != 0x80005000)
+    abort ();
+
+  vll = _smpy2ll (a, b);
+  if (vll != 0xd8000000f4000000ll)
+    abort ();
+  vll = _smpy2ll (d, d);
+  if (vll != 0x7fffffff00000002ll)
+    abort ();
+
+  v = _avg2 (b, e);
+  if (v != 0x08002001)
+    abort ();
+  v = _avgu4 (d4, e4);
+  if (v != 0x88102980)
+    abort ();
+
+  v = _abs2 (a);
+  if (v != 0x50003000)
+    abort ();
+  v = _abs2 (f);
+  if (v != 0x40007fff)
+    abort ();
+
+  return 0;
+}
Index: gcc/testsuite/gcc.target/tic6x/rotdi16-scan.c
===================================================================
--- gcc/testsuite/gcc.target/tic6x/rotdi16-scan.c	(revision 0)
+++ gcc/testsuite/gcc.target/tic6x/rotdi16-scan.c	(revision 0)
@@ -0,0 +1,16 @@ 
+/* { dg-do compile } */
+/* { dg-require-effective-target ti_c64xp } */
+/* { dg-options "-O2" } */
+/* { 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: gcc/testsuite/gcc.target/tic6x/ffssi.c
===================================================================
--- gcc/testsuite/gcc.target/tic6x/ffssi.c	(revision 0)
+++ gcc/testsuite/gcc.target/tic6x/ffssi.c	(revision 0)
@@ -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: gcc/testsuite/gcc.target/tic6x/fpdiv-lib.c
===================================================================
--- gcc/testsuite/gcc.target/tic6x/fpdiv-lib.c	(revision 0)
+++ gcc/testsuite/gcc.target/tic6x/fpdiv-lib.c	(revision 0)
@@ -0,0 +1,15 @@ 
+/* { dg-do compile } */
+/* { dg-require-effective-target ti_c67x } */
+/* { dg-options "-O2 -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: gcc/testsuite/gcc.target/tic6x/cold-lc.c
===================================================================
--- gcc/testsuite/gcc.target/tic6x/cold-lc.c	(revision 0)
+++ gcc/testsuite/gcc.target/tic6x/cold-lc.c	(revision 0)
@@ -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: gcc/testsuite/gcc.target/tic6x/longcalls.c
===================================================================
--- gcc/testsuite/gcc.target/tic6x/longcalls.c	(revision 0)
+++ gcc/testsuite/gcc.target/tic6x/longcalls.c	(revision 0)
@@ -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: gcc/testsuite/gcc.target/tic6x/abi-align-1.c
===================================================================
--- gcc/testsuite/gcc.target/tic6x/abi-align-1.c	(revision 0)
+++ gcc/testsuite/gcc.target/tic6x/abi-align-1.c	(revision 0)
@@ -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: gcc/testsuite/gcc.target/tic6x/fpcmp-finite.c
===================================================================
--- gcc/testsuite/gcc.target/tic6x/fpcmp-finite.c	(revision 0)
+++ gcc/testsuite/gcc.target/tic6x/fpcmp-finite.c	(revision 0)
@@ -0,0 +1,24 @@ 
+/* { dg-do compile } */
+/* { dg-require-effective-target ti_c67x } */
+/* { dg-options "-O2 -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: gcc/testsuite/gcc.target/tic6x/rotdi16.c
===================================================================
--- gcc/testsuite/gcc.target/tic6x/rotdi16.c	(revision 0)
+++ gcc/testsuite/gcc.target/tic6x/rotdi16.c	(revision 0)
@@ -0,0 +1,14 @@ 
+/* { dg-do run } */
+/* { dg-options "-O2" } */
+
+#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: gcc/testsuite/gcc.target/tic6x/bswapl.c
===================================================================
--- gcc/testsuite/gcc.target/tic6x/bswapl.c	(revision 0)
+++ gcc/testsuite/gcc.target/tic6x/bswapl.c	(revision 0)
@@ -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: gcc/testsuite/gcc.target/tic6x/ffsdi.c
===================================================================
--- gcc/testsuite/gcc.target/tic6x/ffsdi.c	(revision 0)
+++ gcc/testsuite/gcc.target/tic6x/ffsdi.c	(revision 0)
@@ -0,0 +1,19 @@ 
+/* { dg-do compile } */
+/* { dg-require-effective-target ti_c64xp } */
+/* { dg-options "-O2" } */
+/* { 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: gcc/testsuite/lib/target-supports.exp
===================================================================
--- gcc/testsuite/lib/target-supports.exp	(revision 176308)
+++ gcc/testsuite/lib/target-supports.exp	(working copy)
@@ -568,6 +568,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*]
@@ -1398,6 +1399,25 @@  proc check_effective_target_broken_cplxf
     }]
 }
 
+# Return 1 is this is a TI C6X target supporting C67X instructions
+proc check_effective_target_ti_c67x { } {
+    return [check_no_compiler_messages ti_c67x assembly {
+	#if !defined(_TMS320C6700)
+	#error FOO
+	#endif
+    }]
+}
+
+# Return 1 is this is a TI C6X target supporting C64X+ instructions
+proc check_effective_target_ti_c64xp { } {
+    return [check_no_compiler_messages ti_c64xp assembly {
+	#if !defined(_TMS320C6400_PLUS)
+	#error FOO
+	#endif
+    }]
+}
+
+
 proc check_alpha_max_hw_available { } {
     return [check_runtime alpha_max_hw_available {
 	int main() { return __builtin_alpha_amask(1<<8) != 0; }
Index: gcc/testsuite/gcc.c-torture/execute/20101011-1.c
===================================================================
--- gcc/testsuite/gcc.c-torture/execute/20101011-1.c	(revision 176308)
+++ gcc/testsuite/gcc.c-torture/execute/20101011-1.c	(working copy)
@@ -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: gcc/testsuite/gcc.dg/pr27095.c
===================================================================
--- gcc/testsuite/gcc.dg/pr27095.c	(revision 176308)
+++ gcc/testsuite/gcc.dg/pr27095.c	(working copy)
@@ -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: gcc/testsuite/gcc.dg/torture/pr37868.c
===================================================================
--- gcc/testsuite/gcc.dg/torture/pr37868.c	(revision 176308)
+++ gcc/testsuite/gcc.dg/torture/pr37868.c	(working copy)
@@ -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: gcc/testsuite/gcc.dg/torture/builtin-math-7.c
===================================================================
--- gcc/testsuite/gcc.dg/torture/builtin-math-7.c	(revision 176308)
+++ gcc/testsuite/gcc.dg/torture/builtin-math-7.c	(working copy)
@@ -5,6 +5,7 @@ 
    Origin: Kaveh R. Ghazi,  August 13, 2009.  */
 
 /* { dg-do run } */
+/* { dg-skip-if "" { tic6x-*-* } "*" "" } */
 /* { dg-add-options ieee } */
 /* { dg-require-effective-target large_double } */
 
Index: gcc/testsuite/gcc.dg/20020312-2.c
===================================================================
--- gcc/testsuite/gcc.dg/20020312-2.c	(revision 176308)
+++ gcc/testsuite/gcc.dg/20020312-2.c	(working copy)
@@ -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__)
Index: gcc/testsuite/ChangeLog
===================================================================
--- gcc/testsuite/ChangeLog	(revision 176308)
+++ gcc/testsuite/ChangeLog	(working copy)
@@ -1,3 +1,37 @@ 
+2011-07-15  Bernd Schmidt  <bernds@codesourcery.com>
+
+	* 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/testsuite/gcc.target/tic6x/builtins/arith24.c: New test.
+	* gcc/testsuite/gcc.target/tic6x/builtins/smpy.c: New test.
+	* gcc/testsuite/gcc.target/tic6x/builtins/smpylh.c: New test.
+	* gcc/testsuite/gcc.target/tic6x/builtins/smpyh.c: New test.
+	* gcc/testsuite/gcc.target/tic6x/builtins/sarith1.c: New test.
+	* gcc/testsuite/gcc.target/tic6x/builtins/extclr.c: New test
+	* gcc/testsuite/gcc.target/tic6x/builtins/c6x-builtins.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.
+	(check_effective_target_ti_c67x, check_effective_target_ti_c64xp):
+	New functions.
+	* 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.
+
 2011-07-14  Andrew Pinski  <pinskia@gmail.com>
 
 	PR tree-opt/49309