This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
[ast-optimizer-branch] Simplification of Simple grammar
- From: Sebastian Pop <m1sp at csc dot liv dot ac dot uk>
- To: dnovillo at redhat dot com
- Cc: gcc at gcc dot gnu dot org
- Date: Wed, 27 Mar 2002 13:38:48 +0000
- Subject: [ast-optimizer-branch] Simplification of Simple grammar
Hi,
I thought a little about what Simple representation can do
for simplifying the work on goto elimination : and I think
that it could be possible to simplify a little more the
Simple grammar.
What I need is just transform all switches in nested if statements.
This way switch_BREAK_STMTs are eliminated and there are no more
problems when the GOTO_STMT is in a SWITCH_STMT.
Another simplification is to allow a single loop structure :
for the moment I treat all loop structures but that multiplies by 3
the amount of code needed to simplify correctly goto, breaks and continues.
A last change could be to have the ELSE_CLAUSE by default on all
IF_STMTs. This way there's no need to call again the function
tree_build_scope everytime we're on an IF_STMT node and we want to be sure
that this node has an ELSE_CLAUSE...
I think that the scope of Simple is to simplify the analysis and transformations
we will write on Simple. Since we don't lose information by transforming
all switches in nested IF_STMTs, or transforming all loop structures
into DO_STMTs, I propose to simplify Simple grammar a little.
Original grammar from tree-simple.c
stmt
: compstmt
| expr ';'
| IF '(' condexpr ')' stmt
| IF '(' condexpr ')' stmt ELSE stmt
| WHILE '(' condexpr ')' stmt
| DO stmt WHILE '(' condexpr ')'
| FOR '('exprseq ';' condexpr ';'exprseq ')' stmt
| SWITCH '(' val ')' casestmts
| ';'
Simplified grammar :
stmt
: compstmt
| expr ';'
| IF '(' condexpr ')' stmt ELSE stmt
| DO stmt WHILE '(' condexpr ')'
| ';'
Seb.