public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] use build_function_type_list in the stormy16 backend
@ 2011-04-20 21:01 Nathan Froyd
  2011-04-21 15:00 ` Nick Clifton
  0 siblings, 1 reply; 2+ messages in thread
From: Nathan Froyd @ 2011-04-20 21:01 UTC (permalink / raw)
  To: gcc-patches; +Cc: nickc

As $SUBJECT suggests.  For safety's sake, we initialize all the
arguments to NULL before passing them to build_function_type_list.  This
is not necessary currently, as we always completely fill in the args
array, but it might save some future coder from quite some grief...

Tested with cross to xstormy16-elf.  OK to commit?

-Nathan

	* config/stormy16/stormy16 (xstormy16_init_builtins): Call
	build_function_type_list instead of build_function_type.
	Rearrange initialization of `args' to do so.

diff --git a/gcc/config/stormy16/stormy16.c b/gcc/config/stormy16/stormy16.c
index 052285c..1a90e16 100644
--- a/gcc/config/stormy16/stormy16.c
+++ b/gcc/config/stormy16/stormy16.c
@@ -2255,15 +2255,21 @@ static struct
 static void
 xstormy16_init_builtins (void)
 {
-  tree args, ret_type, arg;
-  int i, a;
+  tree args[2], ret_type, arg = NULL_TREE, ftype;
+  int i, a, n_args;
 
   ret_type = void_type_node;
 
   for (i = 0; s16builtins[i].name; i++)
     {
-      args = void_list_node;
-      for (a = strlen (s16builtins[i].arg_types) - 1; a >= 0; a--)
+      n_args = strlen (s16builtins[i].arg_types) - 1;
+
+      gcc_assert (n_args <= (int) ARRAY_SIZE (args));
+
+      for (a = n_args; a >= 0; a--)
+	args[a] = NULL_TREE;
+
+      for (a = n_args; a >= 0; a--)
 	{
 	  switch (s16builtins[i].arg_types[a])
 	    {
@@ -2276,10 +2282,10 @@ xstormy16_init_builtins (void)
 	  if (a == 0)
 	    ret_type = arg;
 	  else
-	    args = tree_cons (NULL_TREE, arg, args);
+	    args[a-1] = arg;
 	}
-      add_builtin_function (s16builtins[i].name,
-			    build_function_type (ret_type, args),
+      ftype = build_function_type_list (ret_type, arg[0], arg[1], NULL_TREE);
+      add_builtin_function (s16builtins[i].name, ftype,
 			    i, BUILT_IN_MD, NULL, NULL);
     }
 }

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] use build_function_type_list in the stormy16 backend
  2011-04-20 21:01 [PATCH] use build_function_type_list in the stormy16 backend Nathan Froyd
@ 2011-04-21 15:00 ` Nick Clifton
  0 siblings, 0 replies; 2+ messages in thread
From: Nick Clifton @ 2011-04-21 15:00 UTC (permalink / raw)
  To: Nathan Froyd; +Cc: gcc-patches

Hi Nathan,

> 	* config/stormy16/stormy16 (xstormy16_init_builtins): Call
> 	build_function_type_list instead of build_function_type.
> 	Rearrange initialization of `args' to do so.

Approved - please apply.

Cheers
   Nick

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-04-21 14:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-04-20 21:01 [PATCH] use build_function_type_list in the stormy16 backend Nathan Froyd
2011-04-21 15:00 ` Nick Clifton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).