Skip to content

Commit 8b774cd

Browse files
committed
[flang][OpenMP] Convert processTODO and remove unused objects
Remove `ClauseIterator2` and `clauses2` from ClauseProcessor.
1 parent 23eeb2b commit 8b774cd

File tree

1 file changed

+28
-47
lines changed

1 file changed

+28
-47
lines changed

flang/lib/Lower/OpenMP.cpp

Lines changed: 28 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1669,13 +1669,11 @@ void DataSharingProcessor::defaultPrivatize() {
16691669
/// methods that relate to clauses that can impact the lowering of that
16701670
/// construct.
16711671
class ClauseProcessor {
1672-
using ClauseTy = Fortran::parser::OmpClause;
1673-
16741672
public:
16751673
ClauseProcessor(Fortran::lower::AbstractConverter &converter,
16761674
Fortran::semantics::SemanticsContext &semaCtx,
16771675
const Fortran::parser::OmpClauseList &clauses)
1678-
: converter(converter), semaCtx(semaCtx), clauses2(clauses),
1676+
: converter(converter), semaCtx(semaCtx),
16791677
clauses(omp::makeList(clauses, semaCtx)) {}
16801678

16811679
// 'Unique' clauses: They can appear at most once in the clause list.
@@ -1776,7 +1774,6 @@ class ClauseProcessor {
17761774

17771775
private:
17781776
using ClauseIterator = omp::List<omp::Clause>::const_iterator;
1779-
using ClauseIterator2 = std::list<ClauseTy>::const_iterator;
17801777

17811778
/// Utility to find a clause within a range in the clause list.
17821779
template <typename T>
@@ -1836,7 +1833,6 @@ class ClauseProcessor {
18361833

18371834
Fortran::lower::AbstractConverter &converter;
18381835
Fortran::semantics::SemanticsContext &semaCtx;
1839-
const Fortran::parser::OmpClauseList &clauses2;
18401836
omp::List<omp::Clause> clauses;
18411837
};
18421838

@@ -3132,19 +3128,17 @@ bool ClauseProcessor::processMotionClauses(
31323128
template <typename... Ts>
31333129
void ClauseProcessor::processTODO(mlir::Location currentLocation,
31343130
llvm::omp::Directive directive) const {
3135-
auto checkUnhandledClause = [&](const auto *x) {
3131+
auto checkUnhandledClause = [&](llvm::omp::Clause id, const auto *x) {
31363132
if (!x)
31373133
return;
31383134
TODO(currentLocation,
3139-
"Unhandled clause " +
3140-
llvm::StringRef(Fortran::parser::ParseTreeDumper::GetNodeName(*x))
3141-
.upper() +
3135+
"Unhandled clause " + llvm::omp::getOpenMPClauseName(id).upper() +
31423136
" in " + llvm::omp::getOpenMPDirectiveName(directive).upper() +
31433137
" construct");
31443138
};
31453139

3146-
for (ClauseIterator2 it = clauses2.v.begin(); it != clauses2.v.end(); ++it)
3147-
(checkUnhandledClause(std::get_if<Ts>(&it->u)), ...);
3140+
for (ClauseIterator it = clauses.begin(); it != clauses.end(); ++it)
3141+
(checkUnhandledClause(it->id, std::get_if<Ts>(&it->u)), ...);
31483142
}
31493143

31503144
//===----------------------------------------------------------------------===//
@@ -3725,8 +3719,8 @@ genSingleOp(Fortran::lower::AbstractConverter &converter,
37253719

37263720
ClauseProcessor cp(converter, semaCtx, beginClauseList);
37273721
cp.processAllocate(allocatorOperands, allocateOperands);
3728-
cp.processTODO<Fortran::parser::OmpClause::Copyprivate>(
3729-
currentLocation, llvm::omp::Directive::OMPD_single);
3722+
cp.processTODO<omp::clause::Copyprivate>(currentLocation,
3723+
llvm::omp::Directive::OMPD_single);
37303724

37313725
ClauseProcessor(converter, semaCtx, endClauseList).processNowait(nowaitAttr);
37323726

@@ -3760,10 +3754,9 @@ genTaskOp(Fortran::lower::AbstractConverter &converter,
37603754
cp.processMergeable(mergeableAttr);
37613755
cp.processPriority(stmtCtx, priorityClauseOperand);
37623756
cp.processDepend(dependTypeOperands, dependOperands);
3763-
cp.processTODO<Fortran::parser::OmpClause::InReduction,
3764-
Fortran::parser::OmpClause::Detach,
3765-
Fortran::parser::OmpClause::Affinity>(
3766-
currentLocation, llvm::omp::Directive::OMPD_task);
3757+
cp.processTODO<omp::clause::InReduction, omp::clause::Detach,
3758+
omp::clause::Affinity>(currentLocation,
3759+
llvm::omp::Directive::OMPD_task);
37673760

37683761
return genOpWithBody<mlir::omp::TaskOp>(
37693762
OpWithBodyGenInfo(converter, semaCtx, currentLocation, eval)
@@ -3788,7 +3781,7 @@ genTaskGroupOp(Fortran::lower::AbstractConverter &converter,
37883781
llvm::SmallVector<mlir::Value> allocateOperands, allocatorOperands;
37893782
ClauseProcessor cp(converter, semaCtx, clauseList);
37903783
cp.processAllocate(allocatorOperands, allocateOperands);
3791-
cp.processTODO<Fortran::parser::OmpClause::TaskReduction>(
3784+
cp.processTODO<omp::clause::TaskReduction>(
37923785
currentLocation, llvm::omp::Directive::OMPD_taskgroup);
37933786
return genOpWithBody<mlir::omp::TaskGroupOp>(
37943787
OpWithBodyGenInfo(converter, semaCtx, currentLocation, eval)
@@ -3872,8 +3865,7 @@ genEnterExitUpdateDataOp(Fortran::lower::AbstractConverter &converter,
38723865
cp.processMap(currentLocation, directive, stmtCtx, mapOperands);
38733866
}
38743867

3875-
cp.processTODO<Fortran::parser::OmpClause::Depend>(currentLocation,
3876-
directive);
3868+
cp.processTODO<omp::clause::Depend>(currentLocation, directive);
38773869

38783870
return firOpBuilder.create<OpTy>(currentLocation, ifClauseOperand,
38793871
deviceOperand, nullptr, mlir::ValueRange(),
@@ -4056,16 +4048,11 @@ genTargetOp(Fortran::lower::AbstractConverter &converter,
40564048
cp.processNowait(nowaitAttr);
40574049
cp.processMap(currentLocation, directive, stmtCtx, mapOperands, &mapSymTypes,
40584050
&mapSymLocs, &mapSymbols);
4059-
cp.processTODO<Fortran::parser::OmpClause::Private,
4060-
Fortran::parser::OmpClause::Depend,
4061-
Fortran::parser::OmpClause::Firstprivate,
4062-
Fortran::parser::OmpClause::IsDevicePtr,
4063-
Fortran::parser::OmpClause::HasDeviceAddr,
4064-
Fortran::parser::OmpClause::Reduction,
4065-
Fortran::parser::OmpClause::InReduction,
4066-
Fortran::parser::OmpClause::Allocate,
4067-
Fortran::parser::OmpClause::UsesAllocators,
4068-
Fortran::parser::OmpClause::Defaultmap>(
4051+
cp.processTODO<omp::clause::Private, omp::clause::Depend,
4052+
omp::clause::Firstprivate, omp::clause::IsDevicePtr,
4053+
omp::clause::HasDeviceAddr, omp::clause::Reduction,
4054+
omp::clause::InReduction, omp::clause::Allocate,
4055+
omp::clause::UsesAllocators, omp::clause::Defaultmap>(
40694056
currentLocation, llvm::omp::Directive::OMPD_target);
40704057

40714058
// 5.8.1 Implicit Data-Mapping Attribute Rules
@@ -4168,8 +4155,8 @@ genTeamsOp(Fortran::lower::AbstractConverter &converter,
41684155
cp.processDefault();
41694156
cp.processNumTeams(stmtCtx, numTeamsClauseOperand);
41704157
cp.processThreadLimit(stmtCtx, threadLimitClauseOperand);
4171-
cp.processTODO<Fortran::parser::OmpClause::Reduction>(
4172-
currentLocation, llvm::omp::Directive::OMPD_teams);
4158+
cp.processTODO<omp::clause::Reduction>(currentLocation,
4159+
llvm::omp::Directive::OMPD_teams);
41734160

41744161
return genOpWithBody<mlir::omp::TeamsOp>(
41754162
OpWithBodyGenInfo(converter, semaCtx, currentLocation, eval)
@@ -4221,7 +4208,7 @@ static mlir::omp::DeclareTargetDeviceType getDeclareTargetInfo(
42214208
cp.processEnter(symbolAndClause);
42224209
cp.processLink(symbolAndClause);
42234210
cp.processDeviceType(deviceType);
4224-
cp.processTODO<Fortran::parser::OmpClause::Indirect>(
4211+
cp.processTODO<omp::clause::Indirect>(
42254212
converter.getCurrentLocation(),
42264213
llvm::omp::Directive::OMPD_declare_target);
42274214
}
@@ -4280,8 +4267,7 @@ genOmpSimpleStandalone(Fortran::lower::AbstractConverter &converter,
42804267
break;
42814268
case llvm::omp::Directive::OMPD_taskwait:
42824269
ClauseProcessor(converter, semaCtx, opClauseList)
4283-
.processTODO<Fortran::parser::OmpClause::Depend,
4284-
Fortran::parser::OmpClause::Nowait>(
4270+
.processTODO<omp::clause::Depend, omp::clause::Nowait>(
42854271
currentLocation, llvm::omp::Directive::OMPD_taskwait);
42864272
firOpBuilder.create<mlir::omp::TaskwaitOp>(currentLocation);
42874273
break;
@@ -4483,11 +4469,9 @@ createSimdLoop(Fortran::lower::AbstractConverter &converter,
44834469
cp.processIf(omp::clause::If::DirectiveNameModifier::Simd, ifClauseOperand);
44844470
cp.processSimdlen(simdlenClauseOperand);
44854471
cp.processSafelen(safelenClauseOperand);
4486-
cp.processTODO<Fortran::parser::OmpClause::Aligned,
4487-
Fortran::parser::OmpClause::Allocate,
4488-
Fortran::parser::OmpClause::Linear,
4489-
Fortran::parser::OmpClause::Nontemporal,
4490-
Fortran::parser::OmpClause::Order>(loc, ompDirective);
4472+
cp.processTODO<omp::clause::Aligned, omp::clause::Allocate,
4473+
omp::clause::Linear, omp::clause::Nontemporal,
4474+
omp::clause::Order>(loc, ompDirective);
44914475

44924476
convertLoopBounds(converter, loc, lowerBound, upperBound, step,
44934477
loopVarTypeSize);
@@ -4544,8 +4528,7 @@ static void createWsLoop(Fortran::lower::AbstractConverter &converter,
45444528
cp.processScheduleChunk(stmtCtx, scheduleChunkClauseOperand);
45454529
cp.processReduction(loc, reductionVars, reductionDeclSymbols,
45464530
&reductionSymbols);
4547-
cp.processTODO<Fortran::parser::OmpClause::Linear,
4548-
Fortran::parser::OmpClause::Order>(loc, ompDirective);
4531+
cp.processTODO<omp::clause::Linear, omp::clause::Order>(loc, ompDirective);
45494532

45504533
convertLoopBounds(converter, loc, lowerBound, upperBound, step,
45514534
loopVarTypeSize);
@@ -4612,11 +4595,9 @@ static void createSimdWsLoop(
46124595
const Fortran::parser::OmpClauseList &beginClauseList,
46134596
const Fortran::parser::OmpClauseList *endClauseList, mlir::Location loc) {
46144597
ClauseProcessor cp(converter, semaCtx, beginClauseList);
4615-
cp.processTODO<
4616-
Fortran::parser::OmpClause::Aligned, Fortran::parser::OmpClause::Allocate,
4617-
Fortran::parser::OmpClause::Linear, Fortran::parser::OmpClause::Safelen,
4618-
Fortran::parser::OmpClause::Simdlen, Fortran::parser::OmpClause::Order>(
4619-
loc, ompDirective);
4598+
cp.processTODO<omp::clause::Aligned, omp::clause::Allocate,
4599+
omp::clause::Linear, omp::clause::Safelen,
4600+
omp::clause::Simdlen, omp::clause::Order>(loc, ompDirective);
46204601
// TODO: Add support for vectorization - add vectorization hints inside loop
46214602
// body.
46224603
// OpenMP standard does not specify the length of vector instructions.

0 commit comments

Comments
 (0)