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] SWITCH_EXPR lowering


On Sun, Oct 26, 2003 at 12:19:55AM +0200, Zdenek Dvorak wrote:
> The switch exprs are lowered into the form in that switch body is
> composed just of regularly alternating CASE_LABEL_EXPRs and GOTO_EXPRs.
> This whole is considered a single statement representing a multiway
> jump.  Statement annotations attached to CASE_LABEL_EXPRs are (miss)used
> to map the cases to edges via case_edge field.

I think this is the wrong approach.  

SWITCH_EXPRs already have a vector of all associated case labels, as
seen in SWITCH_LABELS.  This is even collected during gimplification,
so you don't have to do it yourself during lowering.

In its lowered form, SWITCH_BODY becomes NULL.  We simply drop its
container-ness and treat it as a multi-way branch.

We replace all c=CASE_LABEL_EXPR with LABEL_EXPR<CASE_LABEL(c)>, so
we no longer have CASE_LABEL_EXPRs in the instruction stream.  They
continue to exist in the SWITCH_LABELS vector so that we have the
mapping from input index to label.  Simplifying SWITCH_EXPRs when we
propagate in constants is a simple matter of replacing the insn with
a GOTO_EXPR to the correct labe.  Redirecting edges during jump 
threading is a simple matter of replacing the CASE_LABEL of the 
appropriate SWITCH_LABELS entry.

There's likely some small amount of work needed in the tree->rtl 
expander, but I wouldn't expect it to be much.


r~


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