Skip to content

Commit 6fb9989

Browse files
committed
[MLIR][OpenMP] Clause-based OpenMP operation definition
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.
1 parent e1aa6cb commit 6fb9989

File tree

11 files changed

+419
-929
lines changed

11 files changed

+419
-929
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
};
@@ -117,10 +126,6 @@ struct MergeableClauseOps {
117126
UnitAttr mergeableAttr;
118127
};
119128

120-
struct NameClauseOps {
121-
StringAttr nameAttr;
122-
};
123-
124129
struct NogroupClauseOps {
125130
UnitAttr nogroupAttr;
126131
};
@@ -209,8 +214,12 @@ struct UntiedClauseOps {
209214
UnitAttr untiedAttr;
210215
};
211216

212-
struct UseDeviceClauseOps {
213-
llvm::SmallVector<Value> useDevicePtrVars, useDeviceAddrVars;
217+
struct UseDeviceAddrClauseOps {
218+
llvm::SmallVector<Value> useDeviceAddrVars;
219+
};
220+
221+
struct UseDevicePtrClauseOps {
222+
llvm::SmallVector<Value> useDevicePtrVars;
214223
};
215224

216225
//===----------------------------------------------------------------------===//
@@ -225,7 +234,13 @@ template <typename... Mixins>
225234
struct Clauses : public Mixins... {};
226235
} // namespace detail
227236

228-
using CriticalClauseOps = detail::Clauses<HintClauseOps, NameClauseOps>;
237+
using CancelClauseOps =
238+
detail::Clauses<CancelDirectiveNameClauseOps, IfClauseOps>;
239+
240+
using CancellationPointClauseOps =
241+
detail::Clauses<CancelDirectiveNameClauseOps>;
242+
243+
using CriticalClauseOps = detail::Clauses<CriticalNameClauseOps, HintClauseOps>;
229244

230245
// TODO `indirect` clause.
231246
using DeclareTargetClauseOps = detail::Clauses<DeviceTypeClauseOps>;
@@ -264,10 +279,11 @@ using TargetClauseOps =
264279
detail::Clauses<AllocateClauseOps, DependClauseOps, DeviceClauseOps,
265280
HasDeviceAddrClauseOps, IfClauseOps, InReductionClauseOps,
266281
IsDevicePtrClauseOps, MapClauseOps, NowaitClauseOps,
267-
PrivateClauseOps, ReductionClauseOps, ThreadLimitClauseOps>;
282+
PrivateClauseOps, ThreadLimitClauseOps>;
268283

269-
using TargetDataClauseOps = detail::Clauses<DeviceClauseOps, IfClauseOps,
270-
MapClauseOps, UseDeviceClauseOps>;
284+
using TargetDataClauseOps =
285+
detail::Clauses<DeviceClauseOps, IfClauseOps, MapClauseOps,
286+
UseDeviceAddrClauseOps, UseDevicePtrClauseOps>;
271287

272288
using TargetEnterExitUpdateDataClauseOps =
273289
detail::Clauses<DependClauseOps, DeviceClauseOps, IfClauseOps, MapClauseOps,

0 commit comments

Comments
 (0)