This is an archive of the discontinued LLVM Phabricator instance.

[AArch64][SME] Add system registers and related instructions
ClosedPublic

Authored by c-rhodes on Jul 7 2021, 11:39 AM.

Details

Summary

This patch adds the new system registers introduced in SME:

  • ID_AA64SMFR0_EL1 (ro) SME feature identifier.
  • SMCR_ELx (r/w) streaming mode control register for configuring effective SVE Streaming SVE Vector length when the PE is in Streaming SVE mode.
  • SVCR (r/w) streaming vector control register, visible at all exception levels. Provides access to PSTATE.SM and PSTATE.ZA using MSR and MRS instructions.
  • SMPRI_EL1 (r/w) streaming mode execution priority register.
  • SMPRIMAP_EL2 (r/w) streaming mode priority mapping register.
  • SMIDR_EL1 (ro) streaming mode identification register.
  • TPIDR2_EL0 (r/w) for use by SME software to manage per-thread SME context.
  • MPAMSM_EL1 (r/w) MPAM (v8.4) streaming mode register, for labelling memory accesses performed in streaming mode.

Also added in this patch are the SME mode change instructions.
Three MSR immediate instructions are implemented to set or clear
PSTATE.SM, PSTATE.ZA, or both respectively:

  • MSR SVCRSM, #<imm1>
  • MSR SVCRZA, #<imm1>
  • MSR SVCRSMZA, #<imm1>

The following smstart/smstop aliases are also implemented for
convenience:

smstart    -> MSR SVCRSMZA, #1
smstart sm -> MSR SVCRSM,   #1
smstart za -> MSR SVCRZA,   #1

smstop     -> MSR SVCRSMZA, #0
smstop sm  -> MSR SVCRSM,   #0
smstop za  -> MSR SVCRZA,   #0

The reference can be found here:
https://developer.arm.com/documentation/ddi0602/2021-06

Diff Detail

Event Timeline

c-rhodes created this revision.Jul 7 2021, 11:39 AM
c-rhodes requested review of this revision.Jul 7 2021, 11:39 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 7 2021, 11:39 AM
Matt added a subscriber: Matt.Jul 7 2021, 3:02 PM
c-rhodes updated this revision to Diff 358912.Jul 15 2021, 4:13 AM

Changes:

  • Add tests for smstart/smstop.
  • Fix matching of "smstart za", fixes issue described here: https://reviews.llvm.org/D105570#inline-1005832. The matching code that gets generated for aliases:
    • def : InstAlias<"smstart za", (MSRpstatesvcrImm1 0b010, 0b1)>;
    • def : InstAlias<"smstop za", (MSRpstatesvcrImm1 0b010, 0b0)>;

expectes MCK_MPR but za gets parsed as a literal. The fix is to return match in validateTargetOperandClass if MCK_MPR is expected and the token is za.

david-arm added inline comments.Jul 16 2021, 6:54 AM
llvm/lib/Target/AArch64/AArch64RegisterInfo.td
1359

nit: Maybe simpler to just write "InvalidSVCR" here, since you've explicitly written SVCR in the ParserMethod too?

llvm/test/MC/AArch64/SME/smstart.s
17

Can we have a negative test where the keyword is not sm or za and make sure we do something sensible?

c-rhodes updated this revision to Diff 359313.Jul 16 2021, 7:17 AM
c-rhodes set the repository for this revision to rG LLVM Github Monorepo.

Add diagnostics tests for smstart/smstop.

c-rhodes marked an inline comment as done.Jul 16 2021, 7:18 AM
c-rhodes added inline comments.
llvm/lib/Target/AArch64/AArch64RegisterInfo.td
1359

nit: Maybe simpler to just write "InvalidSVCR" here, since you've explicitly written SVCR in the ParserMethod too?

# Name for diagnostic type is consistent with the other operands so I've kept it as it.

david-arm accepted this revision.Jul 16 2021, 7:20 AM

LGTM! Thanks for the negative tests. :)

This revision is now accepted and ready to land.Jul 16 2021, 7:20 AM
This revision was landed with ongoing or failed builds.Jul 20 2021, 1:14 AM
This revision was automatically updated to reflect the committed changes.
RKSimon added inline comments.
llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
6528

@c-rhodes Coverity is warning that ExpectedVal is still uninitialized when we break here - but should this be "return Match_InvalidOperand;" anyhow?

Herald added a project: Restricted Project. · View Herald TranscriptMar 29 2022, 5:12 AM
Herald added a subscriber: ctetreau. · View Herald Transcript
c-rhodes added inline comments.Apr 19 2022, 2:51 AM
llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
6528

@c-rhodes Coverity is warning that ExpectedVal is still uninitialized when we break here - but should this be "return Match_InvalidOperand;" anyhow?

Apologies for late reply, it should, thanks for spotting and fixing!