[clang] [Clang][AArch64] Generalise streaming mode checks for builtins. (PR #93802)

Paul Walker via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 6 08:30:18 PDT 2024


================
@@ -559,31 +559,86 @@ SemaARM::ArmStreamingType getArmStreamingFnType(const FunctionDecl *FD) {
   return SemaARM::ArmNonStreaming;
 }
 
-static void checkArmStreamingBuiltin(Sema &S, CallExpr *TheCall,
-                                     const FunctionDecl *FD,
-                                     SemaARM::ArmStreamingType BuiltinType) {
+static bool checkArmStreamingBuiltin(Sema &S, CallExpr *TheCall,
+                                     FunctionDecl *FD,
+                                     SemaARM::ArmStreamingType BuiltinType,
+                                     unsigned BuiltinID) {
   SemaARM::ArmStreamingType FnType = getArmStreamingFnType(FD);
-  if (BuiltinType == SemaARM::ArmStreamingOrSVE2p1) {
-    // Check intrinsics that are available in [sve2p1 or sme/sme2].
-    llvm::StringMap<bool> CallerFeatureMap;
-    S.Context.getFunctionFeatureMap(CallerFeatureMap, FD);
-    if (Builtin::evaluateRequiredTargetFeatures("sve2p1", CallerFeatureMap))
-      BuiltinType = SemaARM::ArmStreamingCompatible;
-    else
+
+  // Check if the intrinsic is available in the right mode, i.e.
+  // * When compiling for SME only, the caller must be in streaming mode.
+  // * When compiling for SVE only, the caller must be in non-streaming mode.
+  // * When compiling for both SVE and SME, the caller can be in either mode.
+  if (BuiltinType == SemaARM::VerifyRuntimeMode) {
+    static llvm::StringMap<bool> CallerFeatureMapWithoutSVE,
+        CallerFeatureMapWithoutSME;
+
+    // Cache the feature maps, to avoid having to recalculate this for each
+    // builtin call.
+    static unsigned CachedODRHash = 0;
----------------
paulwalker-arm wrote:

As above.

https://github.com/llvm/llvm-project/pull/93802


More information about the cfe-commits mailing list