From 6bd0a4451ccd4a5cbab1f735052edbcafcb856ea Mon Sep 17 00:00:00 2001 From: Valentin Clement Date: Tue, 19 Jan 2021 10:28:09 -0500 Subject: [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 --- flang/lib/Lower/OpenMP.cpp | 5 +++-- flang/lib/Parser/openmp-parsers.cpp | 26 ++++++++++++++------------ flang/lib/Parser/unparse.cpp | 29 +++++++---------------------- flang/lib/Semantics/check-omp-structure.cpp | 6 +++--- 4 files changed, 27 insertions(+), 39 deletions(-) (limited to 'flang') 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(beginBlockDirective.t); for (const auto &clause : parallelOpClauseList.v) { if (const auto &ifClause = - std::get_if(&clause.u)) { - auto &expr = std::get(ifClause->t); + std::get_if(&clause.u)) { + auto &expr = + std::get(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(construct()) || "ACQ_REL" >> construct(construct()) || - "ALIGNED" >> - construct(parenthesized(Parser{})) || + "ALIGNED" >> construct(construct( + parenthesized(Parser{}))) || "ALLOCATE" >> construct(construct( parenthesized(Parser{}))) || "ALLOCATOR" >> construct(construct( @@ -169,10 +169,10 @@ TYPE_PARSER( (parenthesized(Parser{})))) || "DEFAULT"_id >> construct(construct( parenthesized(Parser{}))) || - "DEFAULTMAP" >> - construct(parenthesized(Parser{})) || - "DEPEND" >> - construct(parenthesized(Parser{})) || + "DEFAULTMAP" >> construct(construct( + parenthesized(Parser{}))) || + "DEPEND" >> construct(construct( + parenthesized(Parser{}))) || "DEVICE" >> construct(construct( parenthesized(scalarIntExpr))) || "DIST_SCHEDULE" >> @@ -188,17 +188,19 @@ TYPE_PARSER( parenthesized(scalarIntExpr))) || "HINT" >> construct( construct(parenthesized(constantExpr))) || - "IF" >> construct(parenthesized(Parser{})) || + "IF" >> construct(construct( + parenthesized(Parser{}))) || "INBRANCH" >> construct(construct()) || "IS_DEVICE_PTR" >> construct(construct( parenthesized(nonemptyList(name)))) || "LASTPRIVATE" >> construct(construct( parenthesized(Parser{}))) || - "LINEAR" >> - construct(parenthesized(Parser{})) || + "LINEAR" >> construct(construct( + parenthesized(Parser{}))) || "LINK" >> construct(construct( parenthesized(Parser{}))) || - "MAP" >> construct(parenthesized(Parser{})) || + "MAP" >> construct(construct( + parenthesized(Parser{}))) || "MERGEABLE" >> construct(construct()) || "NOGROUP" >> construct(construct()) || "NOTINBRANCH" >> @@ -227,8 +229,8 @@ TYPE_PARSER( "RELEASE" >> construct(construct()) || "SAFELEN" >> construct(construct( parenthesized(scalarIntConstantExpr))) || - "SCHEDULE" >> - construct(parenthesized(Parser{})) || + "SCHEDULE" >> construct(construct( + parenthesized(Parser{}))) || "SEQ_CST" >> construct(construct()) || "SHARED" >> construct(construct( parenthesized(Parser{}))) || 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>(x.t), ":"); Walk(std::get(x.t)); - Put(") "); } void Unparse(const OmpScheduleModifier &x) { Walk(std::get(x.t)); Walk(",", std::get>(x.t)); } void Unparse(const OmpScheduleClause &x) { - Word("SCHEDULE("); Walk(std::get>(x.t), ":"); Walk(std::get(x.t)); Walk(",", std::get>(x.t)); - Put(")"); } void Unparse(const OmpAlignedClause &x) { - Word("ALIGNED("), Walk(std::get>(x.t), ","); + Walk(std::get>(x.t), ","); Walk(std::get>(x.t)); - Put(") "); } void Unparse(const OmpIfClause &x) { - Word("IF("), - Walk(std::get>(x.t), - ":"); + Walk(std::get>(x.t), ":"); Walk(std::get(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(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(x.t)); Walk(":", std::get>(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(clause->u)}; - if (ScheduleModifierHasType(schedClause, + const auto &schedClause{std::get(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 " -- cgit v1.1