Next: Emulated TLS, Previous: Mode Switching, Up: Target Macros
__attribute__
Target-specific attributes may be defined for functions, data and types. These are described using the following target hooks; they also need to be documented in extend.texi.
If defined, this target hook points to an array of `struct attribute_spec' (defined in tree.h) specifying the machine specific attributes for this target and some of the restrictions on the entities to which these attributes are applied and the arguments they take.
If defined, this target hook is a function which returns true if the machine-specific attribute named name expects an identifier given as its first argument to be passed on as a plain identifier, not subjected to name lookup. If this is not defined, the default is false for all machine-specific attributes.
If defined, this target hook is a function which returns zero if the attributes on type1 and type2 are incompatible, one if they are compatible, and two if they are nearly compatible (which causes a warning to be generated). If this is not defined, machine-specific attributes are supposed always to be compatible.
If defined, this target hook is a function which assigns default attributes to the newly defined type.
Define this target hook if the merging of type attributes needs special handling. If defined, the result is a list of the combined
TYPE_ATTRIBUTES
of type1 and type2. It is assumed thatcomptypes
has already been called and returned 1. This function may callmerge_attributes
to handle machine-independent merging.
Define this target hook if the merging of decl attributes needs special handling. If defined, the result is a list of the combined
DECL_ATTRIBUTES
of olddecl and newdecl. newdecl is a duplicate declaration of olddecl. Examples of when this is needed are when one attribute overrides another, or when an attribute is nullified by a subsequent definition. This function may callmerge_attributes
to handle machine-independent merging.If the only target-specific handling you require is `dllimport' for Microsoft Windows targets, you should define the macro
TARGET_DLLIMPORT_DECL_ATTRIBUTES
to1
. The compiler will then define a function calledmerge_dllimport_decl_attributes
which can then be defined as the expansion ofTARGET_MERGE_DECL_ATTRIBUTES
. You can also addhandle_dll_attribute
in the attribute table for your port to perform initial processing of the `dllimport' and `dllexport' attributes. This is done in i386/cygwin.h and i386/i386.c, for example.
decl is a variable or function with
__attribute__((dllimport))
specified. Use this hook if the target needs to add extra validation checks tohandle_dll_attribute
.
Define this macro to a nonzero value if you want to treat
__declspec(X)
as equivalent to__attribute((X))
. By default, this behavior is enabled only for targets that defineTARGET_DLLIMPORT_DECL_ATTRIBUTES
. The current implementation of__declspec
is via a built-in macro, but you should not rely on this implementation detail.
Define this target hook if you want to be able to add attributes to a decl when it is being created. This is normally useful for back ends which wish to implement a pragma by using the attributes which correspond to the pragma's effect. The node argument is the decl which is being created. The attr_ptr argument is a pointer to the attribute list for this decl. The list itself should not be modified, since it may be shared with other decls, but attributes may be chained on the head of the list and
*
attr_ptr modified to point to the new attributes, or a copy of the list may be made if further changes are needed.
This target hook returns
true
if it is ok to inline fndecl into the current function, despite its having target-specific attributes,false
otherwise. By default, if a function has a target specific attribute attached to it, it will not be inlined.
This hook is called to parse the
attribute(option("..."))
, and it allows the function to set different target machine compile time options for the current function that might be different than the options specified on the command line. The hook should returntrue
if the options are valid.The hook should set the DECL_FUNCTION_SPECIFIC_TARGET field in the function declaration to hold a pointer to a target specific struct cl_target_option structure.
This hook is called to save any additional target specific information in the struct cl_target_option structure for function specific options. See Option file format.
This hook is called to restore any additional target specific information in the struct cl_target_option structure for function specific options.
This hook is called to print any additional target specific information in the struct cl_target_option structure for function specific options.
This target hook parses the options for
#pragma GCC option
to set the machine specific options for functions that occur later in the input stream. The options should be the same as handled by theTARGET_OPTION_VALID_ATTRIBUTE_P
hook.
Sometimes certain combinations of command options do not make sense on a particular target machine. You can override the hook
TARGET_OPTION_OVERRIDE
to take account of this. This hooks is called once just after all the command options have been parsed.Don't use this hook to turn on various extra optimizations for -O. That is what
TARGET_OPTION_OPTIMIZATION
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 hook returns
false
if the caller function cannot inline callee, based on target specific information. By default, inlining is not allowed if the callee function has function specific target options and the caller does not use the same options.