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: PATCH RFA: C frontend: Generate SWITCH_EXPR rather than SWITCH_STMT


Steven Bosscher <stevenb@suse.de> writes:

> On Sunday 03 April 2005 16:59, Ian Lance Taylor wrote:
> > This patch changes the C frontend to generate SWITCH_EXPR rather than
> > SWITCH_STMT.  SWITCH_EXPR is GENERIC, unlike SWITCH_STMT which is
> > specific to the C/C++ frontends.  Generating SWITCH_EXPR directly
> > saves a call to gimplify_switch_stmt for each switch statement.
> 
> It also makes changing the underlying data structures harder.  IIRC the
> SWITCH_BODY of a SWITCH_EXPR is a list of CASE_LABEL_EXPRs, and the C
> SWITCH_STMT_BODY is a STATEMENT_LIST.  So this would have to be changed
> back again if (when) the statically typed 'tree' project starts.

This turns out not to be the case.  There are two variants of
SWITCH_EXPR.  In GENERIC, SWITCH_EXPR has a statement list in operand
1, SWITCH_BODY.  In GIMPLE, SWITCH_EXPR has SWITCH_BODY set to NULL,
and a list of CASE_LABEL_EXPRs in operand 2, SWITCH_LABELS.

See gimplify_switch_expr.  For that matter, see gimplify_switch_stmt
in c-gimplify.c.  Note that gimplify_switch_stmt just generates a
SWITCH_EXPR with exactly the same operands as were used for the
SWITCH_STMT, except that the type move from SWITCH_STMT_TYPE to
TREE_TYPE.

Ian


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