[Flang][openmp][4/5] Make nowait clause part of OmpClause
authorsameeran joshi <sameeranjayant.joshi@amd.com>
Mon, 21 Dec 2020 14:04:12 +0000 (19:34 +0530)
committerSameeran joshi <joshisameeran17@gmail.com>
Tue, 22 Dec 2020 08:32:19 +0000 (14:02 +0530)
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 `OmpNoWait` clause part of `OmpClause`.

Reviewed By: clementval, kiranktp

Differential Revision: https://reviews.llvm.org/D93643

flang/include/flang/Parser/dump-parse-tree.h
flang/include/flang/Parser/parse-tree.h
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

index f69dd149e0a3a16ed948bfe6fa9f102eee160e5d..05152f8c49c684465771beca700bcb6a3f4b7596 100644 (file)
@@ -508,7 +508,6 @@ public:
         "llvm::omp::Clause = ", llvm::omp::getOpenMPClauseName(x))
         .str();
   }
-  NODE(parser, OmpNowait)
   NODE(parser, OmpObject)
   NODE(parser, OmpObjectList)
   NODE(parser, OmpProcBindClause)
index 59fa278e00296c048e75ca816ed7ae9c4a49a0b5..09c61477d2e76dcec2cab3ad60b69cd8f2f043b5 100644 (file)
@@ -3456,9 +3456,6 @@ struct OmpDependClause {
   std::variant<Source, Sink, InOut> u;
 };
 
-// 2.7.1 nowait-clause -> NOWAIT
-EMPTY_CLASS(OmpNowait);
-
 // dist_schedule clause does not fit in generic clause class for tablegen.
 // Therefore it is declared separatly here.
 WRAPPER_CLASS(OmpDistScheduleClause, std::optional<ScalarIntExpr>);
index 50999bef8f5273e3e24885ebdb0326453035803b..62dd0d1e7d29b54609a9600592f4e0ac38c2fc80 100644 (file)
@@ -203,7 +203,7 @@ TYPE_PARSER(
     "NOGROUP" >> construct<OmpClause>(construct<OmpClause::Nogroup>()) ||
     "NOTINBRANCH" >>
         construct<OmpClause>(construct<OmpClause::Notinbranch>()) ||
-    "NOWAIT" >> construct<OmpClause>(construct<OmpNowait>()) ||
+    "NOWAIT" >> construct<OmpClause>(construct<OmpClause::Nowait>()) ||
     "NUM_TASKS" >> construct<OmpClause>(construct<OmpClause::NumTasks>(
                        parenthesized(scalarIntExpr))) ||
     "NUM_TEAMS" >> construct<OmpClause>(construct<OmpClause::NumTeams>(
index 6be063c1b1bc98edfee93a6e7e963a730165c48b..5dbf9940e26e19364c3f436f037c0c13c4ba1d94 100644 (file)
@@ -2065,7 +2065,6 @@ public:
         std::get<std::optional<OmpDefaultmapClause::VariableCategory>>(x.t));
     Word(")");
   }
-  void Unparse(const OmpNowait &) { Word("NOWAIT"); }
   void Unparse(const OmpDistScheduleClause &x) {
     Word("DIST_SCHEDULE(STATIC");
     Walk(", ", x.v);
index 481099b3496689adaa9d791584e7bc5dbdcb0a19..c901630c098bc129801f6608aa5eed8d8002bfba 100644 (file)
@@ -418,6 +418,7 @@ CHECK_SIMPLE_CLAUSE(Link, OMPC_link)
 CHECK_SIMPLE_CLAUSE(Mergeable, OMPC_mergeable)
 CHECK_SIMPLE_CLAUSE(Nogroup, OMPC_nogroup)
 CHECK_SIMPLE_CLAUSE(Notinbranch, OMPC_notinbranch)
+CHECK_SIMPLE_CLAUSE(Nowait, OMPC_nowait)
 CHECK_SIMPLE_CLAUSE(To, OMPC_to)
 CHECK_SIMPLE_CLAUSE(Uniform, OMPC_uniform)
 CHECK_SIMPLE_CLAUSE(Untied, OMPC_untied)
@@ -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(OmpNowait, OMPC_nowait)
 CHECK_SIMPLE_PARSER_CLAUSE(OmpReductionClause, OMPC_reduction)
 // Atomic-clause
 CHECK_SIMPLE_PARSER_CLAUSE(OmpAtomicRead, OMPC_read)
index 89fc3d9faa21bd3c533e87023c979d06d8ff2749..72bb9a523366a0110605dba3fbfbe462c02fc920 100644 (file)
@@ -126,12 +126,12 @@ public:
 
   void Leave(const parser::OmpClauseList &);
   void Enter(const parser::OmpClause &);
-  void Enter(const parser::OmpNowait &);
   void Enter(const parser::OmpClause::Allocate &);
   void Enter(const parser::OmpClause::Allocator &);
   void Enter(const parser::OmpClause::Inbranch &);
   void Enter(const parser::OmpClause::Mergeable &);
   void Enter(const parser::OmpClause::Nogroup &);
+  void Enter(const parser::OmpClause::Nowait &);
   void Enter(const parser::OmpClause::Notinbranch &);
   void Enter(const parser::OmpClause::Untied &);
   void Enter(const parser::OmpClause::Collapse &);
index 28b978975ba068104d3af82b90bea1d79c3a47bb..5c8895b5650e21fa0ee2532af705571fb81b5fcb 100644 (file)
@@ -147,7 +147,6 @@ def OMPC_Ordered : Clause<"ordered"> {
 }
 def OMPC_NoWait : Clause<"nowait"> {
   let clangClass = "OMPNowaitClause";
-  let flangClass = "OmpNowait";
 }
 def OMPC_Untied : Clause<"untied"> { let clangClass = "OMPUntiedClause"; }
 def OMPC_Mergeable : Clause<"mergeable"> {