diff mbox

use build_function_type_list in the spu backend

Message ID 20110420200620.GQ6507@nightcrawler
State New
Headers show

Commit Message

Nathan Froyd April 20, 2011, 8:06 p.m. UTC
As $SUBJECT suggests.  The only tricky bit is initializing all the args
to NULL_TREE so that we can safely pass all the args to
build_function_type_list.

Tested with cross to spu-elf; I couldn't build all of libgcc, but that
appears to be a pre-existing problem.  OK to commit?

-Nathan

	* config/spu/spu.c (spu_init_builtins): Call build_function_type_list
	instead of build_function_type.  Rearrange gathering of args to
	do so.
	* config/spu/spu-builtins.def (SPU_MAX_ARGS_TO_BUILTIN): Define.
diff mbox

Patch

diff --git a/gcc/config/spu/spu-builtins.def b/gcc/config/spu/spu-builtins.def
index 4d01d94..6dfdf8c 100644
--- a/gcc/config/spu/spu-builtins.def
+++ b/gcc/config/spu/spu-builtins.def
@@ -23,6 +23,8 @@ 
 #define _A3(a,b,c)   {a, b, c, SPU_BTI_END_OF_PARAMS}
 #define _A4(a,b,c,d) {a, b, c, d, SPU_BTI_END_OF_PARAMS}
 
+#define SPU_MAX_ARGS_TO_BUILTIN 3
+
 /* definitions to support si intrinsic functions: (These and other builtin
  * definitions must precede definitions of the overloaded generic intrinsics */
 
diff --git a/gcc/config/spu/spu.c b/gcc/config/spu/spu.c
index 941194b..ea9d580 100644
--- a/gcc/config/spu/spu.c
+++ b/gcc/config/spu/spu.c
@@ -5777,9 +5777,10 @@  spu_init_builtins (void)
      sure nodes are shared. */
   for (i = 0, d = spu_builtins; i < NUM_SPU_BUILTINS; i++, d++)
     {
-      tree p;
+      tree ftype;
       char name[64];		/* build_function will make a copy. */
-      int parm;
+      int parm, i;
+      tree args[SPU_MAX_ARGS_TO_BUILTIN];
 
       if (d->name == 0)
 	continue;
@@ -5788,15 +5789,23 @@  spu_init_builtins (void)
       for (parm = 1; d->parm[parm] != SPU_BTI_END_OF_PARAMS; parm++)
 	;
 
-      p = void_list_node;
+      gcc_assert (parm <= (SPU_MAX_ARGS_TO_BUILTIN + 1));
+
+      for (i = 0; i < ARRAY_SIZE (args); i++)
+	args[i] = NULL_TREE;
+
       while (parm > 1)
-	p = tree_cons (NULL_TREE, spu_builtin_types[d->parm[--parm]], p);
+	{
+	  tree arg = spu_builtin_types[d->parm[--parm]];
+	  args[parm-1] = arg;
+	}
 
-      p = build_function_type (spu_builtin_types[d->parm[0]], p);
+      ftype = build_function_type_list (spu_builtin_types[d->parm[0]],
+					args[0], args[1], args[2], NULL_TREE);
 
       sprintf (name, "__builtin_%s", d->name);
       spu_builtin_decls[i] =
-	add_builtin_function (name, p, i, BUILT_IN_MD, NULL, NULL_TREE);
+	add_builtin_function (name, ftype, i, BUILT_IN_MD, NULL, NULL_TREE);
       if (d->fcode == SPU_MASK_FOR_LOAD)
 	TREE_READONLY (spu_builtin_decls[i]) = 1;