@@ -1372,6 +1372,15 @@ static void genTaskwaitClauses(lower::AbstractConverter &converter,
13721372 loc, llvm::omp::Directive::OMPD_taskwait);
13731373}
13741374
1375+ static void genWorkshareClauses (lower::AbstractConverter &converter,
1376+ semantics::SemanticsContext &semaCtx,
1377+ lower::StatementContext &stmtCtx,
1378+ const List<Clause> &clauses, mlir::Location loc,
1379+ mlir::omp::WorkshareOperands &clauseOps) {
1380+ ClauseProcessor cp (converter, semaCtx, clauses);
1381+ cp.processNowait (clauseOps);
1382+ }
1383+
13751384static void genTeamsClauses (lower::AbstractConverter &converter,
13761385 semantics::SemanticsContext &semaCtx,
13771386 lower::StatementContext &stmtCtx,
@@ -2033,6 +2042,24 @@ genTaskyieldOp(lower::AbstractConverter &converter, lower::SymMap &symTable,
20332042 return converter.getFirOpBuilder ().create <mlir::omp::TaskyieldOp>(loc);
20342043}
20352044
2045+ static mlir::omp::WorkshareOp
2046+ genWorkshareOp (lower::AbstractConverter &converter, lower::SymMap &symTable,
2047+ semantics::SemanticsContext &semaCtx,
2048+ lower::pft::Evaluation &eval, mlir::Location loc,
2049+ const ConstructQueue &queue,
2050+ ConstructQueue::const_iterator item) {
2051+ lower::StatementContext stmtCtx;
2052+ mlir::omp::WorkshareOperands clauseOps;
2053+ genWorkshareClauses (converter, semaCtx, stmtCtx, item->clauses , loc,
2054+ clauseOps);
2055+
2056+ return genOpWithBody<mlir::omp::WorkshareOp>(
2057+ OpWithBodyGenInfo (converter, symTable, semaCtx, loc, eval,
2058+ llvm::omp::Directive::OMPD_workshare)
2059+ .setClauses (&item->clauses ),
2060+ queue, item, clauseOps);
2061+ }
2062+
20362063static mlir::omp::TeamsOp
20372064genTeamsOp (lower::AbstractConverter &converter, lower::SymMap &symTable,
20382065 semantics::SemanticsContext &semaCtx, lower::pft::Evaluation &eval,
@@ -2631,10 +2658,7 @@ static void genOMPDispatch(lower::AbstractConverter &converter,
26312658 llvm::omp::getOpenMPDirectiveName (dir) + " )" );
26322659 // case llvm::omp::Directive::OMPD_workdistribute:
26332660 case llvm::omp::Directive::OMPD_workshare:
2634- // FIXME: Workshare is not a commonly used OpenMP construct, an
2635- // implementation for this feature will come later. For the codes
2636- // that use this construct, add a single construct for now.
2637- genSingleOp (converter, symTable, semaCtx, eval, loc, queue, item);
2661+ genWorkshareOp (converter, symTable, semaCtx, eval, loc, queue, item);
26382662 break ;
26392663 default :
26402664 // Combined and composite constructs should have been split into a sequence
0 commit comments