Next: AVR Function Attributes, Previous: ARC Function Attributes, Up: Function Attributes
These function attributes are supported for ARM targets:
general-regs-only
interrupt
You can specify the kind of interrupt to be handled by adding an optional parameter to the interrupt attribute like this:
void f () __attribute__ ((interrupt ("IRQ")));
Permissible values for this parameter are: IRQ
, FIQ
,
SWI
, ABORT
and UNDEF
.
On ARMv7-M the interrupt type is ignored, and the attribute means the function
may be called with a word-aligned stack pointer.
isr
interrupt
attribute above.
long_call
short_call
#pragma long_calls
settings. For ARM, the
long_call
attribute indicates that the function might be far
away from the call site and require a different (more expensive)
calling sequence. The short_call
attribute always places
the offset to the function from the call site into the `BL'
instruction directly.
naked
asm
statements can safely be included in naked functions
(see Basic Asm). While using extended asm
or a mixture of
basic asm
and C code may appear to work, they cannot be
depended upon to work reliably and are not supported.
pcs
pcs
attribute can be used to control the calling convention
used for a function on ARM. The attribute takes an argument that specifies
the calling convention to use.
When compiling using the AAPCS ABI (or a variant of it) then valid
values for the argument are "aapcs"
and "aapcs-vfp"
. In
order to use a variant other than "aapcs"
then the compiler must
be permitted to use the appropriate co-processor registers (i.e., the
VFP registers must be available in order to use "aapcs-vfp"
).
For example,
/* Argument passed in r0, and result returned in r0+r1. */ double f2d (float) __attribute__((pcs("aapcs")));
Variadic functions always use the "aapcs"
calling convention and
the compiler rejects attempts to specify an alternative.
target (
options)
On ARM, the following options are allowed:
Functions from different modes can be inlined in the caller's mode.
The above target attributes can be specified as follows:
__attribute__((target("arch=armv8-a+crc"))) int f (int a) { return a + 5; }
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.