expr.c (expand_expr_real_1): Remove cases for EXIT_BLOCK_EXPR and LABELED_BLOCK_EXPR.

gcc/
	* expr.c (expand_expr_real_1): Remove cases for EXIT_BLOCK_EXPR
	and LABELED_BLOCK_EXPR.
	* gimplify.c (gimplify_labeled_block_expr): Remove.
	(gimplify_exit_block_expr): Remove.
	(gimplify_expr): Don't call them.
	* tree-inline.c (copy_body_r): Don't handle EXIT_BLOCK_EXPR
	and LABELED_BLOCK_EXPR.
	(estimate_num_insns_1): Likewise.
	(walk_tree): Likewise.
	* tree-pretty-print.c (dump_generic_node): Don't handle
	EXIT_BLOCK_EXPR and LABELED_BLOCK_EXPR.
	* tree.def (EXIT_BLOCK_EXPR): Moved to java-tree.def.
	(LABELED_BLOCK_EXPR): Likewise.
	* tree.h (LABELED_BLOCK_LABEL): Moved to java-tree.h.
	(LABELED_BLOCK_BODY): Likewise.
	(EXIT_BLOCK_LABELED_BLOCK): Likewise.
	(EXIT_BLOCK_RETURN): Removed.

java/
	* java-gimplify.c (java_gimplify_labeled_block_expr): New function.
	(java_gimplify_exit_block_expr): New function.
	(java_gimplify_expr): Use them to gimplify EXIT_BLOCK_EXPR and
	LABELED_BLOCK_EXPR.
	* java-tree.def (LABELED_BLOCK_EXPR): Moved from tree.def.
	(EXIT_BLOCK_EXPR): Likewise.
	* java-tree.h (LABELED_BLOCK_LABEL): Moved from tree.h.
	(LABELED_BLOCK_BODY): Likewise.
	(EXIT_BLOCK_LABELED_BLOCK): Likewise.
	* jcf-write.c (generate_bytecode_insns): Don't handle the unused
	EXIT_BLOCK_RETURN operand.  Use EXIT_BLOCK_LABELED_BLOCK instead of
	TREE_OPERAND.
	* lang.c (java_tree_inlining_walk_subtrees): Handle EXIT_BLOCK_EXPR.
	(java_dump_tree): Use LABELED_BLOCK_LABEL, LABELED_BLOCK_BODY, and
	EXIT_BLOCK_LABELED_BLOCK instead of TREE_OPERAND.  Don't handle the
	second operand of EXIT_BLOCK_EXPR.
	* parse.y (find_expr_with_wfl): Use LABELED_BLOCK_BODY instead of
	TREE_OPERAND.
	(build_bc_statement): Use build1 to build EXIT_BLOCK_EXPR nodes.

From-SVN: r91149
This commit is contained in:
Steven Bosscher 2004-11-24 11:41:38 +00:00
parent f39e46bac1
commit 16df8078b8
14 changed files with 115 additions and 149 deletions

View File

@ -1,3 +1,23 @@
2004-11-24 Steven Bosscher <stevenb@suse.de>
* expr.c (expand_expr_real_1): Remove cases for EXIT_BLOCK_EXPR
and LABELED_BLOCK_EXPR.
* gimplify.c (gimplify_labeled_block_expr): Remove.
(gimplify_exit_block_expr): Remove.
(gimplify_expr): Don't call them.
* tree-inline.c (copy_body_r): Don't handle EXIT_BLOCK_EXPR
and LABELED_BLOCK_EXPR.
(estimate_num_insns_1): Likewise.
(walk_tree): Likewise.
* tree-pretty-print.c (dump_generic_node): Don't handle
EXIT_BLOCK_EXPR and LABELED_BLOCK_EXPR.
* tree.def (EXIT_BLOCK_EXPR): Moved to java-tree.def.
(LABELED_BLOCK_EXPR): Likewise.
* tree.h (LABELED_BLOCK_LABEL): Moved to java-tree.h.
(LABELED_BLOCK_BODY): Likewise.
(EXIT_BLOCK_LABELED_BLOCK): Likewise.
(EXIT_BLOCK_RETURN): Removed.
2004-11-24 Steven Bosscher <stevenb@suse.de>
* cfgrtl.c (rtl_delete_block): Fix comment.
@ -88,7 +108,7 @@
(record_jump_cond): Use it instead of gen_lowpart.
2004-11-23 Daniel Jacobowitz <dan@codesourcery.com>
Joseph Myers <joseph@codesourcery.com>
Joseph Myers <joseph@codesourcery.com>
* config/sol2-c.c (solaris_register_pragmas): Use
c_register_pragma_with_expansion.

