C tree question
Mathieu Lacage
Mathieu.Lacage@sophia.inria.fr
Wed Dec 3 08:05:00 GMT 2003
hi Jim,
On Wed, 2003-12-03 at 05:06, Jim Wilson wrote:
> Mathieu Lacage wrote:
> > I have been trying lately to understand what kind of data is stored in
> > the tree output by the C frontend. Thanks to -fdump-translation-unit, I
>
> This option is a debugging aid. It isn't meant to be complete. Its
yes, I use it as a learning aid.
> output may change from time to time. In current sources, it only
> appears to be dumping declarations, so it isn't dumping function bodies
> for instance.
>
> > The exact question I'd like to answer is:
> > 1) if (foo) bar;
> > 2) if (foo) {bar;}
> > where bar; is a non-compound statement generates the exact same tree out
> > of the language frontend.
>
> It would be unwise to make any assumptions here. This may depend on the
> contents of bar, it may depend on the language front end being used, it
> may depend on the target, it may depend on which gcc version you have, etc.
hrm. I was refering to the C frontend (as mentioned earlier in my email)
and I must say I was not expecting the c-parser.in file to change much
between gcc releases. I guess I was wrong.
>
> > 1) is the code fragment above relevant to my if (foo) {bar} sample ? I
> > suspect it might be related only to the enclosing {s of function bodies.
>
> Yes.
Experiments (through printf patches) showed that the code fragment was
indeed invoked on enclosing {s for both function bodies and if then
blocks.
>
> > 2) If it is related to my sample, does the COMPOUND_STMT node still
> > exist at the end of the frontend run ?
>
> No. It might be optimized away in the front end or the middle end,
> depending on the circumstances.
the distinction between the frontend and the middle end is something
which is not clear to me after reading code and the docs. Here is my
take at it:
- frontend: builds a tree which represents the syntax of the input
file.
- middle end: language-specific manipulations on the syntax tree to
generate a valid tree for the language-independent optimization passes
and backends.
>
> Note that this whole area will change when the tree-ssa branch gets
> accepted into the mainline, which could happen sometime after the
> gcc-3.4 release branch is made. This will change how the front ends
> work because it adds a new higher level IL.
ah. I have found the tree-ssa webpage and I am reading the doc I found
there.
thanks for your answers,
regards,
Mathieu
--
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
More information about the Gcc
mailing list