This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [tree-ssa] gimplify LABELED_BLOCK_EXPR and EXIT_BLOCK_EXPR


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]