spu-c.c (spu_build_overload_builtin): Delete.
authorAndrew Pinski <andrew_pinski@playstation.sony.com>
Thu, 7 Dec 2006 23:40:46 +0000 (23:40 +0000)
committerAndrew Pinski <pinskia@gcc.gnu.org>
Thu, 7 Dec 2006 23:40:46 +0000 (15:40 -0800)
2006-12-07  Andrew Pinski  <andrew_pinski@playstation.sony.com>

        * config/spu/spu-c.c (spu_build_overload_builtin): Delete.
        (spu_resolve_overloaded_builtin): Check for non scalar instead
        of vector type and check the function call argument type also for non scalar.
        Call build_function_call instead of spu_build_overload_builtin.

2006-12-07  Andrew Pinski  <andrew_pinski@playstation.sony.com>

        * gcc.target/spu: New directory.
        * gcc.target/spu/spu.exp: New file.
        * gcc.target/spu/intrinsics-1.c: New test.

From-SVN: r119637

gcc/ChangeLog
gcc/config/spu/spu-c.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/spu/intrinsics-1.c [new file with mode: 0644]
gcc/testsuite/gcc.target/spu/spu.exp [new file with mode: 0644]

index fe15e311b536e24f4b3ce666920565b411e8f8c3..25a1e7c001f373549cf2973ff7aab2c048ecce59 100644 (file)
@@ -1,3 +1,10 @@
+2006-12-07  Andrew Pinski  <andrew_pinski@playstation.sony.com>
+
+       * config/spu/spu-c.c (spu_build_overload_builtin): Delete.
+       (spu_resolve_overloaded_builtin): Check for non scalar instead
+       of vector type and check the function call argument type also for non scalar.
+       Call build_function_call instead of spu_build_overload_builtin.
+
 2006-12-07  Trevor Smigiel  <trevor_smigiel@playstation.sony.com>
 
        * config/spu/spu.c (array_to_constant): Correct the order of arguments
index c88e627a49fad0b85ae30d0cf86aee9426fbf088..d52d5242c7ff2d6b573c478266d0f29e46f0304c 100644 (file)
 #include "spu-builtins.h"
 \f
 
-/* Helper for spu_resolve_overloaded_builtin.  */
-static tree
-spu_build_overload_builtin (tree fndecl, tree fnargs)
-{
-  tree param, param_type;
-  tree ret_type = TREE_TYPE (TREE_TYPE (fndecl));
-  tree arg, arglist = NULL_TREE;
-  tree val;
-
-  for (param = TYPE_ARG_TYPES (TREE_TYPE (fndecl)), arg = fnargs;
-       param != void_list_node;
-       param = TREE_CHAIN (param), arg = TREE_CHAIN (arg))
-    {
-      gcc_assert (arg != NULL_TREE);
-      param_type = TREE_VALUE (param);
-      val = default_conversion (TREE_VALUE (arg));
-      val = fold_convert (param_type, val);
-
-      arglist = tree_cons (NULL_TREE, val, arglist);
-    }
-  gcc_assert (arg == NULL_TREE);
-  arglist = nreverse (arglist);
-
-  return fold_convert (ret_type, build_function_call_expr (fndecl, arglist));
-}
-
 /* target hook for resolve_overloaded_builtin(). Returns a function call
    RTX if we can resolve the overloaded builtin */
 tree
 spu_resolve_overloaded_builtin (tree fndecl, tree fnargs)
 {
+#define SCALAR_TYPE_P(t) (INTEGRAL_TYPE_P (t) \
+                         || SCALAR_FLOAT_TYPE_P (t) \
+                         || POINTER_TYPE_P (t))
   spu_function_code new_fcode, fcode =
     DECL_FUNCTION_CODE (fndecl) - END_BUILTINS;
   struct spu_builtin_description *desc;
@@ -119,7 +96,8 @@ spu_resolve_overloaded_builtin (tree fndecl, tree fnargs)
             checking/promotions for scalar arguments, except for the
             first argument of intrinsics which don't have a vector
             parameter. */
-         if ((TREE_CODE (param_type) == VECTOR_TYPE
+         if ((!SCALAR_TYPE_P (param_type)
+              || !SCALAR_TYPE_P (arg_type)
               || ((fcode == SPU_SPLATS || fcode == SPU_PROMOTE
                    || fcode == SPU_HCMPEQ || fcode == SPU_HCMPGT
                    || fcode == SPU_MASKB || fcode == SPU_MASKH
@@ -149,7 +127,8 @@ spu_resolve_overloaded_builtin (tree fndecl, tree fnargs)
       return error_mark_node;
     }
 
-  return spu_build_overload_builtin (match, fnargs);
+  return build_function_call (match, fnargs);
+#undef SCALAR_TYPE_P
 }
 
 
index 77c3bf1883a6d8a7e1c17c7d59774ebdab5248d1..c5ab9b52fa7b09b7b52f15263fe2cbb7b27f37d3 100644 (file)
@@ -1,3 +1,9 @@
+2006-12-07  Andrew Pinski  <andrew_pinski@playstation.sony.com>
+
+       * gcc.target/spu: New directory.
+       * gcc.target/spu/spu.exp: New file.
+       * gcc.target/spu/intrinsics-1.c: New test.
+
 2006-12-07  Lee Millward  <lee.millward@codesourcery.com>
 
         PR c++/29980
diff --git a/gcc/testsuite/gcc.target/spu/intrinsics-1.c b/gcc/testsuite/gcc.target/spu/intrinsics-1.c
new file mode 100644 (file)
index 0000000..08458a5
--- /dev/null
@@ -0,0 +1,18 @@
+/* { dg-do compile } */
+/* { dg-options "-std=c99 -pedantic-errors" } */
+#include <spu_intrinsics.h>
+/* With this intrinsics section, we used to ICE as we would try
+   to convert from an vector to an integer type.  */
+void f(void)
+{
+  vec_uint4 gt, N;
+  vec_int4 a;
+  int *a1;
+  _Complex double b;
+  gt = spu_cmpgt(a, N); /* { dg-error "parameter list" } */
+  gt = spu_cmpgt(a, a1); /* { dg-error "integer from pointer without a cast" } */
+  gt = spu_cmpgt(a, b); /* { dg-error "parameter list" } */
+  gt = spu_cmpgt(a, a);
+  /* Remove this xfail once, we reject implict conversions between vector types.  */
+  a = spu_cmpgt(a, a); /* { dg-error "" "" { xfail *-*-* } } */
+}
diff --git a/gcc/testsuite/gcc.target/spu/spu.exp b/gcc/testsuite/gcc.target/spu/spu.exp
new file mode 100644 (file)
index 0000000..b766986
--- /dev/null
@@ -0,0 +1,41 @@
+#   Copyright (C) 2005 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 2 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 this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  
+
+# GCC testsuite that uses the 'dg.exp' driver.
+
+# Exit immediately if this isn't a SPU target.
+if { ![istarget spu-*-*] } 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