From patchwork Sun Jun 20 09:07:01 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Botcazou X-Patchwork-Id: 56259 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 051411007D1 for ; Sun, 20 Jun 2010 19:11:12 +1000 (EST) Received: (qmail 32066 invoked by alias); 20 Jun 2010 09:11:08 -0000 Received: (qmail 32055 invoked by uid 22791); 20 Jun 2010 09:11:07 -0000 X-SWARE-Spam-Status: No, hits=-2.0 required=5.0 tests=AWL,BAYES_00,TW_TM X-Spam-Check-By: sourceware.org Received: from mel.act-europe.fr (HELO mel.act-europe.fr) (212.99.106.210) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 20 Jun 2010 09:11:02 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id 8B70C29000B; Sun, 20 Jun 2010 11:11:12 +0200 (CEST) Received: from mel.act-europe.fr ([127.0.0.1]) by localhost (smtp.eu.adacore.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id NWSVxH58Cn3n; Sun, 20 Jun 2010 11:11:12 +0200 (CEST) Received: from [192.168.1.2] (91-172-106-62.rev.libertysurf.net [91.172.106.62]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mel.act-europe.fr (Postfix) with ESMTP id F15D629000A; Sun, 20 Jun 2010 11:11:11 +0200 (CEST) From: Eric Botcazou To: Nathan Froyd Subject: Re: [PATCH, RFC/RFH] remove uses of build_constructor_from_list from?Ada FE Date: Sun, 20 Jun 2010 11:07:01 +0200 User-Agent: KMail/1.9.9 Cc: gcc-patches@gcc.gnu.org References: <20100617190728.GQ27105@codesourcery.com> <201006172125.08804.ebotcazou@adacore.com> <20100617201233.GT27105@codesourcery.com> In-Reply-To: <20100617201233.GT27105@codesourcery.com> MIME-Version: 1.0 Message-Id: <201006201107.01608.ebotcazou@adacore.com> 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 > I personally think TREE_VEC should just be a wrapper around VEC, > precisely for cases like this. That would indeed help. But I think that we can get away without that in this case because the cico list is quite special: it's the list of elements of a CONSTRUCTOR. So we can probably turn TYPE_CI_CO_LIST into a CONSTRUCTOR (and rename it into TYPE_CICO_RETVAL in the process for the sake of clarity). In the meantime, I've installed the attached patch so that you can install yours without further ado (after testing though); it's already very valuable because it eliminates the back-and-forth conversion between list and array done in gnat_build_constructor. Tested on i586-suse-linux, applied on the mainline. 2010-06-20 Eric Botcazou * gcc-interface/trans.c (Subprogram_Body_to_gnu): Use while instead of for loop. Call build_constructor_from_list directly in the CICO case. Index: gcc-interface/trans.c =================================================================== --- gcc-interface/trans.c (revision 161023) +++ gcc-interface/trans.c (working copy) @@ -2462,9 +2462,8 @@ Subprogram_Body_to_gnu (Node_Id gnat_nod { /* Skip any entries that have been already filled in; they must correspond to In Out parameters. */ - for (; gnu_cico_list && TREE_VALUE (gnu_cico_list); - gnu_cico_list = TREE_CHAIN (gnu_cico_list)) - ; + while (gnu_cico_list && TREE_VALUE (gnu_cico_list)) + gnu_cico_list = TREE_CHAIN (gnu_cico_list); /* Do any needed references for padded types. */ TREE_VALUE (gnu_cico_list) @@ -2546,8 +2545,8 @@ Subprogram_Body_to_gnu (Node_Id gnat_nod if (list_length (gnu_cico_list) == 1) gnu_retval = TREE_VALUE (gnu_cico_list); else - gnu_retval = gnat_build_constructor (TREE_TYPE (gnu_subprog_type), - gnu_cico_list); + gnu_retval = build_constructor_from_list (TREE_TYPE (gnu_subprog_type), + gnu_cico_list); add_stmt_with_node (build_return_expr (gnu_result_decl, gnu_retval), End_Label (Handled_Statement_Sequence (gnat_node)));