GDC Documentation

At the moment, documentation for GDC, especially the internals, is sparse. The DMD frontend and the GCC internals aren't very well documented either. This page will hopefully help provide insight on GDC's internals.

GCC Internals

GCC is a compiler for many languages and many targets, so it is divided into pieces.


What we know as "GDC" is only an implementation of the Front-end part of GCC. GDC is located within its own subfolder in the core GCC source tree (gcc/d). It is within this subfolder that we must perform all changes to the language.

GCC has other Front-ends such as C (gcc/c), C++ (gcc/cp), Java (gcc/java), and Go (gcc/go), etc. You could look at these for advice, but one probably shouldn't.

GDC Internals

The D Front-end contains the lexer and parser. These together turn the source file into GENERIC. The GDC frontend relies heavily on the Digital Mars D (DMD) sources to perform this work, and you will find the entire DMD Front-end sources in a subfolder (gcc/d/dfrontend).

Other parts of the D Front-end outside this folder are part of GDC. Certain files are special as parts of the GCC back-end depend on their names.


GDC Front-End Interface

The following sources implement various methods among the Front-end AST nodes.


Currently work is under way in upstream DMD to convert all these methods into Visitor classes as part of the 2.065, 2.066 releases to allow work to begin on porting the D Front-end to D. So expect the convention and names of these files to change in the near future.

GDC Back-End Interface

The Middle-end uses callbacks to interface with the Front-end via "lang_hooks" (See gcc/d/d-lang.cc).

The following are implemented by GDC: