Next:Defining data structures for per-function information., Previous:Controlling the Compilation Driver,gcc, Up:Target Description Macros and Functions [Contents][Index]
Here are run-time target specifications.
This function-like macro expands to a block of code that definesbuilt-in preprocessor macros and assertions for the target CPU, usingthe functionsbuiltin_define,builtin_define_std andbuiltin_assert. When the front endcalls this macro it provides a trailing semicolon, and since it hasfinished command line option processing your code can use thoseresults freely.
builtin_assert takes a string in the form you pass to thecommand-line option-A, such ascpu=mips, and createsthe assertion.builtin_define takes a string in the formaccepted by option-D and unconditionally defines the macro.
builtin_define_std takes a string representing the name of anobject-like macro. If it doesn’t lie in the user’s namespace,builtin_define_std defines it unconditionally. Otherwise, itdefines a version with two leading underscores, and another versionwith two leading and trailing underscores, and defines the originalonly if an ISO standard was not requested on the command line. Forexample, passingunix defines__unix,__unix__and possiblyunix; passing_mips defines__mips,__mips__ and possibly_mips, and passing_ABI64defines only_ABI64.
You can also test for the C dialect being compiled. The variablec_language is set to one ofclk_c,clk_cplusplusorclk_objective_c. Note that if we are preprocessingassembler, this variable will beclk_c but the function-likemacropreprocessing_asm_p() will return true, so you might wantto check for that first. If you need to check for strict ANSI, thevariableflag_iso can be used. The function-like macropreprocessing_trad_p() can be used to check for traditionalpreprocessing.
Similarly toTARGET_CPU_CPP_BUILTINS but this macro is optionaland is used for the target operating system instead.
Similarly toTARGET_CPU_CPP_BUILTINS but this macro is optionaland is used for the target object format.elfos.h uses thismacro to define__ELF__, so you probably do not need to defineit yourself.
extern inttarget_flags ¶This variable is declared inoptions.h, which is included beforeany target-specific headers.
intTARGET_DEFAULT_TARGET_FLAGS ¶This variable specifies the initial value oftarget_flags.Its default setting is 0.
boolTARGET_HANDLE_OPTION(struct gcc_options *opts, struct gcc_options *opts_set, const struct cl_decoded_option *decoded, location_tloc) ¶This hook is called whenever the user specifies one of thetarget-specific options described by the.opt definition files(seeOption specification files). It has the opportunity to do some option-specificprocessing and should return true if the option is valid. The defaultdefinition does nothing but return true.
decoded specifies the option and its arguments.opts andopts_set are thegcc_options structures to be used forstoring option state, andloc is the location at which theoption was passed (UNKNOWN_LOCATION except for options passedvia attributes).
boolTARGET_HANDLE_C_OPTION(size_tcode, const char *arg, intvalue) ¶This target hook is called whenever the user specifies one of thetarget-specific C language family options described by the.optdefinition files(seeOption specification files). It has the opportunity to do someoption-specific processing and should return true if the option isvalid. The arguments are like forTARGET_HANDLE_OPTION. Thedefault definition does nothing but return false.
In general, you should useTARGET_HANDLE_OPTION to handleoptions. However, if processing an option requires routines that areonly available in the C (and related language) front ends, then youshould useTARGET_HANDLE_C_OPTION instead.
treeTARGET_OBJC_CONSTRUCT_STRING_OBJECT(treestring) ¶Targets may provide a string object type that can be used withinand between C, C++ and their respective Objective-C dialects.A string object might, for example, embed encoding and length information.These objects are considered opaque to the compiler and handled as references.An ideal implementation makes the composition of the string objectmatch that of the Objective-CNSString (NXString for GNUStep),allowing efficient interworking between C-only and Objective-C code.If a target implements string objects then this hook should return areference to such an object constructed from the normal ‘C’ stringrepresentation provided instring.At present, the hook is used by Objective-C only, to obtain a common-format string object when the target provides one.
voidTARGET_OBJC_DECLARE_UNRESOLVED_CLASS_REFERENCE(const char *classname) ¶Declare that Objective C classclassname is referencedby the current TU.
voidTARGET_OBJC_DECLARE_CLASS_DEFINITION(const char *classname) ¶Declare that Objective C classclassname is definedby the current TU.
boolTARGET_STRING_OBJECT_REF_TYPE_P(const_treestringref) ¶If a target implements string objects then this hook should returntrue ifstringref is a valid reference to such an object.
voidTARGET_CHECK_STRING_OBJECT_FORMAT_ARG(treeformat_arg, treeargs_list) ¶If a target implements string objects then this hook shouldprovide a facility to check the function arguments inargs_listagainst the format specifiers informat_arg where the type offormat_arg is one recognized as a valid string reference type.
voidTARGET_OVERRIDE_OPTIONS_AFTER_CHANGE(void) ¶This target function is similar to the hookTARGET_OPTION_OVERRIDEbut is called when the optimize level is changed via an attribute orpragma or when it is reset at the end of the code affected by theattribute or pragma. It is not called at the beginning of compilationwhenTARGET_OPTION_OVERRIDE is called so if you want to perform theseactions then, you should haveTARGET_OPTION_OVERRIDE callTARGET_OVERRIDE_OPTIONS_AFTER_CHANGE.
This is similar to theTARGET_OPTION_OVERRIDE hookbut is only used in the Clanguage frontends (C, Objective-C, C++, Objective-C++) and so can beused to alter option flag variables which only exist in thosefrontends.
const struct default_options *TARGET_OPTION_OPTIMIZATION_TABLE ¶Some machines may desire to change what optimizations are performed forvarious optimization levels. This variable, if defined, describesoptions to enable at particular sets of optimization levels. Theseoptions are processed oncejust after the optimization level is determined and before the remainderof the command options have been parsed, so may be overridden by otheroptions passed explicitly.
This processing is run once at program startup and when the optimizationoptions are changed via#pragma GCC optimize or by using theoptimize attribute.
voidTARGET_OPTION_INIT_STRUCT(struct gcc_options *opts) ¶Set target-dependent initial values of fields inopts.
const char *TARGET_COMPUTE_MULTILIB(const struct switchstr *switches, intn_switches, const char *multilib_dir, const char *multilib_defaults, const char *multilib_select, const char *multilib_matches, const char *multilib_exclusions, const char *multilib_reuse) ¶Some targets like RISC-V might have complicated multilib reuse rules whichare hard to implement with the current multilib scheme. This hook allowstargets to override the result from the built-in multilib mechanism.switches is the raw option list withn_switches items;multilib_dir is the multi-lib result which is computed by the built-inmulti-lib mechanism;multilib_defaults is the default options list for multi-lib;multilib_select is the string containing the list of supportedmulti-libs, and the option checking list.multilib_matches,multilib_exclusions, andmultilib_reuseare corresponding toMULTILIB_MATCHES,MULTILIB_EXCLUSIONS,andMULTILIB_REUSE.The default definition does nothing but returnmultilib_dir directly.
Some targets need to switch between substantially different subtargetsduring compilation. For example, the MIPS target has one subtarget forthe traditional MIPS architecture and another for MIPS16. Source codecan switch between these two subarchitectures using themips16andnomips16 attributes.
Such subtargets can differ in things like the set of availableregisters, the set of available instructions, the costs of variousoperations, and so on. GCC caches a lot of this type of informationin global variables, and recomputing them for each subtarget takes asignificant amount of time. The compiler therefore provides a facilityfor maintaining several versions of the global variables and quicklyswitching between them; seetarget-globals.h for details.
Define this macro to 1 if your target needs this facility. The defaultis 0.
boolTARGET_FLOAT_EXCEPTIONS_ROUNDING_SUPPORTED_P(void) ¶Returns true if the target supports IEEE 754 floating-point exceptionsand rounding modes, false otherwise. This is intended to relate to thefloat anddouble types, but not necessarilylong double.By default, returns true if theadddf3 instruction pattern isavailable and false otherwise, on the assumption that hardware floatingpoint supports exceptions and rounding modes but software floating pointdoes not.
Next:Defining data structures for per-function information., Previous:Controlling the Compilation Driver,gcc, Up:Target Description Macros and Functions [Contents][Index]