1 // Tablegen tests for the automatic population of OpenMP dialect operation
2 // fields from clauses. Arguments and extra class declarations are checked from
3 // the output of tablegen declarations. Summary, description, assembly format
4 // and traits are checked from the output of tablegen docs.
6 // Run tablegen to generate OmpCommon.td in temp directory first.
7 // RUN: mkdir -p %t/mlir/Dialect/OpenMP
8 // RUN: mlir-tblgen --gen-directive-decl --directives-dialect=OpenMP \
9 // RUN: %S/../../../llvm/include/llvm/Frontend/OpenMP/OMP.td \
10 // RUN: -I %S/../../../llvm/include > %t/mlir/Dialect/OpenMP/OmpCommon.td
12 // RUN: mlir-tblgen -gen-op-decls -I %S/../../include -I %t %s | FileCheck %s --check-prefix=DECL
13 // RUN: mlir-tblgen -gen-op-doc -I %S/../../include -I %t %s | FileCheck %s --check-prefix=DOC
15 include "mlir/Dialect/OpenMP/OpenMPOpBase.td"
19 def TraitOne : NativeOpTrait<"TraitOne">;
20 def TraitTwo : NativeOpTrait<"TraitTwo">;
21 def TraitThree : NativeOpTrait<"TraitThree">;
26 bit traits = false, bit arguments = false, bit assemblyFormat = false,
27 bit description = false, bit extraClassDeclaration = false
28 > : OpenMP_Clause<traits, arguments, assemblyFormat, description,
29 extraClassDeclaration> {
35 Optional<AnyInteger>:$opt_simple_val
38 let optAssemblyFormat = [{
39 `optsimple` `(` $opt_simple_val `:` type($opt_simple_val) `)`
43 Optional clause description.
46 let extraClassDeclaration = [{
47 void optClauseExtraClassDecl();
51 def OptClause : OptClauseSkip<>;
53 def OptClauseTwo : OpenMP_Clause<
54 /*skipTraits=*/false, /*skipArguments=*/false, /*skipAssemblyFormat=*/false,
55 /*skipDescription=*/false, /*skipExtraClassDeclaration=*/false> {
61 Optional<AnyInteger>:$opt_two_val
64 let optAssemblyFormat = [{
65 `opt_two` `(` $opt_two_val `:` type($opt_two_val) `)`
69 Optional clause two description.
72 let extraClassDeclaration = [{
73 void optClauseTwoExtraClassDecl();
78 bit traits = false, bit arguments = false, bit assemblyFormat = false,
79 bit description = false, bit extraClassDeclaration = false
80 > : OpenMP_Clause<traits, arguments, assemblyFormat, description,
81 extraClassDeclaration> {
87 AnyInteger:$req_simple_val
90 let reqAssemblyFormat = [{
91 `reqsimple` `(` $req_simple_val `:` type($req_simple_val) `)`
95 Required clause description.
98 let extraClassDeclaration = [{
99 void reqClauseExtraClassDecl();
103 def ReqClause : ReqClauseSkip<>;
105 def ReqClauseTwo : OpenMP_Clause<
106 /*skipTraits=*/false, /*skipArguments=*/false, /*skipAssemblyFormat=*/false,
107 /*skipDescription=*/false, /*skipExtraClassDeclaration=*/false> {
113 AnyInteger:$req_two_val
116 let reqAssemblyFormat = [{
117 `req_two` `(` $req_two_val `:` type($req_two_val) `)`
121 Required clause two description.
124 let extraClassDeclaration = [{
125 void reqClauseTwoExtraClassDecl();
129 // Clause-based operation definitions.
131 def OpAddArguments : OpenMP_Op<"op_add_arguments",
132 traits=[AttrSizedOperandSegments], clauses=[ReqClause, OptClause]> {
133 let summary = "operation with clauses - arguments added";
135 Description of operation with clauses - arguments added.
136 }] # clausesDescription;
137 let arguments = !con(clausesArgs, (ins Optional<AnyInteger>:$opt_added,
138 AnyInteger:$req_added));
139 let assemblyFormat = clausesReqAssemblyFormat #
140 "`req_added` `(` $req_added `:` type($req_added) `)` oilist(" #
141 clausesOptAssemblyFormat #
142 "|`opt_added` `(` $opt_added `:` type($opt_added) `)`) attr-dict";
145 // DECL-LABEL: class OpAddArguments : public ::mlir::Op<
146 // DECL: getReqSimpleVal() {
147 // DECL: getOptSimpleVal() {
148 // DECL: void reqClauseExtraClassDecl();
149 // DECL: void optClauseExtraClassDecl();
151 // DOC-LABEL: omp::OpAddArguments
152 // DOC: _Operation with clauses - arguments added_
153 // DOC: operation ::= `omp.op_add_arguments`
154 // DOC: `reqsimple` `(` $req_simple_val `:` type($req_simple_val) `)`
155 // DOC: `req_added` `(` $req_added `:` type($req_added) `)`
157 // DOC: `optsimple` `(` $opt_simple_val `:` type($opt_simple_val) `)`
158 // DOC: |`opt_added` `(` $opt_added `:` type($opt_added) `)`
161 // DOC: Description of operation with clauses - arguments added.
162 // DOC: Required clause description.
163 // DOC: Optional clause description.
164 // DOC: Traits: `AttrSizedOperandSegments`, `TraitOne`, `TraitTwo`
166 def OpOptClause : OpenMP_Op<"op_with_opt",
167 traits=[TraitThree], clauses=[OptClause]> {
168 let summary = "operation with optional clause";
170 Description of operation with optional clause.
171 }] # clausesDescription;
174 // DECL-LABEL: class OpOptClause : public ::mlir::Op<
175 // DECL: getOptSimpleVal() {
176 // DECL: void optClauseExtraClassDecl();
178 // DOC-LABEL: omp::OpOptClause
179 // DOC: _Operation with optional clause_
180 // DOC: operation ::= `omp.op_with_opt`
182 // DOC: `optsimple` `(` $opt_simple_val `:` type($opt_simple_val) `)`
185 // DOC: Description of operation with optional clause.
186 // DOC: Optional clause description.
187 // DOC: Traits: `TraitOne`, `TraitThree`
189 def OpReqClause : OpenMP_Op<"op_with_req",
190 traits=[TraitThree], clauses=[ReqClause]> {
191 let summary = "operation with required clause";
193 Description of operation with required clause.
194 }] # clausesDescription;
197 // DECL-LABEL: class OpReqClause : public ::mlir::Op<
198 // DECL: getReqSimpleVal() {
199 // DECL: void reqClauseExtraClassDecl();
201 // DOC-LABEL: omp::OpReqClause
202 // DOC: _Operation with required clause_
203 // DOC: operation ::= `omp.op_with_req`
205 // DOC: `reqsimple` `(` $req_simple_val `:` type($req_simple_val) `)`
208 // DOC: Description of operation with required clause.
209 // DOC: Required clause description.
210 // DOC: Traits: `TraitThree`, `TraitTwo`
212 def OpReqOptClause : OpenMP_Op<"op_with_req_and_opt",
213 traits=[TraitThree], clauses=[ReqClause, OptClause]> {
214 let summary = "operation with required and optional clauses";
216 Description of operation with required and optional clauses.
217 }] # clausesDescription;
220 // DECL-LABEL: class OpReqOptClause : public ::mlir::Op<
221 // DECL: getReqSimpleVal() {
222 // DECL: getOptSimpleVal() {
223 // DECL: void reqClauseExtraClassDecl();
224 // DECL: void optClauseExtraClassDecl();
226 // DOC-LABEL: omp::OpReqOptClause
227 // DOC: _Operation with required and optional clauses_
228 // DOC: operation ::= `omp.op_with_req_and_opt`
229 // DOC: `reqsimple` `(` $req_simple_val `:` type($req_simple_val) `)`
231 // DOC: `optsimple` `(` $opt_simple_val `:` type($opt_simple_val) `)`
234 // DOC: Description of operation with required and optional clauses.
235 // DOC: Required clause description.
236 // DOC: Optional clause description.
237 // DOC: Traits: `TraitOne`, `TraitThree`, `TraitTwo`
239 def OpSingleRegion : OpenMP_Op<"op_single_region",
240 clauses=[OptClause], singleRegion=true> {
241 let summary = "operation with a single region";
243 Description of operation with a single region.
244 }] # clausesDescription;
247 // DECL-LABEL: class OpSingleRegion : public ::mlir::Op<
248 // DECL: getOptSimpleVal() {
249 // DECL: getRegion() {
250 // DECL: void optClauseExtraClassDecl();
252 // DOC-LABEL: omp::OpSingleRegion
253 // DOC: _Operation with a single region_
254 // DOC: operation ::= `omp.op_single_region`
256 // DOC: `optsimple` `(` $opt_simple_val `:` type($opt_simple_val) `)`
257 // DOC: ) $region attr-dict
258 // DOC: Description of operation with a single region.
259 // DOC: Optional clause description.
260 // DOC: Traits: `TraitOne`
262 def OpSkipArguments : OpenMP_Op<"op_skip_arguments",
263 traits=[TraitThree], clauses=[OptClauseSkip<arguments=true>]> {
264 let summary = "operation with clause - arguments skipped";
266 Description of operation with clause - arguments skipped.
267 }] # clausesDescription;
268 let arguments = !con(clausesArgs, (ins Optional<AnyInteger>:$opt_simple_val));
271 // DECL-LABEL: class OpSkipArguments : public ::mlir::Op<
272 // DECL: getOptSimpleVal() {
273 // DECL: void optClauseExtraClassDecl();
275 // DOC-LABEL: omp::OpSkipArguments
276 // DOC: _Operation with clause - arguments skipped_
277 // DOC: operation ::= `omp.op_skip_arguments`
279 // DOC: `optsimple` `(` $opt_simple_val `:` type($opt_simple_val) `)`
282 // DOC: Description of operation with clause - arguments skipped.
283 // DOC: Optional clause description.
284 // DOC: Traits: `TraitOne`, `TraitThree`
286 def OpSkipAssemblyFormat : OpenMP_Op<"op_skip_assembly_format",
287 traits=[TraitThree], clauses=[ReqClauseSkip<assemblyFormat=true>,
289 let summary = "operation with clauses - assemblyFormat skipped";
291 Description of operation with clauses - assemblyFormat skipped.
292 }] # clausesDescription;
293 let assemblyFormat = [{
294 `alt_assembly_format` `(` $req_simple_val `:` type($req_simple_val) `)`
295 }] # clausesAssemblyFormat # "attr-dict";
298 // DECL-LABEL: class OpSkipAssemblyFormat : public ::mlir::Op<
299 // DECL: getReqSimpleVal() {
300 // DECL: getOptSimpleVal() {
301 // DECL: void reqClauseExtraClassDecl();
302 // DECL: void optClauseExtraClassDecl();
304 // DOC-LABEL: omp::OpSkipAssemblyFormat
305 // DOC: _Operation with clauses - assemblyFormat skipped_
306 // DOC: operation ::= `omp.op_skip_assembly_format`
307 // DOC: `alt_assembly_format` `(` $req_simple_val `:` type($req_simple_val) `)`
309 // DOC: `optsimple` `(` $opt_simple_val `:` type($opt_simple_val) `)`
312 // DOC: Description of operation with clauses - assemblyFormat skipped.
313 // DOC: Required clause description.
314 // DOC: Optional clause description.
315 // DOC: Traits: `TraitOne`, `TraitThree`
317 def OpSkipDescription : OpenMP_Op<"op_skip_description",
318 traits=[TraitThree], clauses=[OptClauseSkip<description=true>]> {
319 let summary = "operation with clause - description skipped";
321 Description of operation with clause - description skipped.
322 }] # clausesDescription;
325 // DECL-LABEL: class OpSkipDescription : public ::mlir::Op<
326 // DECL: getOptSimpleVal() {
327 // DECL: void optClauseExtraClassDecl();
329 // DOC-LABEL: omp::OpSkipDescription
330 // DOC: _Operation with clause - description skipped_
331 // DOC: operation ::= `omp.op_skip_description`
333 // DOC: `optsimple` `(` $opt_simple_val `:` type($opt_simple_val) `)`
336 // DOC: Description of operation with clause - description skipped.
337 // DOC-NOT: Optional clause description.
338 // DOC: Traits: `TraitOne`, `TraitThree`
340 def OpSkipExtraClassDeclaration : OpenMP_Op<"op_skip_extra_class_declaration",
341 traits=[TraitThree], clauses=[OptClauseSkip<extraClassDeclaration=true>]> {
342 let summary = "operation with clause - extraClassDeclaration skipped";
344 Description of operation with clause - extraClassDeclaration skipped.
345 }] # clausesDescription;
348 // DECL-LABEL: class OpSkipExtraClassDeclaration : public ::mlir::Op<
349 // DECL: getOptSimpleVal() {
350 // DECL-NOT: void optClauseExtraClassDecl();
352 // DOC-LABEL: omp::OpSkipExtraClassDeclaration
353 // DOC: _Operation with clause - extraClassDeclaration skipped_
354 // DOC: operation ::= `omp.op_skip_extra_class_declaration`
356 // DOC: `optsimple` `(` $opt_simple_val `:` type($opt_simple_val) `)`
359 // DOC: Description of operation with clause - extraClassDeclaration skipped.
360 // DOC: Optional clause description.
361 // DOC: Traits: `TraitOne`, `TraitThree`
363 def OpSkipTraits : OpenMP_Op<"op_skip_traits",
364 traits=[TraitThree], clauses=[OptClauseSkip<traits=true>]> {
365 let summary = "operation with clause - traits skipped";
367 Description of operation with clause - traits skipped.
368 }] # clausesDescription;
371 // DECL-LABEL: class OpSkipTraits : public ::mlir::Op<
372 // DECL: getOptSimpleVal() {
373 // DECL: void optClauseExtraClassDecl();
375 // DOC-LABEL: omp::OpSkipTraits
376 // DOC: _Operation with clause - traits skipped_
377 // DOC: operation ::= `omp.op_skip_traits`
379 // DOC: `optsimple` `(` $opt_simple_val `:` type($opt_simple_val) `)`
382 // DOC: Description of operation with clause - traits skipped.
383 // DOC: Optional clause description.
384 // DOC: Traits: `TraitThree`
386 def OpTwoOptionalClauses : OpenMP_Op<"op_two_opt_clauses",
387 traits=[AttrSizedOperandSegments], clauses=[OptClause, OptClauseTwo]> {
388 let summary = "operation with two optional clauses";
390 Description of operation with two optional clauses.
391 }] # clausesDescription;
394 // DECL-LABEL: class OpTwoOptionalClauses : public ::mlir::Op<
395 // DECL: getOptSimpleVal() {
396 // DECL: getOptTwoVal() {
397 // DECL: void optClauseExtraClassDecl();
398 // DECL: void optClauseTwoExtraClassDecl();
400 // DOC-LABEL: omp::OpTwoOptionalClauses
401 // DOC: _Operation with two optional clauses_
402 // DOC: operation ::= `omp.op_two_opt_clauses`
404 // DOC: `optsimple` `(` $opt_simple_val `:` type($opt_simple_val) `)`
406 // DOC: `opt_two` `(` $opt_two_val `:` type($opt_two_val) `)`
409 // DOC: Description of operation with two optional clauses.
410 // DOC: Optional clause description.
411 // DOC: Optional clause two description.
412 // DOC: Traits: `AttrSizedOperandSegments`, `TraitOne`, `TraitTwo`
414 def OpTwoRequiredClauses : OpenMP_Op<"op_two_req_clauses",
415 clauses=[ReqClause, ReqClauseTwo]> {
416 let summary = "operation with two required clauses";
418 Description of operation with two required clauses.
419 }] # clausesDescription;
422 // DECL-LABEL: class OpTwoRequiredClauses : public ::mlir::Op<
423 // DECL: getReqSimpleVal() {
424 // DECL: getReqTwoVal() {
425 // DECL: void reqClauseExtraClassDecl();
426 // DECL: void reqClauseTwoExtraClassDecl();
428 // DOC-LABEL: omp::OpTwoRequiredClauses
429 // DOC: _Operation with two required clauses_
430 // DOC: operation ::= `omp.op_two_req_clauses`
432 // DOC: `reqsimple` `(` $req_simple_val `:` type($req_simple_val) `)`
434 // DOC: `req_two` `(` $req_two_val `:` type($req_two_val) `)`
437 // DOC: Description of operation with two required clauses.
438 // DOC: Required clause description.
439 // DOC: Required clause two description.
440 // DOC: Traits: `TraitThree`, `TraitTwo`
442 def OpZeroClauses : OpenMP_Op<"op_zero_clauses"> {
443 let summary = "operation with no clauses";
445 Description of operation with no clauses.
446 }] # clausesDescription;
449 // DECL-LABEL: class OpZeroClauses : public ::mlir::Op<
450 // DECL: static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState);
452 // DOC-LABEL: omp::OpZeroClauses
453 // DOC: _Operation with no clauses_
454 // DOC-NOT: operation ::=
455 // DOC: Description of operation with no clauses.