From patchwork Wed Apr 20 20:14:00 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Froyd X-Patchwork-Id: 92312 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 5E488B6FD3 for ; Thu, 21 Apr 2011 06:14:27 +1000 (EST) Received: (qmail 3014 invoked by alias); 20 Apr 2011 20:14:25 -0000 Received: (qmail 3006 invoked by uid 22791); 20 Apr 2011 20:14:24 -0000 X-SWARE-Spam-Status: No, hits=-1.7 required=5.0 tests=AWL, BAYES_00, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (38.113.113.100) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 20 Apr 2011 20:14:09 +0000 Received: (qmail 4965 invoked from network); 20 Apr 2011 20:14:08 -0000 Received: from unknown (HELO codesourcery.com) (froydnj@127.0.0.2) by mail.codesourcery.com with ESMTPA; 20 Apr 2011 20:14:08 -0000 Date: Wed, 20 Apr 2011 16:14:00 -0400 From: Nathan Froyd To: gcc-patches@gcc.gnu.org Cc: nickc@redhat.com Subject: [PATCH] use build_function_type_list in the stormy16 backend Message-ID: <20110420201400.GR6507@nightcrawler> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org 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); } }