gccint: Target Attributes
1
1 18.24 Defining target-specific uses of '__attribute__'
1 ======================================================
1
1 Target-specific attributes may be defined for functions, data and types.
1 These are described using the following target hooks; they also need to
1 be documented in 'extend.texi'.
1
1 -- Target Hook: const struct attribute_spec * TARGET_ATTRIBUTE_TABLE
1 If defined, this target hook points to an array of 'struct
1 attribute_spec' (defined in 'tree-core.h') specifying the machine
1 specific attributes for this target and some of the restrictions on
1 the entities to which these attributes are applied and the
1 arguments they take.
1
1 -- Target Hook: bool TARGET_ATTRIBUTE_TAKES_IDENTIFIER_P (const_tree
1 NAME)
1 If defined, this target hook is a function which returns true if
1 the machine-specific attribute named NAME expects an identifier
1 given as its first argument to be passed on as a plain identifier,
1 not subjected to name lookup. If this is not defined, the default
1 is false for all machine-specific attributes.
1
1 -- Target Hook: int TARGET_COMP_TYPE_ATTRIBUTES (const_tree TYPE1,
1 const_tree TYPE2)
1 If defined, this target hook is a function which returns zero if
1 the attributes on TYPE1 and TYPE2 are incompatible, one if they are
1 compatible, and two if they are nearly compatible (which causes a
1 warning to be generated). If this is not defined, machine-specific
1 attributes are supposed always to be compatible.
1
1 -- Target Hook: void TARGET_SET_DEFAULT_TYPE_ATTRIBUTES (tree TYPE)
1 If defined, this target hook is a function which assigns default
1 attributes to the newly defined TYPE.
1
1 -- Target Hook: tree TARGET_MERGE_TYPE_ATTRIBUTES (tree TYPE1, tree
1 TYPE2)
1 Define this target hook if the merging of type attributes needs
1 special handling. If defined, the result is a list of the combined
1 'TYPE_ATTRIBUTES' of TYPE1 and TYPE2. It is assumed that
1 'comptypes' has already been called and returned 1. This function
1 may call 'merge_attributes' to handle machine-independent merging.
1
1 -- Target Hook: tree TARGET_MERGE_DECL_ATTRIBUTES (tree OLDDECL, tree
1 NEWDECL)
1 Define this target hook if the merging of decl attributes needs
1 special handling. If defined, the result is a list of the combined
1 'DECL_ATTRIBUTES' of OLDDECL and NEWDECL. NEWDECL is a duplicate
1 declaration of OLDDECL. Examples of when this is needed are when
1 one attribute overrides another, or when an attribute is nullified
1 by a subsequent definition. This function may call
1 'merge_attributes' to handle machine-independent merging.
1
1 If the only target-specific handling you require is 'dllimport' for
1 Microsoft Windows targets, you should define the macro
1 'TARGET_DLLIMPORT_DECL_ATTRIBUTES' to '1'. The compiler will then
1 define a function called 'merge_dllimport_decl_attributes' which
1 can then be defined as the expansion of
1 'TARGET_MERGE_DECL_ATTRIBUTES'. You can also add
1 'handle_dll_attribute' in the attribute table for your port to
1 perform initial processing of the 'dllimport' and 'dllexport'
1 attributes. This is done in 'i386/cygwin.h' and 'i386/i386.c', for
1 example.
1
1 -- Target Hook: bool TARGET_VALID_DLLIMPORT_ATTRIBUTE_P (const_tree
1 DECL)
1 DECL is a variable or function with '__attribute__((dllimport))'
1 specified. Use this hook if the target needs to add extra
1 validation checks to 'handle_dll_attribute'.
1
1 -- Macro: TARGET_DECLSPEC
1 Define this macro to a nonzero value if you want to treat
1 '__declspec(X)' as equivalent to '__attribute((X))'. By default,
1 this behavior is enabled only for targets that define
1 'TARGET_DLLIMPORT_DECL_ATTRIBUTES'. The current implementation of
1 '__declspec' is via a built-in macro, but you should not rely on
1 this implementation detail.
1
1 -- Target Hook: void TARGET_INSERT_ATTRIBUTES (tree NODE, tree
1 *ATTR_PTR)
1 Define this target hook if you want to be able to add attributes to
1 a decl when it is being created. This is normally useful for back
1 ends which wish to implement a pragma by using the attributes which
1 correspond to the pragma's effect. The NODE argument is the decl
1 which is being created. The ATTR_PTR argument is a pointer to the
1 attribute list for this decl. The list itself should not be
1 modified, since it may be shared with other decls, but attributes
1 may be chained on the head of the list and '*ATTR_PTR' modified to
1 point to the new attributes, or a copy of the list may be made if
1 further changes are needed.
1
1 -- Target Hook: bool TARGET_FUNCTION_ATTRIBUTE_INLINABLE_P (const_tree
1 FNDECL)
1 This target hook returns 'true' if it is OK to inline FNDECL into
1 the current function, despite its having target-specific
1 attributes, 'false' otherwise. By default, if a function has a
1 target specific attribute attached to it, it will not be inlined.
1
1 -- Target Hook: bool TARGET_OPTION_VALID_ATTRIBUTE_P (tree FNDECL, tree
1 NAME, tree ARGS, int FLAGS)
1 This hook is called to parse 'attribute(target("..."))', which
1 allows setting target-specific options on individual functions.
1 These function-specific options may differ from the options
1 specified on the command line. The hook should return 'true' if
1 the options are valid.
1
1 The hook should set the 'DECL_FUNCTION_SPECIFIC_TARGET' field in
1 the function declaration to hold a pointer to a target-specific
1 'struct cl_target_option' structure.
1
1 -- Target Hook: void TARGET_OPTION_SAVE (struct cl_target_option *PTR,
1 struct gcc_options *OPTS)
1 This hook is called to save any additional target-specific
1 information in the 'struct cl_target_option' structure for
1 function-specific options from the 'struct gcc_options' structure.
1 ⇒Option file format.
1
1 -- Target Hook: void TARGET_OPTION_RESTORE (struct gcc_options *OPTS,
1 struct cl_target_option *PTR)
1 This hook is called to restore any additional target-specific
1 information in the 'struct cl_target_option' structure for
1 function-specific options to the 'struct gcc_options' structure.
1
1 -- Target Hook: void TARGET_OPTION_POST_STREAM_IN (struct
1 cl_target_option *PTR)
1 This hook is called to update target-specific information in the
1 'struct cl_target_option' structure after it is streamed in from
1 LTO bytecode.
1
1 -- Target Hook: void TARGET_OPTION_PRINT (FILE *FILE, int INDENT,
1 struct cl_target_option *PTR)
1 This hook is called to print any additional target-specific
1 information in the 'struct cl_target_option' structure for
1 function-specific options.
1
1 -- Target Hook: bool TARGET_OPTION_PRAGMA_PARSE (tree ARGS, tree
1 POP_TARGET)
1 This target hook parses the options for '#pragma GCC target', which
1 sets the target-specific options for functions that occur later in
1 the input stream. The options accepted should be the same as those
1 handled by the 'TARGET_OPTION_VALID_ATTRIBUTE_P' hook.
1
1 -- Target Hook: void TARGET_OPTION_OVERRIDE (void)
1 Sometimes certain combinations of command options do not make sense
1 on a particular target machine. You can override the hook
1 'TARGET_OPTION_OVERRIDE' to take account of this. This hooks is
1 called once just after all the command options have been parsed.
1
1 Don't use this hook to turn on various extra optimizations for
1 '-O'. That is what 'TARGET_OPTION_OPTIMIZATION' is for.
1
1 If you need to do something whenever the optimization level is
1 changed via the optimize attribute or pragma, see
1 'TARGET_OVERRIDE_OPTIONS_AFTER_CHANGE'
1
1 -- Target Hook: bool TARGET_OPTION_FUNCTION_VERSIONS (tree DECL1, tree
1 DECL2)
1 This target hook returns 'true' if DECL1 and DECL2 are versions of
1 the same function. DECL1 and DECL2 are function versions if and
1 only if they have the same function signature and different target
1 specific attributes, that is, they are compiled for different
1 target machines.
1
1 -- Target Hook: bool TARGET_CAN_INLINE_P (tree CALLER, tree CALLEE)
1 This target hook returns 'false' if the CALLER function cannot
1 inline CALLEE, based on target specific information. By default,
1 inlining is not allowed if the callee function has function
1 specific target options and the caller does not use the same
1 options.
1
1 -- Target Hook: void TARGET_RELAYOUT_FUNCTION (tree FNDECL)
1 This target hook fixes function FNDECL after attributes are
1 processed. Default does nothing. On ARM, the default function's
1 alignment is updated with the attribute target.
1