Converting the gcc backend to a library?

Tim Josling tej@melbpc.org.au
Fri Dec 31 23:54:00 GMT 1999


Mikael Djurfeldt wrote:

> That is, I'd like to link my interpreter with the gcc backend.

This is a very FAQ, for which there is no good answer. Here are
some resources which I have collected.

There is also 'Using and Porting GNU CC' which comes with GCC and
you can salso buy a hardcopy from the FSF. 

Integration with the GCC back end is mainly via the tree.[ch] and
tree.def interface and the assorted subroutines that come with
that. You don't actually generate the RTL yourself - the routines
do that for you from the tree nodes.

You will see many complaints in the documentation that the front
end and back end are not cleanly separated. Also the back end is
more friendly to C front ends at least though this is not a show
stopper.

The back end interface is also pretty low level and could
usefully be encapsulated into some more friendly interface. In
that sense a library is a good idea. I am trying to integrate a
cobol front end into gcc at present and I will probably do some
encapsulation, but this does not have a fixed end date! So as far
as I know, you will have to do a fair bit of work.

Having said that, GCC back end provides tremendous value - 30+
platforms supported out automatically; lots of optimisation;
automatic creation of numerous varieties of debugging
information, ability to use gdb for debugging. 

I'm not sure also if you are aware you will need to run the
output of the gcc back end through an assembler and a linker and
then probably have the OS load the output, so you would need to
carefully manage the performance issues.

Tim Josling

Resources
*********

> 
> Document on building a new front end to gcc (in german). I am
> reading this now.
> < http://www.pu.informatik.tu-darmstadt.de/docs/gccpue/ >

A very good document, worth the effort if you know any german.

> 
> GCC Internals documentation links (some of these may have to be
> accessed from internet explorer for some reason - communications
> error -336 in Netscape)):
> 
> < http://gcc.gnu.org/onlinedocs/ >
> 
> The GNU Compiler Writer's Jump Point:
> 
> < http://members.wri.com/johnnyb/compilers/ >
>



More information about the Gcc mailing list