From patchwork Wed Apr 20 20:06:21 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Froyd X-Patchwork-Id: 92306 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 0C55DB6F35 for ; Thu, 21 Apr 2011 06:06:48 +1000 (EST) Received: (qmail 30618 invoked by alias); 20 Apr 2011 20:06:46 -0000 Received: (qmail 30610 invoked by uid 22791); 20 Apr 2011 20:06:45 -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:06:31 +0000 Received: (qmail 2501 invoked from network); 20 Apr 2011 20:06:29 -0000 Received: from unknown (HELO codesourcery.com) (froydnj@127.0.0.2) by mail.codesourcery.com with ESMTPA; 20 Apr 2011 20:06:29 -0000 Date: Wed, 20 Apr 2011 16:06:21 -0400 From: Nathan Froyd To: gcc-patches@gcc.gnu.org Cc: uweigand@de.ibm.com Subject: [PATCH] use build_function_type_list in the spu backend Message-ID: <20110420200620.GQ6507@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. 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 --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;