On Tue, 2010-06-22 at 15:43 -0400, Jianzhou Zhao wrote:
> On Tue, Jun 22, 2010 at 2:56 PM, Basile Starynkevitch
> > To manipulate GIMPLE easily, you could be tempted to use the MELT plugin
> > or branch, see http://gcc.gnu.org/wiki/MELT for more.
> >
> > MELT is a lispy domain specific language offering notably Gimple pattern
> > matching, & this precise feature of MELT will help you a lot coding a
> > Gimple to LLVM/SSA converter if you wanted to do that.
> 
> This is cool. I will look at it.
> 
> >
> > However, a DraggonEgg plugin exist which precisely do that GCC -> LLVM
> > conversion, according to my incomplete understanding (or perhaps
> > DraggonEgg convert Gimple to LLVM *front-end* but not middle-end
> > representation? I don't know!).
> 
> Thanks for pointing out this DragonEgg project
> http://dragonegg.llvm.org/. It does the translation from Gimple to
> LLVM bitcode (which means SSA in my understanding). It seems that I
> need to find a translation for the other direction, or create a one.

You might still perhaps find MELT useful to prototype a LLVM/SSA ->
Gimple converter. 

I am assuming that you target the latest GCC release, which is 4.5
-since 4.6 is still in stage 1, so I would imagine be released for
Christmas if we are lucky.

GCC 4.5 does not have a Gimple front-end (i.e. a syntax mapping directly
to Gimple I.R.). It could be a new feature of GCC 4.6 (or even later, I
don't know).

Concretely, you could imagine outputting [e.g. as a LLVM pass coded for
LLVM libraries in C++] the LLVM internal representation in some lispy
S-expression syntax, and have that syntax being read by some MELT code
and then code in MELT (using its pattern matching, which is a feature
helpful for you) the conversion from this S-expression syntax to Gimple.

The very practical point is that GCC 4.5 needs a file to have cc1
executed, so you might prototype using gcc 4.5 with MELT plugin with a
fictuous empty.c input file, and build all the Gimple I.R. in MELT.

Of course, everything that MELT can do could be more painfully coded as
a C plugin (but C is a lower level language, and MELT gives you a
powerful pattern matching that will help you).

If you want to know more about MELT, please ask. Also read the wiki
pages, etc. MELT is still work in progress, but it is usable.

Cheers.
 
-- 
Basile STARYNKEVITCH         http://starynkevitch.net/Basile/
email: basile<at>starynkevitch<dot>net mobile: +33 6 8501 2359
8, rue de la Faiencerie, 92340 Bourg La Reine, France
*** opinions {are only mines, sont seulement les miennes} ***


Reply via email to