[PATCH] D93482: [flang][openmp] Make Reduction clause part of OmpClause
Valentin Clement via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 17 12:12:25 PST 2020
clementval created this revision.
clementval added reviewers: sameeranjoshi, kiranchandramohan, yhegde, kiranktp.
Herald added subscribers: guansong, yaxunl.
Herald added a reviewer: sscalpone.
clementval requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added subscribers: llvm-commits, sstefan1.
Herald added a project: LLVM.
After discussion in D93105 <https://reviews.llvm.org/D93105> we found that the reduction clause was not following
the common OmpClause convention. This patch makes reduction clause part of OmpClause
with a value of OmpReductionClause in a similar way than task_reduction.
The unparse function for OmpReductionClause is adapted since the keyword and parenthesis
are issued by the corresponding unparse function for parser::OmpClause::Reduction.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D93482
Files:
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
@@ -81,7 +81,7 @@
}
def OMPC_Reduction : Clause<"reduction"> {
let clangClass = "OMPReductionClause";
- let flangClass = "OmpReductionClause";
+ let flangClassValue = "OmpReductionClause";
}
def OMPC_Linear : Clause<"linear"> {
let clangClass = "OMPLinearClause";
Index: flang/lib/Semantics/check-omp-structure.h
===================================================================
--- flang/lib/Semantics/check-omp-structure.h
+++ flang/lib/Semantics/check-omp-structure.h
@@ -141,6 +141,7 @@
void Enter(const parser::OmpClause::Ordered &);
void Enter(const parser::OmpClause::Priority &);
void Enter(const parser::OmpClause::Private &);
+ void Enter(const parser::OmpClause::Reduction &);
void Enter(const parser::OmpClause::Safelen &);
void Enter(const parser::OmpClause::Shared &);
void Enter(const parser::OmpClause::Simdlen &);
@@ -162,7 +163,6 @@
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 &);
private:
Index: flang/lib/Semantics/check-omp-structure.cpp
===================================================================
--- flang/lib/Semantics/check-omp-structure.cpp
+++ flang/lib/Semantics/check-omp-structure.cpp
@@ -373,6 +373,7 @@
CHECK_SIMPLE_CLAUSE(Nogroup, OMPC_nogroup)
CHECK_SIMPLE_CLAUSE(Notinbranch, OMPC_notinbranch)
CHECK_SIMPLE_CLAUSE(Private, OMPC_private)
+CHECK_SIMPLE_CLAUSE(Reduction, OMPC_reduction)
CHECK_SIMPLE_CLAUSE(Shared, OMPC_shared)
CHECK_SIMPLE_CLAUSE(TaskReduction, OMPC_task_reduction)
CHECK_SIMPLE_CLAUSE(To, OMPC_to)
@@ -414,8 +415,6 @@
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)
-
// Restrictions specific to each clause are implemented apart from the
// generalized restrictions.
Index: flang/lib/Parser/unparse.cpp
===================================================================
--- flang/lib/Parser/unparse.cpp
+++ flang/lib/Parser/unparse.cpp
@@ -2004,11 +2004,9 @@
Put(")");
}
void Unparse(const OmpReductionClause &x) {
- Word("REDUCTION(");
Walk(std::get<OmpReductionOperator>(x.t));
Put(":");
Walk(std::get<OmpObjectList>(x.t));
- Put(")");
}
void Unparse(const OmpAllocateClause &x) {
Word("ALLOCATE(");
Index: flang/lib/Parser/openmp-parsers.cpp
===================================================================
--- flang/lib/Parser/openmp-parsers.cpp
+++ flang/lib/Parser/openmp-parsers.cpp
@@ -216,11 +216,11 @@
parenthesized(Parser<OmpObjectList>{}))) ||
"PROC_BIND" >>
construct<OmpClause>(parenthesized(Parser<OmpProcBindClause>{})) ||
- "REDUCTION" >>
- construct<OmpClause>(parenthesized(Parser<OmpReductionClause>{})) ||
+ "REDUCTION" >> construct<OmpClause>(construct<OmpClause::Reduction>(
+ parenthesized(Parser<OmpReductionClause>{}))) ||
"TASK_REDUCTION" >>
construct<OmpClause>(construct<OmpClause::TaskReduction>(
- parenthesized(Parser<OmpReductionClause>{}))) ||
+ parenthesized(Parser<OmpReductionClause>{}))) ||
"RELAXED" >> construct<OmpClause>(construct<OmpClause::Relaxed>()) ||
"RELEASE" >> construct<OmpClause>(construct<OmpClause::Release>()) ||
"SAFELEN" >> construct<OmpClause>(construct<OmpClause::Safelen>(
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D93482.312581.patch
Type: text/x-patch
Size: 3823 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201217/e391baa2/attachment.bin>
More information about the llvm-commits
mailing list