aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Sema/SemaChecking.cpp
diff options
context:
space:
mode:
authorSander de Smalen <sander.desmalen@arm.com>2024-01-19 16:02:24 +0000
committerGitHub <noreply@github.com>2024-01-19 16:02:24 +0000
commit40a631f452726606e1d43b5d2744aa983949af78 (patch)
treeb15643b2623beab05e079817e7cab57c21b14bf3 /clang/lib/Sema/SemaChecking.cpp
parente89a7c41ba2d94866157056a88cfc083fa9d9cb5 (diff)
downloadllvm-40a631f452726606e1d43b5d2744aa983949af78.zip
llvm-40a631f452726606e1d43b5d2744aa983949af78.tar.gz
llvm-40a631f452726606e1d43b5d2744aa983949af78.tar.bz2
[Clang] Refactor diagnostics for SME builtins. (#78258)
The arm_sme.td file was still using `IsSharedZA` and `IsPreservesZA`, which should be changed to match the new state attributes added in #76971. This patch adds `IsInZA`, `IsOutZA` and `IsInOutZA` as the state for the Clang builtins and fixes up the code in SemaChecking and SveEmitter to match. Note that the code is written in such a way that it can be easily extended with ZT0 state (to follow in a future patch).
Diffstat (limited to 'clang/lib/Sema/SemaChecking.cpp')
-rw-r--r--clang/lib/Sema/SemaChecking.cpp35
1 files changed, 19 insertions, 16 deletions
diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index ace3e38..3e0d94e 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -3005,6 +3005,15 @@ enum ArmStreamingType {
ArmStreamingOrSVE2p1
};
+enum ArmSMEState : unsigned {
+ ArmNoState = 0,
+
+ ArmInZA = 0b01,
+ ArmOutZA = 0b10,
+ ArmInOutZA = 0b11,
+ ArmZAMask = 0b11,
+};
+
bool Sema::ParseSVEImmChecks(
CallExpr *TheCall, SmallVector<std::tuple<int, int, int>, 3> &ImmChecks) {
// Perform all the immediate checks for this builtin call.
@@ -3189,26 +3198,20 @@ static void checkArmStreamingBuiltin(Sema &S, CallExpr *TheCall,
}
}
-static bool hasSMEZAState(const FunctionDecl *FD) {
- if (auto *Attr = FD->getAttr<ArmNewAttr>())
- if (Attr->isNewZA())
- return true;
- if (const auto *T = FD->getType()->getAs<FunctionProtoType>()) {
- FunctionType::ArmStateValue State =
- FunctionType::getArmZAState(T->getAArch64SMEAttributes());
- if (State != FunctionType::ARM_None)
- return true;
- }
- return false;
+static bool hasArmZAState(const FunctionDecl *FD) {
+ const auto *T = FD->getType()->getAs<FunctionProtoType>();
+ return (T && FunctionType::getArmZAState(T->getAArch64SMEAttributes()) !=
+ FunctionType::ARM_None) ||
+ (FD->hasAttr<ArmNewAttr>() && FD->getAttr<ArmNewAttr>()->isNewZA());
}
-static bool hasSMEZAState(unsigned BuiltinID) {
+static ArmSMEState getSMEState(unsigned BuiltinID) {
switch (BuiltinID) {
default:
- return false;
-#define GET_SME_BUILTIN_HAS_ZA_STATE
+ return ArmNoState;
+#define GET_SME_BUILTIN_GET_STATE
#include "clang/Basic/arm_sme_builtins_za_state.inc"
-#undef GET_SME_BUILTIN_HAS_ZA_STATE
+#undef GET_SME_BUILTIN_GET_STATE
}
}
@@ -3225,7 +3228,7 @@ bool Sema::CheckSMEBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall) {
if (BuiltinType)
checkArmStreamingBuiltin(*this, TheCall, FD, *BuiltinType);
- if (hasSMEZAState(BuiltinID) && !hasSMEZAState(FD))
+ if ((getSMEState(BuiltinID) & ArmZAMask) && !hasArmZAState(FD))
Diag(TheCall->getBeginLoc(),
diag::warn_attribute_arm_za_builtin_no_za_state)
<< TheCall->getSourceRange();