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]

'treelang' and GCC function-at-a-time mode


Hi,

I'm trying to figure out how to write a front end that uses the
function-at-a-time mode. I wish to learn about this so that I can
document it and use it for the GNU Fortran 95 project.

>From what I understand so far, the idea of this mode is to use the tree
structures that used to be the C AST as a new IR. I should try to make
my front-end build a whole tree for each function and translate that
tree to RTL, instead of generating and translating trees piece-by-piece
(per statement).

I first tried to figure out how the existing front-ends work. People
told me to look at the C and C++ front ends, but I never did any GCC
hacking before so even that has proved to be too difficult for me :-) 
Next front-end I grepped in was 'treelang', which is supposed to be an
example front end. But apparently it does not use function-at-a-time
mode:

>From `treelang/treetree.c':
   void 
   tree_code_if_else (unsigned char* filename, int lineno)
   {
     /* Output the line  number information.  */
     emit_line_note ((const char *)filename, lineno);
     expand_start_else ();
   }

>From 'stmt.c':
   /* Generate RTL between then-clause and the elseif-clause
      of an if-then-elseif-....  */

   void
   expand_start_elseif (cond)

The way I read this, 'treelang' translates an 'else' clause to RTL once
it sees one. In function-at-a-time mode, I would expect it to add a new
branch to the AST.  So, I think 'treelang' does not use function at a
time mode but instead translates to RTL piece-by-piece.
(If I'm right, perhaps this front-end is not a very good example!)

Now, assuming I'm right, I can (finally) get to the point: What would
this look like in function-at-a-time mode???

I did some more grepping in my gcc snapshot:

>From 'c-common.c':
/* Called between the then-clause and the else-clause
   of an if-then-else.  */

void
c_expand_start_else ()


Should `treelang' use functions from `c-common.c' instead of 'stmt.c' to
make it use function-at-a-time mode. Is that what I should do in G95 and
in my own toy front-ends?


Merry X-mas!!!

Greetz,
Steven




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