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

Sander de Smalen via cfe-commits cfe-commits at lists.llvm.org
Fri Jun 14 02:44:51 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;
----------------
sdesmalen-arm wrote:

You're right, not sure what I was thinking here with the 'static' variable :)

I'd rather not go down the route of parsing the BuiltinTargetGuards here or making assumptions on the format if we're not going to ensure this format in the arm_sve.td file. For example, one can write `(sve,featureX)|(sme2,featureX)` or `(sve|sme),featureX`. Sure we can assume the former format, but in that case I think we need to have a `SVETargetGuard` and a `SMETargetGuard`, that we let TableGen combine into a canonical form for the combined `TargetGuard`.

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


More information about the cfe-commits mailing list