GIMPLE FE: A Gimple Front End

The Gimple FE project, that started as part of Google Summer of code 2010, is aimed at converting the GIMPLE IR to a fixed format textual representation of GIMPLE tuples and to develop a front end which can recognize this textual GIMPLE and parse it. The essence of the project is to enable a user to write the Gimple IR as text (in the form of code) and be able to compile it.

Code Repository

The project is being implemented in the gimple-front-end SVN branch (browse). To get the latest version:

$ svn co svn://

The branch is maintained by Diego Novillo < >. The usual rules for contributing to branches apply to this branch:

  1. Messages and patches to the lists should have their subject prefixed with [gimplefe].

  2. ChangeLog entries should be written to ChangeLog.gimplefe.


GCC internally uses GIMPLE. The compile sequence converts text (source code) into GIMPLE and the Gimple is then lowered to RTL. Internally, GIMPLE is structured in the forms of tuples. A C-like representation of GIMPLE can be dumped using the compiler flag -fdump-tree-gimple and in the tuple form using the flag -fdump-tree-gimple-raw. During development or debugging, GIMPLE is often dumped this way. Most of the GCC development is done in the middle end or the back end of GCC. The compilation sequence is then reexecuted if any change to the source code is made. This repeats the execution of those steps in the compilation sequence - the language front ends - which are not directly related to the middle end. Most of the changes during development are also changes directly related to GIMPLE. Thus, an alternative to remove the redundancy of reexecution is to have the ability to start and stop compilation from an arbitrary point in the compilation process. Part of that is to start the compilation from the middle end itself. Thus, the Gimple FE is aimed to provide a front end that will compile GIMPLE.


Such a feature will be a valuable addition to the compiler for the following reasons:

Gimple Grammar

The syntax of GIMPLE tuples is kept similar to the format given in gcc/gimple.def. The tuple format is extended to include types and declarations. The structure and the syntax of types and declarations can be represented as follows:

A) Global Declaration Section

A.1) Type Section

a ) Explicit Types:

b ) Implicit types

c) Ignored Types

A.2) Decl Section

B) Function body

This section itself is divided as:

The local declaration section will be same as the global declaration section. The Gimple statements in the multiple basic blocks can be laid out in the tuple format as per the tuple descriptions given in gimple.def .

Note: This is just a preliminary grammar. The missing bits will be added as we go on.

Current Implementation State

The entire code can be found in gcc/gimple directory. The file parser.c in this directory consists of the entire functional logic of the parser.


1. Currently the Gimple FE reads the tokens and interprets them. The types of tokens are obtained from the CPP_ttypes table. It should be possible now to implement a seperate gimple_ttypes table that the preprocessor can directly use for Gimple FE. This will make the current code in gcc/gimple/parser.c more compact and clean.

2. The Gimple FE relies on string comparisions a lot. Moreover, as we add new components to the front end the comparisions will increase. There needs to be something to do this in a clean way.

3. Extend the recognizer with error handling and error recovery.


Sandeep Soni ( )

Diego Novillo ( )

None: GimpleFrontEnd (last edited 2011-07-23 02:11:39 by 76)