gcc: ARM Function Attributes
1
1 6.31.4 ARM Function Attributes
1 ------------------------------
1
1 These function attributes are supported for ARM targets:
1
1 'interrupt'
1 Use this attribute to indicate that the specified function is an
1 interrupt handler. The compiler generates function entry and exit
1 sequences suitable for use in an interrupt handler when this
1 attribute is present.
1
1 You can specify the kind of interrupt to be handled by adding an
1 optional parameter to the interrupt attribute like this:
1
1 void f () __attribute__ ((interrupt ("IRQ")));
1
1 Permissible values for this parameter are: 'IRQ', 'FIQ', 'SWI',
1 'ABORT' and 'UNDEF'.
1
1 On ARMv7-M the interrupt type is ignored, and the attribute means
1 the function may be called with a word-aligned stack pointer.
1
1 'isr'
1 Use this attribute on ARM to write Interrupt Service Routines.
1 This is an alias to the 'interrupt' attribute above.
1
1 'long_call'
1 'short_call'
1 These attributes specify how a particular function is called.
1 These attributes override the '-mlong-calls' (⇒ARM Options)
1 command-line switch and '#pragma long_calls' settings. For ARM,
1 the 'long_call' attribute indicates that the function might be far
1 away from the call site and require a different (more expensive)
1 calling sequence. The 'short_call' attribute always places the
1 offset to the function from the call site into the 'BL' instruction
1 directly.
1
1 'naked'
1 This attribute allows the compiler to construct the requisite
1 function declaration, while allowing the body of the function to be
1 assembly code. The specified function will not have
1 prologue/epilogue sequences generated by the compiler. Only basic
11 'asm' statements can safely be included in naked functions (⇒
Basic Asm). While using extended 'asm' or a mixture of basic
1 'asm' and C code may appear to work, they cannot be depended upon
1 to work reliably and are not supported.
1
1 'pcs'
1
1 The 'pcs' attribute can be used to control the calling convention
1 used for a function on ARM. The attribute takes an argument that
1 specifies the calling convention to use.
1
1 When compiling using the AAPCS ABI (or a variant of it) then valid
1 values for the argument are '"aapcs"' and '"aapcs-vfp"'. In order
1 to use a variant other than '"aapcs"' then the compiler must be
1 permitted to use the appropriate co-processor registers (i.e., the
1 VFP registers must be available in order to use '"aapcs-vfp"').
1 For example,
1
1 /* Argument passed in r0, and result returned in r0+r1. */
1 double f2d (float) __attribute__((pcs("aapcs")));
1
1 Variadic functions always use the '"aapcs"' calling convention and
1 the compiler rejects attempts to specify an alternative.
1
1 'target (OPTIONS)'
1 As discussed in ⇒Common Function Attributes, this attribute
1 allows specification of target-specific compilation options.
1
1 On ARM, the following options are allowed:
1
1 'thumb'
1 Force code generation in the Thumb (T16/T32) ISA, depending on
1 the architecture level.
1
1 'arm'
1 Force code generation in the ARM (A32) ISA.
1
1 Functions from different modes can be inlined in the caller's
1 mode.
1
1 'fpu='
1 Specifies the fpu for which to tune the performance of this
1 function. The behavior and permissible arguments are the same
1 as for the '-mfpu=' command-line option.
1
1 'arch='
1 Specifies the architecture version and architectural
1 extensions to use for this function. The behavior and
1 permissible arguments are the same as for the '-march='
1 command-line option.
1
1 The above target attributes can be specified as follows:
1
1 __attribute__((target("arch=armv8-a+crc")))
1 int
1 f (int a)
1 {
1 return a + 5;
1 }
1
1 Additionally, the architectural extension string may be
1 specified on its own. This can be used to turn on and off
1 particular architectural extensions without having to specify
1 a particular architecture version or core. Example:
1
1 __attribute__((target("+crc+nocrypto")))
1 int
1 foo (int a)
1 {
1 return a + 5;
1 }
1
1 In this example 'target("+crc+nocrypto")' enables the 'crc'
1 extension and disables the 'crypto' extension for the function
1 'foo' without modifying an existing '-march=' or '-mcpu'
1 option.
1