diff options
author | Kerry McLaughlin <kerry.mclaughlin@arm.com> | 2025-01-10 09:54:48 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-01-10 09:54:48 +0000 |
commit | 4e32271e8b304eb018c69f74c16edd1668fcdaf3 (patch) | |
tree | 0ba77f907509619b300df5b8c44166df1cd47f37 /clang/lib/Sema/SemaDecl.cpp | |
parent | 4c853be6673fd95b4b900a6c0e1804bf33a0629c (diff) | |
download | llvm-4e32271e8b304eb018c69f74c16edd1668fcdaf3.zip llvm-4e32271e8b304eb018c69f74c16edd1668fcdaf3.tar.gz llvm-4e32271e8b304eb018c69f74c16edd1668fcdaf3.tar.bz2 |
[AArch64][SME] Add diagnostics for SME attributes on lambda functions (#121777)
CheckFunctionDeclaration emits diagnostics if any SME attributes are used
by a function definition without the required +sme or +sme2 target features.
This patch moves these diagnostics to a new function in SemaARM and
also adds a call to this from ActOnStartOfLambdaDefinition.
Diffstat (limited to 'clang/lib/Sema/SemaDecl.cpp')
-rw-r--r-- | clang/lib/Sema/SemaDecl.cpp | 55 |
1 files changed, 3 insertions, 52 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index 7592005..0d476fe 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -45,6 +45,7 @@ #include "clang/Sema/ParsedTemplate.h" #include "clang/Sema/Scope.h" #include "clang/Sema/ScopeInfo.h" +#include "clang/Sema/SemaARM.h" #include "clang/Sema/SemaCUDA.h" #include "clang/Sema/SemaHLSL.h" #include "clang/Sema/SemaInternal.h" @@ -12297,58 +12298,8 @@ bool Sema::CheckFunctionDeclaration(Scope *S, FunctionDecl *NewFD, } } - // Check if the function definition uses any AArch64 SME features without - // having the '+sme' feature enabled and warn user if sme locally streaming - // function returns or uses arguments with VL-based types. - if (DeclIsDefn) { - const auto *Attr = NewFD->getAttr<ArmNewAttr>(); - bool UsesSM = NewFD->hasAttr<ArmLocallyStreamingAttr>(); - bool UsesZA = Attr && Attr->isNewZA(); - bool UsesZT0 = Attr && Attr->isNewZT0(); - - if (NewFD->hasAttr<ArmLocallyStreamingAttr>()) { - if (NewFD->getReturnType()->isSizelessVectorType()) - Diag(NewFD->getLocation(), - diag::warn_sme_locally_streaming_has_vl_args_returns) - << /*IsArg=*/false; - if (llvm::any_of(NewFD->parameters(), [](ParmVarDecl *P) { - return P->getOriginalType()->isSizelessVectorType(); - })) - Diag(NewFD->getLocation(), - diag::warn_sme_locally_streaming_has_vl_args_returns) - << /*IsArg=*/true; - } - if (const auto *FPT = NewFD->getType()->getAs<FunctionProtoType>()) { - FunctionProtoType::ExtProtoInfo EPI = FPT->getExtProtoInfo(); - UsesSM |= - EPI.AArch64SMEAttributes & FunctionType::SME_PStateSMEnabledMask; - UsesZA |= FunctionType::getArmZAState(EPI.AArch64SMEAttributes) != - FunctionType::ARM_None; - UsesZT0 |= FunctionType::getArmZT0State(EPI.AArch64SMEAttributes) != - FunctionType::ARM_None; - } - - if (UsesSM || UsesZA) { - llvm::StringMap<bool> FeatureMap; - Context.getFunctionFeatureMap(FeatureMap, NewFD); - if (!FeatureMap.contains("sme")) { - if (UsesSM) - Diag(NewFD->getLocation(), - diag::err_sme_definition_using_sm_in_non_sme_target); - else - Diag(NewFD->getLocation(), - diag::err_sme_definition_using_za_in_non_sme_target); - } - } - if (UsesZT0) { - llvm::StringMap<bool> FeatureMap; - Context.getFunctionFeatureMap(FeatureMap, NewFD); - if (!FeatureMap.contains("sme2")) { - Diag(NewFD->getLocation(), - diag::err_sme_definition_using_zt0_in_non_sme2_target); - } - } - } + if (DeclIsDefn && Context.getTargetInfo().getTriple().isAArch64()) + ARM().CheckSMEFunctionDefAttributes(NewFD); return Redeclaration; } |