diff options
| author | sameeran joshi <sameeranjayant.joshi@amd.com> | 2020-12-19 00:03:45 +0530 |
|---|---|---|
| committer | Sameeran joshi <joshisameeran17@gmail.com> | 2020-12-22 12:53:34 +0530 |
| commit | 442aac5da68c467563dc6fedf37892ee3d2b688b (patch) | |
| tree | 26a18e256c8bf8c31162d1eef25510c2671d2019 | |
| parent | 9a8ef927df38a933909a512bf0089a28387ad876 (diff) | |
[Flang][openmp][1/5] Make Allocate 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 `allocate` clause part of `OmpClause`.The unparse function for
`OmpAllocateClause` is adapted since the keyword and parenthesis are issued by
the corresponding unparse function for `parser::OmpClause::Allocate`.
Reviewed By: clementval
Differential Revision: https://reviews.llvm.org/D93640
| -rw-r--r-- | flang/lib/Parser/openmp-parsers.cpp | 4 | ||||
| -rw-r--r-- | flang/lib/Parser/unparse.cpp | 5 | ||||
| -rw-r--r-- | flang/lib/Semantics/check-omp-structure.cpp | 2 | ||||
| -rw-r--r-- | flang/lib/Semantics/check-omp-structure.h | 2 | ||||
| -rw-r--r-- | llvm/include/llvm/Frontend/OpenMP/OMP.td | 2 |
5 files changed, 7 insertions, 8 deletions
diff --git a/flang/lib/Parser/openmp-parsers.cpp b/flang/lib/Parser/openmp-parsers.cpp index 67c377e798ca..ff8ba774a6ce 100644 --- a/flang/lib/Parser/openmp-parsers.cpp +++ b/flang/lib/Parser/openmp-parsers.cpp @@ -157,8 +157,8 @@ TYPE_PARSER( "ACQ_REL" >> construct<OmpClause>(construct<OmpClause::AcqRel>()) || "ALIGNED" >> construct<OmpClause>(parenthesized(Parser<OmpAlignedClause>{})) || - "ALLOCATE" >> - construct<OmpClause>(parenthesized(Parser<OmpAllocateClause>{})) || + "ALLOCATE" >> construct<OmpClause>(construct<OmpClause::Allocate>( + parenthesized(Parser<OmpAllocateClause>{}))) || "ALLOCATOR" >> construct<OmpClause>(construct<OmpClause::Allocator>( parenthesized(scalarIntExpr))) || "COLLAPSE" >> construct<OmpClause>(construct<OmpClause::Collapse>( diff --git a/flang/lib/Parser/unparse.cpp b/flang/lib/Parser/unparse.cpp index a027c8fc9af6..ed17bac92965 100644 --- a/flang/lib/Parser/unparse.cpp +++ b/flang/lib/Parser/unparse.cpp @@ -2020,10 +2020,9 @@ public: Put(")"); } void Unparse(const OmpAllocateClause &x) { - Word("ALLOCATE("); - Walk(std::get<std::optional<OmpAllocateClause::Allocator>>(x.t), ":"); + Walk(std::get<std::optional<OmpAllocateClause::Allocator>>(x.t)); + Put(":"); Walk(std::get<OmpObjectList>(x.t)); - Put(")"); } void Unparse(const OmpDependSinkVecLength &x) { Walk(std::get<DefinedOperator>(x.t)); diff --git a/flang/lib/Semantics/check-omp-structure.cpp b/flang/lib/Semantics/check-omp-structure.cpp index 978e1c7962a4..58db75459318 100644 --- a/flang/lib/Semantics/check-omp-structure.cpp +++ b/flang/lib/Semantics/check-omp-structure.cpp @@ -403,6 +403,7 @@ void OmpStructureChecker::Enter(const parser::OmpClause &x) { // Following clauses do not have a seperate node in parse-tree.h. // They fall under 'struct OmpClause' in parse-tree.h. +CHECK_SIMPLE_CLAUSE(Allocate, OMPC_allocate) CHECK_SIMPLE_CLAUSE(Copyin, OMPC_copyin) CHECK_SIMPLE_CLAUSE(Copyprivate, OMPC_copyprivate) CHECK_SIMPLE_CLAUSE(Device, OMPC_device) @@ -489,7 +490,6 @@ void OmpStructureChecker::CheckIsVarPartOfAnotherVar( } } // Following clauses have a seperate node in parse-tree.h. -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) diff --git a/flang/lib/Semantics/check-omp-structure.h b/flang/lib/Semantics/check-omp-structure.h index 2949568f6044..32da0fb00954 100644 --- a/flang/lib/Semantics/check-omp-structure.h +++ b/flang/lib/Semantics/check-omp-structure.h @@ -127,6 +127,7 @@ 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 &); @@ -174,7 +175,6 @@ public: void Enter(const parser::OmpAtomicCapture &); void Leave(const parser::OmpAtomic &); void Enter(const parser::OmpAlignedClause &); - void Enter(const parser::OmpAllocateClause &); void Enter(const parser::OmpDefaultClause &); void Enter(const parser::OmpDefaultmapClause &); void Enter(const parser::OmpDependClause &); diff --git a/llvm/include/llvm/Frontend/OpenMP/OMP.td b/llvm/include/llvm/Frontend/OpenMP/OMP.td index 58aa1bf23b68..6ad8fa92084b 100644 --- a/llvm/include/llvm/Frontend/OpenMP/OMP.td +++ b/llvm/include/llvm/Frontend/OpenMP/OMP.td @@ -254,7 +254,7 @@ def OMPC_AtomicDefaultMemOrder : Clause<"atomic_default_mem_order"> { } def OMPC_Allocate : Clause<"allocate"> { let clangClass = "OMPAllocateClause"; - let flangClass = "OmpAllocateClause"; + let flangClassValue = "OmpAllocateClause"; } def OMPC_NonTemporal : Clause<"nontemporal"> { let clangClass = "OMPNontemporalClause"; |
