Skip to content

Commit 3d12585

Browse files
committed
[flang][omp] Emit omp.workshare in frontend
1 parent 45a8aa4 commit 3d12585

File tree

1 file changed

+26
-4
lines changed

1 file changed

+26
-4
lines changed

flang/lib/Lower/OpenMP/OpenMP.cpp

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1272,6 +1272,15 @@ static void genTaskwaitClauses(lower::AbstractConverter &converter,
12721272
loc, llvm::omp::Directive::OMPD_taskwait);
12731273
}
12741274

1275+
static void genWorkshareClauses(lower::AbstractConverter &converter,
1276+
semantics::SemanticsContext &semaCtx,
1277+
lower::StatementContext &stmtCtx,
1278+
const List<Clause> &clauses, mlir::Location loc,
1279+
mlir::omp::WorkshareOperands &clauseOps) {
1280+
ClauseProcessor cp(converter, semaCtx, clauses);
1281+
cp.processNowait(clauseOps);
1282+
}
1283+
12751284
static void genTeamsClauses(lower::AbstractConverter &converter,
12761285
semantics::SemanticsContext &semaCtx,
12771286
lower::StatementContext &stmtCtx,
@@ -1897,6 +1906,22 @@ genTaskyieldOp(lower::AbstractConverter &converter, lower::SymMap &symTable,
18971906
return converter.getFirOpBuilder().create<mlir::omp::TaskyieldOp>(loc);
18981907
}
18991908

1909+
static mlir::omp::WorkshareOp
1910+
genWorkshareOp(lower::AbstractConverter &converter, lower::SymMap &symTable,
1911+
semantics::SemanticsContext &semaCtx, lower::pft::Evaluation &eval,
1912+
mlir::Location loc, const ConstructQueue &queue,
1913+
ConstructQueue::iterator item) {
1914+
lower::StatementContext stmtCtx;
1915+
mlir::omp::WorkshareOperands clauseOps;
1916+
genWorkshareClauses(converter, semaCtx, stmtCtx, item->clauses, loc, clauseOps);
1917+
1918+
return genOpWithBody<mlir::omp::WorkshareOp>(
1919+
OpWithBodyGenInfo(converter, symTable, semaCtx, loc, eval,
1920+
llvm::omp::Directive::OMPD_workshare)
1921+
.setClauses(&item->clauses),
1922+
queue, item, clauseOps);
1923+
}
1924+
19001925
static mlir::omp::TeamsOp
19011926
genTeamsOp(lower::AbstractConverter &converter, lower::SymMap &symTable,
19021927
semantics::SemanticsContext &semaCtx, lower::pft::Evaluation &eval,
@@ -2309,10 +2334,7 @@ static void genOMPDispatch(lower::AbstractConverter &converter,
23092334
llvm::omp::getOpenMPDirectiveName(dir) + ")");
23102335
// case llvm::omp::Directive::OMPD_workdistribute:
23112336
case llvm::omp::Directive::OMPD_workshare:
2312-
// FIXME: Workshare is not a commonly used OpenMP construct, an
2313-
// implementation for this feature will come later. For the codes
2314-
// that use this construct, add a single construct for now.
2315-
genSingleOp(converter, symTable, semaCtx, eval, loc, queue, item);
2337+
genWorkshareOp(converter, symTable, semaCtx, eval, loc, queue, item);
23162338
break;
23172339
default:
23182340
// Combined and composite constructs should have been split into a sequence

0 commit comments

Comments
 (0)