@@ -64,10 +64,10 @@ OpenMP clause definitions are located in
64
64
[ OpenMPClauses.td] ( https://github.com/llvm/llvm-project/blob/main/mlir/include/mlir/Dialect/OpenMP/OpenMPClauses.td ) .
65
65
For each clause, an ` OpenMP_Clause ` subclass and a definition based on it must
66
66
be created. The subclass must take a ` bit ` template argument for each of the
67
- properties it may define, listed below, which is forwarded to the base class.
68
- The definition must be an instantiation of the base class where all these
69
- template arguments are set to ` false ` . The definition's name must be
70
- ` OpenMP_<Name>Clause ` , whereas its base class' must be
67
+ properties it can populate on associated ` OpenMP_Op ` s. These must be forwarded
68
+ to the base class. The definition must be an instantiation of the base class
69
+ where all these template arguments are set to ` false ` . The definition's name
70
+ must be ` OpenMP_<Name>Clause ` , whereas its base class' must be
71
71
` OpenMP_<Name>ClauseSkip ` . Following this pattern makes it possible to
72
72
optionally skip the inheritance of some properties when defining operations:
73
73
[ more info] ( #overriding-clause-inherited-properties ) .
@@ -79,11 +79,10 @@ implies some op trait, like the `map` clause and the `MapClauseOwningInterface`.
79
79
used to represent the clause. Argument names use snake_case and should contain
80
80
the clause name to avoid name clashes between clauses. Variadic arguments
81
81
(non-attributes) must contain the "_ vars" suffix.
82
- - ` string assemblyFormat ` : Optional formatting string to produce custom
83
- human-friendly printers and parsers for arguments associated with the clause.
84
- It will be combined with assembly formats for other clauses depending on the
85
- ` isRequired ` template argument passed to the parent ` OpenMP_Clause ` class, as
86
- explained [ below] ( #adding-an-operation ) .
82
+ - ` string {req,opt}AssemblyFormat ` : Optional formatting strings to produce
83
+ custom human-friendly printers and parsers for arguments associated with the
84
+ clause. It will be combined with assembly formats for other clauses as explained
85
+ [ below] ( #adding-an-operation ) .
87
86
- ` string description ` : Optional description text to describe the clause and
88
87
its representation.
89
88
- ` string extraClassDeclaration ` : Optional C++ declarations to be added to
@@ -95,13 +94,13 @@ For example:
95
94
class OpenMP_ExampleClauseSkip<
96
95
bit traits = false, bit arguments = false, bit assemblyFormat = false,
97
96
bit description = false, bit extraClassDeclaration = false
98
- > : OpenMP_Clause</*isRequired=*/false, traits, arguments, assemblyFormat,
99
- description, extraClassDeclaration> {
97
+ > : OpenMP_Clause<traits, arguments, assemblyFormat, description ,
98
+ extraClassDeclaration> {
100
99
let arguments = (ins
101
100
Optional<AnyType>:$example_var
102
101
);
103
102
104
- let assemblyFormat = [{
103
+ let optAssemblyFormat = [{
105
104
`example` `(` $example_var `:` type($example_var) `)`
106
105
}];
107
106
@@ -156,9 +155,13 @@ def ExampleOp : OpenMP_Op<"example", traits = [
156
155
This is possible because the ` arguments ` , ` assemblyFormat ` and
157
156
` extraClassDeclaration ` properties of the operation are by default
158
157
populated by concatenating the corresponding properties of the clauses on the
159
- list. In the case of the ` assemblyFormat ` , this also involves splitting the
160
- format strings for required clauses from the ones for optional clauses. The
161
- latter are wrapped in an ` oilist() ` and interleaved with "|" instead of spaces.
158
+ list. In the case of the ` assemblyFormat ` , this involves combining the
159
+ ` reqAssemblyFormat ` and the ` optAssemblyFormat ` properties. The
160
+ ` reqAssemblyFormat ` of all clauses is concatenated first and separated using
161
+ spaces, whereas the ` optAssemblyFormat ` is wrapped in an ` oilist() ` and
162
+ interleaved with "|" instead of spaces. The resulting ` assemblyFormat ` contains
163
+ the required assembly format strings, followed by the optional assembly format
164
+ strings, optionally the ` $region ` and the ` attr-dict ` .
162
165
163
166
### Overriding Clause-Inherited Properties
164
167
@@ -178,7 +181,8 @@ a clause-populated operation property. Instead of overriding the property in the
178
181
definition of the operation and having to manually replicate what would
179
182
otherwise be automatically populated before adding to it, some internal
180
183
properties are defined to hold this default value: ` clausesArgs ` ,
181
- ` clausesAssemblyFormat ` and ` clausesExtraClassDeclaration ` .
184
+ ` clausesAssemblyFormat ` , ` clauses{Req,Opt}AssemblyFormat ` and
185
+ ` clausesExtraClassDeclaration ` .
182
186
183
187
In the following example, assuming both the ` OpenMP_InReductionClause ` and the
184
188
` OpenMP_ReductionClause ` define a ` getReductionVars ` extra class declaration,
0 commit comments