|Search in this site:||
GCC MELT is a high-level domain specific language for extending or
customizing the Gnu Compiler
Collection (i.e. gcc,
g++, gfortran, gnat, gccgo, gobjc, ...). It
is implemented as a GCC plugin (for GNU/Linux systems, with
GCC 4.6, 4.7 or later) in a free software (under GPLv3+
license and FSF copyright).
GCC MELT targets advanced GCC users developing, compiling, improving, evaluating, maintaining, or designing important software (coded in C, C++, Fortran, Ada, Go, Objective C or any language supported by a recent straight- or cross- GCC compiler). For such power users, spending a few days or weeks to customize or extend their compiler for their specific needs is worthwhile, and GCC MELT should lower the required effort, because coding in MELT a GCC extension is much easier than manually developping a GCC plugin in C or C++ (these are efficient languages, but not well fit to easily work on compiler's internal representations).
GCC MELT uses existing GCC plugin hooks to work on GCC internal middle-end representations, notably GCC Generic Trees and GCC Gimples, and the control flow graph. These powerful internal representations are common to all source languages accepted by GCC, so your extension coded in MELT will be able to handle any source code compiled by GCC. In addition, the (crude) GCC MELT probe provides a graphical interface to interactively query some internal GCC representations.
Probably, GCC MELT won't be very useful to casual GCC users working on tiny programming projects, unless they simply use some existing GCC extensions already developed with GCC MELT.
The GCC compiler can be customized or extended (with plugins or MELT extensions) for:
json_packin Jansson library, or
g_object_setin GTK toolkit), or checking some properties at every call of some given function;
pthread_mutex_unlockare balanced in the same function, or that every
fopengets its resulted tested);
CFLAGS += -fplugin=melt -fplugin-arg-melt-extra=extension -fplugin-arg-melt-mode=modein a
Makefile), but don't need to change workflow habits.
MELT is a domain-specific language specifically designed to ease the extension (or customization) of GCC because of the following features:
loop-s in a statically typed manner
The emitted C or C++ code is carefully generated to fit into what your GCC plugin interface expects (GCC switched from C to C++ in its 4.7 version, and GCC MELT is careful to generate a code acceptable by your version of GCC).
|(click on the picture to get the full view)|
A practical way to understand more on main GCC internal representations is to have a relevant (small) source code (e.g. in C, C++, Fortran, or Ada, etc), then compile it with the
For instance (assuming you have
example.cc in some playground directory) compile
g++ -fdump-tree-all -O -c example.cc. This produce
hundreds of dump files, such as
example.cc.073t.phiopt1 which might contain (like dump files suffixed
(Static Single Assignment) statements, that you can browse using an editor or pager (e.g.
less example.cc.073t.phiopt1 or
However, GCC MELT also provides you with a
graphical probe: you could simply run
-fplugin=melt -fplugin-arg-melt-mode=probe -O -c example.cc and
see a graphical window, with the ability to interactively look
at GCC internal representations tied to a
particular source code location. The probe is a small (GtkMM or PyQt)
GUI application communicating, thru asynchronous textual pipes, with
enhanced GCC compiler.
The GCC MELT graphical probe may interest any people curious of GCC internal representations.
GCC MELT is downloadable here (under GPLv3 license, for GNU/Linux systems with a recent GCC), where you can get installation instructions, and also examples of code written in MELT.
Please download and install GCC MELT before reading other material.
GCC MELT has some documentation here , where you can get tutorial, and also reference about MELT, with publications and slides of talks given on it.
GCC MELT is an improvement to GCC itself, so follows the same contribution policies as the GCC compiler. In particular, it demands the same legal prerequisites (which take a lot of time). We cannot accept even small patches without your contribution belonging legally to the FSF (as GCC MELT does).
Thanks to (in alphabetical order) Romain Geissler, Emmanuel Haucourt, Alexandre Lissy, Jérémie Salvucci, Pierre Vittet for their contributions to GCC MELT.
An English-speaking low-traffic technical group (no flamewars, no spam) about GCC MELT is available on
|Subscribe to email@example.com|
|Visit this group|
The old page on GCC MELT is available here