Author: sameeran joshi Date: 2020-12-22T13:17:44+05:30 New Revision: f72c384b5ba943c92fadcbe77f9d7661728905ab
URL: https://github.com/llvm/llvm-project/commit/f72c384b5ba943c92fadcbe77f9d7661728905ab DIFF: https://github.com/llvm/llvm-project/commit/f72c384b5ba943c92fadcbe77f9d7661728905ab.diff LOG: [Flang][openmp][2/5] Make Default clause part of OmpClause After discussion in `D93482` we found that the some of the clauses were not following the common OmpClause convention. The benefits of using OmpClause: - Functionalities from structure checker are mostly aligned to work with `llvm::omp::Clause`. - The unparsing as well can take advantage. - Homogeneity with OpenACC and rest of the clauses in OpenMP. - Could even generate the parser with TableGen, when there is homogeneity. - It becomes confusing when to use `flangClass` and `flangClassValue` inside TableGen, if incase we generate parser using TableGen we could have only a single `let expression`. This patch makes `OmpDefaultClause` clause part of `OmpClause`. The unparse function is dropped as the unparsing is done by `WALK_NESTED_ENUM` for `OmpDefaultClause`. Reviewed By: clementval, kiranktp Differential Revision: https://reviews.llvm.org/D93641 Added: Modified: flang/lib/Lower/OpenMP.cpp flang/lib/Parser/openmp-parsers.cpp flang/lib/Parser/unparse.cpp flang/lib/Semantics/check-omp-structure.cpp flang/lib/Semantics/check-omp-structure.h llvm/include/llvm/Frontend/OpenMP/OMP.td Removed: ################################################################################ diff --git a/flang/lib/Lower/OpenMP.cpp b/flang/lib/Lower/OpenMP.cpp index 97946caa68a0..f73dd09fbe68 100644 --- a/flang/lib/Lower/OpenMP.cpp +++ b/flang/lib/Lower/OpenMP.cpp @@ -191,8 +191,9 @@ genOMP(Fortran::lower::AbstractConverter &converter, // Handle attribute based clauses. for (const auto &clause : parallelOpClauseList.v) { if (const auto &defaultClause = - std::get_if<Fortran::parser::OmpDefaultClause>(&clause.u)) { - switch (defaultClause->v) { + std::get_if<Fortran::parser::OmpClause::Default>(&clause.u)) { + const auto &ompDefaultClause{defaultClause->v}; + switch (ompDefaultClause.v) { case Fortran::parser::OmpDefaultClause::Type::Private: parallelOp.default_valAttr(firOpBuilder.getStringAttr( omp::stringifyClauseDefault(omp::ClauseDefault::defprivate))); diff --git a/flang/lib/Parser/openmp-parsers.cpp b/flang/lib/Parser/openmp-parsers.cpp index ff8ba774a6ce..e982dd19e498 100644 --- a/flang/lib/Parser/openmp-parsers.cpp +++ b/flang/lib/Parser/openmp-parsers.cpp @@ -167,8 +167,8 @@ TYPE_PARSER( parenthesized(Parser<OmpObjectList>{}))) || "COPYPRIVATE" >> construct<OmpClause>(construct<OmpClause::Copyprivate>( (parenthesized(Parser<OmpObjectList>{})))) || - "DEFAULT"_id >> - construct<OmpClause>(parenthesized(Parser<OmpDefaultClause>{})) || + "DEFAULT"_id >> construct<OmpClause>(construct<OmpClause::Default>( + parenthesized(Parser<OmpDefaultClause>{}))) || "DEFAULTMAP" >> construct<OmpClause>(parenthesized(Parser<OmpDefaultmapClause>{})) || "DEPEND" >> diff --git a/flang/lib/Parser/unparse.cpp b/flang/lib/Parser/unparse.cpp index ed17bac92965..a4b0c64011fc 100644 --- a/flang/lib/Parser/unparse.cpp +++ b/flang/lib/Parser/unparse.cpp @@ -2058,11 +2058,6 @@ class UnparseVisitor { }, x.u); } - bool Pre(const OmpDefaultClause &) { - Word("DEFAULT("); - return true; - } - void Post(const OmpDefaultClause &) { Put(")"); } bool Pre(const OmpProcBindClause &) { Word("PROC_BIND("); return true; diff --git a/flang/lib/Semantics/check-omp-structure.cpp b/flang/lib/Semantics/check-omp-structure.cpp index 58db75459318..6ed7106bb9f4 100644 --- a/flang/lib/Semantics/check-omp-structure.cpp +++ b/flang/lib/Semantics/check-omp-structure.cpp @@ -406,6 +406,7 @@ void OmpStructureChecker::Enter(const parser::OmpClause &x) { CHECK_SIMPLE_CLAUSE(Allocate, OMPC_allocate) CHECK_SIMPLE_CLAUSE(Copyin, OMPC_copyin) CHECK_SIMPLE_CLAUSE(Copyprivate, OMPC_copyprivate) +CHECK_SIMPLE_CLAUSE(Default, OMPC_default) CHECK_SIMPLE_CLAUSE(Device, OMPC_device) CHECK_SIMPLE_CLAUSE(Final, OMPC_final) CHECK_SIMPLE_CLAUSE(Firstprivate, OMPC_firstprivate) @@ -490,7 +491,6 @@ void OmpStructureChecker::CheckIsVarPartOfAnotherVar( } } // Following clauses have a seperate node in parse-tree.h. -CHECK_SIMPLE_PARSER_CLAUSE(OmpDefaultClause, OMPC_default) CHECK_SIMPLE_PARSER_CLAUSE(OmpDistScheduleClause, OMPC_dist_schedule) CHECK_SIMPLE_PARSER_CLAUSE(OmpNowait, OMPC_nowait) CHECK_SIMPLE_PARSER_CLAUSE(OmpProcBindClause, OMPC_proc_bind) diff --git a/flang/lib/Semantics/check-omp-structure.h b/flang/lib/Semantics/check-omp-structure.h index 32da0fb00954..dcc2deeb348c 100644 --- a/flang/lib/Semantics/check-omp-structure.h +++ b/flang/lib/Semantics/check-omp-structure.h @@ -137,6 +137,7 @@ class OmpStructureChecker void Enter(const parser::OmpClause::Collapse &); void Enter(const parser::OmpClause::Copyin &); void Enter(const parser::OmpClause::Copyprivate &); + void Enter(const parser::OmpClause::Default &); void Enter(const parser::OmpClause::Device &); void Enter(const parser::OmpClause::Final &); void Enter(const parser::OmpClause::Firstprivate &); @@ -175,7 +176,6 @@ class OmpStructureChecker void Enter(const parser::OmpAtomicCapture &); void Leave(const parser::OmpAtomic &); void Enter(const parser::OmpAlignedClause &); - void Enter(const parser::OmpDefaultClause &); void Enter(const parser::OmpDefaultmapClause &); void Enter(const parser::OmpDependClause &); void Enter(const parser::OmpDistScheduleClause &); diff --git a/llvm/include/llvm/Frontend/OpenMP/OMP.td b/llvm/include/llvm/Frontend/OpenMP/OMP.td index 6ad8fa92084b..f06990068b40 100644 --- a/llvm/include/llvm/Frontend/OpenMP/OMP.td +++ b/llvm/include/llvm/Frontend/OpenMP/OMP.td @@ -62,7 +62,7 @@ def OMPC_Collapse : Clause<"collapse"> { } def OMPC_Default : Clause<"default"> { let clangClass = "OMPDefaultClause"; - let flangClass = "OmpDefaultClause"; + let flangClassValue = "OmpDefaultClause"; } def OMPC_Private : Clause<"private"> { let clangClass = "OMPPrivateClause"; _______________________________________________ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits