This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] make LABEL_DECL has its own rtx field for its associated CODE_LABEL
- From: Nathan Froyd <froydnj at codesourcery dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Sun, 3 Apr 2011 21:58:50 -0400
- Subject: [PATCH] make LABEL_DECL has its own rtx field for its associated CODE_LABEL
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;
};