From patchwork Thu Jun 17 10:47:49 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Botcazou X-Patchwork-Id: 56009 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 09D73B7D29 for ; Thu, 17 Jun 2010 20:48:59 +1000 (EST) Received: (qmail 28509 invoked by alias); 17 Jun 2010 10:48:58 -0000 Received: (qmail 28491 invoked by uid 22791); 17 Jun 2010 10:48:56 -0000 X-SWARE-Spam-Status: No, hits=-1.8 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; Thu, 17 Jun 2010 10:48:50 +0000 Received: from localhost (localhost [127.0.0.1]) by filtered-smtp.eu.adacore.com (Postfix) with ESMTP id DDA2CCB0247; Thu, 17 Jun 2010 12:48:55 +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 YhAmeFxAh33e; Thu, 17 Jun 2010 12:48:55 +0200 (CEST) Received: from [192.168.1.2] (91-163-136-98.rev.libertysurf.net [91.163.136.98]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mel.act-europe.fr (Postfix) with ESMTP id AD305CB01D7; Thu, 17 Jun 2010 12:48:55 +0200 (CEST) From: Eric Botcazou To: Nathan Froyd Subject: Re: [PATCH] convert Ada FE to use VECs for stacks instead =?iso-8859-1?q?of=09TREE=5FLIST?= Date: Thu, 17 Jun 2010 12:47:49 +0200 User-Agent: KMail/1.9.9 Cc: gcc-patches@gcc.gnu.org References: <20100610030403.GE27105@codesourcery.com> <201006111838.53214.ebotcazou@adacore.com> <20100616034617.GN27105@codesourcery.com> In-Reply-To: <20100616034617.GN27105@codesourcery.com> MIME-Version: 1.0 Message-Id: <201006171247.49279.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 > Thanks, this is what I committed. Thanks. push_stack and pop_stack are now useless. Tested on i586-suse-linux, applied on the mainline. 2010-06-17 Eric Botcazou * gcc-interface/trans.c (push_stack, pop_stack): Delete. (Case_Statement_to_gnu): Adjust. (Loop_Statement_to_gnu): Likewise. (Subprogram_Body_to_gnu): Likewise. (Handled_Sequence_Of_Statements_to_gnu): Likewise. (Compilation_Unit_to_gnu): Likewise. Index: gcc-interface/trans.c =================================================================== --- gcc-interface/trans.c (revision 160880) +++ gcc-interface/trans.c (working copy) @@ -187,8 +187,6 @@ static void add_cleanup (tree, Node_Id); static void add_stmt_list (List_Id); static void push_exception_label_stack (VEC(tree,gc) **, Entity_Id); static tree build_stmt_group (List_Id, bool); -static void push_stack (VEC(tree,gc) **, tree); -static void pop_stack (VEC(tree,gc) *); static enum gimplify_status gnat_gimplify_stmt (tree *); static void elaborate_all_entities (Node_Id); static void process_freeze_entity (Node_Id); @@ -1934,10 +1932,10 @@ Case_Statement_to_gnu (Node_Id gnat_node /* We build a SWITCH_EXPR that contains the code with interspersed CASE_LABEL_EXPRs for each label. */ - - push_stack (&gnu_switch_label_stack, - create_artificial_label (input_location)); + VEC_safe_push (tree, gc, gnu_switch_label_stack, + create_artificial_label (input_location)); start_stmt_group (); + for (gnat_when = First_Non_Pragma (Alternatives (gnat_node)); Present (gnat_when); gnat_when = Next_Non_Pragma (gnat_when)) @@ -2026,7 +2024,7 @@ Case_Statement_to_gnu (Node_Id gnat_node VEC_last (tree, gnu_switch_label_stack))); gnu_result = build3 (SWITCH_EXPR, TREE_TYPE (gnu_expr), gnu_expr, end_stmt_group (), NULL_TREE); - pop_stack (gnu_switch_label_stack); + VEC_pop (tree, gnu_switch_label_stack); return gnu_result; } @@ -2092,7 +2090,7 @@ Loop_Statement_to_gnu (Node_Id gnat_node /* Save the end label of this LOOP_STMT in a stack so that a corresponding N_Exit_Statement can find it. */ - push_stack (&gnu_loop_label_stack, gnu_loop_label); + VEC_safe_push (tree, gc, gnu_loop_label_stack, gnu_loop_label); /* Set the condition under which the loop must keep going. For the case "LOOP .... END LOOP;" the condition is always true. */ @@ -2309,7 +2307,7 @@ Loop_Statement_to_gnu (Node_Id gnat_node else gnu_result = gnu_loop_stmt; - pop_stack (gnu_loop_label_stack); + VEC_pop (tree, gnu_loop_label_stack); return gnu_result; } @@ -2442,9 +2440,10 @@ Subprogram_Body_to_gnu (Node_Id gnat_nod properly copies them out. We do this by making a new block and converting any inner return into a goto to a label at the end of the block. */ gnu_cico_list = TYPE_CI_CO_LIST (gnu_subprog_type); - push_stack (&gnu_return_label_stack, - gnu_cico_list ? create_artificial_label (input_location) - : NULL_TREE); + VEC_safe_push (tree, gc, gnu_return_label_stack, + gnu_cico_list + ? create_artificial_label (input_location) + : NULL_TREE); /* Get a tree corresponding to the code for the subprogram. */ start_stmt_group (); @@ -2555,7 +2554,7 @@ Subprogram_Body_to_gnu (Node_Id gnat_nod gnu_result = end_stmt_group (); } - pop_stack (gnu_return_label_stack); + VEC_pop (tree, gnu_return_label_stack); /* Set the end location. */ Sloc_to_locus @@ -3252,12 +3251,13 @@ Handled_Sequence_Of_Statements_to_gnu (N start_stmt_group (); gnat_pushlevel (); - push_stack (&gnu_except_ptr_stack, - create_var_decl (get_identifier ("EXCEPT_PTR"), - NULL_TREE, - build_pointer_type (except_type_node), - build_call_0_expr (get_excptr_decl), false, - false, false, false, NULL, gnat_node)); + VEC_safe_push (tree, gc, gnu_except_ptr_stack, + create_var_decl (get_identifier ("EXCEPT_PTR"), + NULL_TREE, + build_pointer_type (except_type_node), + build_call_0_expr (get_excptr_decl), + false, + false, false, false, NULL, gnat_node)); /* Generate code for each handler. The N_Exception_Handler case does the real work and returns a COND_EXPR for each handler, which we chain @@ -3293,7 +3293,7 @@ Handled_Sequence_Of_Statements_to_gnu (N /* End the binding level dedicated to the exception handlers and get the whole statement group. */ - pop_stack (gnu_except_ptr_stack); + VEC_pop (tree, gnu_except_ptr_stack); gnat_poplevel (); gnu_handler = end_stmt_group (); @@ -3548,7 +3548,7 @@ Compilation_Unit_to_gnu (Node_Id gnat_no NULL_TREE, void_ftype, NULL_TREE, false, true, false, NULL, gnat_unit); struct elab_info *info; - push_stack (&gnu_elab_proc_stack, gnu_elab_proc_decl); + VEC_safe_push (tree, gc, gnu_elab_proc_stack, gnu_elab_proc_decl); DECL_ELABORATION_PROC_P (gnu_elab_proc_decl) = 1; /* Initialize the information structure for the function. */ @@ -3635,7 +3635,7 @@ Compilation_Unit_to_gnu (Node_Id gnat_no /* Generate elaboration code for this unit, if necessary, and say whether we did or not. */ - pop_stack (gnu_elab_proc_stack); + VEC_pop (tree, gnu_elab_proc_stack); /* Invalidate the global renaming pointers. This is necessary because stabilization of the renamed entities may create SAVE_EXPRs which @@ -5928,20 +5928,6 @@ build_stmt_group (List_Id gnat_list, boo return end_stmt_group (); } -/* Push and pop routines for stacks. */ - -static void -push_stack (VEC(tree,gc) **gnu_stack_ptr, tree value) -{ - VEC_safe_push (tree, gc, *gnu_stack_ptr, value); -} - -static void -pop_stack (VEC(tree,gc) *gnu_stack) -{ - VEC_pop (tree, gnu_stack); -} - /* Generate GIMPLE in place for the expression at *EXPR_P. */ int