Keil Logo

Technical Support

On-Line Manuals

Compiler Reference Guide

Preface Arm Compiler Tools Overview armclang Reference armclang Command-line Options Summary of armclang command-line options -C (armclang) -c (armclang) -D -E -e -fbare-metal-pie -fbracket-depth=N -fcommon, -fno-common -fdata-sections, -fno-data-sections -ffast-math, -fno-fast-math -ffixed-rN -ffp-mode -ffunction-sections, -fno-function-sections -fident, -fno-ident @file -fldm-stm, -fno-ldm-stm -fno-builtin -fno-inline-functions -flto, -fno-lto -fexceptions, -fno-exceptions -fomit-frame-pointer, -fno-omit-frame-pointer -fpic, -fno-pic -fropi, -fno-ropi -fropi-lowering, -fno-ropi-lowering -frwpi, -fno-rwpi -frwpi-lowering, -fno-rwpi-lowering -fsanitize -fshort-enums, -fno-short-enums -fshort-wchar, -fno-short-wchar -fstack-protector, -fstack-protector-all, -fstack- -fstrict-aliasing, -fno-strict-aliasing -fsysv, -fno-sysv -ftrapv -fvectorize, -fno-vectorize -fvisibility -fwrapv -g, -gdwarf-2, -gdwarf-3, -gdwarf-4 (armclang) -I -include -L -l -M, -MM -MD, -MMD -MF -MG -MP -MT -march -marm -masm -mbig-endian -mbranch-protection -mcmodel -mcmse -mcpu -mexecute-only -mfloat-abi -mfpu -mimplicit-it -mlittle-endian -mno-neg-immediates -moutline, -mno-outline -mpixolib -munaligned-access, -mno-unaligned-access -mthumb -nostdlib -nostdlibinc -o (armclang) -O (armclang) -pedantic -pedantic-errors -Rpass -S -save-temps -shared (armclang) -std --target -U -u (armclang) -v (armclang) --version (armclang) --version_number (armclang) --vsn (armclang) -W -Wl -Xlinker -x (armclang) -### Compiler-specific Keywords and Operators Compiler-specific keywords and operators __alignof__ __asm __declspec attributes __declspec(noinline) __declspec(noreturn) __declspec(nothrow) __inline __promise __unaligned Global named register variables Compiler-specific Function, Variable, and Type Att Function attributes __attribute__((always_inline)) function attribute __attribute__((cmse_nonsecure_call)) function attr __attribute__((cmse_nonsecure_entry)) function att __attribute__((const)) function attribute __attribute__((constructor(priority))) function at __attribute__((format_arg(string-index))) function __attribute__((interrupt("type"))) function attrib __attribute__((malloc)) function attribute __attribute__((naked)) function attribute __attribute__((noinline)) function attribute __attribute__((nonnull)) function attribute __attribute__((noreturn)) function attribute __attribute__((nothrow)) function attribute __attribute__((pcs("calling_convention"))) functio __attribute__((pure)) function attribute __attribute__((section("name"))) function attribut __attribute__((target("options"))) function attrib __attribute__((unused)) function attribute __attribute__((used)) function attribute __attribute__((value_in_regs)) function attribute __attribute__((visibility("visibility_type"))) fun __attribute__((weak)) function attribute __attribute__((weakref("target"))) function attrib Type attributes __attribute__((aligned)) type attribute __attribute__((packed)) type attribute __attribute__((transparent_union)) type attribute Variable attributes __attribute__((alias)) variable attribute __attribute__((aligned)) variable attribute __attribute__((deprecated)) variable attribute __attribute__((packed)) variable attribute __attribute__((section("name"))) variable attribut __attribute__((unused)) variable attribute __attribute__((used)) variable attribute __attribute__((visibility("visibility_type"))) var __attribute__((weak)) variable attribute __attribute__((weakref("target"))) variable attrib Compiler-specific Intrinsics __breakpoint intrinsic __current_pc intrinsic __current_sp intrinsic __disable_fiq intrinsic __disable_irq intrinsic __enable_fiq intrinsic __enable_irq intrinsic __force_stores intrinsic __memory_changed intrinsic __schedule_barrier intrinsic __semihost intrinsic __vfp_status intrinsic Compiler-specific Pragmas #pragma clang system_header #pragma clang diagnostic #pragma clang section #pragma once #pragma pack(...) #pragma unroll[(n)], #pragma unroll_completely #pragma weak symbol, #pragma weak symbol1 = symbol Other Compiler-specific Features ACLE support Predefined macros Inline functions Volatile variables Half-precision floating-point data types Half-precision floating-point number format Half-precision floating-point intrinsics Library support for _Float16 data type BFloat16 floating-point number format TT instruction intrinsics Non-secure function pointer intrinsics Supported architecture feature combinations for sp armclang Integrated Assembler Syntax of assembly files for integrated assembler Assembly expressions Alignment directives Data definition directives String definition directives Floating-point data definition directives Section directives Conditional assembly directives Macro directives Symbol binding directives Org directive AArch32 Target selection directives AArch64 Target selection directives Space-filling directives Type directive Integrated assembler support for the CSDB instruct armclang Inline Assembler Inline Assembly File-scope inline assembly Inline assembly statements within a function Assembly string Output and input operands Clobber list volatile Inline assembly constraint strings Constraint modifiers Constraint codes Constraint codes common to AArch32 state and AArch Constraint codes for AArch32 state Constraint codes for AArch64 state Using multiple alternative operand constraints Inline assembly template modifiers Template modifiers common to AArch32 state and AAr Template modifiers for AArch32 state Template modifiers for AArch64 state Forcing inline assembly operands into specific reg Symbol references and branches into and out of inl Duplication of labels in inline assembly statement armlink Reference fromelf Reference armar Reference armasm Legacy Assembler Reference Appendixes

