Skip to content

Commit b880d25

Browse files
committed
Address review comments
1 parent 4e2166f commit b880d25

File tree

7 files changed

+37
-23
lines changed

7 files changed

+37
-23
lines changed

clang/include/clang/AST/Type.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4598,7 +4598,7 @@ class FunctionType : public Type {
45984598
SME_AgnosticZAStateMask = 1 << SME_AgnosticZAStateShift,
45994599

46004600
SME_AttributeMask =
4601-
0b1'111'111'11 // We can't support more than 16 bits because of
4601+
0b1'111'111'11 // We can't support more than 9 bits because of
46024602
// the bitmask in FunctionTypeArmAttributes
46034603
// and ExtProtoInfo.
46044604
};

clang/include/clang/Basic/AttrDocs.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7648,7 +7648,7 @@ the function is agnostic about. The supported states for S are:
76487648
* ``"sme_za_state"`` for any state enabled by PSTATE.ZA (including the
76497649
bit itself)
76507650

7651-
The attributes ``__arm_agnostic("sme_za_state") cannot be used in conjunction
7651+
The attributes ``__arm_agnostic("sme_za_state")`` cannot be used in conjunction
76527652
with ``__arm_in(S)``, ``__arm_out(S)``, ``__arm_inout(S)`` or
76537653
``__arm_preserves(S)`` where state S describes state enabled by PSTATE.ZA,
76547654
such as "za" or "zt0".

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3836,8 +3836,8 @@ def err_sme_unimplemented_za_save_restore : Error<
38363836
"function that has live 'za' state requires a spill/fill of ZA, which is not yet "
38373837
"implemented">;
38383838
def err_sme_unimplemented_agnostic_new : Error<
3839-
"support to handle __arm_agnostic(\"sme_za_state\") together with "
3840-
"__arm_new(\"za\") or __arm_new(\"zt0\") is not yet implemented">;
3839+
"__arm_agnostic(\"sme_za_state\") is not supported together with "
3840+
"__arm_new(\"za\") or __arm_new(\"zt0\")">;
38413841
def note_sme_use_preserves_za : Note<
38423842
"add '__arm_preserves(\"za\")' to the callee if it preserves ZA">;
38433843
def err_sme_definition_using_sm_in_non_sme_target : Error<

clang/lib/AST/ItaniumMangle.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3585,13 +3585,15 @@ void CXXNameMangler::mangleSMEAttrs(unsigned SMEAttrs) {
35853585
else if (SMEAttrs & FunctionType::SME_PStateSMCompatibleMask)
35863586
Bitmask |= AAPCSBitmaskSME::ArmStreamingCompatibleBit;
35873587

3588-
// TODO: Must represent __arm_agnostic("sme_za_state")
3589-
3590-
Bitmask |= encodeAAPCSZAState(FunctionType::getArmZAState(SMEAttrs))
3591-
<< AAPCSBitmaskSME::ZA_Shift;
3588+
if (SMEAttrs & FunctionType::SME_AgnosticZAStateMask)
3589+
Bitmask |= AAPCSBitmaskSME::ArmAgnosticSMEZAStateBit;
3590+
else {
3591+
Bitmask |= encodeAAPCSZAState(FunctionType::getArmZAState(SMEAttrs))
3592+
<< AAPCSBitmaskSME::ZA_Shift;
35923593

3593-
Bitmask |= encodeAAPCSZAState(FunctionType::getArmZT0State(SMEAttrs))
3594-
<< AAPCSBitmaskSME::ZT0_Shift;
3594+
Bitmask |= encodeAAPCSZAState(FunctionType::getArmZT0State(SMEAttrs))
3595+
<< AAPCSBitmaskSME::ZT0_Shift;
3596+
}
35953597

35963598
Out << "Lj" << static_cast<unsigned>(Bitmask) << "EE";
35973599
}

