2.1 Assembling SVE code

Use armclang with a suitable SVE-enabled target to assemble code containing SVE instructions.

The SVE architectural extension to the ARMv8-A architecture (armv8-a+sve) provides SVE instructions. Many of these SVE instructions make use of the new p and z register classes.

Note:

The legacy ARM assembler, armasm, does not support SVE instructions.

The following example shows a simple assembly program that includes SVE instructions.

// example1.s
    .global main     
main:
    mov     x0, 0x90000000
    mov     x8, xzr
    ptrue   p0.s                        //SVE instruction
    fcpy    z0.s, p0/m, #5.00000000     //SVE instruction
    orr     w10, wzr, #0x400
loop:
    st1w    z0.s, p0, [x0, x8, lsl #2]  //SVE instruction
    incw    x8                          //SVE instruction
    whilelt p0.s, x8, x10               //SVE instruction
    b.any   loop                        //SVE instruction
    mov     w0, wzr
    ret

To assemble this source file into a binary object file, use armclang with an SVE-enabled target:

armclang -c --target=aarch64-arm-none-eabi -march=armv8-a+sve example1.s -o example1.o

The command-line options in this example are:

-c

Standard armclang option. Instructs the compiler to perform the compilation step, but not the link step.

--target=aarch64-arm-none-eabi

Standard armclang option. Instructs the compiler to generate A64 instructions for AArch64 state.

Note:

SVE is not supported with AArch32 state, so the --target=aarch64-arm-none-eabi option is mandatory.
-march=armv8-a+sve

New target argument for the standard armclang -march option. Specifies that the compiler targets the ARMv8-A architecture profile with the SVE target feature enabled.

The default for AArch64 is -march=armv8-a, that is the ARMv8-A architecture profile without the SVE extension. You must explicitly specify +sve to assemble SVE instructions.

Valid SVE-enabled targets are:

  • -march=armv8-a+sve
  • -march=armv8.1-a+sve
  • -march=armv8.2-a+sve
  • -march=armv8.3-a+sve
example1.s

Standard armclang option. Input assembly language file.

-o example1.o

Standard armclang option. Output ELF object file.

Non-ConfidentialPDF file icon PDF versionARM 100891_0607_01_en
Copyright © 2016, 2017 ARM Limited or its affiliates. All rights reserved.