@@ -2993,6 +2993,38 @@ static QualType getNeonEltType(NeonTypeFlags Flags, ASTContext &Context,
29932993 llvm_unreachable("Invalid NeonTypeFlag!");
29942994}
29952995
2996+ enum ArmStreamingType { ArmNonStreaming, ArmStreaming, ArmStreamingCompatible };
2997+
2998+ static ArmStreamingType getArmStreamingFnType(const FunctionDecl *FD) {
2999+ if (FD->hasAttr<ArmLocallyStreamingAttr>())
3000+ return ArmStreaming;
3001+ if (const auto *T = FD->getType()->getAs<FunctionProtoType>()) {
3002+ if (T->getAArch64SMEAttributes() & FunctionType::SME_PStateSMEnabledMask)
3003+ return ArmStreaming;
3004+ if (T->getAArch64SMEAttributes() & FunctionType::SME_PStateSMCompatibleMask)
3005+ return ArmStreamingCompatible;
3006+ }
3007+ return ArmNonStreaming;
3008+ }
3009+
3010+ static void checkArmStreamingBuiltin(Sema &S, CallExpr *TheCall,
3011+ const FunctionDecl *FD,
3012+ ArmStreamingType BuiltinType) {
3013+ ArmStreamingType FnType = getArmStreamingFnType(FD);
3014+
3015+ if (FnType == ArmStreaming && BuiltinType == ArmNonStreaming) {
3016+ S.Diag(TheCall->getBeginLoc(), diag::warn_attribute_arm_sm_incompat_builtin)
3017+ << TheCall->getSourceRange() << "streaming";
3018+ }
3019+
3020+ if (FnType == ArmStreamingCompatible &&
3021+ BuiltinType != ArmStreamingCompatible) {
3022+ S.Diag(TheCall->getBeginLoc(), diag::warn_attribute_arm_sm_incompat_builtin)
3023+ << TheCall->getSourceRange() << "streaming compatible";
3024+ return;
3025+ }
3026+ }
3027+
29963028bool Sema::CheckSVEBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall) {
29973029 // Range check SVE intrinsics that take immediate values.
29983030 SmallVector<std::tuple<int,int,int>, 3> ImmChecks;
@@ -3148,6 +3180,23 @@ bool Sema::CheckSVEBuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall) {
31483180
31493181bool Sema::CheckNeonBuiltinFunctionCall(const TargetInfo &TI,
31503182 unsigned BuiltinID, CallExpr *TheCall) {
3183+ if (const FunctionDecl *FD = getCurFunctionDecl()) {
3184+
3185+ switch (BuiltinID) {
3186+ default:
3187+ break;
3188+ #define GET_NEON_BUILTINS
3189+ #define TARGET_BUILTIN(id, ...) case NEON::BI##id:
3190+ #define BUILTIN(id, ...) case NEON::BI##id:
3191+ #include "clang/Basic/arm_neon.inc"
3192+ checkArmStreamingBuiltin(*this, TheCall, FD, ArmNonStreaming);
3193+ break;
3194+ #undef TARGET_BUILTIN
3195+ #undef BUILTIN
3196+ #undef GET_NEON_BUILTINS
3197+ }
3198+ }
3199+
31513200 llvm::APSInt Result;
31523201 uint64_t mask = 0;
31533202 unsigned TV = 0;
0 commit comments