clang/lib/Sema/SemaType.cpp

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7761,20 +7761,22 @@ static bool handleArmAgnosticAttribute(Sema &S,
77617761
if (!S.checkStringLiteralArgumentAttr(Attr, I, StateName, &LiteralLoc))
77627762
return true;
77637763

7764-
if (StateName == "sme_za_state") {
7765-
if (EPI.AArch64SMEAttributes &
7766-
(FunctionType::SME_ZAMask | FunctionType::SME_ZT0Mask)) {
7767-
S.Diag(Attr.getLoc(), diag::err_conflicting_attributes_arm_agnostic);
7768-
Attr.setInvalid();
7769-
return true;
7770-
}
7771-
EPI.setArmSMEAttribute(FunctionType::SME_AgnosticZAStateMask);
7772-
} else {
7764+
if (StateName != "sme_za_state") {
77737765
S.Diag(LiteralLoc, diag::err_unknown_arm_state) << StateName;
77747766
Attr.setInvalid();
77757767
return true;
77767768
}
7769+
7770+
if (EPI.AArch64SMEAttributes &
7771+
(FunctionType::SME_ZAMask | FunctionType::SME_ZT0Mask)) {
7772+
S.Diag(Attr.getLoc(), diag::err_conflicting_attributes_arm_agnostic);
7773+
Attr.setInvalid();
7774+
return true;
7775+
}
7776+
7777+
EPI.setArmSMEAttribute(FunctionType::SME_AgnosticZAStateMask);
77777778
}
7779+
77787780
return false;
77797781
}
77807782

clang/test/CodeGenCXX/aarch64-mangle-sme-atts.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,16 @@ __arm_new("zt0") void fn_zt0_out(int (*foo)() __arm_out("zt0")) { foo(); }
4545
// CHECK: define dso_local void @_Z12fn_zt0_inoutP11__SME_ATTRSIFivELj192EE(
4646
__arm_new("zt0") void fn_zt0_inout(int (*foo)() __arm_inout("zt0")) { foo(); }
4747

48+
//
49+
// __arm_agnostic("sme_za_state") Attribute
50+
//
51+
52+
// CHECK: define dso_local void @_Z24fn_sme_za_state_agnosticP11__SME_ATTRSIFvvELj4EE(
53+
void fn_sme_za_state_agnostic(void (*foo)() __arm_agnostic("sme_za_state")) { foo(); }
54+
55+
// CHECK: define dso_local void @_Z34fn_sme_za_state_streaming_agnosticP11__SME_ATTRSIFvvELj5EE(
56+
void fn_sme_za_state_streaming_agnostic(void (*foo)() __arm_streaming __arm_agnostic("sme_za_state")) { foo(); }
57+
4858
//
4959
// Streaming-mode, ZA & ZT0 Attributes
5060
//

clang/test/Sema/aarch64-sme-func-attrs.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,12 @@ void sme_arm_agnostic_shared_za_za(void) __arm_agnostic("sme_za_state") __arm_in
101101
// expected-error@+1 {{__arm_agnostic("sme_za_state") cannot share ZA state with its caller}}
102102
void sme_arm_agnostic_shared_za_za_rev(void) __arm_inout("za") __arm_agnostic("sme_za_state") {}
103103

104-
// expected-cpp-error@+2 {{support to handle __arm_agnostic("sme_za_state") together with __arm_new("za") or __arm_new("zt0") is not yet implemented}}
105-
// expected-error@+1 {{support to handle __arm_agnostic("sme_za_state") together with __arm_new("za") or __arm_new("zt0") is not yet implemented}}
104+
// expected-cpp-error@+2 {{__arm_agnostic("sme_za_state") is not supported together with __arm_new("za") or __arm_new("zt0")}}
105+
// expected-error@+1 {{__arm_agnostic("sme_za_state") is not supported together with __arm_new("za") or __arm_new("zt0")}}
106106
__arm_new("zt0") void sme_arm_agnostic_arm_new_zt0(void) __arm_agnostic("sme_za_state") {}
107107

108-
// expected-cpp-error@+2 {{support to handle __arm_agnostic("sme_za_state") together with __arm_new("za") or __arm_new("zt0") is not yet implemented}}
109-
// expected-error@+1 {{support to handle __arm_agnostic("sme_za_state") together with __arm_new("za") or __arm_new("zt0") is not yet implemented}}
108+
// expected-cpp-error@+2 {{__arm_agnostic("sme_za_state") is not supported together with __arm_new("za") or __arm_new("zt0")}}
109+
// expected-error@+1 {{__arm_agnostic("sme_za_state") is not supported together with __arm_new("za") or __arm_new("zt0")}}
110110
__arm_new("za") void sme_arm_agnostic_arm_new_za(void) __arm_agnostic("sme_za_state") {}
111111

112112
//

0 commit comments

Comments
 (0)