This is an archive of the discontinued LLVM Phabricator instance.

[AArch64][SME] Fix lowering of llvm.aarch64.get.pstatesm()

Authored by sdesmalen on Aug 10 2022, 7:44 AM.



A thread may not have access to SME or TPIDR2_EL0, so in order to
safely query PSTATE.SM in a streaming-compatible function, the
code should call __arm_sme_state(), as described in the ABI:

This means that the value of is:

  • 0 if the function is non-streaming.
  • 1 if the function has arm_streaming or arm_locally_streaming.
  • evaluated at runtime by a call to __arm_sme_state() otherwise.

Diff Detail

Event Timeline

sdesmalen created this revision.Aug 10 2022, 7:44 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 10 2022, 7:44 AM
sdesmalen requested review of this revision.Aug 10 2022, 7:44 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 10 2022, 7:44 AM
david-arm added inline comments.Aug 15 2022, 7:50 AM

Is this right? The ABI document in github suggests:

X2-X15, X19-X29 and SP are call-preserved.

for __arm_sme_state, which is different to the comment, specifically the X0-X13 bit.


I assume you removed this line because you chopped out some unwanted CHECK lines after running the script?

aemerson added inline comments.Sep 8 2022, 3:45 AM

Reminder to use the suggested merged method from the other patch here.

sdesmalen updated this revision to Diff 459049.Sep 9 2022, 6:57 AM
sdesmalen marked 3 inline comments as done.

Split out calling convention for SME support routines in two and added LLVM IR
parsing such that they can be used in a generic way by adding them to function
calls (rather than relying on an intermediary intrinsic to be expanded).

sdesmalen added inline comments.Sep 9 2022, 6:57 AM

Good spot, I've fixed this to add two calling conventions instead.


I removed it, because otherwise it generates loads of CHECK lines for the RUN line with the CHECK-CSRMASK check-prefix.

sdesmalen updated this revision to Diff 459063.Sep 9 2022, 7:50 AM

Fixed sme-support-routines-calling-convention.ll

sdesmalen updated this revision to Diff 459428.Sep 12 2022, 5:49 AM

Fixed up test (again)

aemerson accepted this revision.Sep 12 2022, 4:21 PM
aemerson added inline comments.

Nit: this could be just SMEAttrs Attrs(DAG.getMachineFunction().getFunction());?

This revision is now accepted and ready to land.Sep 12 2022, 4:21 PM
This revision was landed with ongoing or failed builds.Sep 15 2022, 8:16 AM
This revision was automatically updated to reflect the committed changes.

Thanks @aemerson!


Good spot, I thought I fixed all of those up already.