3.8 __attribute__((interrupt("type"))) function attribute

This attribute instructs the compiler to generate a function in a manner that is suitable for use as an exception handler.

Syntax

__attribute__((interrupt("type")))

Where type is one of the following:

Usage

This attribute affects the code generation of a function as follows:

  • If the function is AAPCS, the stack is realigned to 8 bytes on entry.
  • For processors that are not based on the M-profile, preserves all processor registers, rather than only the registers that the AAPCS requires to be preserved. Floating-point registers are not preserved.

  • For processors that are not based on the M-profile, the function returns using an instruction that is architecturally defined as a return from exception.

Restrictions

When using __attribute__((interrupt("type"))) functions:

  • No arguments or return values can be used with the functions.
  • The functions are incompatible with -frwpi.

Note:

In Arm®v6‑M, Armv7‑M, and Armv8‑M, the architectural exception handling mechanism preserves all processor registers, and a standard function return can cause an exception return. Therefore, specifying this attribute does not affect the behavior of the compiled output. However, Arm recommends using this attribute on exception handlers for clarity and easier software porting.

Note:

  • For architectures that support A32 and T32 instructions, functions specified with this attribute compile to A32 or T32 code depending on whether the compile option specifies A32 code or T32 code.

  • For T32 only architectures, for example the Armv6‑M architecture, functions specified with this attribute compile to T32 code.

  • This attribute is not available for A64 code.
Non-ConfidentialPDF file icon PDF version100067_0609_00_en
Copyright © 2014–2017 Arm Limited (or its affiliates). All rights reserved.