This is an archive of the discontinued LLVM Phabricator instance.

[mlir][llvm] Add arm_streaming LLVM function attributes
ClosedPublic

Authored by c-rhodes on May 18 2023, 11:19 PM.

Details

Summary

This patch adds two optional attributes to 'llvm.func' op for the Armv9
Streaming SVE (SSVE) mode [1] that map 1-1 with LLVM function attributes [2]:

  • arm_streaming -> aarch64_pstate_sm_enabled
  • arm_locally_streaming -> aarch64_pstate_sm_body

Streaming-mode is part of the interface (ABI) for functions with the
first attribute and it's the responsibility of the caller to manage
PSTATE.SM on entry/exit to functions with this attribute [3]. The LLVM
backend will emit 'smstart sm' / 'smstop sm' [4] around calls to
streaming functions.

In locally streaming functions PSTATE.SM is kept internal and managed by
the callee on entry/exit. The LLVM backend will emit 'smstart sm' /
'smstop sm' in the prologue / epilogue for functions with this
attribute.

The integration test for SSVE has been updated to no longer use the
passthrough mechanism that's intended for prototyping.

PATCH [1 / 2] in series for RFC: https://discourse.llvm.org/t/rfc-supporting-armv9-scalable-matrix-extension-sme-streaming-sve-ssve-mode-in-mlir/70678

[1] https://developer.arm.com/documentation/ddi0616/aa
[2] https://llvm.org/docs/AArch64SME.html#introduction
[3] https://github.com/ARM-software/abi-aa/blob/main/aapcs64/aapcs64.rst#671pstatesm-interfaces
[4] https://developer.arm.com/documentation/ddi0602/2023-03/Base-Instructions/SMSTART--Enables-access-to-Streaming-SVE-mode-and-SME-architectural-state--an-alias-of-MSR--immediate--

Diff Detail

Event Timeline

c-rhodes created this revision.May 18 2023, 11:19 PM
Herald added a reviewer: ftynse. · View Herald Transcript
Herald added a project: Restricted Project. · View Herald Transcript
c-rhodes requested review of this revision.May 18 2023, 11:19 PM
awarzynski accepted this revision.May 19 2023, 7:21 AM

Thank you for working on this!

LGTM modulo one comment. I'll be away for a week, hence approving as is - I don't want to block it.

mlir/lib/Target/LLVMIR/ModuleImport.cpp
1545–1549

Do we need this? I don't see similar checks for other attributes. If you'd like to keep it, then perhaps worth adding a test that shows that {passthrough = ["aarch64_pstate_sm_enabled"]} does nothing?

This revision is now accepted and ready to land.May 19 2023, 7:21 AM
c-rhodes edited the summary of this revision. (Show Details)May 19 2023, 8:12 AM
WanderAway accepted this revision.May 19 2023, 8:15 AM

LGTM. Maybe when the SME dialect eventually gets created (soon TM), we can migrate these attributes to the dialect itself.

c-rhodes added inline comments.May 19 2023, 8:16 AM
mlir/lib/Target/LLVMIR/ModuleImport.cpp
1545–1549

Do we need this? I don't see similar checks for other attributes. If you'd like to keep it, then perhaps worth adding a test that shows that {passthrough = ["aarch64_pstate_sm_enabled"]} does nothing?

We do, they'll be added as passthrough attributes otherwise. There's a similar check above for memory attribute.

Matt added a subscriber: Matt.May 19 2023, 8:22 AM

I'll land this tomorrow unless there's any further comments by then.

dcaballe accepted this revision.May 23 2023, 5:48 PM

Sorry for the delay. LGTM as a first step.

LGTM. Maybe when the SME dialect eventually gets created (soon TM), we can migrate these attributes to the dialect itself.

+1

This revision was automatically updated to reflect the committed changes.
mlir/test/Target/LLVMIR/Import/function-attributes.ll