GCC frontend

Chris,

    LLVM is an excellent piece of work,

LLVM is one of the few project I know that has used the
mysterious GCC front-end. I think it will be a great
contribution to the community if you could writeup and document how to
interface to
the GCC front-end data-structures (like LLVM has done). Specifically:

a) detail the gcc front-end tree data-structures
b) how to go about interfacing to them
c) what are changes that LLVM did to the gcc front end

My interest is to interface to gcc data-structures to produce an
open-source language
independent IL in Ocaml -- like LLVM but at a higher level suitable for program
analysis in Ocaml (like the CIL effort at berkeley -- note CIL folks developed
their C frontend from scratch -- a waste of effort when they could
have leveraged the gcc frontend)
Unfortunately there is very little documentation for the gcc front
end interface.
I have to spend a lot of time code-browsing the gcc code trying to
understand the
gcc code and data-structures. Since you have done this already,
I will really appreciate if you could document your efforts.

This will be a valuable contribution to the community since gcc is
the ONLY (and defacto standard) open-source compiler for C,C++,
and at the same time its front end interface is very poorly documented.

Thanks and Regards

    LLVM is an excellent piece of work,

Thanks!

LLVM is one of the few project I know that has used the mysterious GCC
front-end. I think it will be a great contribution to the community if
you could writeup and document how to interface to the GCC front-end
data-structures (like LLVM has done). Specifically:

a) detail the gcc front-end tree data-structures
b) how to go about interfacing to them
c) what are changes that LLVM did to the gcc front end

While that would be a useful document, I don't think that anyone will be
jumping to write it unfortunately. We all have plenty of other
interesting things to do, and writing docs that makes it easier for people
to not use LLVM is not a high-priority. :slight_smile:

My interest is to interface to gcc data-structures to produce an
open-source language independent IL in Ocaml -- like LLVM but at a
higher level suitable for program analysis in Ocaml (like the CIL effort
at berkeley -- note CIL folks developed their C frontend from scratch --
a waste of effort when they could have leveraged the gcc frontend)

Ok.

Unfortunately there is very little documentation for the gcc front end
interface. I have to spend a lot of time code-browsing the gcc code
trying to understand the gcc code and data-structures. Since you have
done this already, I will really appreciate if you could document your
efforts.

You could look a the llvmgcc source, or you could build on what we already
have with LLVM. I'm not sure exactly what you hope to gain with a
OCaml-like CIL, but I suspect that you can get 95% or more of the benefit
by writing an OCaml backend for LLVM. Please read up on LLVM and get a
clear understanding of what we can and can not do, you might be suprised.

-Chris

Ramu,

Let me second what Chris said. It's far easier to write an LLVM-to-NewIL translator (or LLVM-to-OCaml back-end), than a GCC-to-NewIL front-end. And that is if you have a compelling reason to invent a new IL and write new analyses and transformations for it, rather than using an existing IL and compiler system.

--Vikram
http://www.cs.uiuc.edu/~vadve
http://llvm.cs.uiuc.edu/

Ramu Ramamurthy wrote:

the GCC front-end data-structures (like LLVM has done). Specifically:

a) detail the gcc front-end tree data-structures

Ehm... I'm not sure that's reasonable because,

1. I might be mistaken, but LLVM uses gcc state from before merge of the
tree-ssa branch, which has considerably changed internal representation
2. There's http://gcc.gnu.org/onlinedocs/gccint/ already. I don't know how
good it is, but improving it is not something LLVM folks can do

- Volodya