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:
- Target an architecture using the
- Target a specific processor using
-mcpuoption, or omit to target the architecture.
- (ARMv7-A and ARMv8-A AArch32 targets only) Specify the floating-point
hardware available using the
-mfpuoption, or omit to use the default for the target.
- (ARMv7-A and ARMv8-A AArch32 targets only) Specify the instruction set
-mthumb, or omit to default to
Specifying the target architecture
To specify a target architecture with
armclang, use the
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.
--targetoption is an
armclangoption. For all of the other tools, such as
armlink, use the
--fpuoptions to specify target processors and architectures.
--targetoption 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
If you want to optimize your code for a particular processor, use
-mcpu option supports the following values:
For ARMv8-A AArch64 targets, you can specify feature modifiers with
-mcpu, for example
Specifying the floating-point hardware available on the target
-mfpu option overrides the
default FPU option implied by the target architecture (
--target) or processor (
-mfpuoption is ignored with ARMv8-A AArch64 targets. Use the
-mcpuoption 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=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:
-marmtargets the A32 (ARMv8-A) or ARM (ARMv7-A) instruction set. This is the default for the
-mthumbtargets the T32 (ARMv8-A) or Thumb (ARMv7-A) instruction set.
-mthumboptions are not valid with AArch64 targets. The compiler ignores the
-mthumboptions and generates a warning with AArch64 targets.
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||
|ARMv8-A AArch64 state||Cortex-A57||A64||
|ARMv8-A AArch32 state||Generic||A32||
|ARMv8-A AArch32 state||Cortex-A53||A32||
|ARMv8-A AArch32 state||Cortex-A57||T32||