From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17750 invoked by alias); 11 Mar 2011 04:23:55 -0000 Received: (qmail 17656 invoked by uid 22791); 11 Mar 2011 04:23:53 -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; Fri, 11 Mar 2011 04:23:48 +0000 Received: (qmail 1607 invoked from network); 11 Mar 2011 04:23:46 -0000 Received: from unknown (HELO codesourcery.com) (froydnj@127.0.0.2) by mail.codesourcery.com with ESMTPA; 11 Mar 2011 04:23:46 -0000 From: Nathan Froyd To: gcc-patches@gcc.gnu.org Cc: Nathan Froyd Subject: [PATCH 06/18] define CASE_CHAIN accessor for CASE_LABEL_EXPR Date: Fri, 11 Mar 2011 04:24:00 -0000 Message-Id: <1299817406-16745-7-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-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2011-03/txt/msg00556.txt.bz2 This patch begins a subseries of patches aimed at removing TREE_CHAIN from expression trees. tree-cfg.c uses TREE_CHAIN for some analysis steps on CASE_LABEL_EXPRs. I looked at this for a while, thinking it'd be easy to use VECs instead, but AFAICS, it wasn't. I went for the next best thing, hiding TREE_CHAIN usage behind CASE_CHAIN; doing this will enable swapping out the TREE_CHAIN for a TREE_OPERAND at a later point. -Nathan * tree.h (CASE_CHAIN): Define. * tree-cfg.c (edge_to_cases_cleanup, get_cases_for_edge): Use it. (gimple_redirect_edge_and_branch): Likewise. diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c index 1f533a3..bdce4cb 100644 --- a/gcc/tree-cfg.c +++ b/gcc/tree-cfg.c @@ -838,8 +838,8 @@ edge_to_cases_cleanup (const void *key ATTRIBUTE_UNUSED, void **value, for (t = (tree) *value; t; t = next) { - next = TREE_CHAIN (t); - TREE_CHAIN (t) = NULL; + next = CASE_CHAIN (t); + CASE_CHAIN (t) = NULL; } *value = NULL; @@ -922,7 +922,7 @@ get_cases_for_edge (edge e, gimple t) /* Add it to the chain of CASE_LABEL_EXPRs referencing E, or create a new chain. */ slot = pointer_map_insert (edge_to_cases, this_edge); - TREE_CHAIN (elt) = (tree) *slot; + CASE_CHAIN (elt) = (tree) *slot; *slot = elt; } @@ -4900,7 +4900,7 @@ gimple_redirect_edge_and_branch (edge e, basic_block dest) { last = cases; CASE_LABEL (cases) = label; - cases = TREE_CHAIN (cases); + cases = CASE_CHAIN (cases); } /* If there was already an edge in the CFG, then we need @@ -4909,8 +4909,8 @@ gimple_redirect_edge_and_branch (edge e, basic_block dest) { tree cases2 = get_cases_for_edge (e2, stmt); - TREE_CHAIN (last) = TREE_CHAIN (cases2); - TREE_CHAIN (cases2) = first; + CASE_CHAIN (last) = CASE_CHAIN (cases2); + CASE_CHAIN (cases2) = first; } bitmap_set_bit (touched_switch_bbs, gimple_bb (stmt)->index); } diff --git a/gcc/tree.h b/gcc/tree.h index 35479f9..58b3b9d 100644 --- a/gcc/tree.h +++ b/gcc/tree.h @@ -1689,6 +1689,7 @@ extern void protected_set_expr_location (tree, location_t); #define CASE_LOW(NODE) TREE_OPERAND (CASE_LABEL_EXPR_CHECK (NODE), 0) #define CASE_HIGH(NODE) TREE_OPERAND (CASE_LABEL_EXPR_CHECK (NODE), 1) #define CASE_LABEL(NODE) TREE_OPERAND (CASE_LABEL_EXPR_CHECK (NODE), 2) +#define CASE_CHAIN(NODE) TREE_CHAIN (CASE_LABEL_EXPR_CHECK (NODE)) /* The operands of a TARGET_MEM_REF. Operands 0 and 1 have to match corresponding MEM_REF operands. */ -- 1.7.0.4