View File

@ -8124,8 +8124,6 @@ expand_expr_real_1 (tree exp, rtx target, enum machine_mode tmode,
case POSTDECREMENT_EXPR:
case LOOP_EXPR:
case EXIT_EXPR:
case LABELED_BLOCK_EXPR:
case EXIT_BLOCK_EXPR:
case TRUTH_ANDIF_EXPR:
case TRUTH_ORIF_EXPR:
/* Lowered by gimplify.c. */

View File

@ -1210,43 +1210,6 @@ gimplify_case_label_expr (tree *expr_p)
return GS_ALL_DONE;
}
/* Gimplify a LABELED_BLOCK_EXPR into a LABEL_EXPR following
a (possibly empty) body. */
static enum gimplify_status
gimplify_labeled_block_expr (tree *expr_p)
{
tree body = LABELED_BLOCK_BODY (*expr_p);
tree label = LABELED_BLOCK_LABEL (*expr_p);
tree t;
DECL_CONTEXT (label) = current_function_decl;
t = build (LABEL_EXPR, void_type_node, label);
if (body != NULL_TREE)
t = build (COMPOUND_EXPR, void_type_node, body, t);
*expr_p = t;
return GS_OK;
}
/* Gimplify a EXIT_BLOCK_EXPR into a GOTO_EXPR. */
static enum gimplify_status
gimplify_exit_block_expr (tree *expr_p)
{
tree labeled_block = TREE_OPERAND (*expr_p, 0);
tree label;
/* First operand must be a LABELED_BLOCK_EXPR, which should
already be lowered (or partially lowered) when we get here. */
gcc_assert (TREE_CODE (labeled_block) == LABELED_BLOCK_EXPR);
label = LABELED_BLOCK_LABEL (labeled_block);
*expr_p = build1 (GOTO_EXPR, void_type_node, label);
return GS_OK;
}
/* Build a GOTO to the LABEL_DECL pointed to by LABEL_P, building it first
if necessary. */
@ -3703,14 +3666,6 @@ gimplify_expr (tree *expr_p, tree *pre_p, tree *post_p,
ret = gimplify_switch_expr (expr_p, pre_p);
break;
case LABELED_BLOCK_EXPR:
ret = gimplify_labeled_block_expr (expr_p);
break;
case EXIT_BLOCK_EXPR:
ret = gimplify_exit_block_expr (expr_p);
break;
case EXIT_EXPR:
ret = gimplify_exit_expr (expr_p);
break;

View File

@ -1,3 +1,25 @@
2004-11-24 Steven Bosscher <stevenb@suse.de>
* java-gimplify.c (java_gimplify_labeled_block_expr): New function.
(java_gimplify_exit_block_expr): New function.
(java_gimplify_expr): Use them to gimplify EXIT_BLOCK_EXPR and
LABELED_BLOCK_EXPR.
* java-tree.def (LABELED_BLOCK_EXPR): Moved from tree.def.
(EXIT_BLOCK_EXPR): Likewise.
* java-tree.h (LABELED_BLOCK_LABEL): Moved from tree.h.
(LABELED_BLOCK_BODY): Likewise.
(EXIT_BLOCK_LABELED_BLOCK): Likewise.
* jcf-write.c (generate_bytecode_insns): Don't handle the unused
EXIT_BLOCK_RETURN operand. Use EXIT_BLOCK_LABELED_BLOCK instead of
TREE_OPERAND.
* lang.c (java_tree_inlining_walk_subtrees): Handle EXIT_BLOCK_EXPR.
(java_dump_tree): Use LABELED_BLOCK_LABEL, LABELED_BLOCK_BODY, and
EXIT_BLOCK_LABELED_BLOCK instead of TREE_OPERAND. Don't handle the
second operand of EXIT_BLOCK_EXPR.
* parse.y (find_expr_with_wfl): Use LABELED_BLOCK_BODY instead of
TREE_OPERAND.
(build_bc_statement): Use build1 to build EXIT_BLOCK_EXPR nodes.
2004-11-23 Ben Elliston <bje@au.ibm.com>
* xref.h (xref_flag_value): Remove.

View File

@ -32,6 +32,8 @@ The Free Software Foundation is independent of Sun Microsystems, Inc. */
#include "tree-gimple.h"
#include "toplev.h"
static tree java_gimplify_labeled_block_expr (tree);
static tree java_gimplify_exit_block_expr (tree);
static tree java_gimplify_case_expr (tree);
static tree java_gimplify_default_expr (tree);
static tree java_gimplify_block (tree);
@ -79,6 +81,14 @@ java_gimplify_expr (tree *expr_p, tree *pre_p ATTRIBUTE_UNUSED,
SET_EXPR_LOCATION (*expr_p, input_location);
break;
case LABELED_BLOCK_EXPR:
*expr_p = java_gimplify_labeled_block_expr (*expr_p);
break;
case EXIT_BLOCK_EXPR:
*expr_p = java_gimplify_exit_block_expr (*expr_p);
break;
case CASE_EXPR:
*expr_p = java_gimplify_case_expr (*expr_p);
break;
@ -164,6 +174,39 @@ java_gimplify_expr (tree *expr_p, tree *pre_p ATTRIBUTE_UNUSED,
return GS_OK;
}
/* Gimplify a LABELED_BLOCK_EXPR into a LABEL_EXPR following
a (possibly empty) body. */
static tree
java_gimplify_labeled_block_expr (tree expr)
{
tree body = LABELED_BLOCK_BODY (expr);
tree label = LABELED_BLOCK_LABEL (expr);
tree t;
DECL_CONTEXT (label) = current_function_decl;
t = build (LABEL_EXPR, void_type_node, label);
if (body != NULL_TREE)
t = build (COMPOUND_EXPR, void_type_node, body, t);
return t;
}
/* Gimplify a EXIT_BLOCK_EXPR into a GOTO_EXPR. */
static tree
java_gimplify_exit_block_expr (tree expr)
{
tree labeled_block = EXIT_BLOCK_LABELED_BLOCK (expr);
tree label;
/* First operand must be a LABELED_BLOCK_EXPR, which should
already be lowered (or partially lowered) when we get here. */
gcc_assert (TREE_CODE (labeled_block) == LABELED_BLOCK_EXPR);
label = LABELED_BLOCK_LABEL (labeled_block);
return build1 (GOTO_EXPR, void_type_node, label);
}
/* This is specific to the bytecode compiler. If a variable has
LOCAL_SLOT_P set, replace an assignment to it with an assignment to
the corresponding variable that holds all its aliases. */

View File

@ -41,6 +41,14 @@ DEFTREECODE (NEW_CLASS_EXPR, "new_class_expr", tcc_expression, 3)
/* Defines `this' as an expression. */
DEFTREECODE (THIS_EXPR, "this", tcc_unary, 0)
/* A labeled block. Operand 0 is the label that will be generated to
mark the end of the block. Operand 1 is the labeled block body. */
DEFTREECODE (LABELED_BLOCK_EXPR, "labeled_block_expr", tcc_expression, 2)
/* Exit a labeled block, possibly returning a value. Operand 0 is a
LABELED_BLOCK_EXPR to exit. */
DEFTREECODE (EXIT_BLOCK_EXPR, "exit_block_expr", tcc_statement, 1)
/* Case statement expression.
Operand 1 is the case value. */
DEFTREECODE (CASE_EXPR, "case", tcc_expression, 1)

View File

@ -1815,6 +1815,16 @@ enum
#undef DEBUG_JAVA_BINDING_LEVELS
/* In a LABELED_BLOCK_EXPR node. */
#define LABELED_BLOCK_LABEL(NODE) \
TREE_OPERAND_CHECK_CODE (NODE, LABELED_BLOCK_EXPR, 0)
#define LABELED_BLOCK_BODY(NODE) \
TREE_OPERAND_CHECK_CODE (NODE, LABELED_BLOCK_EXPR, 1)
/* In an EXIT_BLOCK_EXPR node. */
#define EXIT_BLOCK_LABELED_BLOCK(NODE) \
TREE_OPERAND_CHECK_CODE (NODE, EXIT_BLOCK_EXPR, 0)
/* In an EXPR_WITH_FILE_LOCATION node. */
#define EXPR_WFL_EMIT_LINE_NOTE(NODE) \
(EXPR_WITH_FILE_LOCATION_CHECK (NODE)->common.public_flag)

View File

@ -1898,8 +1898,7 @@ generate_bytecode_insns (tree exp, int target, struct jcf_partial *state)
case EXIT_BLOCK_EXPR:
{
struct jcf_block *label = state->labeled_blocks;
if (TREE_OPERAND (exp, 1) != NULL) goto notimpl;
while (label->u.labeled_block != TREE_OPERAND (exp, 0))
while (label->u.labeled_block != EXIT_BLOCK_LABELED_BLOCK (exp))
label = label->next;
call_cleanups (label, state);
emit_goto (label, state);
@ -2653,7 +2652,6 @@ generate_bytecode_insns (tree exp, int target, struct jcf_partial *state)
}
}
/* fall through */
notimpl:
default:
error("internal error in generate_bytecode_insn - tree code not implemented: %s",
tree_code_name [(int) TREE_CODE (exp)]);

View File

@ -731,6 +731,10 @@ java_tree_inlining_walk_subtrees (tree *tp ATTRIBUTE_UNUSED,
WALK_SUBTREE (BLOCK_EXPR_BODY (t));
return NULL_TREE;
case EXIT_BLOCK_EXPR:
*subtrees = 0;
return NULL_TREE;
default:
return NULL_TREE;
}
@ -921,13 +925,12 @@ java_dump_tree (void *dump_info, tree t)
return true;
case LABELED_BLOCK_EXPR:
dump_child ("label", TREE_OPERAND (t, 0));
dump_child ("block", TREE_OPERAND (t, 1));
dump_child ("label", LABELED_BLOCK_LABEL (t));
dump_child ("block", LABELED_BLOCK_BODY (t));
return true;
case EXIT_BLOCK_EXPR:
dump_child ("block", TREE_OPERAND (t, 0));
dump_child ("val", TREE_OPERAND (t, 1));
dump_child ("block", EXIT_BLOCK_LABELED_BLOCK (t));
return true;
case BLOCK:

View File

@ -3255,7 +3255,7 @@ find_expr_with_wfl (tree node)
continue;
case LABELED_BLOCK_EXPR:
node = TREE_OPERAND (node, 1);
node = LABELED_BLOCK_BODY (node);
continue;
default:
@ -11747,8 +11747,6 @@ java_complete_lhs (tree node)
return node;
case EXIT_BLOCK_EXPR:
/* We don't complete operand 1, because it's the return value of
the EXIT_BLOCK_EXPR which doesn't exist it Java */
return patch_bc_statement (node);
case CASE_EXPR:
@ -15269,8 +15267,7 @@ build_bc_statement (int location, int is_break, tree name)
}
/* Unlabeled break/continue will be handled during the
break/continue patch operation */
break_continue = build2 (EXIT_BLOCK_EXPR, NULL_TREE,
label_block_expr, NULL_TREE);
break_continue = build1 (EXIT_BLOCK_EXPR, NULL_TREE, label_block_expr);
IS_BREAK_STMT_P (break_continue) = is_break;
TREE_SIDE_EFFECTS (break_continue) = 1;

