[flang-commits] [flang] [flang][OpenMP] Support `bind` clause code-gen for standalone `loop`s (PR #122674)

Kareem Ergawy via flang-commits flang-commits at lists.llvm.org
Mon Jan 27 04:29:46 PST 2025


================
@@ -117,7 +120,27 @@ class GenericLoopConversionPattern
     return result;
   }
 
-  /// Rewrites standalone `loop` directives to equivalent `simd` constructs.
+  void rewriteStandaloneLoop(mlir::omp::LoopOp loopOp,
+                             mlir::ConversionPatternRewriter &rewriter) const {
+    using namespace mlir::omp;
+    std::optional<ClauseBindKind> bindKind = loopOp.getBindKind();
+
+    if (!bindKind.has_value())
+      return rewriteToSimdLoop(loopOp, rewriter);
+
+    switch (*loopOp.getBindKind()) {
+    case ClauseBindKind::Parallel:
+      return rewriteToWsloop(loopOp, rewriter);
+    case ClauseBindKind::Teams:
+      return rewriteToDistrbute(loopOp, rewriter);
----------------
ergawy wrote:

The idea for a general annotation for auto generated constructs and extending this later on with a clarifying message sounds very good to me.

Thanks both for the suggestion. I will add a (generalized) `TODO` in this pass to not forget it.

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


More information about the flang-commits mailing list