Skip to content

Commit d1fcfce

Browse files
authored
[MLIR][OpenMP] Clause-based OpenMP operation definition (#92523)
This patch updates `OpenMP_Op` definitions to be based on the new set of `OpenMP_Clause` definitions, and to take advantage of clause-based automatically-generated argument lists, descriptions, assembly format and class declarations. There are also changes introduced to the clause operands structures to match the current set of tablegen clause definitions. These two are very closely linked and should be kept in sync. It would probably be a good idea to try generating clause operands structures from the tablegen `OpenMP_Clause` definitions in the future. As a result of this change, arguments for some operations have been reordered. This patch also addresses this by updating affected operation build calls and unit tests. Some other updates to tests related to the order of arguments in the resulting assembly format and others due to certain previous inconsistencies in the printing/parsing of clauses are addressed. The printer and parser functions for the `map` clause are updated, so that they are able to handle `map` clauses linked to entry block arguments as well as those which aren't. This PR causes a build failure in the flang subproject. This is addressed by the next PR in the stack.
1 parent 3e168f5 commit d1fcfce

File tree

11 files changed

+422
-983
lines changed

11 files changed

+422
-983
lines changed

mlir/include/mlir/Dialect/OpenMP/OpenMPClauseOperands.h

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ struct AllocateClauseOps {
3939
llvm::SmallVector<Value> allocatorVars, allocateVars;
4040
};
4141

42+
struct CancelDirectiveNameClauseOps {
43+
ClauseCancellationConstructTypeAttr cancelDirectiveNameAttr;
44+
};
45+
4246
struct CollapseClauseOps {
4347
llvm::SmallVector<Value> loopLBVar, loopUBVar, loopStepVar;
4448
};
@@ -48,6 +52,10 @@ struct CopyprivateClauseOps {
4852
llvm::SmallVector<Attribute> copyprivateFuncs;
4953
};
5054

55+
struct CriticalNameClauseOps {
56+
StringAttr criticalNameAttr;
57+
};
58+
5159
struct DependClauseOps {
5260
llvm::SmallVector<Attribute> dependTypeAttrs;
5361
llvm::SmallVector<Value> dependVars;
@@ -84,6 +92,7 @@ struct GrainsizeClauseOps {
8492
struct HasDeviceAddrClauseOps {
8593
llvm::SmallVector<Value> hasDeviceAddrVars;
8694
};
95+
8796
struct HintClauseOps {
8897
IntegerAttr hintAttr;
8998
};
@@ -118,10 +127,6 @@ struct MergeableClauseOps {
118127
UnitAttr mergeableAttr;
119128
};
120129

121-
struct NameClauseOps {
122-
StringAttr nameAttr;
123-
};
124-
125130
struct NogroupClauseOps {
126131
UnitAttr nogroupAttr;
127132
};
@@ -212,8 +217,12 @@ struct UntiedClauseOps {
212217
UnitAttr untiedAttr;
213218
};
214219

215-
struct UseDeviceClauseOps {
216-
llvm::SmallVector<Value> useDevicePtrVars, useDeviceAddrVars;
220+
struct UseDeviceAddrClauseOps {
221+
llvm::SmallVector<Value> useDeviceAddrVars;
222+
};
223+
224+
struct UseDevicePtrClauseOps {
225+
llvm::SmallVector<Value> useDevicePtrVars;
217226
};
218227

219228
//===----------------------------------------------------------------------===//
@@ -228,7 +237,13 @@ template <typename... Mixins>
228237
struct Clauses : public Mixins... {};
229238
} // namespace detail
230239

231-
using CriticalClauseOps = detail::Clauses<HintClauseOps, NameClauseOps>;
240+
using CancelClauseOps =
241+
detail::Clauses<CancelDirectiveNameClauseOps, IfClauseOps>;
242+
243+
using CancellationPointClauseOps =
244+
detail::Clauses<CancelDirectiveNameClauseOps>;
245+
246+
using CriticalClauseOps = detail::Clauses<CriticalNameClauseOps, HintClauseOps>;
232247

233248
// TODO `indirect` clause.
234249
using DeclareTargetClauseOps = detail::Clauses<DeviceTypeClauseOps>;
@@ -267,10 +282,11 @@ using TargetClauseOps =
267282
detail::Clauses<AllocateClauseOps, DependClauseOps, DeviceClauseOps,
268283
HasDeviceAddrClauseOps, IfClauseOps, InReductionClauseOps,
269284
IsDevicePtrClauseOps, MapClauseOps, NowaitClauseOps,
270-
PrivateClauseOps, ReductionClauseOps, ThreadLimitClauseOps>;
285+
PrivateClauseOps, ThreadLimitClauseOps>;
271286

272-
using TargetDataClauseOps = detail::Clauses<DeviceClauseOps, IfClauseOps,
273-
MapClauseOps, UseDeviceClauseOps>;
287+
using TargetDataClauseOps =
288+
detail::Clauses<DeviceClauseOps, IfClauseOps, MapClauseOps,
289+
UseDeviceAddrClauseOps, UseDevicePtrClauseOps>;
274290

275291
using TargetEnterExitUpdateDataClauseOps =
276292
detail::Clauses<DependClauseOps, DeviceClauseOps, IfClauseOps, MapClauseOps,

0 commit comments

Comments
 (0)