View File

@ -512,25 +512,6 @@ copy_body_r (tree *tp, int *walk_subtrees, void *data)
remap_save_expr (tp, id->decl_map, walk_subtrees);
else if (TREE_CODE (*tp) == BIND_EXPR)
copy_bind_expr (tp, walk_subtrees, id);
else if (TREE_CODE (*tp) == LABELED_BLOCK_EXPR)
{
/* We need a new copy of this labeled block; the EXIT_BLOCK_EXPR
will refer to it, so save a copy ready for remapping. We
save it in the decl_map, although it isn't a decl. */
tree new_block = copy_node (*tp);
insert_decl_map (id, *tp, new_block);
*tp = new_block;
}
else if (TREE_CODE (*tp) == EXIT_BLOCK_EXPR)
{
splay_tree_node n
= splay_tree_lookup (id->decl_map,
(splay_tree_key) TREE_OPERAND (*tp, 0));
/* We _must_ have seen the enclosing LABELED_BLOCK_EXPR. */
gcc_assert (n);
*tp = copy_node (*tp);
TREE_OPERAND (*tp, 0) = (tree) n->value;
}
/* Types may need remapping as well. */
else if (TYPE_P (*tp))
*tp = remap_type (*tp, id);
@ -1174,14 +1155,12 @@ estimate_num_insns_1 (tree *tp, int *walk_subtrees, void *data)
case FILTER_EXPR: /* ??? */
case COMPOUND_EXPR:
case BIND_EXPR:
case LABELED_BLOCK_EXPR:
case WITH_CLEANUP_EXPR:
case NOP_EXPR:
case VIEW_CONVERT_EXPR:
case SAVE_EXPR:
case ADDR_EXPR:
case COMPLEX_EXPR:
case EXIT_BLOCK_EXPR:
case CASE_LABEL_EXPR:
case SSA_NAME:
case CATCH_EXPR:
@ -2080,8 +2059,7 @@ walk_tree (tree *tp, walk_tree_fn func, void *data, struct pointer_set_t *pset)
}
}
else if (code != EXIT_BLOCK_EXPR
&& code != SAVE_EXPR
else if (code != SAVE_EXPR
&& code != BIND_EXPR
&& IS_EXPR_CODE_CLASS (TREE_CODE_CLASS (code)))
{
@ -2171,9 +2149,6 @@ walk_tree (tree *tp, walk_tree_fn func, void *data, struct pointer_set_t *pset)
case CONSTRUCTOR:
WALK_SUBTREE_TAIL (CONSTRUCTOR_ELTS (*tp));
case EXIT_BLOCK_EXPR:
WALK_SUBTREE_TAIL (TREE_OPERAND (*tp, 1));
case SAVE_EXPR:
WALK_SUBTREE_TAIL (TREE_OPERAND (*tp, 0));

View File

@ -1247,48 +1247,6 @@ dump_generic_node (pretty_printer *buffer, tree node, int spc, int flags,
pp_string (buffer, " [non-local]");
break;
case LABELED_BLOCK_EXPR:
op0 = LABELED_BLOCK_LABEL (node);
/* If this is for break or continue, don't bother printing it. */
if (DECL_NAME (op0))
{
const char *name = IDENTIFIER_POINTER (DECL_NAME (op0));
if (strcmp (name, "break") == 0
|| strcmp (name, "continue") == 0)
{
dump_generic_node (buffer, LABELED_BLOCK_BODY (node), spc, flags, false);
break;
}
}
dump_generic_node (buffer, LABELED_BLOCK_LABEL (node), spc, flags, false);
pp_string (buffer, ": {");
if (!(flags & TDF_SLIM))
newline_and_indent (buffer, spc+2);
dump_generic_node (buffer, LABELED_BLOCK_BODY (node), spc+2, flags, true);
if (!flags)
newline_and_indent (buffer, spc);
pp_character (buffer, '}');
is_expr = false;
break;
case EXIT_BLOCK_EXPR:
op0 = LABELED_BLOCK_LABEL (EXIT_BLOCK_LABELED_BLOCK (node));
/* If this is for a break or continue, print it accordingly. */
if (DECL_NAME (op0))
{
const char *name = IDENTIFIER_POINTER (DECL_NAME (op0));
if (strcmp (name, "break") == 0
|| strcmp (name, "continue") == 0)
{
pp_string (buffer, name);
break;
}
}
pp_string (buffer, "<<<exit block ");
dump_generic_node (buffer, op0, spc, flags, false);
pp_string (buffer, ">>>");
break;
case EXC_PTR_EXPR:
pp_string (buffer, "<<<exception object>>>");
break;

View File

@ -499,11 +499,6 @@ DEFTREECODE (VEC_COND_EXPR, "vec_cond_expr", tcc_expression, 3)
nodes for the function. */
DEFTREECODE (BIND_EXPR, "bind_expr", tcc_expression, 3)
/* A labeled block. Operand 0 is the label that will be generated to
mark the end of the block.
Operand 1 is the labeled block body. */
DEFTREECODE (LABELED_BLOCK_EXPR, "labeled_block_expr", tcc_expression, 2)
/* Function call. Operand 0 is the function.
Operand 1 is the argument list, a list of expressions
made out of a chain of TREE_LIST nodes.
@ -806,11 +801,6 @@ DEFTREECODE (EXIT_EXPR, "exit_expr", tcc_statement, 1)
The type should be void and the value should be ignored. */
DEFTREECODE (LOOP_EXPR, "loop_expr", tcc_statement, 1)
/* Exit a labeled block, possibly returning a value. Operand 0 is a
LABELED_BLOCK_EXPR to exit. Operand 1 is the value to return. It
may be left null. */
DEFTREECODE (EXIT_BLOCK_EXPR, "exit_block_expr", tcc_statement, 2)
/* Switch expression.
TREE_TYPE is the original type of the condition, before any

View File

@ -1157,17 +1157,6 @@ struct tree_vec GTY(())
#define REF_ORIGINAL(NODE) TREE_CHAIN (TREE_CHECK3 (NODE, \
INDIRECT_REF, ALIGN_INDIRECT_REF, MISALIGNED_INDIRECT_REF))
/* In a LABELED_BLOCK_EXPR node. */
#define LABELED_BLOCK_LABEL(NODE) \
TREE_OPERAND_CHECK_CODE (NODE, LABELED_BLOCK_EXPR, 0)
#define LABELED_BLOCK_BODY(NODE) \
TREE_OPERAND_CHECK_CODE (NODE, LABELED_BLOCK_EXPR, 1)
/* In an EXIT_BLOCK_EXPR node. */
#define EXIT_BLOCK_LABELED_BLOCK(NODE) \
TREE_OPERAND_CHECK_CODE (NODE, EXIT_BLOCK_EXPR, 0)
#define EXIT_BLOCK_RETURN(NODE) TREE_OPERAND_CHECK_CODE (NODE, EXIT_BLOCK_EXPR, 1)
/* In a LOOP_EXPR node. */
#define LOOP_EXPR_BODY(NODE) TREE_OPERAND_CHECK_CODE (NODE, LOOP_EXPR, 0)