ARMv8的两种执行状态: AArch64/AArch32

Copied from ARM® Compiler User Guide
When compiling code, you must first decide which target the executable is to run on. An ARMv8-A target can run in different states:
• AArch64 state targets execute A64 instructions using 64-bit wide general-purpose registers.
• AArch32 state targets execute A32 or T32 instructions using 32-bit wide general-purpose registers.
The –target option determines which target state to compile for. This option is a mandatory option.
To create an executable for an AArch64 target in a single step:
armclang –target=aarch64-arm-none-eabi hello.c
This command creates an executable, a.out.
The –target option selects the target that you want to compile for. This example compiles for an AArch64 state target. Because only –target is specified, the compiler defaults to generating code that runs on any ARMv8-A target. You can also use -mcpu to target a specific processor.
To create an executable for an AArch32 target in a single step:
armclang –target=arm-arm-none-eabi -mcpu=cortex-a53 hello.c
In this example, there is no default target for AArch32 state, so you must specify either -march to target an architecture or -mcpu to target a processor. This example uses -mcpu to target the Cortex®-A53 processor. The compiler generates code that is optimized specifically for the Cortex-A53, but might not run on other processors.
Use -mcpu=list or -march=list to see all available options.

• 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.

ARMv8-A有两种执行状态: AArch64和AArch32(后者是为了兼容以前的32bit的程序)。
AArch64执行A64指令,使用64bit的通用寄存器;
AArch32执行A32/T32指令,使用32bit的通用寄存器;
arm compiler使用 –target=aarch64-arm-none-eabi 来产生 AArch64的可执行程序。默认使用ARMv8-A target,也可使用 -mcpu 指定特定的ARMv8处理器。
使用 –target=arm-arm-none-eabi 来产生 AArch32的可执行程序。对AArch32而言,没有默认target(处理器),所以需要使用 -march 或者 -mcpu 来指定处理器:
–target=arm-arm-none-eabi -mcpu=cortex-a53

可使用 -mcpu=list 或者 -march=list 查看可选的架构和处理器选项。

–target是armclang用的参数,别的工具,例如armasm/armlink,使用 –cpu 和 -fpu 参数来指定处理器和架构。

你可能感兴趣的:(arm,toolchain)