next up previous
Next: MD Syntax Up: Project on Machine Description Previous: Project on Machine Description

What is ``GCC Machine Description'' ?

The phrase ``machine description'' is used in different contexts with different meanings. In the context of hardware, it refers to a high level description of the CPU - especially the programmer visible part. Within the context of GCC, however, we use it to refer to the specification of all the required values of the target system for which the compilation activity is to take place. This specification not only involves the description of the target CPU, but also the target architecture relevant for compilation (for instance, the word size), the target system software (for instance, the OS), and even the required particulars of the software development tools chain (for instance, the layout of the assembler file).

The GCC Machine Description, MD for short, is mainly composed of a set of C Preprocessor macros and a description of the target CPU in RTL.4. The macros file will be referred to as the ``MD header'' file, and will be denoted by <target>.h, where <target> will be replaced by the actual target name if necessary, for example i386.h. Some of these macros are, or may be implemented as, C functions. These supporting C functions reside in <target>.c file. The target description in RTL is found in <target>.md. Some additional C files are also included if the implementation so requires. Referring to the root of the GCC source tree as $GCCHOME, all the MD files are found in $GCCHOME/gcc/config/<target>/ directory.

The MD files are located during the configure process via the -target= switch (if not specified, the target is assumed to be the machine on which configure is running). The GCC build first uses these files to fill up the target dependent parts of the compiler and conceptually generates the sources for the requested target. It then proceeds to compile the compiler for the target. For example, during the generation, the GCC build system makes a note of the instructions that the target supports (as specified in <target>.md). This information is used during the conversion of the AST to the IR, and during the conversion of the IR to target ASM. The <target>.md file, therefore, specifies two main pieces of information: the structure of the IR for a given AST node type, and the target ASM instruction sequence. To facilitate lookup, a ``key'' is also required.

As an example of ``target-cpu-independent'' information that GCC MD files contain, we refer to the TARGET_ASM_FUNCTION_PROLOGUE (and the complementary TARGET_ASM_FUNCTION_EPILOGUE) macro found in the <target>.h file. This macro is responsible for defining the structure of the activation record implementation for the target. There are macros that specify the syntactic headers required by the target assembler in its input.

We are concerned with the <target>.md file only in this work.


next up previous
Next: MD Syntax Up: Project on Machine Description Previous: Project on Machine Description
2006-01-08