[llvm] [AArch64][SME] Split SMECallAttrs out of SMEAttrs (PR #137239)
Sander de Smalen via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 25 06:40:42 PDT 2025
================
@@ -126,27 +122,87 @@ class SMEAttrs {
bool isPreservesZT0() const {
return decodeZT0State(Bitmask) == StateValue::Preserved;
}
- bool isUndefZT0() const { return Bitmask & ZT0_Undef; }
+ bool hasUndefZT0() const { return Bitmask & ZT0_Undef; }
bool sharesZT0() const {
StateValue State = decodeZT0State(Bitmask);
return State == StateValue::In || State == StateValue::Out ||
State == StateValue::InOut || State == StateValue::Preserved;
}
bool hasZT0State() const { return isNewZT0() || sharesZT0(); }
- bool requiresPreservingZT0(const SMEAttrs &Callee) const {
- return hasZT0State() && !Callee.isUndefZT0() && !Callee.sharesZT0() &&
- !Callee.hasAgnosticZAInterface();
+
+ SMEAttrs operator|(SMEAttrs Other) const {
+ SMEAttrs Merged(*this);
+ Merged.set(Other.Bitmask, /*Enable=*/true);
+ return Merged;
}
- bool requiresDisablingZABeforeCall(const SMEAttrs &Callee) const {
- return hasZT0State() && !hasZAState() && Callee.hasPrivateZAInterface() &&
- !(Callee.Bitmask & SME_ABI_Routine);
+
+ SMEAttrs withoutPerCallsiteFlags() const {
+ return (Bitmask & ~Callsite_Flags);
}
- bool requiresEnablingZAAfterCall(const SMEAttrs &Callee) const {
- return requiresLazySave(Callee) || requiresDisablingZABeforeCall(Callee);
+
+ bool operator==(SMEAttrs const &Other) const {
+ return Bitmask == Other.Bitmask;
}
- bool requiresPreservingAllZAState(const SMEAttrs &Callee) const {
- return hasAgnosticZAInterface() && !Callee.hasAgnosticZAInterface() &&
- !(Callee.Bitmask & SME_ABI_Routine);
+
+private:
+ void addKnownFunctionAttrs(StringRef FuncName);
+};
+
+/// SMECallAttrs is a utility class to hold the SMEAttrs for a callsite. It has
+/// interfaces to query whether a streaming mode change or lazy-save mechanism
+/// is required when going from one function to another (e.g. through a call).
+class SMECallAttrs {
+ SMEAttrs CallerFn;
+ SMEAttrs CalledFn;
+ SMEAttrs Callsite;
+ bool IsIndirect = false;
+
+public:
+ SMECallAttrs(SMEAttrs Caller, SMEAttrs Callee,
+ SMEAttrs Callsite = SMEAttrs::Normal)
+ : CallerFn(Caller), CalledFn(Callee), Callsite(Callsite) {}
+
+ SMECallAttrs(const CallBase &CB);
+
+ SMEAttrs &caller() { return CallerFn; }
+ SMEAttrs &callee() {
+ if (IsIndirect)
+ return Callsite;
+ return CalledFn;
+ }
----------------
sdesmalen-arm wrote:
nit:
```suggestion
SMEAttrs &callee() { return IsIndirect ? Callsite : CalledFn; }
```
https://github.com/llvm/llvm-project/pull/137239
More information about the llvm-commits
mailing list