@@ -1270,6 +1270,15 @@ static void genTaskwaitClauses(lower::AbstractConverter &converter,
12701270 loc, llvm::omp::Directive::OMPD_taskwait);
12711271}
12721272
1273+ static void genWorkshareClauses (lower::AbstractConverter &converter,
1274+ semantics::SemanticsContext &semaCtx,
1275+ lower::StatementContext &stmtCtx,
1276+ const List<Clause> &clauses, mlir::Location loc,
1277+ mlir::omp::WorkshareOperands &clauseOps) {
1278+ ClauseProcessor cp (converter, semaCtx, clauses);
1279+ cp.processNowait (clauseOps);
1280+ }
1281+
12731282static void genTeamsClauses (lower::AbstractConverter &converter,
12741283 semantics::SemanticsContext &semaCtx,
12751284 lower::StatementContext &stmtCtx,
@@ -1890,6 +1899,22 @@ genTaskyieldOp(lower::AbstractConverter &converter, lower::SymMap &symTable,
18901899 return converter.getFirOpBuilder ().create <mlir::omp::TaskyieldOp>(loc);
18911900}
18921901
1902+ static mlir::omp::WorkshareOp
1903+ genWorkshareOp (lower::AbstractConverter &converter, lower::SymMap &symTable,
1904+ semantics::SemanticsContext &semaCtx, lower::pft::Evaluation &eval,
1905+ mlir::Location loc, const ConstructQueue &queue,
1906+ ConstructQueue::iterator item) {
1907+ lower::StatementContext stmtCtx;
1908+ mlir::omp::WorkshareOperands clauseOps;
1909+ genWorkshareClauses (converter, semaCtx, stmtCtx, item->clauses , loc, clauseOps);
1910+
1911+ return genOpWithBody<mlir::omp::WorkshareOp>(
1912+ OpWithBodyGenInfo (converter, symTable, semaCtx, loc, eval,
1913+ llvm::omp::Directive::OMPD_workshare)
1914+ .setClauses (&item->clauses ),
1915+ queue, item, clauseOps);
1916+ }
1917+
18931918static mlir::omp::TeamsOp
18941919genTeamsOp (lower::AbstractConverter &converter, lower::SymMap &symTable,
18951920 semantics::SemanticsContext &semaCtx, lower::pft::Evaluation &eval,
@@ -2249,10 +2274,7 @@ static void genOMPDispatch(lower::AbstractConverter &converter,
22492274 llvm::omp::getOpenMPDirectiveName (dir) + " )" );
22502275 // case llvm::omp::Directive::OMPD_workdistribute:
22512276 case llvm::omp::Directive::OMPD_workshare:
2252- // FIXME: Workshare is not a commonly used OpenMP construct, an
2253- // implementation for this feature will come later. For the codes
2254- // that use this construct, add a single construct for now.
2255- genSingleOp (converter, symTable, semaCtx, eval, loc, queue, item);
2277+ genWorkshareOp (converter, symTable, semaCtx, eval, loc, queue, item);
22562278 break ;
22572279
22582280 // Composite constructs
0 commit comments