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
fix-cortex-a53-835769
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=
strict-align
omit-leaf-frame-pointer
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=
arch=
tune=
cpu=
sign-return-address
none
.
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.