@@ -1330,6 +1330,15 @@ static void genTaskwaitClauses(lower::AbstractConverter &converter,
13301330 loc, llvm::omp::Directive::OMPD_taskwait);
13311331}
13321332
1333+ static void genWorkshareClauses (lower::AbstractConverter &converter,
1334+ semantics::SemanticsContext &semaCtx,
1335+ lower::StatementContext &stmtCtx,
1336+ const List<Clause> &clauses, mlir::Location loc,
1337+ mlir::omp::WorkshareOperands &clauseOps) {
1338+ ClauseProcessor cp (converter, semaCtx, clauses);
1339+ cp.processNowait (clauseOps);
1340+ }
1341+
13331342static void genTeamsClauses (lower::AbstractConverter &converter,
13341343 semantics::SemanticsContext &semaCtx,
13351344 lower::StatementContext &stmtCtx,
@@ -1923,6 +1932,22 @@ genTaskyieldOp(lower::AbstractConverter &converter, lower::SymMap &symTable,
19231932 return converter.getFirOpBuilder ().create <mlir::omp::TaskyieldOp>(loc);
19241933}
19251934
1935+ static mlir::omp::WorkshareOp
1936+ genWorkshareOp (lower::AbstractConverter &converter, lower::SymMap &symTable,
1937+ semantics::SemanticsContext &semaCtx, lower::pft::Evaluation &eval,
1938+ mlir::Location loc, const ConstructQueue &queue,
1939+ ConstructQueue::iterator item) {
1940+ lower::StatementContext stmtCtx;
1941+ mlir::omp::WorkshareOperands clauseOps;
1942+ genWorkshareClauses (converter, semaCtx, stmtCtx, item->clauses , loc, clauseOps);
1943+
1944+ return genOpWithBody<mlir::omp::WorkshareOp>(
1945+ OpWithBodyGenInfo (converter, symTable, semaCtx, loc, eval,
1946+ llvm::omp::Directive::OMPD_workshare)
1947+ .setClauses (&item->clauses ),
1948+ queue, item, clauseOps);
1949+ }
1950+
19261951static mlir::omp::TeamsOp
19271952genTeamsOp (lower::AbstractConverter &converter, lower::SymMap &symTable,
19281953 semantics::SemanticsContext &semaCtx, lower::pft::Evaluation &eval,
@@ -2515,10 +2540,7 @@ static void genOMPDispatch(lower::AbstractConverter &converter,
25152540 llvm::omp::getOpenMPDirectiveName (dir) + " )" );
25162541 // case llvm::omp::Directive::OMPD_workdistribute:
25172542 case llvm::omp::Directive::OMPD_workshare:
2518- // FIXME: Workshare is not a commonly used OpenMP construct, an
2519- // implementation for this feature will come later. For the codes
2520- // that use this construct, add a single construct for now.
2521- genSingleOp (converter, symTable, semaCtx, eval, loc, queue, item);
2543+ genWorkshareOp (converter, symTable, semaCtx, eval, loc, queue, item);
25222544 break ;
25232545 default :
25242546 // Combined and composite constructs should have been split into a sequence
0 commit comments