gccint: Target Structure

1 
1 18.1 The Global 'targetm' Variable
1 ==================================
1 
1  -- Variable: struct gcc_target targetm
1      The target '.c' file must define the global 'targetm' variable
1      which contains pointers to functions and data relating to the
1      target machine.  The variable is declared in 'target.h';
1      'target-def.h' defines the macro 'TARGET_INITIALIZER' which is used
1      to initialize the variable, and macros for the default initializers
1      for elements of the structure.  The '.c' file should override those
1      macros for which the default definition is inappropriate.  For
1      example:
1           #include "target.h"
1           #include "target-def.h"
1 
1           /* Initialize the GCC target structure.  */
1 
1           #undef TARGET_COMP_TYPE_ATTRIBUTES
1           #define TARGET_COMP_TYPE_ATTRIBUTES MACHINE_comp_type_attributes
1 
1           struct gcc_target targetm = TARGET_INITIALIZER;
1 
1  Where a macro should be defined in the '.c' file in this manner to form
1 part of the 'targetm' structure, it is documented below as a "Target
1 Hook" with a prototype.  Many macros will change in future from being
1 defined in the '.h' file to being part of the 'targetm' structure.
1 
1  Similarly, there is a 'targetcm' variable for hooks that are specific
1 to front ends for C-family languages, documented as "C Target Hook".
1 This is declared in 'c-family/c-target.h', the initializer
1 'TARGETCM_INITIALIZER' in 'c-family/c-target-def.h'.  If targets
1 initialize 'targetcm' themselves, they should set
1 'target_has_targetcm=yes' in 'config.gcc'; otherwise a default
1 definition is used.
1 
1  Similarly, there is a 'targetm_common' variable for hooks that are
1 shared between the compiler driver and the compilers proper, documented
1 as "Common Target Hook".  This is declared in 'common/common-target.h',
1 the initializer 'TARGETM_COMMON_INITIALIZER' in
1 'common/common-target-def.h'.  If targets initialize 'targetm_common'
1 themselves, they should set 'target_has_targetm_common=yes' in
1 'config.gcc'; otherwise a default definition is used.
1