gccint: Back End
1
1 6.3.9 Anatomy of a Target Back End
1 ----------------------------------
1
1 A back end for a target architecture in GCC has the following parts:
1
1 * A directory 'MACHINE' under 'gcc/config', containing a machine
11 description 'MACHINE.md' file (⇒Machine Descriptions Machine
Desc.), header files 'MACHINE.h' and 'MACHINE-protos.h' and a
11 source file 'MACHINE.c' (⇒Target Description Macros and
Functions Target Macros.), possibly a target Makefile fragment
1 't-MACHINE' (⇒The Target Makefile Fragment Target Fragment.),
1 and maybe some other files. The names of these files may be
1 changed from the defaults given by explicit specifications in
1 'config.gcc'.
1 * If necessary, a file 'MACHINE-modes.def' in the 'MACHINE'
1 directory, containing additional machine modes to represent
1 condition codes. ⇒Condition Code, for further details.
1 * An optional 'MACHINE.opt' file in the 'MACHINE' directory,
1 containing a list of target-specific options. You can also add
1 other option files using the 'extra_options' variable in
1 'config.gcc'. ⇒Options.
11 * Entries in 'config.gcc' (⇒(gccint)) for the systems with this target architecture) for the systems with this target architecture.
1 * Documentation in 'gcc/doc/invoke.texi' for any command-line options
11 supported by this target (⇒Run-time Target Specification
Run-time Target.). This means both entries in the summary table of
1 options and details of the individual options.
1 * Documentation in 'gcc/doc/extend.texi' for any target-specific
11 attributes supported (⇒Defining target-specific uses of
'__attribute__' Target Attributes.), including where the same
1 attribute is already supported on some targets, which are
1 enumerated in the manual.
1 * Documentation in 'gcc/doc/extend.texi' for any target-specific
1 pragmas supported.
1 * Documentation in 'gcc/doc/extend.texi' of any target-specific
1 built-in functions supported.
1 * Documentation in 'gcc/doc/extend.texi' of any target-specific
1 format checking styles supported.
1 * Documentation in 'gcc/doc/md.texi' of any target-specific
11 constraint letters (⇒Constraints for Particular Machines
Machine Constraints.).
1 * A note in 'gcc/doc/contrib.texi' under the person or people who
1 contributed the target support.
1 * Entries in 'gcc/doc/install.texi' for all target triplets supported
1 with this target architecture, giving details of any special notes
1 about installation for this target, or saying that there are no
1 special notes if there are none.
1 * Possibly other support outside the 'gcc' directory for runtime
1 libraries. FIXME: reference docs for this. The 'libstdc++'
1 porting manual needs to be installed as info for this to work, or
1 to be a chapter of this manual.
1
1 The 'MACHINE.h' header is included very early in GCC's standard
1 sequence of header files, while 'MACHINE-protos.h' is included late in
1 the sequence. Thus 'MACHINE-protos.h' can include declarations
1 referencing types that are not defined when 'MACHINE.h' is included,
1 specifically including those from 'rtl.h' and 'tree.h'. Since both RTL
1 and tree types may not be available in every context where
1 'MACHINE-protos.h' is included, in this file you should guard
1 declarations using these types inside appropriate '#ifdef RTX_CODE' or
1 '#ifdef TREE_CODE' conditional code segments.
1
1 If the backend uses shared data structures that require 'GTY' markers
1 for garbage collection (⇒Type Information), you must declare
1 those in 'MACHINE.h' rather than 'MACHINE-protos.h'. Any definitions
1 required for building libgcc must also go in 'MACHINE.h'.
1
1 GCC uses the macro 'IN_TARGET_CODE' to distinguish between
1 machine-specific '.c' and '.cc' files and machine-independent '.c' and
1 '.cc' files. Machine-specific files should use the directive:
1
1 #define IN_TARGET_CODE 1
1
1 before including 'config.h'.
1
1 If the back end is added to the official GCC source repository, the
1 following are also necessary:
1
1 * An entry for the target architecture in 'readings.html' on the GCC
1 web site, with any relevant links.
1 * Details of the properties of the back end and target architecture
1 in 'backends.html' on the GCC web site.
1 * A news item about the contribution of support for that target
1 architecture, in 'index.html' on the GCC web site.
1 * Normally, one or more maintainers of that target listed in
1 'MAINTAINERS'. Some existing architectures may be unmaintained,
1 but it would be unusual to add support for a target that does not
1 have a maintainer when support is added.
1 * Target triplets covering all 'config.gcc' stanzas for the target,
1 in the list in 'contrib/config-list.mk'.
1