[llvm] [AArch64][SME] Support saving/restoring ZT0 in the MachineSMEABIPass (PR #166362)
Benjamin Maxwell via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 26 05:11:50 PST 2025
================
@@ -72,16 +72,30 @@ using namespace llvm;
namespace {
-enum ZAState {
+// Note: For agnostic ZA, we assume the function is always entered/exited in the
+// "ACTIVE" state -- this _may_ not be the case (since OFF is also a
+// possibility, but for the purpose of placing ZA saves/restores, that does not
+// matter).
+enum ZAState : uint8_t {
// Any/unknown state (not valid)
ANY = 0,
// ZA is in use and active (i.e. within the accumulator)
ACTIVE,
+ // ZA is active, but ZT0 has been saved.
+ // This handles the edge case of sharedZA && !sharesZT0.
+ ACTIVE_ZT0_SAVED,
+
// A ZA save has been set up or committed (i.e. ZA is dormant or off)
+ // If the function uses ZT0 it must also be saved.
LOCAL_SAVED,
+ // ZA has been committed to the lazy save buffer of the current function.
+ // If the function uses ZT0 it must also be saved.
+ // ZA is off when a save has been committed.
----------------
MacDue wrote:
> So ZA is just off?
I've tweaked the last line just to say "ZA is off."
> In order to get to LOCAL_COMMITTED it must have first been in state LOCAL_SAVED, which saves ZT0 if available, so this comment can be removed?
The states are defined in isolation. A direct transition from `ACTIVE` to `LOCAL_COMMITTED` is legal (as an implementation detail you may implement that as `ACTIVE` -> `LOCAL_SAVED` -> `LOCAL_COMMITTED`).
https://github.com/llvm/llvm-project/pull/166362
More information about the llvm-commits
mailing list