[gcjx] Patch: FYI: make LABEL_DECLs artificial
Tom Tromey
tromey@redhat.com
Wed May 18 00:10:00 GMT 2005
I'm checking this in on the gcjx branch.
After the vectorization thread it seemed like a good idea to set
DECL_ARTIFICIAL on compiler-generated LABEL_DECLs.
Tom
Index: ChangeLog
from Tom Tromey <tromey@redhat.com>
* lower.cc (visit_bytecode_block): Use build_label.
(find_label): Set DECL_ARTIFICIAL.
* tree.hh (tree_generator::build_label): Declare.
* tree.cc (build_label): New method.
(visit_do): Use it.
(visit_for_enhanced): Likewise.
(visit_for): Likewise.
(visit_switch): Likewise.
(visit_switch_block): Likewise.
(visit_while): Likewise.
Index: lower.cc
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/Attic/lower.cc,v
retrieving revision 1.1.2.19
diff -u -r1.1.2.19 lower.cc
--- lower.cc 29 Apr 2005 03:01:07 -0000 1.1.2.19
+++ lower.cc 18 May 2005 00:09:36 -0000
@@ -1088,8 +1088,7 @@
for (int i = low; i < high; ++i)
{
- tree label = build0 (LABEL_DECL, NULL_TREE);
- DECL_CONTEXT (label) = current_block;
+ tree label = build_label ();
int where = base_pc + get4 (bytes, pc);
tree case_label = build3 (CASE_LABEL_EXPR, NULL_TREE,
@@ -1100,8 +1099,7 @@
TSI_CONTINUE_LINKING);
}
- tree label = build0 (LABEL_DECL, NULL_TREE);
- DECL_CONTEXT (label) = current_block;
+ tree label = build_label ();
tree def_label = build3 (CASE_LABEL_EXPR, void_type_node,
NULL_TREE, NULL_TREE, label);
tsi_link_after (&out, def_label, TSI_CONTINUE_LINKING);
@@ -1134,8 +1132,7 @@
int match = get4 (bytes, pc);
int dest = base_pc + get4 (bytes, pc);
- tree label = build0 (LABEL_DECL, NULL_TREE);
- DECL_CONTEXT (label) = current_block;
+ tree label = build_label ();
tree case_label = build3 (CASE_LABEL_EXPR, void_type_node,
build_int (match), NULL_TREE,
@@ -1146,8 +1143,7 @@
TSI_CONTINUE_LINKING);
}
- tree label = build0 (LABEL_DECL, NULL_TREE);
- DECL_CONTEXT (label) = current_block;
+ tree label = build_label ();
tree def_label = build3 (CASE_LABEL_EXPR, void_type_node,
NULL_TREE, NULL_TREE, label);
@@ -1716,6 +1712,7 @@
labels[pc] = build_decl (LABEL_DECL, get_identifier (buf), NULL_TREE);
DECL_CONTEXT (labels[pc]) = method_tree;
DECL_IGNORED_P (labels[pc]) = 1;
+ DECL_ARTIFICIAL (labels[pc]) = 1;
}
return labels[pc];
}
Index: tree.cc
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/Attic/tree.cc,v
retrieving revision 1.1.2.45
diff -u -r1.1.2.45 tree.cc
--- tree.cc 29 Apr 2005 03:01:07 -0000 1.1.2.45
+++ tree.cc 18 May 2005 00:09:37 -0000
@@ -110,6 +110,15 @@
return result;
}
+tree
+tree_generator::build_label ()
+{
+ tree result = build0 (LABEL_DECL, NULL_TREE);
+ DECL_CONTEXT (result) = current_block;
+ DECL_ARTIFICIAL (result) = 1;
+ return result;
+}
+
void
@@ -533,10 +542,8 @@
const ref_stmt &body)
{
// Some labels which we'll use later.
- tree test = build0 (LABEL_DECL, NULL_TREE);
- DECL_CONTEXT (test) = current_block;
- tree done = build0 (LABEL_DECL, NULL_TREE);
- DECL_CONTEXT (done) = current_block;
+ tree test = build_label ();
+ tree done = build_label ();
target_map[dstmt] = std::make_pair (test, done);
// Generate code for the expression and the body.
@@ -590,10 +597,8 @@
const ref_expression &container,
const ref_variable_decl &var)
{
- tree update_tree = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE);
- DECL_CONTEXT (update_tree) = current_block;
- tree done_tree = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE);
- DECL_CONTEXT (done_tree) = current_block;
+ tree update_tree = build_label ();
+ tree done_tree = build_label ();
target_map[fstmt] = std::make_pair (update_tree, done_tree);
// Push a new block around the loop.
@@ -755,10 +760,8 @@
const ref_stmt &update,
const ref_stmt &body)
{
- tree update_tree = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE);
- DECL_CONTEXT (update_tree) = current_block;
- tree done_tree = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE);
- DECL_CONTEXT (done_tree) = current_block;
+ tree update_tree = build_label ();
+ tree done_tree = build_label ();
target_map[fstmt] = std::make_pair (update_tree, done_tree);
save_tree saver (current_block, make_node (BLOCK));
@@ -843,6 +846,8 @@
// analysis time, so we compute it here.
if (label->get_break_target () == NULL)
{
+ // Note that we don't use build_label() here since this is not
+ // an artificial label.
tree brk = build0 (LABEL_DECL, NULL_TREE);
DECL_CONTEXT (brk) = current_block;
target_map[label] = std::make_pair (NULL_TREE, brk);
@@ -886,8 +891,7 @@
expr->visit (this);
tree expr_tree = current;
- tree done = build0 (LABEL_DECL, NULL_TREE);
- DECL_CONTEXT (done) = current_block;
+ tree done = build_label ();
target_map[swstmt] = std::make_pair (NULL_TREE, done);
tree body_tree = alloc_stmt_list ();
@@ -900,8 +904,7 @@
{
if ((*i).get () == def)
{
- tree label = build0 (LABEL_DECL, NULL_TREE);
- DECL_CONTEXT (label) = current_block;
+ tree label = build_label ();
tree case_label = build3 (CASE_LABEL_EXPR, NULL_TREE, NULL_TREE,
NULL_TREE, label);
@@ -940,8 +943,7 @@
i != labels.end ();
++i)
{
- tree label = build0 (LABEL_DECL, NULL_TREE);
- DECL_CONTEXT (label) = current_block;
+ tree label = build_label ();
jint value = jint (intb->convert ((*i)->type (), (*i)->value ()));
tree new_label = build3 (CASE_LABEL_EXPR, NULL_TREE, build_int (value),
@@ -1086,10 +1088,8 @@
const ref_expression &cond,
const ref_stmt &body)
{
- tree again = build0 (LABEL_DECL, NULL_TREE);
- DECL_CONTEXT (again) = current_block;
- tree done = build0 (LABEL_DECL, NULL_TREE);
- DECL_CONTEXT (done) = current_block;
+ tree again = build_label ();
+ tree done = build_label ();
target_map[wstmt] = std::make_pair (again, done);
// Create the body of the loop: first the 'again' label, then the
Index: tree.hh
===================================================================
RCS file: /cvs/gcc/gcc/gcc/java/Attic/tree.hh,v
retrieving revision 1.1.2.13
diff -u -r1.1.2.13 tree.hh
--- tree.hh 4 Apr 2005 04:30:32 -0000 1.1.2.13
+++ tree.hh 18 May 2005 00:09:37 -0000
@@ -132,6 +132,7 @@
tree build_mod (tree, tree, tree);
tree build_array_reference (tree, tree, tree, bool = true);
tree build_exception_object_ref (tree);
+ tree build_label ();
void stringbuffer_append (model_expression *, tree &, model_class *,
tree = NULL_TREE);
More information about the Java-patches
mailing list