From 1a6f43991ff7e5249f24660074f0dd784aeecd5f Mon Sep 17 00:00:00 2001 From: sameeran joshi Date: Mon, 21 Dec 2020 22:44:22 +0530 Subject: [PATCH] [Flang][openmp][5/5] Make dist_schedule 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 `OmpDistScheduleClause` clause part of `OmpClause`. The unparse function for `OmpDistScheduleClause` is adapted since the keyword and parenthesis are issued by the corresponding unparse function for `parser::OmpClause::DistSchedule`. Reviewed By: clementval, kiranktp Differential Revision: https://reviews.llvm.org/D93644 --- flang/include/flang/Parser/dump-parse-tree.h | 1 - flang/include/flang/Parser/parse-tree.h | 4 ---- flang/lib/Parser/openmp-parsers.cpp | 2 +- flang/lib/Parser/unparse.cpp | 5 ----- flang/lib/Semantics/check-omp-structure.cpp | 2 +- flang/lib/Semantics/check-omp-structure.h | 2 +- llvm/include/llvm/Frontend/OpenMP/OMP.td | 1 - 7 files changed, 3 insertions(+), 14 deletions(-) diff --git a/flang/include/flang/Parser/dump-parse-tree.h b/flang/include/flang/Parser/dump-parse-tree.h index 05152f8..60e0000 100644 --- a/flang/include/flang/Parser/dump-parse-tree.h +++ b/flang/include/flang/Parser/dump-parse-tree.h @@ -485,7 +485,6 @@ public: NODE_ENUM(OmpDependenceType, Type) NODE(parser, OmpDependSinkVec) NODE(parser, OmpDependSinkVecLength) - NODE(parser, OmpDistScheduleClause) NODE(parser, OmpEndAtomic) NODE(parser, OmpEndBlockDirective) NODE(parser, OmpEndCriticalDirective) diff --git a/flang/include/flang/Parser/parse-tree.h b/flang/include/flang/Parser/parse-tree.h index 09c6147..7e258b6 100644 --- a/flang/include/flang/Parser/parse-tree.h +++ b/flang/include/flang/Parser/parse-tree.h @@ -3456,10 +3456,6 @@ struct OmpDependClause { std::variant u; }; -// dist_schedule clause does not fit in generic clause class for tablegen. -// Therefore it is declared separatly here. -WRAPPER_CLASS(OmpDistScheduleClause, std::optional); - // OpenMP Clauses struct OmpClause { UNION_CLASS_BOILERPLATE(OmpClause); diff --git a/flang/lib/Parser/openmp-parsers.cpp b/flang/lib/Parser/openmp-parsers.cpp index 62dd0d1..1386b2b 100644 --- a/flang/lib/Parser/openmp-parsers.cpp +++ b/flang/lib/Parser/openmp-parsers.cpp @@ -176,7 +176,7 @@ TYPE_PARSER( "DEVICE" >> construct(construct( parenthesized(scalarIntExpr))) || "DIST_SCHEDULE" >> - construct(construct( + construct(construct( parenthesized("STATIC" >> maybe("," >> scalarIntExpr)))) || "FINAL" >> construct(construct( parenthesized(scalarLogicalExpr))) || diff --git a/flang/lib/Parser/unparse.cpp b/flang/lib/Parser/unparse.cpp index 5dbf994..fdb694f 100644 --- a/flang/lib/Parser/unparse.cpp +++ b/flang/lib/Parser/unparse.cpp @@ -2065,11 +2065,6 @@ public: std::get>(x.t)); Word(")"); } - void Unparse(const OmpDistScheduleClause &x) { - Word("DIST_SCHEDULE(STATIC"); - Walk(", ", x.v); - Put(")"); - } #define GEN_FLANG_CLAUSE_UNPARSE #include "llvm/Frontend/OpenMP/OMP.inc" void Unparse(const OmpLoopDirective &x) { diff --git a/flang/lib/Semantics/check-omp-structure.cpp b/flang/lib/Semantics/check-omp-structure.cpp index c901630..e2c8333 100644 --- a/flang/lib/Semantics/check-omp-structure.cpp +++ b/flang/lib/Semantics/check-omp-structure.cpp @@ -430,6 +430,7 @@ CHECK_SIMPLE_CLAUSE(Release, OMPC_release) CHECK_SIMPLE_CLAUSE(Relaxed, OMPC_relaxed) CHECK_SIMPLE_CLAUSE(Hint, OMPC_hint) CHECK_SIMPLE_CLAUSE(ProcBind, OMPC_proc_bind) +CHECK_SIMPLE_CLAUSE(DistSchedule, OMPC_dist_schedule) CHECK_REQ_SCALAR_INT_CLAUSE(Allocator, OMPC_allocator) CHECK_REQ_SCALAR_INT_CLAUSE(Grainsize, OMPC_grainsize) @@ -493,7 +494,6 @@ void OmpStructureChecker::CheckIsVarPartOfAnotherVar( } } // Following clauses have a seperate node in parse-tree.h. -CHECK_SIMPLE_PARSER_CLAUSE(OmpDistScheduleClause, OMPC_dist_schedule) CHECK_SIMPLE_PARSER_CLAUSE(OmpReductionClause, OMPC_reduction) // Atomic-clause CHECK_SIMPLE_PARSER_CLAUSE(OmpAtomicRead, OMPC_read) diff --git a/flang/lib/Semantics/check-omp-structure.h b/flang/lib/Semantics/check-omp-structure.h index 72bb9a5..a966eaf 100644 --- a/flang/lib/Semantics/check-omp-structure.h +++ b/flang/lib/Semantics/check-omp-structure.h @@ -139,6 +139,7 @@ public: void Enter(const parser::OmpClause::Copyprivate &); void Enter(const parser::OmpClause::Default &); void Enter(const parser::OmpClause::Device &); + void Enter(const parser::OmpClause::DistSchedule &); void Enter(const parser::OmpClause::Final &); void Enter(const parser::OmpClause::Firstprivate &); void Enter(const parser::OmpClause::From &); @@ -179,7 +180,6 @@ public: void Enter(const parser::OmpAlignedClause &); void Enter(const parser::OmpDefaultmapClause &); void Enter(const parser::OmpDependClause &); - void Enter(const parser::OmpDistScheduleClause &); void Enter(const parser::OmpIfClause &); void Enter(const parser::OmpLinearClause &); void Enter(const parser::OmpMapClause &); diff --git a/llvm/include/llvm/Frontend/OpenMP/OMP.td b/llvm/include/llvm/Frontend/OpenMP/OMP.td index 5c8895b..fa67a64 100644 --- a/llvm/include/llvm/Frontend/OpenMP/OMP.td +++ b/llvm/include/llvm/Frontend/OpenMP/OMP.td @@ -204,7 +204,6 @@ def OMPC_Hint : Clause<"hint"> { } def OMPC_DistSchedule : Clause<"dist_schedule"> { let clangClass = "OMPDistScheduleClause"; - let flangClass = "OmpDistScheduleClause"; let flangClassValue = "ScalarIntExpr"; let isValueOptional = true; } -- 2.7.4