This is an archive of the discontinued LLVM Phabricator instance.

[mlir][llvm] Add aarch64_pstate_za_new LLVM function attribute
AbandonedPublic

Authored by c-rhodes on Jun 12 2023, 4:01 AM.

Details

Summary

This patch adds an optional attribute 'aarch64_pstate_za_new' to the
'llvm.func' op for the Armv9 Scalable Matrix Extension (SME) [1]. It
maps 1-1 with the LLVM function attribute of the same name [2] and
enables the SME ZA storage array.

The attribute has the following behaviour [3]:

The function’s ZA state is created on entry to the function and
destroyed on return from the function. That is, the function does not
use ZA to receive data from callers or to pass data back to callers.

ZA state being private to a function vs shared with the caller will be
simpler to begin enabling SME in MLIR.

[1] https://developer.arm.com/documentation/ddi0616/aa
[2] https://llvm.org/docs/AArch64SME.html#introduction
[3] https://arm-software.github.io/acle/main/acle.html#aarch64_pstate_za_new

Diff Detail

Event Timeline

c-rhodes created this revision.Jun 12 2023, 4:01 AM
Herald added a project: Restricted Project. · View Herald Transcript
c-rhodes requested review of this revision.Jun 12 2023, 4:01 AM
c-rhodes updated this revision to Diff 530450.Jun 12 2023, 4:02 AM

Patch was missing context.

awarzynski accepted this revision.Jun 12 2023, 5:25 AM

LGTM, thanks!

This revision is now accepted and ready to land.Jun 12 2023, 5:25 AM
c-rhodes updated this revision to Diff 530476.Jun 12 2023, 5:39 AM
c-rhodes added a subscriber: sdesmalen.

Use aarch64_pstate_za_new name everywhere rather than arm_za_new. Better to more closely match LLVM than C/C++ ACLE and also avoid confusion with Clang (thanks @sdesmalen for pointing this out).

c-rhodes retitled this revision from [mlir][llvm] Add arm_new_za LLVM function attribute to [mlir][llvm] Add aarch64_pstate_za_new LLVM function attribute.Jun 12 2023, 5:40 AM
c-rhodes edited the summary of this revision. (Show Details)
dcaballe accepted this revision.Jun 12 2023, 11:41 PM

Thanks!

c-rhodes planned changes to this revision.Jun 13 2023, 1:22 AM

The backend emits calls to the following SME support routines [1]:

  • __arm_tpidr2_restore
  • __arm_tpidr2_save

for this attribute. There's currently no public implementation of these routines and it's not yet clear where they will live. I think for now ZA will have to be enabled with the:

  • llvm.aarch64.sme.za.enable
  • llvm.aarch64.sme.za.disable

intrinsics [2] manually. Currently looking into this.

[1] https://github.com/ARM-software/abi-aa/blob/main/aapcs64/aapcs64.rst#sme-support-routines
[2] https://github.com/llvm/llvm-project/blob/main/llvm/test/CodeGen/AArch64/sme-toggle-pstateza.ll