Skip to content

Commit 3c81587

Browse files
authored
[OpenMP] Add definitions for DECLARE_INDUCTION and related clauses (#166235)
Add definitions for DECLARE_INDUCTION, COLLECTOR, and INDUCTOR to OMP.td.
1 parent c2fe1d9 commit 3c81587

File tree

5 files changed

+33
-3
lines changed

5 files changed

+33
-3
lines changed

flang/include/flang/Lower/OpenMP/Clauses.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@ using At = tomp::clause::AtT<TypeTy, IdTy, ExprTy>;
204204
using Bind = tomp::clause::BindT<TypeTy, IdTy, ExprTy>;
205205
using Capture = tomp::clause::CaptureT<TypeTy, IdTy, ExprTy>;
206206
using Collapse = tomp::clause::CollapseT<TypeTy, IdTy, ExprTy>;
207+
using Collector = tomp::clause::CollectorT<TypeTy, IdTy, ExprTy>;
207208
using Compare = tomp::clause::CompareT<TypeTy, IdTy, ExprTy>;
208209
using Contains = tomp::clause::ContainsT<TypeTy, IdTy, ExprTy>;
209210
using Copyin = tomp::clause::CopyinT<TypeTy, IdTy, ExprTy>;
@@ -239,6 +240,7 @@ using If = tomp::clause::IfT<TypeTy, IdTy, ExprTy>;
239240
using Inbranch = tomp::clause::InbranchT<TypeTy, IdTy, ExprTy>;
240241
using Inclusive = tomp::clause::InclusiveT<TypeTy, IdTy, ExprTy>;
241242
using Indirect = tomp::clause::IndirectT<TypeTy, IdTy, ExprTy>;
243+
using Inductor = tomp::clause::InductorT<TypeTy, IdTy, ExprTy>;
242244
using Init = tomp::clause::InitT<TypeTy, IdTy, ExprTy>;
243245
using Initializer = tomp::clause::InitializerT<TypeTy, IdTy, ExprTy>;
244246
using InReduction = tomp::clause::InReductionT<TypeTy, IdTy, ExprTy>;

flang/lib/Lower/OpenMP/Clauses.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,8 +249,10 @@ MAKE_EMPTY_CLASS(Groupprivate, Groupprivate);
249249

250250
MAKE_INCOMPLETE_CLASS(AdjustArgs, AdjustArgs);
251251
MAKE_INCOMPLETE_CLASS(AppendArgs, AppendArgs);
252+
MAKE_INCOMPLETE_CLASS(Collector, Collector);
252253
MAKE_INCOMPLETE_CLASS(GraphId, GraphId);
253254
MAKE_INCOMPLETE_CLASS(GraphReset, GraphReset);
255+
MAKE_INCOMPLETE_CLASS(Inductor, Inductor);
254256
MAKE_INCOMPLETE_CLASS(Replayable, Replayable);
255257
MAKE_INCOMPLETE_CLASS(Transparent, Transparent);
256258

flang/lib/Semantics/check-omp-structure.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5466,6 +5466,7 @@ CHECK_SIMPLE_CLAUSE(Affinity, OMPC_affinity)
54665466
CHECK_SIMPLE_CLAUSE(AppendArgs, OMPC_append_args)
54675467
CHECK_SIMPLE_CLAUSE(Bind, OMPC_bind)
54685468
CHECK_SIMPLE_CLAUSE(Capture, OMPC_capture)
5469+
CHECK_SIMPLE_CLAUSE(Collector, OMPC_collector)
54695470
CHECK_SIMPLE_CLAUSE(Compare, OMPC_compare)
54705471
CHECK_SIMPLE_CLAUSE(Contains, OMPC_contains)
54715472
CHECK_SIMPLE_CLAUSE(Default, OMPC_default)
@@ -5487,6 +5488,7 @@ CHECK_SIMPLE_CLAUSE(Holds, OMPC_holds)
54875488
CHECK_SIMPLE_CLAUSE(Inbranch, OMPC_inbranch)
54885489
CHECK_SIMPLE_CLAUSE(Inclusive, OMPC_inclusive)
54895490
CHECK_SIMPLE_CLAUSE(Indirect, OMPC_indirect)
5491+
CHECK_SIMPLE_CLAUSE(Inductor, OMPC_inductor)
54905492
CHECK_SIMPLE_CLAUSE(Initializer, OMPC_initializer)
54915493
CHECK_SIMPLE_CLAUSE(Init, OMPC_init)
54925494
CHECK_SIMPLE_CLAUSE(Link, OMPC_link)

llvm/include/llvm/Frontend/OpenMP/ClauseT.h

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,12 @@ struct CollapseT {
446446
N v;
447447
};
448448

449-
// V5.2: [15.8.3] `extended-atomic` clauses
449+
// [6.0:266]
450+
template <typename T, typename I, typename E> //
451+
struct CollectorT {
452+
using IncompleteTrait = std::true_type;
453+
};
454+
450455
template <typename T, typename I, typename E> //
451456
struct CompareT {
452457
using EmptyTrait = std::true_type;
@@ -736,6 +741,12 @@ struct IndirectT {
736741
OPT(InvokedByFptr) v;
737742
};
738743

744+
// [6.0:265-266]
745+
template <typename T, typename I, typename E> //
746+
struct InductorT {
747+
using IncompleteTrait = std::true_type;
748+
};
749+
739750
// V5.2: [14.1.2] `init` clause
740751
template <typename T, typename I, typename E> //
741752
struct InitT {
@@ -1324,8 +1335,9 @@ using EmptyClausesT = std::variant<
13241335

13251336
template <typename T, typename I, typename E>
13261337
using IncompleteClausesT =
1327-
std::variant<AdjustArgsT<T, I, E>, AppendArgsT<T, I, E>, GraphIdT<T, I, E>,
1328-
GraphResetT<T, I, E>, MatchT<T, I, E>, OtherwiseT<T, I, E>,
1338+
std::variant<AdjustArgsT<T, I, E>, AppendArgsT<T, I, E>,
1339+
CollectorT<T, I, E>, GraphIdT<T, I, E>, GraphResetT<T, I, E>,
1340+
InductorT<T, I, E>, MatchT<T, I, E>, OtherwiseT<T, I, E>,
13291341
ReplayableT<T, I, E>, TransparentT<T, I, E>, WhenT<T, I, E>>;
13301342

13311343
template <typename T, typename I, typename E>

llvm/include/llvm/Frontend/OpenMP/OMP.td

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,8 @@ def OMPC_Collapse : Clause<[Spelling<"collapse">]> {
123123
let clangClass = "OMPCollapseClause";
124124
let flangClass = "ScalarIntConstantExpr";
125125
}
126+
def OMPC_Collector : Clause<[Spelling<"collector">]> {
127+
}
126128
def OMPC_Compare : Clause<[Spelling<"compare">]> {
127129
let clangClass = "OMPCompareClause";
128130
}
@@ -264,6 +266,8 @@ def OMPC_Inclusive : Clause<[Spelling<"inclusive">]> {
264266
def OMPC_Indirect : Clause<[Spelling<"indirect">]> {
265267
let flangClass = "OmpIndirectClause";
266268
}
269+
def OMPC_Inductor : Clause<[Spelling<"inductor">]> {
270+
}
267271
def OMPC_Init : Clause<[Spelling<"init">]> {
268272
let clangClass = "OMPInitClause";
269273
let flangClass = "OmpInitClause";
@@ -749,6 +753,14 @@ def OMP_Critical : Directive<[Spelling<"critical">]> {
749753
let association = AS_Block;
750754
let category = CA_Executable;
751755
}
756+
def OMP_DeclareInduction : Directive<[Spelling<"declare_induction">]> {
757+
let allowedOnceClauses = [
758+
VersionedClause<OMPC_Collector, 60>,
759+
VersionedClause<OMPC_Inductor, 60>,
760+
];
761+
let association = AS_None;
762+
let category = CA_Declarative;
763+
}
752764
def OMP_DeclareMapper : Directive<[Spelling<"declare mapper", 1, 52>,
753765
Spelling<"declare_mapper", 60>]> {
754766
let requiredClauses = [

0 commit comments

Comments
 (0)