Skip to content

Commit 7e785c4

Browse files
committed
[flang][OpenMP] Convert processTODO and remove unused objects
Remove `ClauseIterator2` and `clauses2` from ClauseProcessor.
1 parent bf64cd3 commit 7e785c4

File tree

2 files changed

+25
-45
lines changed

2 files changed

+25
-45
lines changed

flang/lib/Lower/OpenMP/ClauseProcessor.h

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,11 @@ namespace omp {
4646
/// methods that relate to clauses that can impact the lowering of that
4747
/// construct.
4848
class ClauseProcessor {
49-
using ClauseTy = Fortran::parser::OmpClause;
50-
5149
public:
5250
ClauseProcessor(Fortran::lower::AbstractConverter &converter,
5351
Fortran::semantics::SemanticsContext &semaCtx,
5452
const Fortran::parser::OmpClauseList &clauses)
55-
: converter(converter), semaCtx(semaCtx), clauses2(clauses),
53+
: converter(converter), semaCtx(semaCtx),
5654
clauses(makeList(clauses, semaCtx)) {}
5755

5856
// 'Unique' clauses: They can appear at most once in the clause list.
@@ -157,7 +155,6 @@ class ClauseProcessor {
157155

158156
private:
159157
using ClauseIterator = List<Clause>::const_iterator;
160-
using ClauseIterator2 = std::list<ClauseTy>::const_iterator;
161158

162159
/// Utility to find a clause within a range in the clause list.
163160
template <typename T>
@@ -183,7 +180,6 @@ class ClauseProcessor {
183180

184181
Fortran::lower::AbstractConverter &converter;
185182
Fortran::semantics::SemanticsContext &semaCtx;
186-
const Fortran::parser::OmpClauseList &clauses2;
187183
List<Clause> clauses;
188184
};
189185

@@ -239,19 +235,17 @@ bool ClauseProcessor::processMotionClauses(
239235
template <typename... Ts>
240236
void ClauseProcessor::processTODO(mlir::Location currentLocation,
241237
llvm::omp::Directive directive) const {
242-
auto checkUnhandledClause = [&](const auto *x) {
238+
auto checkUnhandledClause = [&](llvm::omp::Clause id, const auto *x) {
243239
if (!x)
244240
return;
245241
TODO(currentLocation,
246-
"Unhandled clause " +
247-
llvm::StringRef(Fortran::parser::ParseTreeDumper::GetNodeName(*x))
248-
.upper() +
242+
"Unhandled clause " + llvm::omp::getOpenMPClauseName(id).upper() +
249243
" in " + llvm::omp::getOpenMPDirectiveName(directive).upper() +
250244
" construct");
251245
};
252246

253-
for (ClauseIterator2 it = clauses2.v.begin(); it != clauses2.v.end(); ++it)
254-
(checkUnhandledClause(std::get_if<Ts>(&it->u)), ...);
247+
for (ClauseIterator it = clauses.begin(); it != clauses.end(); ++it)
248+
(checkUnhandledClause(it->id, std::get_if<Ts>(&it->u)), ...);
255249
}
256250

257251
template <typename T>

flang/lib/Lower/OpenMP/OpenMP.cpp

Lines changed: 20 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -683,9 +683,7 @@ genTaskOp(Fortran::lower::AbstractConverter &converter,
683683
cp.processMergeable(mergeableAttr);
684684
cp.processPriority(stmtCtx, priorityClauseOperand);
685685
cp.processDepend(dependTypeOperands, dependOperands);
686-
cp.processTODO<Fortran::parser::OmpClause::InReduction,
687-
Fortran::parser::OmpClause::Detach,
688-
Fortran::parser::OmpClause::Affinity>(
686+
cp.processTODO<clause::InReduction, clause::Detach, clause::Affinity>(
689687
currentLocation, llvm::omp::Directive::OMPD_task);
690688

691689
return genOpWithBody<mlir::omp::TaskOp>(
@@ -711,8 +709,8 @@ genTaskGroupOp(Fortran::lower::AbstractConverter &converter,
711709
llvm::SmallVector<mlir::Value> allocateOperands, allocatorOperands;
712710
ClauseProcessor cp(converter, semaCtx, clauseList);
713711
cp.processAllocate(allocatorOperands, allocateOperands);
714-
cp.processTODO<Fortran::parser::OmpClause::TaskReduction>(
715-
currentLocation, llvm::omp::Directive::OMPD_taskgroup);
712+
cp.processTODO<clause::TaskReduction>(currentLocation,
713+
llvm::omp::Directive::OMPD_taskgroup);
716714
return genOpWithBody<mlir::omp::TaskGroupOp>(
717715
OpWithBodyGenInfo(converter, semaCtx, currentLocation, eval)
718716
.setGenNested(genNested)
@@ -983,16 +981,12 @@ genTargetOp(Fortran::lower::AbstractConverter &converter,
983981
cp.processMap(currentLocation, directive, stmtCtx, mapOperands, &mapSymTypes,
984982
&mapSymLocs, &mapSymbols);
985983

986-
cp.processTODO<Fortran::parser::OmpClause::Private,
987-
Fortran::parser::OmpClause::Firstprivate,
988-
Fortran::parser::OmpClause::IsDevicePtr,
989-
Fortran::parser::OmpClause::HasDeviceAddr,
990-
Fortran::parser::OmpClause::Reduction,
991-
Fortran::parser::OmpClause::InReduction,
992-
Fortran::parser::OmpClause::Allocate,
993-
Fortran::parser::OmpClause::UsesAllocators,
994-
Fortran::parser::OmpClause::Defaultmap>(
995-
currentLocation, llvm::omp::Directive::OMPD_target);
984+
cp.processTODO<clause::Private, clause::Firstprivate, clause::IsDevicePtr,
985+
clause::HasDeviceAddr, clause::Reduction, clause::InReduction,
986+
clause::Allocate, clause::UsesAllocators,
987+
clause::Defaultmap>(currentLocation,
988+
llvm::omp::Directive::OMPD_target);
989+
996990
// 5.8.1 Implicit Data-Mapping Attribute Rules
997991
// The following code follows the implicit data-mapping rules to map all the
998992
// symbols used inside the region that have not been explicitly mapped using
@@ -1097,8 +1091,8 @@ genTeamsOp(Fortran::lower::AbstractConverter &converter,
10971091
cp.processDefault();
10981092
cp.processNumTeams(stmtCtx, numTeamsClauseOperand);
10991093
cp.processThreadLimit(stmtCtx, threadLimitClauseOperand);
1100-
cp.processTODO<Fortran::parser::OmpClause::Reduction>(
1101-
currentLocation, llvm::omp::Directive::OMPD_teams);
1094+
cp.processTODO<clause::Reduction>(currentLocation,
1095+
llvm::omp::Directive::OMPD_teams);
11021096

11031097
return genOpWithBody<mlir::omp::TeamsOp>(
11041098
OpWithBodyGenInfo(converter, semaCtx, currentLocation, eval)
@@ -1150,9 +1144,8 @@ static mlir::omp::DeclareTargetDeviceType getDeclareTargetInfo(
11501144
cp.processEnter(symbolAndClause);
11511145
cp.processLink(symbolAndClause);
11521146
cp.processDeviceType(deviceType);
1153-
cp.processTODO<Fortran::parser::OmpClause::Indirect>(
1154-
converter.getCurrentLocation(),
1155-
llvm::omp::Directive::OMPD_declare_target);
1147+
cp.processTODO<clause::Indirect>(converter.getCurrentLocation(),
1148+
llvm::omp::Directive::OMPD_declare_target);
11561149
}
11571150

11581151
return deviceType;
@@ -1209,8 +1202,7 @@ genOmpSimpleStandalone(Fortran::lower::AbstractConverter &converter,
12091202
break;
12101203
case llvm::omp::Directive::OMPD_taskwait:
12111204
ClauseProcessor(converter, semaCtx, opClauseList)
1212-
.processTODO<Fortran::parser::OmpClause::Depend,
1213-
Fortran::parser::OmpClause::Nowait>(
1205+
.processTODO<clause::Depend, clause::Nowait>(
12141206
currentLocation, llvm::omp::Directive::OMPD_taskwait);
12151207
firOpBuilder.create<mlir::omp::TaskwaitOp>(currentLocation);
12161208
break;
@@ -1412,11 +1404,8 @@ createSimdLoop(Fortran::lower::AbstractConverter &converter,
14121404
cp.processIf(clause::If::DirectiveNameModifier::Simd, ifClauseOperand);
14131405
cp.processSimdlen(simdlenClauseOperand);
14141406
cp.processSafelen(safelenClauseOperand);
1415-
cp.processTODO<Fortran::parser::OmpClause::Aligned,
1416-
Fortran::parser::OmpClause::Allocate,
1417-
Fortran::parser::OmpClause::Linear,
1418-
Fortran::parser::OmpClause::Nontemporal,
1419-
Fortran::parser::OmpClause::Order>(loc, ompDirective);
1407+
cp.processTODO<clause::Aligned, clause::Allocate, clause::Linear,
1408+
clause::Nontemporal, clause::Order>(loc, ompDirective);
14201409

14211410
convertLoopBounds(converter, loc, lowerBound, upperBound, step,
14221411
loopVarTypeSize);
@@ -1473,8 +1462,7 @@ static void createWsLoop(Fortran::lower::AbstractConverter &converter,
14731462
cp.processScheduleChunk(stmtCtx, scheduleChunkClauseOperand);
14741463
cp.processReduction(loc, reductionVars, reductionDeclSymbols,
14751464
&reductionSymbols);
1476-
cp.processTODO<Fortran::parser::OmpClause::Linear,
1477-
Fortran::parser::OmpClause::Order>(loc, ompDirective);
1465+
cp.processTODO<clause::Linear, clause::Order>(loc, ompDirective);
14781466

14791467
convertLoopBounds(converter, loc, lowerBound, upperBound, step,
14801468
loopVarTypeSize);
@@ -1541,11 +1529,9 @@ static void createSimdWsLoop(
15411529
const Fortran::parser::OmpClauseList &beginClauseList,
15421530
const Fortran::parser::OmpClauseList *endClauseList, mlir::Location loc) {
15431531
ClauseProcessor cp(converter, semaCtx, beginClauseList);
1544-
cp.processTODO<
1545-
Fortran::parser::OmpClause::Aligned, Fortran::parser::OmpClause::Allocate,
1546-
Fortran::parser::OmpClause::Linear, Fortran::parser::OmpClause::Safelen,
1547-
Fortran::parser::OmpClause::Simdlen, Fortran::parser::OmpClause::Order>(
1548-
loc, ompDirective);
1532+
cp.processTODO<clause::Aligned, clause::Allocate, clause::Linear,
1533+
clause::Safelen, clause::Simdlen, clause::Order>(loc,
1534+
ompDirective);
15491535
// TODO: Add support for vectorization - add vectorization hints inside loop
15501536
// body.
15511537
// OpenMP standard does not specify the length of vector instructions.

0 commit comments

Comments
 (0)