C-- roundtripping: switch, if and other control flow statements

Edward Z. Yang ezyang at MIT.EDU
Fri Apr 15 17:32:07 CEST 2011

Hello all,

I'm interested in improving GHC's C-- parser's support (and also making
accomodations for the parser in our C-- pretty-printer) to the point
where we can round-trip output from -ddump-opt-cmm with no semantic
change.  There are several roadblocks on the way here, but the one
I'm currently tackling is the fact that the parser does not understand
flow control statements like such:

    if (b) goto foo;

It requires that the statement be closed in braces, and this will generate
a new, anonymous block containing the instruction:

    if (b) { goto foo; }


    if (b) goto temp
    goto foo;

This is, somewhat surprisingly, preventing me from getting a nice minimal
test-case for a bug in the linear register allocator.  I need a way
to not get an anonymous block being generated.

I've tried extending the grammar to accept both, but for switch statements
making the change at the obvious point introduces a reduce-reduce conflict.
I suspect I can hack my way around it, but for now I've renamed the keyword
to 'raw_switch', which doesn't accept blocks on the right side of the case.


More information about the Glasgow-haskell-users mailing list