Skip to content

Commit 4dd5180

Browse files
authored
[Flang][OpenMP][Lower] Split MLIR codegen for clauses and constructs (#86963)
This patch performs several cleanups with the main purpose of normalizing the code patterns used to trigger codegen for MLIR OpenMP operations and making the processing of clauses and constructs independent. The following changes are made: - Clean up unused `directive` argument to `ClauseProcessor::processMap()`. - Move general helper functions in OpenMP.cpp to the appropriate section of the file. - Create `gen<OpName>Clauses()` functions containing the clause processing code specific for the associated OpenMP construct. - Update `gen<OpName>Op()` functions to call the corresponding `gen<OpName>Clauses()` function. - Sort calls to `ClauseProcessor::process<ClauseName>()` alphabetically, to avoid inadvertently relying on some arbitrary order. Update some tests that broke due to the order change. - Normalize `genOMP()` functions so they all delegate the generation of MLIR to `gen<OpName>Op()` functions following the same pattern. - Only process `nowait` clause on `TARGET` constructs if not compiling for the target device. A later patch can move the calls to `gen<OpName>Clauses()` out of `gen<OpName>Op()` functions and passing completed clause structures instead, in preparation to supporting composite constructs. That will make it possible to reuse clause processing for a given leaf construct when appearing alone or in a combined or composite construct, while controlling where the associated code is produced.
1 parent 422bf13 commit 4dd5180

File tree

6 files changed

+1198
-953
lines changed

6 files changed

+1198
-953
lines changed

flang/lib/Lower/OpenMP/ClauseProcessor.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -832,8 +832,8 @@ createMapInfoOp(fir::FirOpBuilder &builder, mlir::Location loc,
832832
}
833833

834834
bool ClauseProcessor::processMap(
835-
mlir::Location currentLocation, const llvm::omp::Directive &directive,
836-
Fortran::lower::StatementContext &stmtCtx, mlir::omp::MapClauseOps &result,
835+
mlir::Location currentLocation, Fortran::lower::StatementContext &stmtCtx,
836+
mlir::omp::MapClauseOps &result,
837837
llvm::SmallVectorImpl<const Fortran::semantics::Symbol *> *mapSyms,
838838
llvm::SmallVectorImpl<mlir::Location> *mapSymLocs,
839839
llvm::SmallVectorImpl<mlir::Type> *mapSymTypes) const {

flang/lib/Lower/OpenMP/ClauseProcessor.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,7 @@ class ClauseProcessor {
114114
// They may be used later on to create the block_arguments for some of the
115115
// target directives that require it.
116116
bool processMap(
117-
mlir::Location currentLocation, const llvm::omp::Directive &directive,
118-
Fortran::lower::StatementContext &stmtCtx,
117+
mlir::Location currentLocation, Fortran::lower::StatementContext &stmtCtx,
119118
mlir::omp::MapClauseOps &result,
120119
llvm::SmallVectorImpl<const Fortran::semantics::Symbol *> *mapSyms =
121120
nullptr,

0 commit comments

Comments
 (0)