Search code examples
armcpu-registersarmv7

Where's the ARM register convention?


According to the ARMv7 documentation, R0-R12 are general-purpose registers and R13, R14 and R15 are the SP, LR and PC. I've seen in some questions in the ARM forum, StackOverflow or other sites that R11 is often used as frame pointer (ARM forum, pp, StackOverflow, Microsoft), however I can't find any official documentation, from ARM or GCC, declaring the use of this register. Some people also said it was in the AAPCS, however, the only information available in this document about R11 is that it is a variable register.

If anybody could help locate an official document stating the usage of these registers, including R11 as the frame pointer, I'd be truly grateful.


Solution

  • I think you're looking for the ABI, Application Binary Interface.

    This is a collection of documents. At the base level, R11 is indeed declared as "Variable-register 8.".

    That's by itself not a very restricting definition. Implementations can assign basically any variable, whether that's a programmer-visible variable or some internal helper variable for whatever language-specific feature they need. A Frame Pointer variable is a useful variable in some languages, but not all, and it would be a shame to sacrifice the 8th variable register in implementations that don't require a Frame Pointer.

    So ARM has no point in making an official statement how R11 is to be used as a Frame Pointer, and GCC can't make official statements on behalf of ARM.