Customizing your GCC compiler with MELT *
Abstract: The free GCC 1 compiler can be extended with plugins. This permits extensions customizing GCC for a specific industry, corporation, or large software project (in C, C++, Ada, Fortran, …), to provide particular diagnostics, optimizations, or custom tools working on your source code base.
Customizing GCC requires understanding its internal representations and passes. But coding your GCC extension as a plugin in C is not that easy (because C is not well suited to handle compiler’s internal representations).
The MELT tool (GPLv3 free software) provides you with a domain specific language tailored to GCC internals. The MELT language has a familiar Lispy look, and gives you several features (functional, applicative, object-oriented, reflexive programming styles, powerful pattern matching, strong interface to GCC internals) to ease development of your specific GCC extensions.
Any large, legacy, or business-strategic software base (for instance ≈ 1 million lines of C, C++, Fortran, Ada, ObjectiveC, ... source code compiled by GCC) has been developed for several years by a team of qualified software developers so represents a significant investment.
Each such software has its own peculiarities and habits, specific to your project or system, your corporation, an industry, an application domain. So you can take profit of your specific GCC extensions2 to get :
Each above goal amounts to finding patterns in GCC internal representations of your source code, and you will need to partly understand GCC internals to realize it, and to know very well your code base and habits to specify them. Coding such extensions in C is impractical and not cost-effective (since GCC is a complex and growing 4.5MLOC software). Gluing scripting languages (like Python, Ruby, Ocaml ...) into GCC is not realistic.
MELT is an available free software (GPLv3) GCC plugin (or branch) to ease the development of your specific GCC extensions. It provides a domain specific language suited to GCC internals, to easily code your own GCC extensions in. Notable features include:
→ Use MELT to customize GCC for your own needs !
This document was translated from LATEX by HEVEA.