From 16df8078b8ea2cf3ce37f47e62cdc66c69fe6c70 Mon Sep 17 00:00:00 2001 From: Steven Bosscher Date: Wed, 24 Nov 2004 11:41:38 +0000 Subject: 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 --- gcc/java/java-gimplify.c | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 'gcc/java/java-gimplify.c') diff --git a/gcc/java/java-gimplify.c b/gcc/java/java-gimplify.c index c8130a7..51fbb84 100644 --- a/gcc/java/java-gimplify.c +++ b/gcc/java/java-gimplify.c @@ -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. */ -- cgit v1.1