diff options
author | Valentin Clement <clementval@gmail.com> | 2021-01-19 10:28:09 -0500 |
---|---|---|
committer | clementval <clementval@gmail.com> | 2021-01-19 10:28:46 -0500 |
commit | 6bd0a4451ccd4a5cbab1f735052edbcafcb856ea (patch) | |
tree | 529fd023f5c0fac6cab7b536a99050442dbcdac6 /flang | |
parent | 909d6c86eae32ef350ac35ba8564ed728544ac63 (diff) | |
download | llvm-6bd0a4451ccd4a5cbab1f735052edbcafcb856ea.zip llvm-6bd0a4451ccd4a5cbab1f735052edbcafcb856ea.tar.gz llvm-6bd0a4451ccd4a5cbab1f735052edbcafcb856ea.tar.bz2 |
[flang][directive] Get rid of flangClassValue in TableGen
The TableGen emitter for directives has two slots for flangClass information and this was mainly
to be able to keep up with the legacy openmp parser at the time. Now that all clauses are encapsulated in
AccClause or OmpClause, these two strings are not necessary anymore and were the the source of couple
of problem while working with the generic structure checker for OpenMP.
This patch remove the flangClassValue string from DirectiveBase.td and use the string flangClass as the
placeholder for the encapsulated class.
Reviewed By: sameeranjoshi
Differential Revision: https://reviews.llvm.org/D94821
Diffstat (limited to 'flang')
-rw-r--r-- | flang/lib/Lower/OpenMP.cpp | 5 | ||||
-rw-r--r-- | flang/lib/Parser/openmp-parsers.cpp | 26 | ||||
-rw-r--r-- | flang/lib/Parser/unparse.cpp | 29 | ||||
-rw-r--r-- | flang/lib/Semantics/check-omp-structure.cpp | 6 |
4 files changed, 27 insertions, 39 deletions
diff --git a/flang/lib/Lower/OpenMP.cpp b/flang/lib/Lower/OpenMP.cpp index f765723..c16b1be 100644 --- a/flang/lib/Lower/OpenMP.cpp +++ b/flang/lib/Lower/OpenMP.cpp @@ -148,8 +148,9 @@ genOMP(Fortran::lower::AbstractConverter &converter, std::get<Fortran::parser::OmpClauseList>(beginBlockDirective.t); for (const auto &clause : parallelOpClauseList.v) { if (const auto &ifClause = - std::get_if<Fortran::parser::OmpIfClause>(&clause.u)) { - auto &expr = std::get<Fortran::parser::ScalarLogicalExpr>(ifClause->t); + std::get_if<Fortran::parser::OmpClause::If>(&clause.u)) { + auto &expr = + std::get<Fortran::parser::ScalarLogicalExpr>(ifClause->v.t); ifClauseOperand = fir::getBase( converter.genExprValue(*Fortran::semantics::GetExpr(expr))); } else if (const auto &numThreadsClause = diff --git a/flang/lib/Parser/openmp-parsers.cpp b/flang/lib/Parser/openmp-parsers.cpp index 4588a95..93f70e1 100644 --- a/flang/lib/Parser/openmp-parsers.cpp +++ b/flang/lib/Parser/openmp-parsers.cpp @@ -155,8 +155,8 @@ TYPE_PARSER( TYPE_PARSER( "ACQUIRE" >> construct<OmpClause>(construct<OmpClause::Acquire>()) || "ACQ_REL" >> construct<OmpClause>(construct<OmpClause::AcqRel>()) || - "ALIGNED" >> - construct<OmpClause>(parenthesized(Parser<OmpAlignedClause>{})) || + "ALIGNED" >> construct<OmpClause>(construct<OmpClause::Aligned>( + parenthesized(Parser<OmpAlignedClause>{}))) || "ALLOCATE" >> construct<OmpClause>(construct<OmpClause::Allocate>( parenthesized(Parser<OmpAllocateClause>{}))) || "ALLOCATOR" >> construct<OmpClause>(construct<OmpClause::Allocator>( @@ -169,10 +169,10 @@ TYPE_PARSER( (parenthesized(Parser<OmpObjectList>{})))) || "DEFAULT"_id >> construct<OmpClause>(construct<OmpClause::Default>( parenthesized(Parser<OmpDefaultClause>{}))) || - "DEFAULTMAP" >> - construct<OmpClause>(parenthesized(Parser<OmpDefaultmapClause>{})) || - "DEPEND" >> - construct<OmpClause>(parenthesized(Parser<OmpDependClause>{})) || + "DEFAULTMAP" >> construct<OmpClause>(construct<OmpClause::Defaultmap>( + parenthesized(Parser<OmpDefaultmapClause>{}))) || + "DEPEND" >> construct<OmpClause>(construct<OmpClause::Depend>( + parenthesized(Parser<OmpDependClause>{}))) || "DEVICE" >> construct<OmpClause>(construct<OmpClause::Device>( parenthesized(scalarIntExpr))) || "DIST_SCHEDULE" >> @@ -188,17 +188,19 @@ TYPE_PARSER( parenthesized(scalarIntExpr))) || "HINT" >> construct<OmpClause>( construct<OmpClause::Hint>(parenthesized(constantExpr))) || - "IF" >> construct<OmpClause>(parenthesized(Parser<OmpIfClause>{})) || + "IF" >> construct<OmpClause>(construct<OmpClause::If>( + parenthesized(Parser<OmpIfClause>{}))) || "INBRANCH" >> construct<OmpClause>(construct<OmpClause::Inbranch>()) || "IS_DEVICE_PTR" >> construct<OmpClause>(construct<OmpClause::IsDevicePtr>( parenthesized(nonemptyList(name)))) || "LASTPRIVATE" >> construct<OmpClause>(construct<OmpClause::Lastprivate>( parenthesized(Parser<OmpObjectList>{}))) || - "LINEAR" >> - construct<OmpClause>(parenthesized(Parser<OmpLinearClause>{})) || + "LINEAR" >> construct<OmpClause>(construct<OmpClause::Linear>( + parenthesized(Parser<OmpLinearClause>{}))) || "LINK" >> construct<OmpClause>(construct<OmpClause::Link>( parenthesized(Parser<OmpObjectList>{}))) || - "MAP" >> construct<OmpClause>(parenthesized(Parser<OmpMapClause>{})) || + "MAP" >> construct<OmpClause>(construct<OmpClause::Map>( + parenthesized(Parser<OmpMapClause>{}))) || "MERGEABLE" >> construct<OmpClause>(construct<OmpClause::Mergeable>()) || "NOGROUP" >> construct<OmpClause>(construct<OmpClause::Nogroup>()) || "NOTINBRANCH" >> @@ -227,8 +229,8 @@ TYPE_PARSER( "RELEASE" >> construct<OmpClause>(construct<OmpClause::Release>()) || "SAFELEN" >> construct<OmpClause>(construct<OmpClause::Safelen>( parenthesized(scalarIntConstantExpr))) || - "SCHEDULE" >> - construct<OmpClause>(parenthesized(Parser<OmpScheduleClause>{})) || + "SCHEDULE" >> construct<OmpClause>(construct<OmpClause::Schedule>( + parenthesized(Parser<OmpScheduleClause>{}))) || "SEQ_CST" >> construct<OmpClause>(construct<OmpClause::SeqCst>()) || "SHARED" >> construct<OmpClause>(construct<OmpClause::Shared>( parenthesized(Parser<OmpObjectList>{}))) || diff --git a/flang/lib/Parser/unparse.cpp b/flang/lib/Parser/unparse.cpp index 5bf8db8..8adcc32 100644 --- a/flang/lib/Parser/unparse.cpp +++ b/flang/lib/Parser/unparse.cpp @@ -1974,43 +1974,33 @@ public: } void Unparse(const OmpMapType::Always &) { Word("ALWAYS,"); } void Unparse(const OmpMapClause &x) { - Word("MAP("); Walk(std::get<std::optional<OmpMapType>>(x.t), ":"); Walk(std::get<OmpObjectList>(x.t)); - Put(") "); } void Unparse(const OmpScheduleModifier &x) { Walk(std::get<OmpScheduleModifier::Modifier1>(x.t)); Walk(",", std::get<std::optional<OmpScheduleModifier::Modifier2>>(x.t)); } void Unparse(const OmpScheduleClause &x) { - Word("SCHEDULE("); Walk(std::get<std::optional<OmpScheduleModifier>>(x.t), ":"); Walk(std::get<OmpScheduleClause::ScheduleType>(x.t)); Walk(",", std::get<std::optional<ScalarIntExpr>>(x.t)); - Put(")"); } void Unparse(const OmpAlignedClause &x) { - Word("ALIGNED("), Walk(std::get<std::list<Name>>(x.t), ","); + Walk(std::get<std::list<Name>>(x.t), ","); Walk(std::get<std::optional<ScalarIntConstantExpr>>(x.t)); - Put(") "); } void Unparse(const OmpIfClause &x) { - Word("IF("), - Walk(std::get<std::optional<OmpIfClause::DirectiveNameModifier>>(x.t), - ":"); + Walk(std::get<std::optional<OmpIfClause::DirectiveNameModifier>>(x.t), ":"); Walk(std::get<ScalarLogicalExpr>(x.t)); - Put(") "); } void Unparse(const OmpLinearClause::WithoutModifier &x) { - Word("LINEAR("), Walk(x.names, ", "); + Walk(x.names, ", "); Walk(":", x.step); - Put(")"); } void Unparse(const OmpLinearClause::WithModifier &x) { - Word("LINEAR("), Walk(x.modifier), Put("("), Walk(x.names, ","), Put(")"); + Walk(x.modifier), Put("("), Walk(x.names, ","), Put(")"); Walk(":", x.step); - Put(")"); } void Unparse(const OmpReductionClause &x) { Walk(std::get<OmpReductionOperator>(x.t)); @@ -2040,28 +2030,23 @@ public: bool Pre(const OmpDependClause &x) { return std::visit(common::visitors{ [&](const OmpDependClause::Source &) { - Word("DEPEND(SOURCE)"); + Word("SOURCE"); return false; }, [&](const OmpDependClause::Sink &y) { - Word("DEPEND(SINK:"); + Word("SINK:"); Walk(y.v); Put(")"); return false; }, - [&](const OmpDependClause::InOut &) { - Word("DEPEND"); - return true; - }, + [&](const OmpDependClause::InOut &) { return true; }, }, x.u); } void Unparse(const OmpDefaultmapClause &x) { - Word("DEFAULTMAP("); Walk(std::get<OmpDefaultmapClause::ImplicitBehavior>(x.t)); Walk(":", std::get<std::optional<OmpDefaultmapClause::VariableCategory>>(x.t)); - Word(")"); } #define GEN_FLANG_CLAUSE_UNPARSE #include "llvm/Frontend/OpenMP/OMP.inc" diff --git a/flang/lib/Semantics/check-omp-structure.cpp b/flang/lib/Semantics/check-omp-structure.cpp index a906449..16f851a 100644 --- a/flang/lib/Semantics/check-omp-structure.cpp +++ b/flang/lib/Semantics/check-omp-structure.cpp @@ -389,15 +389,15 @@ void OmpStructureChecker::Leave(const parser::OmpClauseList &) { if (llvm::omp::doSet.test(GetContext().directive)) { if (auto *clause{FindClause(llvm::omp::Clause::OMPC_schedule)}) { // only one schedule clause is allowed - const auto &schedClause{std::get<parser::OmpScheduleClause>(clause->u)}; - if (ScheduleModifierHasType(schedClause, + const auto &schedClause{std::get<parser::OmpClause::Schedule>(clause->u)}; + if (ScheduleModifierHasType(schedClause.v, parser::OmpScheduleModifierType::ModType::Nonmonotonic)) { if (FindClause(llvm::omp::Clause::OMPC_ordered)) { context_.Say(clause->source, "The NONMONOTONIC modifier cannot be specified " "if an ORDERED clause is specified"_err_en_US); } - if (ScheduleModifierHasType(schedClause, + if (ScheduleModifierHasType(schedClause.v, parser::OmpScheduleModifierType::ModType::Monotonic)) { context_.Say(clause->source, "The MONOTONIC and NONMONOTONIC modifiers " |