You copied the Doc URL to your clipboard.

Specifying a target architecture, processor, and instruction set

When compiling code, the compiler must know which architecture or processor to target, which optional architectural features are available, and which instruction set to use.


If you only want to run code on one particular processor, you can target that specific processor. Performance is optimized, but code is only guaranteed to run on that processor.

If you want your code to run on a wide range of processors, you can target an architecture. The code runs on any processor implementation of the target architecture, but performance might be impacted.

The options for specifying a target are as follows:

  1. Target an architecture using the --target option.
  2. Target a specific processor using -mcpu option, or omit to target the architecture.
  3. (ARMv7-A and ARMv8-A AArch32 targets only) Specify the floating-point hardware available using the -mfpu option, or omit to use the default for the target.
  4. (ARMv7-A and ARMv8-A AArch32 targets only) Specify the instruction set using -marm or -mthumb, or omit to default to -marm.

Specifying the target architecture

To specify a target architecture with armclang, use the --target command-line option:


Supported targets are as follows:

The AArch64 state of the ARMv8-A architecture profile. This target supports the ARMv8 A64 instruction set.
The AArch32 state of the ARMv8-A architecture profile. This target supports the ARMv8 A32 and T32 instruction sets.
The ARMv7-A architecture profile. This target supports the ARMv7 ARM and Thumb instruction sets.


The --target option is an armclang option. For all of the other tools, such as armasm and armlink, use the --cpu and --fpu options to specify target processors and architectures.


The --target option is mandatory. You must always specify a target architecture.

Targeting a specific processor

Targeting an architecture with --target generates generic code that runs on any processor with that architecture.

If you want to optimize your code for a particular processor, use the -mcpu option.

The -mcpu option supports the following values:

  • cortex-a5
  • cortex-a7
  • cortex-a8
  • cortex-a9
  • cortex-a12
  • cortex-a15
  • cortex-a17
  • cortex-a53
  • cortex-a57

For ARMv8-A AArch64 targets, you can specify feature modifiers with -mcpu, for example -mcpu=cortex-a57+nocrypto.

Specifying the floating-point hardware available on the target

The -mfpu option overrides the default FPU option implied by the target architecture (--target) or processor (-mcpu).


The -mfpu option is ignored with ARMv8-A AArch64 targets. Use the -mcpu option to override the default FPU for AArch64 targets. For example, to prevent the use of floating-point instructions or floating-point registers for AArch64 targets use the -mcpu=name+nofp+nosimd option. Subsequent use of floating-point data types in this mode is unsupported.

Specifying the instruction set

Different architectures support different instruction sets:

  • ARMv8-A processors in AArch64 state execute A64 instructions.
  • ARMv8-A processors in AArch32 state can execute A32 or T32 instructions.
  • ARMv7-A processors can execute ARM or Thumb instructions.

To specify the target instruction set for ARMv8-A AArch32 state and ARMv7-A, use the following command-line options:

  • -marm targets the A32 (ARMv8-A) or ARM (ARMv7-A) instruction set. This is the default for the armv8a-arm-none-eabi and armv7a-arm-none-eabi targets.
  • -mthumb targets the T32 (ARMv8-A) or Thumb (ARMv7-A) instruction set.


The -marm and -mthumb options are not valid with AArch64 targets. The compiler ignores the -marm and -mthumb options and generates a warning with AArch64 targets.

Command-line examples

The following examples show how to compile for different combinations of architecture, processor, and instruction set:

Table 3-1 Compiling for different combinations of architecture, processor, and instruction set

Architecture Processor Instruction set armclang command
ARMv8-A AArch64 state Generic A64

armclang --target=aarch64-arm-none-eabi test.c

ARMv8-A AArch64 state Cortex-A57 A64

armclang --target=aarch64-arm-none-eabi -mcpu=cortex-a57 test.c

ARMv8-A AArch32 state Generic A32

armclang --target=armv8a-arm-none-eabi test.c

ARMv8-A AArch32 state Cortex-A53 A32

armclang --target=armv8a-arm-none-eabi -mcpu=cortex-a53 test.c

ARMv8-A AArch32 state Cortex-A57 T32

armclang --target=armv8a-arm-none-eabi -mcpu=cortex-a57 -mthumb test.c

ARMv7-A Cortex-A9 ARM

armclang --target=armv7a-arm-none-eabi -mcpu=cortex-a9 test.c

ARMv7-A Cortex-A15 Thumb

armclang --target=armv7a-arm-none-eabi -mcpu=cortex-a15 -mthumb test.c

Related information

Was this page helpful? Yes No