[llvm] [AArch64][SME] Refactor MachineSMEABI pass state (NFCI) (PR #156674)
Gaëtan Bossu via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 11 05:17:30 PDT 2025
================
@@ -110,6 +110,65 @@ struct PhysRegSave {
Register X0Save = AArch64::NoRegister;
};
+/// Contains the needed ZA state (and live registers) at an instruction.
+struct InstInfo {
+ ZAState NeededState{ZAState::ANY};
+ MachineBasicBlock::iterator InsertPt;
+ LiveRegs PhysLiveRegs = LiveRegs::None;
+};
+
+/// Contains the needed ZA state for each instruction in a block. Instructions
+/// that do not require a ZA state are not recorded.
+struct BlockInfo {
+ ZAState FixedEntryState{ZAState::ANY};
+ SmallVector<InstInfo> Insts;
+ LiveRegs PhysLiveRegsAtEntry = LiveRegs::None;
+ LiveRegs PhysLiveRegsAtExit = LiveRegs::None;
+};
+
+/// Contains the needed ZA state information for all blocks within a function.
+struct FunctionInfo {
+ SmallVector<BlockInfo> Blocks;
+ std::optional<MachineBasicBlock::iterator> AfterSMEProloguePt;
+ LiveRegs PhysLiveRegsAfterSMEPrologue = LiveRegs::None;
+};
+
+/// State/helpers that is only needed when emitting code to handle
+/// saving/restoring ZA.
+struct EmitContext {
+ EmitContext() = default;
+
+ /// Get or create a TPIDR2 block in \p MF.
+ int getTPIDR2Block(MachineFunction &MF) {
+ if (TPIDR2BlockFI)
+ return *TPIDR2BlockFI;
+ MachineFrameInfo &MFI = MF.getFrameInfo();
+ TPIDR2BlockFI = MFI.CreateStackObject(16, Align(16), false);
+ return *TPIDR2BlockFI;
+ }
+
+ /// Get or create agnostic ZA buffer pointer in \p MF.
+ Register getAgnosticZABufferPtr(MachineFunction &MF) {
----------------
gbossu wrote:
Curious: Why is it an `AgnosticZABuffer` and not just a `ZABuffer`? Does it matter in which context we create a buffer to save ZA? (it probably does, I just don't remember the details 😃)
https://github.com/llvm/llvm-project/pull/156674
More information about the llvm-commits
mailing list