[flang-commits] [flang] [Flang][OpenMP] Support iterator modifier in map and motion clauses (PR #197757)
via flang-commits
flang-commits at lists.llvm.org
Tue Aug 4 19:49:24 PDT 2026
================
@@ -317,6 +317,48 @@ static mlir::Value buildIteratorOp(Fortran::lower::AbstractConverter &converter,
return itOp.getResult();
}
+// Build an omp.iterator op that yields a MapInfoOp for a single
+// iterated object.
+static mlir::Value buildIteratedMapEntry(
+ Fortran::lower::AbstractConverter &converter,
+ Fortran::semantics::SemanticsContext &semaCtx, mlir::Location loc,
+ llvm::ArrayRef<IteratorRange> iteratorRanges, const omp::Object &object,
+ llvm::StringRef mapperIdName, mlir::omp::ClauseMapFlags mapTypeBits,
+ llvm::omp::Directive directive) {
+ mlir::Type ptrTy =
+ mlir::LLVM::LLVMPointerType::get(&converter.getMLIRContext());
+ mlir::Type iterTy =
+ mlir::omp::IteratedType::get(&converter.getMLIRContext(), ptrTy);
+
+ return buildIteratorOp(
+ converter, loc, iterTy, iteratorRanges,
+ [&](fir::FirOpBuilder &builder, mlir::Location loc,
+ llvm::ArrayRef<mlir::Value> /*ivs*/) -> mlir::Value {
+ lower::StatementContext iterStmtCtx;
+ std::optional<IteratorMapInfo> mapInfo = genIteratorMapInfo(
+ converter, builder, semaCtx, iterStmtCtx, object, loc);
+ if (!mapInfo)
+ TODO(loc, "object type not supported by iterator modifier");
+
+ // Use the array base as var_ptr with bounds so the runtime can
+ // associate this mapping with whole-array mappings via the base
+ // address.
+ mlir::Value baseAddr = mapInfo->entity.getBase();
+ if (mlir::isa<fir::BaseBoxType>(baseAddr.getType()))
+ baseAddr = fir::BoxAddrOp::create(builder, loc, baseAddr);
----------------
MattPD wrote:
Confirmed: the data-only contract is explicit now.
https://github.com/llvm/llvm-project/pull/197757
More information about the flang-commits
mailing list