This is the mail archive of the gcc@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: Obtain AST from GCC


Sean Hsiao wrote:
> We need to know some information about Abstract Syntax Tree. So, I need to
> modify the original code of GCC to obtain the AST. However, there are too
> many files, would you please tell me which file of GCC generates AST? Thank
> you very much!!

The trees are generated by the front ends, and every front end is
different.  Some front ends generate their own data structures which are
different from trees, and then convert them into trees.  Also, how this
works can sometimes change from one gcc version to the next.  So where
you want to look may depend on which gcc version you are looking at.

The basic functions for manipulating trees can be found in the tree.c file.

The basic function for converting trees to rtl is expand_expr.  You
could put a breakpoint there and trace backwards to see where the trees
are coming from.  You may find that there is no one single place where
you can see the trees.

There are some dumping options available in some gcc versions that might
be useful, for instance, -fdump-translation-unit.  These dumps are
intentionally incomplete though.  You could try looking at the code that
implements these options.
-- 
Jim Wilson, GNU Tools Support, http://www.SpecifixInc.com


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