This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: GCC Needs a backend cleanup and complete rewrite
On 23-Feb-2001, Kevin Handy <kth@srv.net> wrote:
>
> You could make a C++ wrapper like has been done for other
> libraries (gtk for example). Then you would have both the current
> C backend, and a C++ backend for those who want to use that.
>
> I think that if it is done right, a C++ back end might make
> it easier for someone to write a new front end (and understand
> the back end), because it would (if written right) group
> functions into a logical relationship.
Actually, that's what I did for the Mercury front-end, except for
Mercury, of course, rather than for C++: I wrote a Mercury wrapper for
GCC's front-end interface. It's not complete, because I only wrapped
the stuff that I needed for the Mercury front-end. Also there are a
couple of things in it which are a bit Mercury-specific. But reading
the Mercury wrapper may still make it easier for someone wanting to
write a new front end to see what is needed.
It's not an OOP style wrapper. But it is a "typeful programming"
style wrapper:
| Another technique is "typeful programming": this is where you write
| down the name of function, the type of its input and outputs, and it
| becomes obvious how the function must be implemented. Don't ask me
| how, but this technique works surprisingly often :-)
|
| - Joe English <jenglish@flightlab.com>,
| comp.lang.functional, 28 Dec 2000.
That is, although GCC uses a single `tree' type for all the tree nodes
in its front-end parse tree, I mapped these to lots of distinct types
in the Mercury wrapper. For each type, there are a small number of
routines in the wrapper that process values of that type.
(For reference, the Mercury interface to the wrapper is declared in
the file gcc.m that I posted to gcc-patches a while back.
See <http://gcc.gnu.org/ml/gcc-patches/2001-01/msg02197.html>.)
--
Fergus Henderson <fjh@cs.mu.oz.au> | "I have always known that the pursuit
| of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh> | -- the last words of T. S. Garp.