From patchwork Mon Apr 4 01:58:50 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Froyd X-Patchwork-Id: 89573 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 C7AA1B6F86 for ; Mon, 4 Apr 2011 11:59:06 +1000 (EST) Received: (qmail 22593 invoked by alias); 4 Apr 2011 01:59:03 -0000 Received: (qmail 22518 invoked by uid 22791); 4 Apr 2011 01:59:01 -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; Mon, 04 Apr 2011 01:58:56 +0000 Received: (qmail 22183 invoked from network); 4 Apr 2011 01:58:54 -0000 Received: from unknown (HELO codesourcery.com) (froydnj@127.0.0.2) by mail.codesourcery.com with ESMTPA; 4 Apr 2011 01:58:54 -0000 Date: Sun, 3 Apr 2011 21:58:50 -0400 From: Nathan Froyd To: gcc-patches@gcc.gnu.org Subject: [PATCH] make LABEL_DECL has its own rtx field for its associated CODE_LABEL Message-ID: <20110404015850.GB16239@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 This patch does just what $SUBJECT suggests: pushes down the DECL_RTL field into LABEL_DECL. In this way, LABEL_DECL can inherit from tree_decl_common instead of tree_decl_with_rtl. I realize this looks like pure code shuffling; the reason for doing this is that I want to split tree_decl_common into two structures: one that includes DECL_SIZE and DECL_SIZE_UNIT and one that doesn't. The latter can then be used for CONST_DECL, LABEL_DECL, and--possibly--RESULT_DECL and--*maybe*--PARM_DECL. (Once the latter two have DECL_RTL "pushed down" as well, of course.) And I think that less multipurposing of DECL_RTL is not a bad thing. Tested on x86_64-unknown-linux-gnu. OK to commit? -Nathan * tree.h (struct tree_label_decl): Inherit from tree_decl_common. Add `label' field. (LABEL_DECL_CODE_LABEL): New macro. * stmt.c (label_rtx): Use it. (expand_label): Use `label_r', rather than fetching DECL_RTL. * tree.c (initialize_tree_contains_struct): Adjust LABEL_DECL inheritance and tree_contains_struct asserts. diff --git a/gcc/stmt.c b/gcc/stmt.c index 1a9f9e5..13a906f 100644 --- a/gcc/stmt.c +++ b/gcc/stmt.c @@ -135,17 +135,15 @@ static struct case_node *add_case_node (struct case_node *, tree, rtx label_rtx (tree label) { - gcc_assert (TREE_CODE (label) == LABEL_DECL); - - if (!DECL_RTL_SET_P (label)) + if (!LABEL_DECL_CODE_LABEL (label)) { rtx r = gen_label_rtx (); - SET_DECL_RTL (label, r); + LABEL_DECL_CODE_LABEL (label) = r; if (FORCED_LABEL (label) || DECL_NONLOCAL (label)) LABEL_PRESERVE_P (r) = 1; } - return DECL_RTL (label); + return LABEL_DECL_CODE_LABEL (label); } /* As above, but also put it on the forced-reference list of the @@ -207,7 +205,7 @@ expand_label (tree label) do_pending_stack_adjust (); emit_label (label_r); if (DECL_NAME (label)) - LABEL_NAME (DECL_RTL (label)) = IDENTIFIER_POINTER (DECL_NAME (label)); + LABEL_NAME (label_r) = IDENTIFIER_POINTER (DECL_NAME (label)); if (DECL_NONLOCAL (label)) { diff --git a/gcc/tree.c b/gcc/tree.c index ee47982..3c2154f 100644 --- a/gcc/tree.c +++ b/gcc/tree.c @@ -440,6 +440,7 @@ initialize_tree_contains_struct (void) case TS_DECL_WRTL: case TS_CONST_DECL: + case TS_LABEL_DECL: MARK_TS_DECL_COMMON (code); break; @@ -449,7 +450,6 @@ initialize_tree_contains_struct (void) case TS_DECL_WITH_VIS: case TS_PARM_DECL: - case TS_LABEL_DECL: case TS_RESULT_DECL: MARK_TS_DECL_WRTL (code); break; @@ -492,7 +492,6 @@ initialize_tree_contains_struct (void) gcc_assert (tree_contains_struct[PARM_DECL][TS_DECL_WRTL]); gcc_assert (tree_contains_struct[RESULT_DECL][TS_DECL_WRTL]); gcc_assert (tree_contains_struct[FUNCTION_DECL][TS_DECL_WRTL]); - gcc_assert (tree_contains_struct[LABEL_DECL][TS_DECL_WRTL]); gcc_assert (tree_contains_struct[CONST_DECL][TS_DECL_MINIMAL]); gcc_assert (tree_contains_struct[VAR_DECL][TS_DECL_MINIMAL]); gcc_assert (tree_contains_struct[PARM_DECL][TS_DECL_MINIMAL]); diff --git a/gcc/tree.h b/gcc/tree.h index fcdebd9..952e13d 100644 --- a/gcc/tree.h +++ b/gcc/tree.h @@ -2940,6 +2940,11 @@ struct GTY(()) tree_field_decl { #define LABEL_DECL_UID(NODE) \ (LABEL_DECL_CHECK (NODE)->label_decl.label_decl_uid) +/* The CODE_LABEL associated with a LABEL_DECL. This macro should not + be used directly; use label_rtx instead. */ +#define LABEL_DECL_CODE_LABEL(NODE) \ + (LABEL_DECL_CHECK (NODE)->label_decl.label) + /* In a LABEL_DECL, the EH region number for which the label is the post_landing_pad. */ #define EH_LANDING_PAD_NR(NODE) \ @@ -2951,7 +2956,8 @@ struct GTY(()) tree_field_decl { (LABEL_DECL_CHECK (NODE)->decl_common.decl_flag_0) struct GTY(()) tree_label_decl { - struct tree_decl_with_rtl common; + struct tree_decl_common common; + rtx label; int label_decl_uid; int eh_landing_pad_nr; };