Non-Confidential | ![]() | ARM 100066_0608_00_en | ||
| ||||
Home > Compiling C and C++ Code > 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:
Specify the execution state using the --target
option.
The execution state can be AArch64 or AArch32 depending on the processor.
Target one of the following:
-march
option.-mcpu
option.-mfpu
option, or omit to use the default for the target.-marm
or -mthumb
, or omit to default to -marm
. To specify a target execution state with armclang
, use the --target
command-line option:
--target=
arch
-vendor
-os
-abi
Supported targets are as follows:
aarch64-arm-none-eabi
-march=armv8-a
unless -mcpu
is specified.arm-arm-none-eabi
-march
(to target an
architecture) or -mcpu
(to target a
processor).--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.--target
option is mandatory. You
must always specify a target execution state.Targeting an architecture with --target
and
-march
generates generic code that runs on any
processor with that architecture.
Use the -march=list
option to see all supported architectures.
-march
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.Targeting a processor with --target
and -mcpu
optimizes code
for the specified processor.
Use the -mcpu=list
option to see all
supported processors.
You can specify feature modifiers with -mcpu
and -march
. For example
-mcpu=cortex-a57+nocrypto
.
The -mfpu
option overrides the default FPU
option implied by the target architecture or processor.
-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 the
cryptographic extensions for AArch64 targets use the -mcpu=name
+nocrypto
option.Different architectures support different instruction sets:
To specify the target instruction set, use the following command-line options:
-marm
targets the A32 (formerly ARM)
instruction set. This is the default for all targets that support ARM or A32
instructions.-mthumb
targets the T32 (formerly Thumb)
instruction set. This is the default for all targets that only support Thumb or
T32 instructions.-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.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 |
|
ARMv7-A | Generic | A32 |
|
ARMv7-A | Cortex‑A9 | A32 |
|
ARMv7-A | Cortex‑A15 | T32 |
|
ARMv7-R | Cortex‑R7 | A32 |
|
ARMv7-R | Cortex‑R7 | T32 |
|
ARMv7-M | Generic | T32 |
|
ARMv6-M | Cortex‑M0 | T32 |
|
ARMv8-M.Mainline | Generic | T32 |
|
ARMv8-M.Baseline | Generic | T32 |
|