Skip to content

Commit 2590140

Browse files
committed
Separate "ZT0 undef" from StateValue
This allows this to be independent from new/preserves/shares ZT0.
1 parent e635774 commit 2590140

File tree

3 files changed

+11
-13
lines changed

3 files changed

+11
-13
lines changed

llvm/lib/Target/AArch64/Utils/AArch64SMEAttributes.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ SMEAttrs::SMEAttrs(const AttributeList &Attrs) {
7575
Bitmask |= SM_Body;
7676
if (Attrs.hasFnAttr("aarch64_za_state_agnostic"))
7777
Bitmask |= ZA_State_Agnostic;
78+
if (Attrs.hasFnAttr("aarch64_zt0_undef"))
79+
Bitmask |= ZT0_Undef;
7880
if (Attrs.hasFnAttr("aarch64_in_za"))
7981
Bitmask |= encodeZAState(StateValue::In);
8082
if (Attrs.hasFnAttr("aarch64_out_za"))
@@ -95,8 +97,6 @@ SMEAttrs::SMEAttrs(const AttributeList &Attrs) {
9597
Bitmask |= encodeZT0State(StateValue::Preserved);
9698
if (Attrs.hasFnAttr("aarch64_new_zt0"))
9799
Bitmask |= encodeZT0State(StateValue::New);
98-
if (Attrs.hasFnAttr("aarch64_zt0_undef"))
99-
Bitmask |= encodeZT0State(StateValue::Undef);
100100
}
101101

102102
bool SMEAttrs::requiresSMChange(const SMEAttrs &Callee) const {

llvm/lib/Target/AArch64/Utils/AArch64SMEAttributes.h

+5-7
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@ class SMEAttrs {
3232
Out = 2, // aarch64_out_zt0
3333
InOut = 3, // aarch64_inout_zt0
3434
Preserved = 4, // aarch64_preserves_zt0
35-
New = 5, // aarch64_new_zt0
36-
Undef = 6 // aarch64_zt0_undef
35+
New = 5 // aarch64_new_zt0
3736
};
3837

3938
// Enum with bitmasks for each individual SME feature.
@@ -44,9 +43,10 @@ class SMEAttrs {
4443
SM_Body = 1 << 2, // aarch64_pstate_sm_body
4544
SME_ABI_Routine = 1 << 3, // Used for SME ABI routines to avoid lazy saves
4645
ZA_State_Agnostic = 1 << 4,
47-
ZA_Shift = 5,
46+
ZT0_Undef = 1 << 5, // Use to mark ZT0 as undef to avoid spills
47+
ZA_Shift = 6,
4848
ZA_Mask = 0b111 << ZA_Shift,
49-
ZT0_Shift = 8,
49+
ZT0_Shift = 9,
5050
ZT0_Mask = 0b111 << ZT0_Shift
5151
};
5252

@@ -126,9 +126,7 @@ class SMEAttrs {
126126
bool isPreservesZT0() const {
127127
return decodeZT0State(Bitmask) == StateValue::Preserved;
128128
}
129-
bool isUndefZT0() const {
130-
return decodeZT0State(Bitmask) == StateValue::Undef;
131-
}
129+
bool isUndefZT0() const { return Bitmask & ZT0_Undef; }
132130
bool sharesZT0() const {
133131
StateValue State = decodeZT0State(Bitmask);
134132
return State == StateValue::In || State == StateValue::Out ||

llvm/unittests/Target/AArch64/SMEAttributesTest.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -225,14 +225,14 @@ TEST(SMEAttributes, Basics) {
225225
ASSERT_FALSE(ZT0_New.hasSharedZAInterface());
226226
ASSERT_TRUE(ZT0_New.hasPrivateZAInterface());
227227

228-
SA ZT0_Undef = SA(SA::encodeZT0State(SA::StateValue::Undef));
229-
ASSERT_FALSE(ZT0_Undef.isNewZT0());
228+
SA ZT0_Undef = SA(SA::ZT0_Undef | SA::encodeZT0State(SA::StateValue::New));
229+
ASSERT_TRUE(ZT0_Undef.isNewZT0());
230230
ASSERT_FALSE(ZT0_Undef.isInZT0());
231231
ASSERT_FALSE(ZT0_Undef.isOutZT0());
232232
ASSERT_FALSE(ZT0_Undef.isInOutZT0());
233233
ASSERT_FALSE(ZT0_Undef.isPreservesZT0());
234234
ASSERT_FALSE(ZT0_Undef.sharesZT0());
235-
ASSERT_FALSE(ZT0_Undef.hasZT0State());
235+
ASSERT_TRUE(ZT0_Undef.hasZT0State());
236236
ASSERT_FALSE(ZT0_Undef.hasSharedZAInterface());
237237
ASSERT_TRUE(ZT0_Undef.hasPrivateZAInterface());
238238
ASSERT_TRUE(ZT0_Undef.isUndefZT0());
@@ -307,7 +307,7 @@ TEST(SMEAttributes, Transitions) {
307307
SA ZT0_Shared = SA(SA::encodeZT0State(SA::StateValue::In));
308308
SA ZA_ZT0_Shared = SA(SA::encodeZAState(SA::StateValue::In) |
309309
SA::encodeZT0State(SA::StateValue::In));
310-
SA Undef_ZT0 = SA((SA::encodeZT0State(SA::StateValue::Undef)));
310+
SA Undef_ZT0 = SA(SA::ZT0_Undef);
311311

312312
// Shared ZA -> Private ZA Interface
313313
ASSERT_FALSE(ZA_Shared.requiresDisablingZABeforeCall(Private_ZA));

0 commit comments

Comments
 (0)