[PATCH] D93643: [Flang][openmp][4/5] Make nowait clause part of OmpClause

sameeran joshi via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 21 09:30:52 PST 2020


sameeranjoshi created this revision.
sameeranjoshi added reviewers: kiranchandramohan, clementval, kiranktp, SouraVX.
Herald added subscribers: guansong, yaxunl.
sameeranjoshi requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added a subscriber: sstefan1.
Herald added a project: LLVM.

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`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D93643

Files:
  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: llvm/include/llvm/Frontend/OpenMP/OMP.td
===================================================================
--- llvm/include/llvm/Frontend/OpenMP/OMP.td
+++ llvm/include/llvm/Frontend/OpenMP/OMP.td
@@ -147,7 +147,6 @@
 }
 def OMPC_NoWait : Clause<"nowait"> {
   let clangClass = "OMPNowaitClause";
-  let flangClass = "OmpNowait";
 }
 def OMPC_Untied : Clause<"untied"> { let clangClass = "OMPUntiedClause"; }
 def OMPC_Mergeable : Clause<"mergeable"> {
Index: flang/lib/Semantics/check-omp-structure.h
===================================================================
--- flang/lib/Semantics/check-omp-structure.h
+++ flang/lib/Semantics/check-omp-structure.h
@@ -126,7 +126,7 @@
 
   void Leave(const parser::OmpClauseList &);
   void Enter(const parser::OmpClause &);
-  void Enter(const parser::OmpNowait &);
+  void Enter(const parser::OmpClause::Nowait &);
   void Enter(const parser::OmpClause::Allocator &);
   void Enter(const parser::OmpClause::Inbranch &);
   void Enter(const parser::OmpClause::Mergeable &);
Index: flang/lib/Semantics/check-omp-structure.cpp
===================================================================
--- flang/lib/Semantics/check-omp-structure.cpp
+++ flang/lib/Semantics/check-omp-structure.cpp
@@ -416,6 +416,7 @@
 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)
@@ -492,7 +493,6 @@
 CHECK_SIMPLE_PARSER_CLAUSE(OmpAllocateClause, OMPC_allocate)
 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)
 CHECK_SIMPLE_PARSER_CLAUSE(OmpReductionClause, OMPC_reduction)
 // Atomic-clause
Index: flang/lib/Parser/unparse.cpp
===================================================================
--- flang/lib/Parser/unparse.cpp
+++ flang/lib/Parser/unparse.cpp
@@ -2076,7 +2076,6 @@
         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: flang/lib/Parser/openmp-parsers.cpp
===================================================================
--- flang/lib/Parser/openmp-parsers.cpp
+++ flang/lib/Parser/openmp-parsers.cpp
@@ -203,7 +203,7 @@
     "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: flang/include/flang/Parser/parse-tree.h
===================================================================
--- flang/include/flang/Parser/parse-tree.h
+++ flang/include/flang/Parser/parse-tree.h
@@ -3456,9 +3456,6 @@
   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: flang/include/flang/Parser/dump-parse-tree.h
===================================================================
--- flang/include/flang/Parser/dump-parse-tree.h
+++ flang/include/flang/Parser/dump-parse-tree.h
@@ -504,7 +504,6 @@
         "llvm::omp::Clause = ", llvm::omp::getOpenMPClauseName(x))
         .str();
   }
-  NODE(parser, OmpNowait)
   NODE(parser, OmpObject)
   NODE(parser, OmpObjectList)
   NODE(parser, OmpProcBindClause)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D93643.313126.patch
Type: text/x-patch
Size: 4126 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201221/a8297642/attachment.bin>


More information about the llvm-commits mailing list