-ffixed-rN

B1.12 -ffixed-rN

Prevents the compiler from using the specified general-purpose register, unless the use is required for Arm ABI compliance. The option also prevents the register contents being placed on the stack.You must use this option if you want to reserve registers for use as a global named register variable.

Default

By default, the compiler is free to use general-purpose registers for any purpose, such as for temporary storage of local variables, within the requirements of the Arm ABI.

Syntax

-ffixed-rN

Parameters

N specifies the register number from 6-11, and enables you to reserve general-purpose registers R6 to R11.

Restrictions

This feature is only available for AArch32 state.

If you use -mpixolib, then you must not use the following registers as global named register variables:

  • R8
  • R9

If you use -frwpi or -frwpi-lowering, then you must not use register R9 as a global named register variable. armclang thows an error if you do.

The Arm ABI reserves the following registers for use as a frame pointer if needed:

  • R7 in T32 state.
  • R11 in A32 state.

armclang thows an error if you use global named register variables under these conditions.

Code size

Declaring a general-purpose register as a global named register variable means that the register is not available to the compiler for other operations. If you declare too many global named register variables, code size increases significantly. Sometimes, your program might not compile, for example if there are insufficient registers available to compute a particular expression.

Operation

-ffixed-rN reserves the specified general-purpose register so that the compiler does not use the specified register unless required for Arm ABI compliance. You must reserve the register if you want to use the register as a global named register variable. You can also use -ffixed-rN for generating compatible objects, for example to generate objects that you want to link with other objects that have been built with -frwpi.

For example, -ffixed-r8 reserves register R8 so that the compiler cannot use R8 for storing temporary variables.

Note:

The specified registers might still be used in other object files, for example library code, that have not been compiled using the -ffixed-rN option.

Examples

The following example demonstrates the effect of the -ffixed-rN option.

Source file bar.c contains the following code:

int bar(unsigned int i, unsigned int j,
        unsigned int k, unsigned int l,
        unsigned int m, unsigned int n,
        unsigned int o, unsigned int p,
        unsigned int q, unsigned int r,
        unsigned int s)
{
    return (i + j + k + l + m + n + o + p + q + r + s);
}

Compile this code without any -ffixed-rN option:

armclang --target=arm-arm-none-eabi -march=armv8-a -O0 -S bar.c -o bar.s

The generated assembly file, bar.s, saves the registers that it needs to use, which are {r4, r5, r6, r7, r8, lr}:

bar:
    .fnstart
    .cfi_sections .debug_frame
    .cfi_startproc
@ %bb.0:
    .save    {r4, r5, r6, r7, r8, lr}
    push    {r4, r5, r6, r7, r8, lr}
    .cfi_def_cfa_offset 24
    .cfi_offset lr, -4
    .cfi_offset r8, -8
    .cfi_offset r7, -12
    .cfi_offset r6, -16
    .cfi_offset r5, -20
    .cfi_offset r4, -24
    .pad    #16
    sub    sp, sp, #16
       
    /* Code in between is hidden */

    add    sp, sp, #16
    pop    {r4, r5, r6, r7, r8, pc}
.Lfunc_end0:

To ensure that the compiler does not use registers R6, R7, and R8, compile the same code in foo.c with the -ffixed-r6, -ffixed-r7, and -ffixed-r8 options:

armclang --target=arm-arm-none-eabi -march=armv8-a -O0 -ffixed-r6 -ffixed-r7 -ffixed-r8 -S bar.c -o bar.s

The generated assembly file, bar.s, saves the registers that it needs to use, which are {r4, r5, r9, r10, r11, lr}. In this bar.s, the compiler uses registers R9, R10, and R11 instead of R6, R7, and R8:

bar:
    .fnstart
    .cfi_sections .debug_frame
    .cfi_startproc
@ %bb.0:
    .save    {r4, r5, r9, r10, r11, lr}
    push    {r4, r5, r9, r10, r11, lr}
    .cfi_def_cfa_offset 24
    .cfi_offset lr, -4
    .cfi_offset r11, -8
    .cfi_offset r10, -12
    .cfi_offset r9, -16
    .cfi_offset r5, -20
    .cfi_offset r4, -24
    .pad    #16
    sub    sp, sp, #16
       
    /* Code in between is hidden */

    add    sp, sp, #16
    pop    {r4, r5, r9, r10, r11, pc}
.Lfunc_end0:
Non-ConfidentialPDF file icon PDF version101754_0614_00_en
Copyright © 2019, 2020 Arm Limited or its affiliates. All rights reserved. 
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.