[flang-commits] [flang] [Flang][OpenMP] Process motion clauses in a single call (NFC) (PR #108046)

Krzysztof Parzyszek via flang-commits flang-commits at lists.llvm.org
Tue Sep 10 09:11:57 PDT 2024


================
@@ -1114,6 +1114,37 @@ bool ClauseProcessor::processUseDevicePtr(
   return clauseFound;
 }
 
+bool ClauseProcessor::processMotionClauses(lower::StatementContext &stmtCtx,
+                                           mlir::omp::MapClauseOps &result) {
+  std::map<const semantics::Symbol *,
+           llvm::SmallVector<OmpMapMemberIndicesData>>
+      parentMemberIndices;
+  llvm::SmallVector<const semantics::Symbol *> mapSymbols;
+
+  auto callbackFn = [&](const auto &clause, const parser::CharBlock &source) {
+    mlir::Location clauseLocation = converter.genLocation(source);
+
+    // TODO Support motion modifiers: present, mapper, iterator.
+    constexpr llvm::omp::OpenMPOffloadMappingFlags mapTypeBits =
+        std::is_same_v<llvm::remove_cvref_t<decltype(clause)>, omp::clause::To>
+            ? llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_TO
+            : llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_FROM;
+
+    processMapObjects(stmtCtx, clauseLocation, std::get<ObjectList>(clause.t),
+                      mapTypeBits, parentMemberIndices, result.mapVars,
+                      &mapSymbols);
+  };
+
+  bool clauseFound = findRepeatableClause<omp::clause::To>(callbackFn);
+  clauseFound =
+      findRepeatableClause<omp::clause::From>(callbackFn) || clauseFound;
----------------
kparzysz wrote:

Maaaaybe using `|` would look nicer?
```
  bool clauseFound = findRepeatableClause<omp::clause::To>(callbackFn) |
                     findRepeatableClause<omp::clause::From>(callbackFn);
```
Just a thought...

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


More information about the flang-commits mailing list