[llvm-branch-commits] [flang] [mlir] [Flang][MLIR][OpenMP] Explicitly represent omp.target kernel types (PR #186166)

Michael Kruse via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Thu Mar 19 07:47:36 PDT 2026


================
@@ -201,6 +190,393 @@ class HostEvalInfo {
   llvm::SmallVector<const semantics::Symbol *> iv;
   bool loopNestApplied = false, parallelApplied = false;
 };
+
+class OpenMPPatternProcessor {
+public:
+  OpenMPPatternProcessor(semantics::SemanticsContext &semaCtx)
+      : semaCtx(semaCtx) {}
+  virtual ~OpenMPPatternProcessor() = default;
+
+  /// Run the pattern from the given evaluation.
+  void process(lower::pft::Evaluation &eval) {
+    dirsToProcess = initialDirsToProcess();
+    processEval(eval);
+  }
+
+protected:
+  /// Returns the set of directives of interest at the beginning of the pattern.
+  virtual OmpDirectiveSet initialDirsToProcess() const = 0;
+
+  /// Processes a single directive and, based on it, returns the set of other
+  /// directives of interest that would be part of the pattern if nested inside
+  /// of it.
+  virtual OmpDirectiveSet processDirective(lower::pft::Evaluation &eval,
+                                           llvm::omp::Directive dir) = 0;
+
+  /// Obtain the list of clauses of the given OpenMP block or loop construct
+  /// evaluation. If it's not an OpenMP construct, no modifications are made to
+  /// the \c clauses output argument.
+  void extractClauses(lower::pft::Evaluation &eval, List<Clause> &clauses) {
+    const auto *ompEval = eval.getIf<parser::OpenMPConstruct>();
+    if (!ompEval)
+      return;
----------------
Meinersbur wrote:

```suggestion
    if (!ompEval) {
      return;
    }
```
[style] [Always wrap the bodies of if(), else, while(), for(), do, &c. with braces, even when the body is a single statement or empty](https://flang.llvm.org/docs/C%2B%2Bstyle.html#layout)


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


More information about the llvm-branch-commits mailing list