diff options
Diffstat (limited to 'flang/lib/Lower/OpenMP/Utils.cpp')
-rw-r--r-- | flang/lib/Lower/OpenMP/Utils.cpp | 109 |
1 files changed, 14 insertions, 95 deletions
diff --git a/flang/lib/Lower/OpenMP/Utils.cpp b/flang/lib/Lower/OpenMP/Utils.cpp index b194150..13fda97 100644 --- a/flang/lib/Lower/OpenMP/Utils.cpp +++ b/flang/lib/Lower/OpenMP/Utils.cpp @@ -20,6 +20,7 @@ #include <flang/Lower/PFTBuilder.h> #include <flang/Optimizer/Builder/FIRBuilder.h> #include <flang/Optimizer/Builder/Todo.h> +#include <flang/Parser/openmp-utils.h> #include <flang/Parser/parse-tree.h> #include <flang/Parser/tools.h> #include <flang/Semantics/tools.h> @@ -115,7 +116,7 @@ createMapInfoOp(fir::FirOpBuilder &builder, mlir::Location loc, mlir::omp::VariableCaptureKind mapCaptureType, mlir::Type retTy, bool partialMap, mlir::FlatSymbolRefAttr mapperId) { if (auto boxTy = llvm::dyn_cast<fir::BaseBoxType>(baseAddr.getType())) { - baseAddr = builder.create<fir::BoxAddrOp>(loc, baseAddr); + baseAddr = fir::BoxAddrOp::create(builder, loc, baseAddr); retTy = baseAddr.getType(); } @@ -129,8 +130,8 @@ createMapInfoOp(fir::FirOpBuilder &builder, mlir::Location loc, if (seqType.hasDynamicExtents()) varType = mlir::TypeAttr::get(seqType.getEleTy()); - mlir::omp::MapInfoOp op = builder.create<mlir::omp::MapInfoOp>( - loc, retTy, baseAddr, varType, + mlir::omp::MapInfoOp op = mlir::omp::MapInfoOp::create( + builder, loc, retTy, baseAddr, varType, builder.getIntegerAttr(builder.getIntegerType(64, false), mapType), builder.getAttr<mlir::omp::VariableCaptureKindAttr>(mapCaptureType), varPtrPtr, members, membersIndex, bounds, mapperId, @@ -195,8 +196,8 @@ static void generateArrayIndices(lower::AbstractConverter &converter, clauseLocation, firOpBuilder.getIndexType(), 1); subscript = firOpBuilder.createConvert( clauseLocation, firOpBuilder.getIndexType(), subscript); - indices.push_back(firOpBuilder.create<mlir::arith::SubIOp>(clauseLocation, - subscript, one)); + indices.push_back(mlir::arith::SubIOp::create(firOpBuilder, clauseLocation, + subscript, one)); } } @@ -329,9 +330,10 @@ mlir::Value createParentSymAndGenIntermediateMaps( subscriptIndices, objectList[i]); assert(!subscriptIndices.empty() && "missing expected indices for map clause"); - curValue = firOpBuilder.create<fir::CoordinateOp>( - clauseLocation, firOpBuilder.getRefType(arrType.getEleTy()), - curValue, subscriptIndices); + curValue = fir::CoordinateOp::create( + firOpBuilder, clauseLocation, + firOpBuilder.getRefType(arrType.getEleTy()), curValue, + subscriptIndices); } } @@ -345,9 +347,9 @@ mlir::Value createParentSymAndGenIntermediateMaps( fir::IntOrValue idxConst = mlir::IntegerAttr::get( firOpBuilder.getI32Type(), indices[currentIndicesIdx]); mlir::Type memberTy = recordType.getType(indices[currentIndicesIdx]); - curValue = firOpBuilder.create<fir::CoordinateOp>( - clauseLocation, firOpBuilder.getRefType(memberTy), curValue, - llvm::SmallVector<fir::IntOrValue, 1>{idxConst}); + curValue = fir::CoordinateOp::create( + firOpBuilder, clauseLocation, firOpBuilder.getRefType(memberTy), + curValue, llvm::SmallVector<fir::IntOrValue, 1>{idxConst}); // If we're a final member, the map will be generated by the processMap // call that invoked this function. @@ -417,7 +419,7 @@ mlir::Value createParentSymAndGenIntermediateMaps( // Load the currently accessed member, so we can continue to access // further segments. - curValue = firOpBuilder.create<fir::LoadOp>(clauseLocation, curValue); + curValue = fir::LoadOp::create(firOpBuilder, clauseLocation, curValue); currentIndicesIdx++; } } @@ -662,89 +664,6 @@ bool collectLoopRelatedInfo( return found; } -/// Get the directive enumeration value corresponding to the given OpenMP -/// construct PFT node. -llvm::omp::Directive -extractOmpDirective(const parser::OpenMPConstruct &ompConstruct) { - return common::visit( - common::visitors{ - [](const parser::OpenMPAllocatorsConstruct &c) { - return llvm::omp::OMPD_allocators; - }, - [](const parser::OpenMPAssumeConstruct &c) { - return llvm::omp::OMPD_assume; - }, - [](const parser::OpenMPAtomicConstruct &c) { - return llvm::omp::OMPD_atomic; - }, - [](const parser::OpenMPBlockConstruct &c) { - return std::get<parser::OmpBlockDirective>( - std::get<parser::OmpBeginBlockDirective>(c.t).t) - .v; - }, - [](const parser::OpenMPCriticalConstruct &c) { - return llvm::omp::OMPD_critical; - }, - [](const parser::OpenMPDeclarativeAllocate &c) { - return llvm::omp::OMPD_allocate; - }, - [](const parser::OpenMPDispatchConstruct &c) { - return llvm::omp::OMPD_dispatch; - }, - [](const parser::OpenMPExecutableAllocate &c) { - return llvm::omp::OMPD_allocate; - }, - [](const parser::OpenMPLoopConstruct &c) { - return std::get<parser::OmpLoopDirective>( - std::get<parser::OmpBeginLoopDirective>(c.t).t) - .v; - }, - [](const parser::OpenMPSectionConstruct &c) { - return llvm::omp::OMPD_section; - }, - [](const parser::OpenMPSectionsConstruct &c) { - return std::get<parser::OmpSectionsDirective>( - std::get<parser::OmpBeginSectionsDirective>(c.t).t) - .v; - }, - [](const parser::OpenMPStandaloneConstruct &c) { - return common::visit( - common::visitors{ - [](const parser::OpenMPSimpleStandaloneConstruct &c) { - return c.v.DirId(); - }, - [](const parser::OpenMPFlushConstruct &c) { - return llvm::omp::OMPD_flush; - }, - [](const parser::OpenMPCancelConstruct &c) { - return llvm::omp::OMPD_cancel; - }, - [](const parser::OpenMPCancellationPointConstruct &c) { - return llvm::omp::OMPD_cancellation_point; - }, - [](const parser::OmpMetadirectiveDirective &c) { - return llvm::omp::OMPD_metadirective; - }, - [](const parser::OpenMPDepobjConstruct &c) { - return llvm::omp::OMPD_depobj; - }, - [](const parser::OpenMPInteropConstruct &c) { - return llvm::omp::OMPD_interop; - }}, - c.u); - }, - [](const parser::OpenMPUtilityConstruct &c) { - return common::visit( - common::visitors{[](const parser::OmpErrorDirective &c) { - return llvm::omp::OMPD_error; - }, - [](const parser::OmpNothingDirective &c) { - return llvm::omp::OMPD_nothing; - }}, - c.u); - }}, - ompConstruct.u); -} } // namespace omp } // namespace lower } // namespace Fortran |