Previous: , Up: gcc Directory   [Contents][Index]


6.3.9 Anatomy of a Target Back End

A back end for a target architecture in GCC has the following parts:

The machine.h header is included very early in GCC’s standard sequence of header files, while machine-protos.h is included late in the sequence. Thus machine-protos.h can include declarations referencing types that are not defined when machine.h is included, specifically including those from rtl.h and tree.h. Since both RTL and tree types may not be available in every context where machine-protos.h is included, in this file you should guard declarations using these types inside appropriate #ifdef RTX_CODE or #ifdef TREE_CODE conditional code segments.

If the backend uses shared data structures that require GTY markers for garbage collection (see Type Information), you must declare those in machine.h rather than machine-protos.h. Any definitions required for building libgcc must also go in machine.h.

GCC uses the macro IN_TARGET_CODE to distinguish between machine-specific .c and .cc files and machine-independent .c and .cc files. Machine-specific files should use the directive:

#define IN_TARGET_CODE 1

before including config.h.

If the back end is added to the official GCC source repository, the following are also necessary:


Previous: , Up: gcc Directory   [Contents][Index]