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]

Re: tree structure and inserting own profiling code


> Since I had to implement things the compiler already does (much more
> better), I want to let the compiler insert my code. So I am
> searching for a position in the source code of the (GNU-) compiler,
> where the whole algorithm (input for the compiler) is stored, and
> where I can add my profiling code.

You did not explain exactly what kind of profiling code you want to
add, and in what places you want to add it. There seem to be three
logical places:

a) When an expression is parsed, tree structures are created, which
   represent the expressions. You could arrange to create other
   structures. This would be language-specific; for C++, a good entry
   point would be build_binary_op.

b) Later, the tree nodes are converted to RTL nodes (register transfer
   language). Again, you could wrap the resulting RTL with more RTL;
   the place to do this might be expand_expr.

c) Eventually, the RTL is used to produce assembler input. This will
   use the machine description files, which you could modify to
   control the exact assembler text being written.

Of those, option b) has texi documentation; see rtl.texi for details.
For option c), you'll find extend.texi useful. For option a), there is
little documentation at the moment, except for the comments in
tree.def and tree.h

If you want to look at those structures in gdb, I recommend calling
the functions debug_tree and debug_rtx from gdb, respectively. If you
load the .gdbinit file that comes with gcc, you can also use pt and
pr.

Hope this helps,
Martin


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