Skip to content

Commit 2ab106c

Browse files
authored
[flang][OpenMP] Convert processTODO and remove unused objects (#81627)
Remove `ClauseIterator2` and `clauses2` from ClauseProcessor. [Clause representation 5/6]
1 parent 6d939a6 commit 2ab106c

File tree

2 files changed

+23
-44
lines changed

2 files changed

+23
-44
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.
@@ -156,7 +154,6 @@ class ClauseProcessor {
156154

157155
private:
158156
using ClauseIterator = List<Clause>::const_iterator;
159-
using ClauseIterator2 = std::list<ClauseTy>::const_iterator;
160157

161158
/// Utility to find a clause within a range in the clause list.
162159
template <typename T>
@@ -182,7 +179,6 @@ class ClauseProcessor {
182179

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

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

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

256250
template <typename T>

flang/lib/Lower/OpenMP/OpenMP.cpp

Lines changed: 18 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -734,9 +734,7 @@ genTaskOp(Fortran::lower::AbstractConverter &converter,
734734
cp.processMergeable(mergeableAttr);
735735
cp.processPriority(stmtCtx, priorityClauseOperand);
736736
cp.processDepend(dependTypeOperands, dependOperands);
737-
cp.processTODO<Fortran::parser::OmpClause::InReduction,
738-
Fortran::parser::OmpClause::Detach,
739-
Fortran::parser::OmpClause::Affinity>(
737+
cp.processTODO<clause::InReduction, clause::Detach, clause::Affinity>(
740738
currentLocation, llvm::omp::Directive::OMPD_task);
741739

742740
return genOpWithBody<mlir::omp::TaskOp>(
@@ -762,8 +760,8 @@ genTaskgroupOp(Fortran::lower::AbstractConverter &converter,
762760
llvm::SmallVector<mlir::Value> allocateOperands, allocatorOperands;
763761
ClauseProcessor cp(converter, semaCtx, clauseList);
764762
cp.processAllocate(allocatorOperands, allocateOperands);
765-
cp.processTODO<Fortran::parser::OmpClause::TaskReduction>(
766-
currentLocation, llvm::omp::Directive::OMPD_taskgroup);
763+
cp.processTODO<clause::TaskReduction>(currentLocation,
764+
llvm::omp::Directive::OMPD_taskgroup);
767765
return genOpWithBody<mlir::omp::TaskgroupOp>(
768766
OpWithBodyGenInfo(converter, semaCtx, currentLocation, eval)
769767
.setGenNested(genNested)
@@ -1102,16 +1100,11 @@ genTargetOp(Fortran::lower::AbstractConverter &converter,
11021100
cp.processMap(currentLocation, directive, stmtCtx, mapOperands, &mapSymTypes,
11031101
&mapSymLocs, &mapSymbols);
11041102

1105-
cp.processTODO<Fortran::parser::OmpClause::Private,
1106-
Fortran::parser::OmpClause::Firstprivate,
1107-
Fortran::parser::OmpClause::IsDevicePtr,
1108-
Fortran::parser::OmpClause::HasDeviceAddr,
1109-
Fortran::parser::OmpClause::Reduction,
1110-
Fortran::parser::OmpClause::InReduction,
1111-
Fortran::parser::OmpClause::Allocate,
1112-
Fortran::parser::OmpClause::UsesAllocators,
1113-
Fortran::parser::OmpClause::Defaultmap>(
1103+
cp.processTODO<clause::Private, clause::Firstprivate, clause::IsDevicePtr,
1104+
clause::HasDeviceAddr, clause::Reduction, clause::InReduction,
1105+
clause::Allocate, clause::UsesAllocators, clause::Defaultmap>(
11141106
currentLocation, llvm::omp::Directive::OMPD_target);
1107+
11151108
// 5.8.1 Implicit Data-Mapping Attribute Rules
11161109
// The following code follows the implicit data-mapping rules to map all the
11171110
// symbols used inside the region that have not been explicitly mapped using
@@ -1230,8 +1223,8 @@ genTeamsOp(Fortran::lower::AbstractConverter &converter,
12301223
cp.processDefault();
12311224
cp.processNumTeams(stmtCtx, numTeamsClauseOperand);
12321225
cp.processThreadLimit(stmtCtx, threadLimitClauseOperand);
1233-
cp.processTODO<Fortran::parser::OmpClause::Reduction>(
1234-
currentLocation, llvm::omp::Directive::OMPD_teams);
1226+
cp.processTODO<clause::Reduction>(currentLocation,
1227+
llvm::omp::Directive::OMPD_teams);
12351228

12361229
return genOpWithBody<mlir::omp::TeamsOp>(
12371230
OpWithBodyGenInfo(converter, semaCtx, currentLocation, eval)
@@ -1283,9 +1276,8 @@ static mlir::omp::DeclareTargetDeviceType getDeclareTargetInfo(
12831276
cp.processEnter(symbolAndClause);
12841277
cp.processLink(symbolAndClause);
12851278
cp.processDeviceType(deviceType);
1286-
cp.processTODO<Fortran::parser::OmpClause::Indirect>(
1287-
converter.getCurrentLocation(),
1288-
llvm::omp::Directive::OMPD_declare_target);
1279+
cp.processTODO<clause::Indirect>(converter.getCurrentLocation(),
1280+
llvm::omp::Directive::OMPD_declare_target);
12891281
}
12901282

12911283
return deviceType;
@@ -1367,8 +1359,7 @@ genOmpSimpleStandalone(Fortran::lower::AbstractConverter &converter,
13671359
break;
13681360
case llvm::omp::Directive::OMPD_taskwait:
13691361
ClauseProcessor(converter, semaCtx, opClauseList)
1370-
.processTODO<Fortran::parser::OmpClause::Depend,
1371-
Fortran::parser::OmpClause::Nowait>(
1362+
.processTODO<clause::Depend, clause::Nowait>(
13721363
currentLocation, llvm::omp::Directive::OMPD_taskwait);
13731364
firOpBuilder.create<mlir::omp::TaskwaitOp>(currentLocation);
13741365
break;
@@ -1550,11 +1541,8 @@ createSimdLoop(Fortran::lower::AbstractConverter &converter,
15501541
cp.processIf(clause::If::DirectiveNameModifier::Simd, ifClauseOperand);
15511542
cp.processSimdlen(simdlenClauseOperand);
15521543
cp.processSafelen(safelenClauseOperand);
1553-
cp.processTODO<Fortran::parser::OmpClause::Aligned,
1554-
Fortran::parser::OmpClause::Allocate,
1555-
Fortran::parser::OmpClause::Linear,
1556-
Fortran::parser::OmpClause::Nontemporal,
1557-
Fortran::parser::OmpClause::Order>(loc, ompDirective);
1544+
cp.processTODO<clause::Aligned, clause::Allocate, clause::Linear,
1545+
clause::Nontemporal, clause::Order>(loc, ompDirective);
15581546

15591547
mlir::TypeRange resultType;
15601548
auto simdLoopOp = firOpBuilder.create<mlir::omp::SimdLoopOp>(
@@ -1607,8 +1595,7 @@ static void createWsloop(Fortran::lower::AbstractConverter &converter,
16071595
cp.processScheduleChunk(stmtCtx, scheduleChunkClauseOperand);
16081596
cp.processReduction(loc, reductionVars, reductionTypes, reductionDeclSymbols,
16091597
&reductionSymbols);
1610-
cp.processTODO<Fortran::parser::OmpClause::Linear,
1611-
Fortran::parser::OmpClause::Order>(loc, ompDirective);
1598+
cp.processTODO<clause::Linear, clause::Order>(loc, ompDirective);
16121599

16131600
if (ReductionProcessor::doReductionByRef(reductionVars))
16141601
byrefOperand = firOpBuilder.getUnitAttr();
@@ -1670,11 +1657,9 @@ static void createSimdWsloop(
16701657
const Fortran::parser::OmpClauseList &beginClauseList,
16711658
const Fortran::parser::OmpClauseList *endClauseList, mlir::Location loc) {
16721659
ClauseProcessor cp(converter, semaCtx, beginClauseList);
1673-
cp.processTODO<
1674-
Fortran::parser::OmpClause::Aligned, Fortran::parser::OmpClause::Allocate,
1675-
Fortran::parser::OmpClause::Linear, Fortran::parser::OmpClause::Safelen,
1676-
Fortran::parser::OmpClause::Simdlen, Fortran::parser::OmpClause::Order>(
1677-
loc, ompDirective);
1660+
cp.processTODO<clause::Aligned, clause::Allocate, clause::Linear,
1661+
clause::Safelen, clause::Simdlen, clause::Order>(loc,
1662+
ompDirective);
16781663
// TODO: Add support for vectorization - add vectorization hints inside loop
16791664
// body.
16801665
// OpenMP standard does not specify the length of vector instructions.

0 commit comments

Comments
 (0)