1 // Tablegen tests for the automatic generation of OpenMP clause operand
2 // structure definitions.
4 // Run tablegen to generate OmpCommon.td in temp directory first.
5 // RUN: mkdir -p %t/mlir/Dialect/OpenMP
6 // RUN: mlir-tblgen --gen-directive-decl --directives-dialect=OpenMP \
7 // RUN: %S/../../../llvm/include/llvm/Frontend/OpenMP/OMP.td \
8 // RUN: -I %S/../../../llvm/include > %t/mlir/Dialect/OpenMP/OmpCommon.td
10 // RUN: mlir-tblgen -gen-openmp-clause-ops -I %S/../../include -I %t %s 2>&1 | FileCheck %s
12 include "mlir/Dialect/OpenMP/OpenMPOpBase.td"
15 def OpenMP_MyFirstClause : OpenMP_Clause<
16 /*skipTraits=*/false, /*skipArguments=*/false, /*skipAssemblyFormat=*/false,
17 /*skipDescription=*/false, /*skipExtraClassDeclaration=*/false> {
22 DeclareTargetAttr:$omp_attr,
25 F32ArrayAttr:$float_array_attr,
26 StrArrayAttr:$str_array_attr,
27 AnyIntElementsAttr:$anyint_elems_attr,
28 RankedF32ElementsAttr<[3, 4, 5]>:$float_nd_elems_attr,
30 // Optional attributes
31 OptionalAttr<BoolAttr>:$opt_bool_attr,
32 OptionalAttr<I64ArrayAttr>:$opt_int_array_attr,
33 OptionalAttr<DenseI8ArrayAttr>:$opt_int_elems_attr,
35 // Multi-level composition
36 ConfinedAttr<OptionalAttr<I64Attr>, [IntMinValue<0>]>:$complex_opt_int_attr,
38 // ElementsAttrBase-related edge cases.
39 // CHECK: warning: could not infer array-like attribute element type for argument 'elements_attr', will use bare `storageType`
40 ElementsAttr:$elements_attr,
41 // CHECK: warning: could not infer array-like attribute element type for argument 'string_elements_attr', will use bare `storageType`
42 StringElementsAttr:$string_elements_attr
45 // CHECK: struct MyFirstClauseOps {
46 // CHECK-NEXT: ::mlir::IntegerAttr intAttr;
47 // CHECK-NEXT: ::mlir::TypeAttr typeAttr;
48 // CHECK-NEXT: ::mlir::omp::DeclareTargetAttr ompAttr;
50 // CHECK-NEXT: ::llvm::SmallVector<::mlir::Attribute> floatArrayAttr;
51 // CHECK-NEXT: ::llvm::SmallVector<::mlir::Attribute> strArrayAttr;
52 // CHECK-NEXT: ::llvm::SmallVector<::llvm::APInt> anyintElemsAttr;
53 // CHECK-NEXT: ::llvm::SmallVector<::llvm::APFloat> floatNdElemsAttr;
55 // CHECK-NEXT: ::mlir::BoolAttr optBoolAttr;
56 // CHECK-NEXT: ::llvm::SmallVector<::mlir::Attribute> optIntArrayAttr;
57 // CHECK-NEXT: ::llvm::SmallVector<int8_t> optIntElemsAttr;
59 // CHECK-NEXT: ::mlir::IntegerAttr complexOptIntAttr;
61 // CHECK-NEXT: ::mlir::ElementsAttr elementsAttr;
62 // CHECK-NEXT: ::mlir::DenseElementsAttr stringElementsAttr;
65 def OpenMP_MySecondClause : OpenMP_Clause<
66 /*skipTraits=*/false, /*skipArguments=*/false, /*skipAssemblyFormat=*/false,
67 /*skipDescription=*/false, /*skipExtraClassDeclaration=*/false> {
70 Optional<AnyType>:$opt_any_val,
71 Variadic<Index>:$variadic_index_val
74 // CHECK: struct MySecondClauseOps {
75 // CHECK-NEXT: ::mlir::Value intVal;
76 // CHECK-NEXT: ::mlir::Value optAnyVal;
77 // CHECK-NEXT: ::llvm::SmallVector<::mlir::Value> variadicIndexVal;
80 def OpenMP_MyFirstOp : OpenMP_Op<"op", clauses=[OpenMP_MyFirstClause]>;
81 // CHECK: using MyFirstOperands = detail::Clauses<MyFirstClauseOps>;
83 def OpenMP_MySecondOp : OpenMP_Op<"op", clauses=[OpenMP_MyFirstClause, OpenMP_MySecondClause]>;
84 // CHECK: using MySecondOperands = detail::Clauses<MyFirstClauseOps, MySecondClauseOps>;