[flang-commits] [flang] [flang][MLIR][OpenMP] Emit `UpdateDataOp` from `!$omp target update` (PR #75345)

Kareem Ergawy via flang-commits flang-commits at lists.llvm.org
Mon Dec 18 20:24:11 PST 2023


================
@@ -1892,6 +1908,63 @@ bool ClauseProcessor::processUseDevicePtr(
       });
 }
 
+bool ClauseProcessor::processToMotionClauses(
+    Fortran::semantics::SemanticsContext &semanticsContext,
+    Fortran::lower::StatementContext &stmtCtx,
+    llvm::SmallVectorImpl<mlir::Value> &mapOperands) {
+  return processMotionClauses<ClauseProcessor::ClauseTy::To>(
+      semanticsContext, stmtCtx, mapOperands);
+}
+
+bool ClauseProcessor::processFromMotionClauses(
+    Fortran::semantics::SemanticsContext &semanticsContext,
+    Fortran::lower::StatementContext &stmtCtx,
+    llvm::SmallVectorImpl<mlir::Value> &mapOperands) {
+  return processMotionClauses<ClauseProcessor::ClauseTy::From>(
+      semanticsContext, stmtCtx, mapOperands);
+}
+
+template <typename T>
+bool ClauseProcessor::processMotionClauses(
----------------
ergawy wrote:

The underlying difference here is that motion clauses have type `OmpObjectList` while `ClauseProcessor::processMap` works with `OmpMapClause` which is composed of `std::tuple<std::optional<OmpMapType>, OmpObjectList>`.

So we can definitely reuse `ClauseProcessor::processMap` but this will come at the cost of complicating `findRepeatableClause`'s `callbackFn` defined in `ClauseProcessor::processMap` to differentiate between the cases for the motion clauses and the case of the map clause.

I think it is cleaner and easier to read if we leave them separated. Let me know if you disagree.

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


More information about the flang-commits mailing list