brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.4 KiB · 3e5896a Raw
85 lines · plain
1// Tablegen tests for the automatic generation of OpenMP clause operand2// structure definitions.3 4// Run tablegen to generate OmpCommon.td in temp directory first.5// RUN: mkdir -p %t/mlir/Dialect/OpenMP6// 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.td9 10// RUN: mlir-tblgen -gen-openmp-clause-ops -I %S/../../include -I %t %s 2>&1 | FileCheck %s11 12include "mlir/Dialect/OpenMP/OpenMPOpBase.td"13 14 15def OpenMP_MyFirstClause : OpenMP_Clause<16    /*skipTraits=*/false, /*skipArguments=*/false, /*skipAssemblyFormat=*/false,17    /*skipDescription=*/false, /*skipExtraClassDeclaration=*/false> {18  let arguments = (ins19    // Simple attributes20    I32Attr:$int_attr,21    TypeAttr:$type_attr,22    DeclareTargetAttr:$omp_attr,23 24    // Array attributes25    F32ArrayAttr:$float_array_attr,26    StrArrayAttr:$str_array_attr,27    AnyIntElementsAttr:$anyint_elems_attr,28    RankedF32ElementsAttr<[3, 4, 5]>:$float_nd_elems_attr,29 30    // Optional attributes31    OptionalAttr<BoolAttr>:$opt_bool_attr,32    OptionalAttr<I64ArrayAttr>:$opt_int_array_attr,33    OptionalAttr<DenseI8ArrayAttr>:$opt_int_elems_attr,34 35    // Multi-level composition36    ConfinedAttr<OptionalAttr<I64Attr>, [IntMinValue<0>]>:$complex_opt_int_attr,37 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_attr43  );44}45// CHECK:      struct MyFirstClauseOps {46// CHECK-NEXT:   ::mlir::IntegerAttr intAttr;47// CHECK-NEXT:   ::mlir::TypeAttr typeAttr;48// CHECK-NEXT:   ::mlir::omp::DeclareTargetAttr ompAttr;49 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;54 55// CHECK-NEXT:   ::mlir::BoolAttr optBoolAttr;56// CHECK-NEXT:   ::llvm::SmallVector<::mlir::Attribute> optIntArrayAttr;57// CHECK-NEXT:   ::llvm::SmallVector<int8_t> optIntElemsAttr;58 59// CHECK-NEXT:   ::mlir::IntegerAttr complexOptIntAttr;60 61// CHECK-NEXT:   ::mlir::ElementsAttr elementsAttr;62// CHECK-NEXT:   ::mlir::DenseElementsAttr stringElementsAttr;63// CHECK-NEXT: }64 65def OpenMP_MySecondClause : OpenMP_Clause<66    /*skipTraits=*/false, /*skipArguments=*/false, /*skipAssemblyFormat=*/false,67    /*skipDescription=*/false, /*skipExtraClassDeclaration=*/false> {68  let arguments = (ins69    I32:$int_val,70    Optional<AnyType>:$opt_any_val,71    Variadic<Index>:$variadic_index_val72  );73}74// CHECK:      struct MySecondClauseOps {75// CHECK-NEXT:   ::mlir::Value intVal;76// CHECK-NEXT:   ::mlir::Value optAnyVal;77// CHECK-NEXT:   ::llvm::SmallVector<::mlir::Value> variadicIndexVal;78// CHECK-NEXT: }79 80def OpenMP_MyFirstOp : OpenMP_Op<"op", clauses=[OpenMP_MyFirstClause]>;81// CHECK: using MyFirstOperands = detail::Clauses<MyFirstClauseOps>;82 83def OpenMP_MySecondOp : OpenMP_Op<"op", clauses=[OpenMP_MyFirstClause, OpenMP_MySecondClause]>;84// CHECK: using MySecondOperands = detail::Clauses<MyFirstClauseOps, MySecondClauseOps>;85