From patchwork Fri Mar 11 04:23:25 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Froyd X-Patchwork-Id: 86374 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 2084DB6FA4 for ; Fri, 11 Mar 2011 15:31:20 +1100 (EST) Received: (qmail 29054 invoked by alias); 11 Mar 2011 04:31:05 -0000 Received: (qmail 28911 invoked by uid 22791); 11 Mar 2011 04:31:00 -0000 X-SWARE-Spam-Status: No, hits=-1.6 required=5.0 tests=AWL, BAYES_00, TW_TM, 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; Fri, 11 Mar 2011 04:30:55 +0000 Received: (qmail 1872 invoked from network); 11 Mar 2011 04:24:13 -0000 Received: from unknown (HELO codesourcery.com) (froydnj@127.0.0.2) by mail.codesourcery.com with ESMTPA; 11 Mar 2011 04:24:13 -0000 From: Nathan Froyd To: gcc-patches@gcc.gnu.org Cc: Nathan Froyd , fortran@gcc.gnu.org, java-patches@gcc.gnu.org Subject: [PATCH 17/18] introduce block_chainon and use BLOCK_CHAIN more Date: Thu, 10 Mar 2011 23:23:25 -0500 Message-Id: <1299817406-16745-18-git-send-email-froydnj@codesourcery.com> In-Reply-To: <1299817406-16745-1-git-send-email-froydnj@codesourcery.com> References: <1299817406-16745-1-git-send-email-froydnj@codesourcery.com> 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 BLOCKs have a TREE_CHAIN and a TREE_TYPE; TREE_TYPE is useless for blocks, but we can't remove TREE_TYPE without also removing TREE_CHAIN. This patch lays the groundwork to do just that. It changes places that use chainon on BLOCKs to use block_chainon, which works identically to chainon except it uses BLOCK_CHAIN. And it fixes up a few places that used TREE_CHAIN when they meant BLOCK_CHAIN. -Nathan gcc/ada/ * gcc-interface/utils.c (gnat_poplevel): Use block_chainon. gcc/ * function.h (block_chainon): Declare. * function.c (block_chainon): Define. gcc/cp/ * decl.c (poplevel): Use block_chainon. gcc/fortran/ * f95-lang.c (poplevel): Use BLOCK_CHAIN and block_chainon. gcc/java/ * decl.c (poplevel): Use BLOCK_CHAIN and block_chainon. diff --git a/gcc/ada/gcc-interface/utils.c b/gcc/ada/gcc-interface/utils.c index eac87e0..dd06ca3 100644 --- a/gcc/ada/gcc-interface/utils.c +++ b/gcc/ada/gcc-interface/utils.c @@ -395,8 +395,8 @@ gnat_poplevel (void) else if (BLOCK_VARS (block) == NULL_TREE) { BLOCK_SUBBLOCKS (level->chain->block) - = chainon (BLOCK_SUBBLOCKS (block), - BLOCK_SUBBLOCKS (level->chain->block)); + = block_chainon (BLOCK_SUBBLOCKS (block), + BLOCK_SUBBLOCKS (level->chain->block)); BLOCK_CHAIN (block) = free_block_chain; free_block_chain = block; } diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index a0ef39f..de96ac2 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -794,7 +794,7 @@ poplevel (int keep, int reverse, int functionbody) } else if (block) current_binding_level->blocks - = chainon (current_binding_level->blocks, block); + = block_chainon (current_binding_level->blocks, block); /* If we did not make a block for the level just exited, any blocks made for inner levels @@ -803,7 +803,7 @@ poplevel (int keep, int reverse, int functionbody) of something else. */ else if (subblocks) current_binding_level->blocks - = chainon (current_binding_level->blocks, subblocks); + = block_chainon (current_binding_level->blocks, subblocks); /* Each and every BLOCK node created here in `poplevel' is important (e.g. for proper debugging information) so if we created one diff --git a/gcc/fortran/f95-lang.c b/gcc/fortran/f95-lang.c index 687f60b..aebe397 100644 --- a/gcc/fortran/f95-lang.c +++ b/gcc/fortran/f95-lang.c @@ -444,7 +444,7 @@ poplevel (int keep, int reverse, int functionbody) /* Record the BLOCK node just built as the subblock its enclosing scope. */ for (subblock_node = subblock_chain; subblock_node; - subblock_node = TREE_CHAIN (subblock_node)) + subblock_node = BLOCK_CHAIN (subblock_node)) BLOCK_SUPERCONTEXT (subblock_node) = block_node; /* Clear out the meanings of the local variables of this level. */ @@ -475,7 +475,7 @@ poplevel (int keep, int reverse, int functionbody) else if (block_node) { current_binding_level->blocks - = chainon (current_binding_level->blocks, block_node); + = block_chainon (current_binding_level->blocks, block_node); } /* If we did not make a block for the level just exited, any blocks made for @@ -484,7 +484,7 @@ poplevel (int keep, int reverse, int functionbody) else. */ else if (subblock_chain) current_binding_level->blocks - = chainon (current_binding_level->blocks, subblock_chain); + = block_chainon (current_binding_level->blocks, subblock_chain); if (block_node) TREE_USED (block_node) = 1; diff --git a/gcc/function.c b/gcc/function.c index 3f721fb..094cf74 100644 --- a/gcc/function.c +++ b/gcc/function.c @@ -4167,6 +4167,34 @@ blocks_nreverse (tree t) return prev; } +/* Concatenate two chains of blocks (chained through BLOCK_CHAIN) + by modifying the last node in chain 1 to point to chain 2. */ + +tree +block_chainon (tree op1, tree op2) +{ + tree t1; + + if (!op1) + return op2; + if (!op2) + return op1; + + for (t1 = op1; BLOCK_CHAIN (t1); t1 = BLOCK_CHAIN (t1)) + continue; + BLOCK_CHAIN (t1) = op2; + +#ifdef ENABLE_TREE_CHECKING + { + tree t2; + for (t2 = op2; t2; t2 = BLOCK_CHAIN (t2)) + gcc_assert (t2 != t1); + } +#endif + + return op1; +} + /* Count the subblocks of the list starting with BLOCK. If VECTOR is non-NULL, list them all into VECTOR, in a depth-first preorder traversal of the block tree. Also clear TREE_ASM_WRITTEN in all diff --git a/gcc/function.h b/gcc/function.h index 6e7f539..73af294 100644 --- a/gcc/function.h +++ b/gcc/function.h @@ -713,6 +713,7 @@ extern void number_blocks (tree); extern void clear_block_marks (tree); extern tree blocks_nreverse (tree); +extern tree block_chainon (tree, tree); /* Return size needed for stack frame based on slots so far allocated. This size counts from zero. It is not rounded to STACK_BOUNDARY; diff --git a/gcc/java/decl.c b/gcc/java/decl.c index a17b826..6e94dff 100644 --- a/gcc/java/decl.c +++ b/gcc/java/decl.c @@ -1481,7 +1481,7 @@ poplevel (int keep, int reverse, int functionbody) /* In each subblock, record that this is its superior. */ - for (link = subblocks; link; link = TREE_CHAIN (link)) + for (link = subblocks; link; link = BLOCK_CHAIN (link)) BLOCK_SUPERCONTEXT (link) = block; /* Clear out the meanings of the local variables of this level. */ @@ -1545,7 +1545,7 @@ poplevel (int keep, int reverse, int functionbody) if (block) { current_binding_level->blocks - = chainon (current_binding_level->blocks, block); + = block_chainon (current_binding_level->blocks, block); } /* If we did not make a block for the level just exited, any blocks made for inner levels @@ -1554,7 +1554,7 @@ poplevel (int keep, int reverse, int functionbody) of something else. */ else if (subblocks) current_binding_level->blocks - = chainon (current_binding_level->blocks, subblocks); + = block_chainon (current_binding_level->blocks, subblocks); if (bind) java_add_stmt (bind);