Next: Per-Function Data, Previous: Driver, Up: Target Macros
Here are run-time target specifications.
This function-like macro expands to a block of code that defines built-in preprocessor macros and assertions for the target CPU, using the functions
builtin_define
,builtin_define_std
andbuiltin_assert
. When the front end calls this macro it provides a trailing semicolon, and since it has finished command line option processing your code can use those results freely.
builtin_assert
takes a string in the form you pass to the command-line option -A, such ascpu=mips
, and creates the assertion.builtin_define
takes a string in the form accepted by option -D and unconditionally defines the macro.
builtin_define_std
takes a string representing the name of an object-like macro. If it doesn't lie in the user's namespace,builtin_define_std
defines it unconditionally. Otherwise, it defines a version with two leading underscores, and another version with two leading and trailing underscores, and defines the original only if an ISO standard was not requested on the command line. For example, passingunix
defines__unix
,__unix__
and possiblyunix
; passing_mips
defines__mips
,__mips__
and possibly_mips
, and passing_ABI64
defines only_ABI64
.You can also test for the C dialect being compiled. The variable
c_language
is set to one ofclk_c
,clk_cplusplus
orclk_objective_c
. Note that if we are preprocessing assembler, this variable will beclk_c
but the function-like macropreprocessing_asm_p()
will return true, so you might want to check for that first. If you need to check for strict ANSI, the variableflag_iso
can be used. The function-like macropreprocessing_trad_p()
can be used to check for traditional preprocessing.
Similarly to
TARGET_CPU_CPP_BUILTINS
but this macro is optional and is used for the target operating system instead.
Similarly to
TARGET_CPU_CPP_BUILTINS
but this macro is optional and is used for the target object format. elfos.h uses this macro to define__ELF__
, so you probably do not need to define it yourself.
This variable is declared in options.h, which is included before any target-specific headers.
This variable specifies the initial value of
target_flags
. Its default setting is 0.
This hook is called whenever the user specifies one of the target-specific options described by the .opt definition files (see Options). It has the opportunity to do some option-specific processing and should return true if the option is valid. The default definition does nothing but return true.
code specifies the
OPT_
name enumeration value associated with the selected option; name is just a rendering of the option name in which non-alphanumeric characters are replaced by underscores. arg specifies the string argument and is null if no argument was given. If the option is flagged as aUInteger
(see Option properties), value is the numeric value of the argument. Otherwise value is 1 if the positive form of the option was used and 0 if the “no-” form was.
This target hook is called whenever the user specifies one of the target-specific C language family options described by the .opt definition files(see Options). It has the opportunity to do some option-specific processing and should return true if the option is valid. The arguments are like for
TARGET_HANDLE_OPTION
. The default definition does nothing but return false.In general, you should use
TARGET_HANDLE_OPTION
to handle options. However, if processing an option requires routines that are only available in the C (and related language) front ends, then you should useTARGET_HANDLE_C_OPTION
instead.
This macro is a C statement to print on
stderr
a string describing the particular machine description choice. Every machine description should defineTARGET_VERSION
. For example:#ifdef MOTOROLA #define TARGET_VERSION \ fprintf (stderr, " (68k, Motorola syntax)"); #else #define TARGET_VERSION \ fprintf (stderr, " (68k, MIT syntax)"); #endif
Sometimes certain combinations of command options do not make sense on a particular target machine. You can define a macro
OVERRIDE_OPTIONS
to take account of this. This macro, if defined, is executed once just after all the command options have been parsed.Don't use this macro to turn on various extra optimizations for -O. That is what
OPTIMIZATION_OPTIONS
is for.If you need to do something whenever the optimization level is changed via the optimize attribute or pragma, see
TARGET_OVERRIDE_OPTIONS_AFTER_CHANGE
This target function is similar to the macro
OVERRIDE_OPTIONS
but is called when the optimize level is changed via an attribute or pragma or when it is reset at the end of the code affected by the attribute or pragma. It is not called at the beginning of compilation whenOVERRIDE_OPTIONS
is called so if you want to perform these actions then, you should haveOVERRIDE_OPTIONS
callTARGET_OVERRIDE_OPTIONS_AFTER_CHANGE
.
This is similar to
OVERRIDE_OPTIONS
but is only used in the C language frontends (C, Objective-C, C++, Objective-C++) and so can be used to alter option flag variables which only exist in those frontends.
Some machines may desire to change what optimizations are performed for various optimization levels. This macro, if defined, is executed once just after the optimization level is determined and before the remainder of the command options have been parsed. Values set in this macro are used as the default values for the other command line options.
level is the optimization level specified; 2 if -O2 is specified, 1 if -O is specified, and 0 if neither is specified.
size is nonzero if -Os is specified and zero otherwise.
This macro is run once at program startup and when the optimization options are changed via
#pragma GCC optimize
or by using theoptimize
attribute.Do not examine
write_symbols
in this macro! The debugging options are not supposed to alter the generated code.