1
1
#include " Utils/AArch64SMEAttributes.h"
2
2
#include " llvm/AsmParser/Parser.h"
3
3
#include " llvm/IR/Function.h"
4
+ #include " llvm/IR/InstrTypes.h"
4
5
#include " llvm/IR/Module.h"
5
6
#include " llvm/Support/SourceMgr.h"
6
7
@@ -69,6 +70,15 @@ TEST(SMEAttributes, Constructors) {
69
70
ASSERT_TRUE (SA (*parseIR (" declare void @foo() \" aarch64_new_zt0\" " )
70
71
->getFunction (" foo" ))
71
72
.isNewZT0 ());
73
+ ASSERT_TRUE (
74
+ SA (cast<CallBase>((parseIR (" declare void @callee()\n "
75
+ " define void @foo() {"
76
+ " call void @callee() \" aarch64_zt0_undef\"\n "
77
+ " ret void\n }" )
78
+ ->getFunction (" foo" )
79
+ ->begin ()
80
+ ->front ())))
81
+ .isUndefZT0 ());
72
82
73
83
// Invalid combinations.
74
84
EXPECT_DEBUG_DEATH (SA (SA::SM_Enabled | SA::SM_Compatible),
@@ -215,6 +225,18 @@ TEST(SMEAttributes, Basics) {
215
225
ASSERT_FALSE (ZT0_New.hasSharedZAInterface ());
216
226
ASSERT_TRUE (ZT0_New.hasPrivateZAInterface ());
217
227
228
+ SA ZT0_Undef = SA (SA::encodeZT0State (SA::StateValue::Undef));
229
+ ASSERT_FALSE (ZT0_Undef.isNewZT0 ());
230
+ ASSERT_FALSE (ZT0_Undef.isInZT0 ());
231
+ ASSERT_FALSE (ZT0_Undef.isOutZT0 ());
232
+ ASSERT_FALSE (ZT0_Undef.isInOutZT0 ());
233
+ ASSERT_FALSE (ZT0_Undef.isPreservesZT0 ());
234
+ ASSERT_FALSE (ZT0_Undef.sharesZT0 ());
235
+ ASSERT_FALSE (ZT0_Undef.hasZT0State ());
236
+ ASSERT_FALSE (ZT0_Undef.hasSharedZAInterface ());
237
+ ASSERT_TRUE (ZT0_Undef.hasPrivateZAInterface ());
238
+ ASSERT_TRUE (ZT0_Undef.isUndefZT0 ());
239
+
218
240
ASSERT_FALSE (SA (SA::Normal).isInZT0 ());
219
241
ASSERT_FALSE (SA (SA::Normal).isOutZT0 ());
220
242
ASSERT_FALSE (SA (SA::Normal).isInOutZT0 ());
@@ -285,6 +307,7 @@ TEST(SMEAttributes, Transitions) {
285
307
SA ZT0_Shared = SA (SA::encodeZT0State (SA::StateValue::In));
286
308
SA ZA_ZT0_Shared = SA (SA::encodeZAState (SA::StateValue::In) |
287
309
SA::encodeZT0State (SA::StateValue::In));
310
+ SA Undef_ZT0 = SA ((SA::encodeZT0State (SA::StateValue::Undef)));
288
311
289
312
// Shared ZA -> Private ZA Interface
290
313
ASSERT_FALSE (ZA_Shared.requiresDisablingZABeforeCall (Private_ZA));
@@ -295,6 +318,13 @@ TEST(SMEAttributes, Transitions) {
295
318
ASSERT_TRUE (ZT0_Shared.requiresPreservingZT0 (Private_ZA));
296
319
ASSERT_TRUE (ZT0_Shared.requiresEnablingZAAfterCall (Private_ZA));
297
320
321
+ // Shared Undef ZT0 -> Private ZA Interface
322
+ // Note: "Undef ZT0" is a callsite attribute that means ZT0 is undefined at
323
+ // point the of the call.
324
+ ASSERT_TRUE (ZT0_Shared.requiresDisablingZABeforeCall (Undef_ZT0));
325
+ ASSERT_FALSE (ZT0_Shared.requiresPreservingZT0 (Undef_ZT0));
326
+ ASSERT_TRUE (ZT0_Shared.requiresEnablingZAAfterCall (Undef_ZT0));
327
+
298
328
// Shared ZA & ZT0 -> Private ZA Interface
299
329
ASSERT_FALSE (ZA_ZT0_Shared.requiresDisablingZABeforeCall (Private_ZA));
300
330
ASSERT_TRUE (ZA_ZT0_Shared.requiresPreservingZT0 (Private_ZA));
0 commit comments