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, and which instruction set to use.

Command-line syntax

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

--target=arch-vendor-os-env

Supported targets are as follows:

aarch64-arm-none-eabi
The AArch64 state of the ARMv8 architecture. This target supports the A64 instruction set. This is the default target.
armv8a-arm-none-eabi
The AArch32 state of the ARMv8 architecture. This target supports the A32 and T32 instruction sets.

Note

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

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-a53
  • cortex-a57

Processors in AArch64 state execute A64 instructions. Processors in AArch32 state can execute A32 or T32 instructions. To specify the target instruction set for AArch32 state, use the following command-line options:

  • -marm targets the A32 instruction set. This is the default for the armv8a-arm-none-eabi target.
  • -mthumb targets the T32 instruction set.

Note

The -marm and -mthumb options are only valid with AArch32 targets, for example --target=armv8a-arm-none-eabi. The compiler ignores the -marm and -mthumb options and generates a warning with AArch64 targets.

Command-line examples

ARM Compiler 6 lets you compile for the following combinations of architecture and instruction set:

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

Architecture Processor Instruction set armclang command
ARMv8 AArch32 state Generic A32

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

or, because -marm is the default for AArch32 targets:

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

ARMv8 AArch32 state Cortex-A57 A32

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

or, because -marm is the default for AArch32 targets:

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

ARMv8 AArch32 state Cortex-A53 A32

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

or, because -marm is the default for AArch32 targets:

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

ARMv8 AArch32 state Generic T32

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

ARMv8 AArch32 state Cortex-A57 T32

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

ARMv8 AArch32 state Cortex-A53 T32

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

ARMv8 AArch64 state Generic A64

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

or, because --target=aarch64-arm-none-eabi is the default:

armclang test.c

ARMv8 AArch64 state Cortex-A57 A64

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

or, because --target=aarch64-arm-none-eabi is the default:

armclang -mcpu=cortex-a57 test.c

ARMv8 AArch64 state Cortex-A53 A64

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

or, because --target=aarch64-arm-none-eabi is the default:

armclang -mcpu=cortex-a53 test.c

Was this page helpful? Yes No