[PATCH] D93642: [Flang][openmp][3/5] Make ProcBind clause part of OmpClause

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


sameeranjoshi created this revision.
sameeranjoshi added reviewers: kiranchandramohan, clementval, kiranktp, SouraVX.
Herald added subscribers: mehdi_amini, guansong, yaxunl.
Herald added a reviewer: sscalpone.
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 `OmpProcBindClause` clause part of `OmpClause`.
The unparse function is dropped as the unparsing is done by `WALK_NESTED_ENUM`
for `OmpProcBindClause`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D93642

Files:
  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


Index: llvm/include/llvm/Frontend/OpenMP/OMP.td
===================================================================
--- llvm/include/llvm/Frontend/OpenMP/OMP.td
+++ llvm/include/llvm/Frontend/OpenMP/OMP.td
@@ -107,7 +107,7 @@
 def OMP_PROC_BIND_unknown : ClauseVal<"unknown",6,0> { let isDefault = true; }
 def OMPC_ProcBind : Clause<"proc_bind"> {
   let clangClass = "OMPProcBindClause";
-  let flangClass = "OmpProcBindClause";
+  let flangClassValue = "OmpProcBindClause";
   let enumClauseValue = "ProcBindKind";
   let allowedClauseValues = [
     OMP_PROC_BIND_master,
Index: flang/lib/Semantics/check-omp-structure.h
===================================================================
--- flang/lib/Semantics/check-omp-structure.h
+++ flang/lib/Semantics/check-omp-structure.h
@@ -148,6 +148,7 @@
   void Enter(const parser::OmpClause::Ordered &);
   void Enter(const parser::OmpClause::Priority &);
   void Enter(const parser::OmpClause::Private &);
+  void Enter(const parser::OmpClause::ProcBind &);
   void Enter(const parser::OmpClause::Safelen &);
   void Enter(const parser::OmpClause::Shared &);
   void Enter(const parser::OmpClause::Simdlen &);
@@ -182,7 +183,6 @@
   void Enter(const parser::OmpIfClause &);
   void Enter(const parser::OmpLinearClause &);
   void Enter(const parser::OmpMapClause &);
-  void Enter(const parser::OmpProcBindClause &);
   void Enter(const parser::OmpReductionClause &);
   void Enter(const parser::OmpScheduleClause &);
 
Index: flang/lib/Semantics/check-omp-structure.cpp
===================================================================
--- flang/lib/Semantics/check-omp-structure.cpp
+++ flang/lib/Semantics/check-omp-structure.cpp
@@ -426,6 +426,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_REQ_SCALAR_INT_CLAUSE(Allocator, OMPC_allocator)
 CHECK_REQ_SCALAR_INT_CLAUSE(Grainsize, OMPC_grainsize)
@@ -493,7 +494,6 @@
 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
 CHECK_SIMPLE_PARSER_CLAUSE(OmpAtomicRead, OMPC_read)
Index: flang/lib/Parser/unparse.cpp
===================================================================
--- flang/lib/Parser/unparse.cpp
+++ flang/lib/Parser/unparse.cpp
@@ -2064,11 +2064,6 @@
     return true;
   }
   void Post(const OmpDefaultClause &) { Put(")"); }
-  bool Pre(const OmpProcBindClause &) {
-    Word("PROC_BIND(");
-    return true;
-  }
-  void Post(const OmpProcBindClause &) { Put(")"); }
   void Unparse(const OmpDefaultmapClause &x) {
     Word("DEFAULTMAP(");
     Walk(std::get<OmpDefaultmapClause::ImplicitBehavior>(x.t));
Index: flang/lib/Parser/openmp-parsers.cpp
===================================================================
--- flang/lib/Parser/openmp-parsers.cpp
+++ flang/lib/Parser/openmp-parsers.cpp
@@ -216,8 +216,8 @@
                       parenthesized(scalarIntExpr))) ||
     "PRIVATE" >> construct<OmpClause>(construct<OmpClause::Private>(
                      parenthesized(Parser<OmpObjectList>{}))) ||
-    "PROC_BIND" >>
-        construct<OmpClause>(parenthesized(Parser<OmpProcBindClause>{})) ||
+    "PROC_BIND" >> construct<OmpClause>(construct<OmpClause::ProcBind>(
+                       parenthesized(Parser<OmpProcBindClause>{}))) ||
     "REDUCTION" >>
         construct<OmpClause>(parenthesized(Parser<OmpReductionClause>{})) ||
     "RELAXED" >> construct<OmpClause>(construct<OmpClause::Relaxed>()) ||
Index: flang/lib/Lower/OpenMP.cpp
===================================================================
--- flang/lib/Lower/OpenMP.cpp
+++ flang/lib/Lower/OpenMP.cpp
@@ -213,8 +213,9 @@
         }
       }
       if (const auto &procBindClause =
-              std::get_if<Fortran::parser::OmpProcBindClause>(&clause.u)) {
-        switch (procBindClause->v) {
+              std::get_if<Fortran::parser::OmpClause::ProcBind>(&clause.u)) {
+        const auto &ompProcBindClause{procBindClause->v};
+        switch (ompProcBindClause.v) {
         case Fortran::parser::OmpProcBindClause::Type::Master:
           parallelOp.proc_bind_valAttr(
               firOpBuilder.getStringAttr(omp::stringifyClauseProcBindKind(


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


More information about the llvm-commits mailing list