[flang-commits] [flang] [fang][cuda] Allow * in call chevron syntax (PR #115381)

Valentin Clement バレンタイン クレメン via flang-commits flang-commits at lists.llvm.org
Thu Nov 7 17:25:49 PST 2024


================
@@ -3065,18 +3065,38 @@ std::optional<Chevrons> ExpressionAnalyzer::AnalyzeChevrons(
         which);
     return false;
   }};
+
   if (const auto &chevrons{call.chevrons}) {
-    if (auto expr{Analyze(std::get<0>(chevrons->t))};
-        expr && checkLaunchArg(*expr, "grid")) {
-      result.emplace_back(*expr);
+    bool gridIsStar{false};
+    bool blockIsStar{false};
+    auto &starOrExpr0{std::get<0>(chevrons->t)};
+    if (starOrExpr0.v) {
+      if (auto expr{Analyze(*starOrExpr0.v)};
+          expr && checkLaunchArg(*expr, "grid")) {
+        result.emplace_back(*expr);
+      } else {
+        return std::nullopt;
+      }
     } else {
-      return std::nullopt;
-    }
-    if (auto expr{Analyze(std::get<1>(chevrons->t))};
-        expr && checkLaunchArg(*expr, "block")) {
-      result.emplace_back(*expr);
+      gridIsStar = true;
+      result.emplace_back(
+          AsGenericExpr(evaluate::Constant<evaluate::SubscriptInteger>{-1}));
+    }
+    auto &starOrExpr1{std::get<1>(chevrons->t)};
+    if (starOrExpr1.v) {
+      if (auto expr{Analyze(*starOrExpr1.v)};
+          expr && checkLaunchArg(*expr, "block")) {
+        result.emplace_back(*expr);
+      } else {
+        return std::nullopt;
+      }
     } else {
-      return std::nullopt;
+      blockIsStar = true;
+      result.emplace_back(
+          AsGenericExpr(evaluate::Constant<evaluate::SubscriptInteger>{-1}));
+    }
+    if (gridIsStar && blockIsStar) {
+      Say("Grid and block can not be * in kernel launch parameter"_err_en_US);
----------------
clementval wrote:

```suggestion
      Say("Grid and block can not both be * in kernel launch parameter"_err_en_US);
```

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


More information about the flang-commits mailing list