Skip to content

Commit 1299d51

Browse files
committed
[flang][OpenMP] Convert processTODO and remove unused objects
Remove `ClauseIterator2` and `clauses2` from ClauseProcessor.
1 parent 8743715 commit 1299d51

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
//===----------------------------------------------------------------------===//
@@ -3723,8 +3717,8 @@ genSingleOp(Fortran::lower::AbstractConverter &converter,
37233717

37243718
ClauseProcessor cp(converter, semaCtx, beginClauseList);
37253719
cp.processAllocate(allocatorOperands, allocateOperands);
3726-
cp.processTODO<Fortran::parser::OmpClause::Copyprivate>(
3727-
currentLocation, llvm::omp::Directive::OMPD_single);
3720+
cp.processTODO<omp::clause::Copyprivate>(currentLocation,
3721+
llvm::omp::Directive::OMPD_single);
37283722

37293723
ClauseProcessor(converter, semaCtx, endClauseList).processNowait(nowaitAttr);
37303724

@@ -3757,10 +3751,9 @@ genTaskOp(Fortran::lower::AbstractConverter &converter,
37573751
cp.processMergeable(mergeableAttr);
37583752
cp.processPriority(stmtCtx, priorityClauseOperand);
37593753
cp.processDepend(dependTypeOperands, dependOperands);
3760-
cp.processTODO<Fortran::parser::OmpClause::InReduction,
3761-
Fortran::parser::OmpClause::Detach,
3762-
Fortran::parser::OmpClause::Affinity>(
3763-
currentLocation, llvm::omp::Directive::OMPD_task);
3754+
cp.processTODO<omp::clause::InReduction, omp::clause::Detach,
3755+
omp::clause::Affinity>(currentLocation,
3756+
llvm::omp::Directive::OMPD_task);
37643757

37653758
return genOpWithBody<mlir::omp::TaskOp>(
37663759
OpWithBodyGenInfo(converter, semaCtx, currentLocation, eval)
@@ -3785,7 +3778,7 @@ genTaskGroupOp(Fortran::lower::AbstractConverter &converter,
37853778
llvm::SmallVector<mlir::Value> allocateOperands, allocatorOperands;
37863779
ClauseProcessor cp(converter, semaCtx, clauseList);
37873780
cp.processAllocate(allocatorOperands, allocateOperands);
3788-
cp.processTODO<Fortran::parser::OmpClause::TaskReduction>(
3781+
cp.processTODO<omp::clause::TaskReduction>(
37893782
currentLocation, llvm::omp::Directive::OMPD_taskgroup);
37903783
return genOpWithBody<mlir::omp::TaskGroupOp>(
37913784
OpWithBodyGenInfo(converter, semaCtx, currentLocation, eval)
@@ -3869,8 +3862,7 @@ genEnterExitUpdateDataOp(Fortran::lower::AbstractConverter &converter,
38693862
cp.processMap(currentLocation, directive, stmtCtx, mapOperands);
38703863
}
38713864

3872-
cp.processTODO<Fortran::parser::OmpClause::Depend>(currentLocation,
3873-
directive);
3865+
cp.processTODO<omp::clause::Depend>(currentLocation, directive);
38743866

38753867
return firOpBuilder.create<OpTy>(currentLocation, ifClauseOperand,
38763868
deviceOperand, nullptr, mlir::ValueRange(),
@@ -4053,16 +4045,11 @@ genTargetOp(Fortran::lower::AbstractConverter &converter,
40534045
cp.processNowait(nowaitAttr);
40544046
cp.processMap(currentLocation, directive, stmtCtx, mapOperands, &mapSymTypes,
40554047
&mapSymLocs, &mapSymbols);
4056-
cp.processTODO<Fortran::parser::OmpClause::Private,
4057-
Fortran::parser::OmpClause::Depend,
4058-
Fortran::parser::OmpClause::Firstprivate,
4059-
Fortran::parser::OmpClause::IsDevicePtr,
4060-
Fortran::parser::OmpClause::HasDeviceAddr,
4061-
Fortran::parser::OmpClause::Reduction,
4062-
Fortran::parser::OmpClause::InReduction,
4063-
Fortran::parser::OmpClause::Allocate,
4064-
Fortran::parser::OmpClause::UsesAllocators,
4065-
Fortran::parser::OmpClause::Defaultmap>(
4048+
cp.processTODO<omp::clause::Private, omp::clause::Depend,
4049+
omp::clause::Firstprivate, omp::clause::IsDevicePtr,
4050+
omp::clause::HasDeviceAddr, omp::clause::Reduction,
4051+
omp::clause::InReduction, omp::clause::Allocate,
4052+
omp::clause::UsesAllocators, omp::clause::Defaultmap>(
40664053
currentLocation, llvm::omp::Directive::OMPD_target);
40674054

40684055
// 5.8.1 Implicit Data-Mapping Attribute Rules
@@ -4165,8 +4152,8 @@ genTeamsOp(Fortran::lower::AbstractConverter &converter,
41654152
cp.processDefault();
41664153
cp.processNumTeams(stmtCtx, numTeamsClauseOperand);
41674154
cp.processThreadLimit(stmtCtx, threadLimitClauseOperand);
4168-
cp.processTODO<Fortran::parser::OmpClause::Reduction>(
4169-
currentLocation, llvm::omp::Directive::OMPD_teams);
4155+
cp.processTODO<omp::clause::Reduction>(currentLocation,
4156+
llvm::omp::Directive::OMPD_teams);
41704157

41714158
return genOpWithBody<mlir::omp::TeamsOp>(
41724159
OpWithBodyGenInfo(converter, semaCtx, currentLocation, eval)
@@ -4218,7 +4205,7 @@ static mlir::omp::DeclareTargetDeviceType getDeclareTargetInfo(
42184205
cp.processEnter(symbolAndClause);
42194206
cp.processLink(symbolAndClause);
42204207
cp.processDeviceType(deviceType);
4221-
cp.processTODO<Fortran::parser::OmpClause::Indirect>(
4208+
cp.processTODO<omp::clause::Indirect>(
42224209
converter.getCurrentLocation(),
42234210
llvm::omp::Directive::OMPD_declare_target);
42244211
}
@@ -4277,8 +4264,7 @@ genOmpSimpleStandalone(Fortran::lower::AbstractConverter &converter,
42774264
break;
42784265
case llvm::omp::Directive::OMPD_taskwait:
42794266
ClauseProcessor(converter, semaCtx, opClauseList)
4280-
.processTODO<Fortran::parser::OmpClause::Depend,
4281-
Fortran::parser::OmpClause::Nowait>(
4267+
.processTODO<omp::clause::Depend, omp::clause::Nowait>(
42824268
currentLocation, llvm::omp::Directive::OMPD_taskwait);
42834269
firOpBuilder.create<mlir::omp::TaskwaitOp>(currentLocation);
42844270
break;
@@ -4428,11 +4414,9 @@ createSimdLoop(Fortran::lower::AbstractConverter &converter,
44284414
cp.processIf(omp::clause::If::DirectiveNameModifier::Simd, ifClauseOperand);
44294415
cp.processSimdlen(simdlenClauseOperand);
44304416
cp.processSafelen(safelenClauseOperand);
4431-
cp.processTODO<Fortran::parser::OmpClause::Aligned,
4432-
Fortran::parser::OmpClause::Allocate,
4433-
Fortran::parser::OmpClause::Linear,
4434-
Fortran::parser::OmpClause::Nontemporal,
4435-
Fortran::parser::OmpClause::Order>(loc, ompDirective);
4417+
cp.processTODO<omp::clause::Aligned, omp::clause::Allocate,
4418+
omp::clause::Linear, omp::clause::Nontemporal,
4419+
omp::clause::Order>(loc, ompDirective);
44364420

44374421
convertLoopBounds(converter, loc, lowerBound, upperBound, step,
44384422
loopVarTypeSize);
@@ -4487,8 +4471,7 @@ static void createWsLoop(Fortran::lower::AbstractConverter &converter,
44874471
loopVarTypeSize);
44884472
cp.processScheduleChunk(stmtCtx, scheduleChunkClauseOperand);
44894473
cp.processReduction(loc, reductionVars, reductionDeclSymbols);
4490-
cp.processTODO<Fortran::parser::OmpClause::Linear,
4491-
Fortran::parser::OmpClause::Order>(loc, ompDirective);
4474+
cp.processTODO<omp::clause::Linear, omp::clause::Order>(loc, ompDirective);
44924475

44934476
convertLoopBounds(converter, loc, lowerBound, upperBound, step,
44944477
loopVarTypeSize);
@@ -4548,11 +4531,9 @@ static void createSimdWsLoop(
45484531
const Fortran::parser::OmpClauseList &beginClauseList,
45494532
const Fortran::parser::OmpClauseList *endClauseList, mlir::Location loc) {
45504533
ClauseProcessor cp(converter, semaCtx, beginClauseList);
4551-
cp.processTODO<
4552-
Fortran::parser::OmpClause::Aligned, Fortran::parser::OmpClause::Allocate,
4553-
Fortran::parser::OmpClause::Linear, Fortran::parser::OmpClause::Safelen,
4554-
Fortran::parser::OmpClause::Simdlen, Fortran::parser::OmpClause::Order>(
4555-
loc, ompDirective);
4534+
cp.processTODO<omp::clause::Aligned, omp::clause::Allocate,
4535+
omp::clause::Linear, omp::clause::Safelen,
4536+
omp::clause::Simdlen, omp::clause::Order>(loc, ompDirective);
45564537
// TODO: Add support for vectorization - add vectorization hints inside loop
45574538
// body.
45584539
// OpenMP standard does not specify the length of vector instructions.

0 commit comments

Comments
 (0)