This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [tree-ssa] gimplify LABELED_BLOCK_EXPR and EXIT_BLOCK_EXPR
- From: Jason Merrill <jason at redhat dot com>
- To: Jeff Sturm <jsturm at one-point dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Wed, 18 Jun 2003 13:37:22 -0400
- Subject: Re: [tree-ssa] gimplify LABELED_BLOCK_EXPR and EXIT_BLOCK_EXPR
- References: <Pine.LNX.4.44.0306172137570.14640-100000@ops2.one-point.com>
On Tue, 17 Jun 2003 21:49:06 -0400 (EDT), Jeff Sturm <jsturm@one-point.com> wrote:
> +/* Gimplify a LABELED_BLOCK_EXPR into a LABEL_EXPR following
> + a (possibly empty) body. */
> +
> +static void
> +gimplify_labeled_block_expr (tree *expr_p, tree *pre_p)
> +{
> + tree body = LABELED_BLOCK_BODY (*expr_p);
> + tree label = build (LABEL_EXPR, void_type_node,
> + LABELED_BLOCK_LABEL (*expr_p));
> +
> + if (body != NULL_TREE)
> + {
> + gimplify_stmt (&body);
> + add_tree (body, pre_p);
> + }
> + *expr_p = label;
> +}
In general, if you're going to replace one node with another (or several
others) I'd just do that directly and let gimplify_expr handle reducing the
new form further. So don't pass in pre_p, but replace *expr_p with the
body and the new LABEL_EXPR.
> +/* Gimplify a EXIT_BLOCK_EXPR into a GOTO_EXPR. */
> +
> +static void
> +gimplify_exit_block_expr (tree *expr_p)
> +{
> + tree labeled_block = TREE_OPERAND (*expr_p, 0);
> + tree label;
> +
> +#if defined ENABLE_CHECKING
> + if (TREE_CODE (labeled_block) != LABELED_BLOCK_EXPR)
> + abort ();
> +#endif
> +
> + label = LABELED_BLOCK_LABEL (labeled_block);
> + DECL_CONTEXT (label) = current_function_decl;
Setting DECL_CONTEXT should happen in gimplify_labeled_block_expr.
> + *expr_p = build1 (GOTO_EXPR, void_type_node, label);
> }
Jason