The following target-specific function attributes are available for the AArch64 target. For the most part, these options mirror the behavior of similar command-line options (see AArch64 Options), but on a per-function basis.
general-regs-only
¶Indicates that no floating-point or Advanced SIMD registers should be used when generating code for this function. If the function explicitly uses floating-point code, then the compiler gives an error. This is the same behavior as that of the command-line option -mgeneral-regs-only.
fix-cortex-a53-835769
¶Indicates that the workaround for the Cortex-A53 erratum 835769 should be
applied to this function. To explicitly disable the workaround for this
function specify the negated form: no-fix-cortex-a53-835769
.
This corresponds to the behavior of the command line options
-mfix-cortex-a53-835769 and -mno-fix-cortex-a53-835769.
cmodel=
¶Indicates that code should be generated for a particular code model for this function. The behavior and permissible arguments are the same as for the command line option -mcmodel=.
strict-align
¶Indicates that the compiler should not assume that unaligned memory references are handled by the system. The behavior is the same as for the command-line option -mstrict-align.
omit-leaf-frame-pointer
¶Indicates that the frame pointer should be omitted for a leaf function call.
To keep the frame pointer, the inverse attribute
no-omit-leaf-frame-pointer
can be specified. These attributes have
the same behavior as the command-line options -momit-leaf-frame-pointer
and -mno-omit-leaf-frame-pointer.
tls-dialect=
¶Specifies the TLS dialect to use for this function. The behavior and permissible arguments are the same as for the command-line option -mtls-dialect=.
arch=
¶Specifies the architecture version and architectural extensions to use for this function. The behavior and permissible arguments are the same as for the -march= command-line option.
tune=
¶Specifies the core for which to tune the performance of this function. The behavior and permissible arguments are the same as for the -mtune= command-line option.
cpu=
¶Specifies the core for which to tune the performance of this function and also whose architectural features to use. The behavior and valid arguments are the same as for the -mcpu= command-line option.
The above target attributes can be specified as follows:
__attribute__((target("attr-string"))) int f (int a) { return a + 5; }
where attr-string
is one of the attribute strings specified above.
Additionally, the architectural extension string may be specified on its own. This can be used to turn on and off particular architectural extensions without having to specify a particular architecture version or core. Example:
__attribute__((target("+crc+nocrypto"))) int foo (int a) { return a + 5; }
In this example target("+crc+nocrypto")
enables the crc
extension and disables the crypto
extension for the function foo
without modifying an existing -march= or -mcpu option.
Multiple target function attributes can be specified by separating them with a comma. For example:
__attribute__((target("arch=armv8-a+crc+crypto,tune=cortex-a53"))) int foo (int a) { return a + 5; }
is valid and compiles function foo
for ARMv8-A with crc
and crypto
extensions and tunes it for cortex-a53
.
Specifying target attributes on individual functions or performing link-time optimization across translation units compiled with different target options can affect function inlining rules:
In particular, a caller function can inline a callee function only if the
architectural features available to the callee are a subset of the features
available to the caller.
For example: A function foo
compiled with -march=armv8-a+crc,
or tagged with the equivalent arch=armv8-a+crc
attribute,
can inline a function bar
compiled with -march=armv8-a+nocrc
because the all the architectural features that function bar
requires
are available to function foo
. Conversely, function bar
cannot
inline function foo
.
Additionally inlining a function compiled with -mstrict-align into a
function compiled without -mstrict-align
is not allowed.
However, inlining a function compiled without -mstrict-align into a
function compiled with -mstrict-align is allowed.
Note that CPU tuning options and attributes such as the -mcpu=,
-mtune= do not inhibit inlining unless the CPU specified by the
-mcpu= option or the cpu=
attribute conflicts with the
architectural feature rules specified above.