@@ -44,7 +44,8 @@ class SMEAttrs {
44
44
ZA_Shift = 6 ,
45
45
ZA_Mask = 0b111 << ZA_Shift,
46
46
ZT0_Shift = 9 ,
47
- ZT0_Mask = 0b111 << ZT0_Shift
47
+ ZT0_Mask = 0b111 << ZT0_Shift,
48
+ Callsite_Flags = ZT0_Undef
48
49
};
49
50
50
51
SMEAttrs () = default ;
@@ -129,10 +130,13 @@ class SMEAttrs {
129
130
}
130
131
bool hasZT0State () const { return isNewZT0 () || sharesZT0 (); }
131
132
132
- SMEAttrs operator |(SMEAttrs Other) const {
133
- SMEAttrs Merged (*this );
134
- Merged.set (Other.Bitmask , /* Enable=*/ true );
135
- return Merged;
133
+ bool isNormal () const { return Bitmask == Normal; }
134
+ SMEAttrs withoutPerCallsiteFlags () const {
135
+ return (Bitmask & ~Callsite_Flags);
136
+ }
137
+
138
+ bool operator ==(SMEAttrs const &Other) const {
139
+ return Bitmask == Other.Bitmask ;
136
140
}
137
141
138
142
private:
@@ -143,54 +147,57 @@ class SMEAttrs {
143
147
// / interfaces to query whether a streaming mode change or lazy-save mechanism
144
148
// / is required when going from one function to another (e.g. through a call).
145
149
class SMECallAttrs {
146
- SMEAttrs Caller ;
147
- SMEAttrs Callee ;
150
+ SMEAttrs CallerFn ;
151
+ SMEAttrs CalledFn ;
148
152
SMEAttrs Callsite;
153
+ bool IsIndirect = false ;
149
154
150
155
public:
151
156
SMECallAttrs (SMEAttrs Caller, SMEAttrs Callee,
152
157
SMEAttrs Callsite = SMEAttrs::Normal)
153
- : Caller (Caller), Callee (Callee), Callsite(Callsite) {}
158
+ : CallerFn (Caller), CalledFn (Callee), Callsite(Callsite) {}
154
159
155
160
SMECallAttrs (const CallBase &CB);
156
161
157
- SMEAttrs &caller () { return Caller; }
158
- SMEAttrs &callee () { return Callee; }
162
+ SMEAttrs &caller () { return CallerFn; }
163
+ SMEAttrs &callee () {
164
+ if (IsIndirect)
165
+ return Callsite;
166
+ return CalledFn;
167
+ }
159
168
SMEAttrs &callsite () { return Callsite; }
160
- SMEAttrs const &caller () const { return Caller; }
161
- SMEAttrs const &callee () const { return Callee; }
169
+ SMEAttrs const &caller () const { return CallerFn; }
170
+ SMEAttrs const &callee () const {
171
+ return const_cast <SMECallAttrs *>(this )->callee ();
172
+ }
162
173
SMEAttrs const &callsite () const { return Callsite; }
163
- SMEAttrs calleeOrCallsite () const { return Callsite | Callee; }
164
174
165
175
// / \return true if a call from Caller -> Callee requires a change in
166
176
// / streaming mode.
167
177
bool requiresSMChange () const ;
168
178
169
179
bool requiresLazySave () const {
170
- return Caller .hasZAState () && (Callsite | Callee ).hasPrivateZAInterface () &&
171
- !Callee .isSMEABIRoutine ();
180
+ return caller () .hasZAState () && callee ( ).hasPrivateZAInterface () &&
181
+ !callee () .isSMEABIRoutine ();
172
182
}
173
183
174
184
bool requiresPreservingZT0 () const {
175
- return Caller.hasZT0State () && !Callsite.hasUndefZT0 () &&
176
- !(Callsite | Callee).sharesZT0 () &&
177
- !(Callsite | Callee).hasAgnosticZAInterface ();
185
+ return caller ().hasZT0State () && !callsite ().hasUndefZT0 () &&
186
+ !callee ().sharesZT0 () && !callee ().hasAgnosticZAInterface ();
178
187
}
179
188
180
189
bool requiresDisablingZABeforeCall () const {
181
- return Caller.hasZT0State () && !Caller.hasZAState () &&
182
- (Callsite | Callee).hasPrivateZAInterface () &&
183
- !Callee.isSMEABIRoutine ();
190
+ return caller ().hasZT0State () && !caller ().hasZAState () &&
191
+ callee ().hasPrivateZAInterface () && !callee ().isSMEABIRoutine ();
184
192
}
185
193
186
194
bool requiresEnablingZAAfterCall () const {
187
195
return requiresLazySave () || requiresDisablingZABeforeCall ();
188
196
}
189
197
190
198
bool requiresPreservingAllZAState () const {
191
- return Caller.hasAgnosticZAInterface () &&
192
- !(Callsite | Callee).hasAgnosticZAInterface () &&
193
- !Callee.isSMEABIRoutine ();
199
+ return caller ().hasAgnosticZAInterface () &&
200
+ !callee ().hasAgnosticZAInterface () && !callee ().isSMEABIRoutine ();
194
201
}
195
202
};
196
203
0 commit comments