|
| 1 | +// RUN: mlir-tblgen -gen-dialect-decls -I %S/../../include %s | FileCheck %s --check-prefix=DIALECT |
| 2 | +// RUN: mlir-tblgen -gen-op-decls -I %S/../../include %s | FileCheck %s --check-prefix=OP |
| 3 | +// RUN: mlir-tblgen -gen-typedef-decls -I %S/../../include %s | FileCheck %s --check-prefix=TYPE |
| 4 | +// RUN: mlir-tblgen -gen-attrdef-decls -I %S/../../include %s | FileCheck %s --check-prefix=ATTR |
| 5 | +// RUN: mlir-tblgen -gen-attr-interface-decls -I %S/../../include %s | FileCheck %s --check-prefix=ATTR-INTERFACE |
| 6 | +// RUN: mlir-tblgen -gen-op-interface-decls -I %S/../../include %s | FileCheck %s --check-prefix=OP-INTERFACE |
| 7 | +// RUN: mlir-tblgen -gen-type-interface-decls -I %S/../../include %s | FileCheck %s --check-prefix=TYPE-INTERFACE |
| 8 | +// RUN: mlir-tblgen -gen-enum-decls -I %S/../../include %s | FileCheck %s --check-prefix=ENUM |
| 9 | + |
| 10 | +include "mlir/IR/AttrTypeBase.td" |
| 11 | +include "mlir/IR/EnumAttr.td" |
| 12 | +include "mlir/IR/OpBase.td" |
| 13 | + |
| 14 | +// check dialect with summary and description |
| 15 | +def A_Dialect : Dialect { |
| 16 | + let name = "a"; |
| 17 | + let cppNamespace = ""; |
| 18 | + |
| 19 | + let summary = "This is a summary"; |
| 20 | + let description = [{ |
| 21 | + |
| 22 | + This is a description, needs trimming |
| 23 | + |
| 24 | + }]; |
| 25 | +// DIALECT: /// This is a summary |
| 26 | +// DIALECT-NEXT: /// This is a description, needs trimming |
| 27 | +// DIALECT-NEXT: class ADialect : public ::mlir::Dialect { |
| 28 | +} |
| 29 | + |
| 30 | +def A_SomeOp1 : Op<A_Dialect, "some_op1", []>{ |
| 31 | + let summary = "Some Op1 summary line1 \nsummary line2"; |
| 32 | + |
| 33 | + let description = [{ |
| 34 | + Some Op1 description |
| 35 | + }]; |
| 36 | + |
| 37 | + let cppNamespace = "OP1"; |
| 38 | +// OP: namespace OP1 |
| 39 | +// OP-NEXT: /// Some Op1 summary line1 |
| 40 | +// OP-NEXT: /// summary line2 |
| 41 | +// OP-NEXT: /// Some Op1 description |
| 42 | +// OP-NEXT: class SomeOp1; |
| 43 | +} |
| 44 | + |
| 45 | +// test weird characters in description |
| 46 | +def A_SomeOp2 : Op<A_Dialect, "some_op2", []>{ |
| 47 | + let summary = ""; |
| 48 | + |
| 49 | + let description = [{ |
| 50 | + $ptr (`,` $mask^)? (`,` $other^)? |
| 51 | + oilist( |
| 52 | + `a` `=` $1 | `b` `=` $2 |
| 53 | + ) |
| 54 | + }]; |
| 55 | +// OP: /// $ptr (`,` $mask^)? (`,` $other^)? |
| 56 | +// OP-NEXT: /// oilist( |
| 57 | +// OP-NEXT: /// `a` `=` $1 | `b` `=` $2 |
| 58 | +// OP-NEXT: /// ) |
| 59 | +// OP-NEXT: class SomeOp2; |
| 60 | +} |
| 61 | + |
| 62 | +def A_TensorType : TypeDef<A_Dialect,"Tensor"> { |
| 63 | + let typeName = "a.simple_a_tensor"; |
| 64 | + |
| 65 | + let summary = "Tensor Type A summary"; |
| 66 | + |
| 67 | + let description = [{ |
| 68 | + Tensor Type A description |
| 69 | + }]; |
| 70 | + |
| 71 | + let extraClassDeclaration = [{ |
| 72 | + void getSignlessBlockType() const { |
| 73 | + } |
| 74 | + }]; |
| 75 | +// TYPE: /// Tensor Type A summary |
| 76 | +// TYPE-NEXT: /// Tensor Type A description |
| 77 | +// TYPE-NEXT: class TensorType; |
| 78 | +} |
| 79 | + |
| 80 | +def A_SimpleAttr : AttrDef<A_Dialect,"SimpleA"> { |
| 81 | + let attrName = "a.simple_attr"; |
| 82 | + let summary = "Simple Attr A summary"; |
| 83 | + |
| 84 | + let description = [{ |
| 85 | + Simple Attr A description |
| 86 | + }]; |
| 87 | +// ATTR: /// Simple Attr A summary |
| 88 | +// ATTR-NEXT: /// Simple Attr A description |
| 89 | +// ATTR-NEXT: class SimpleAAttr; |
| 90 | +} |
| 91 | + |
| 92 | +def EncodingTrait : AttrInterface<"EncodingTrait"> { |
| 93 | + let cppNamespace = "mlir::a::traits"; |
| 94 | + let description = [{ |
| 95 | + Common trait for all layouts. |
| 96 | + }]; |
| 97 | + let methods = [ |
| 98 | + ]; |
| 99 | +// ATTR-INTERFACE: namespace mlir |
| 100 | +// ATTR-INTERFACE-NEXT: namespace a |
| 101 | +// ATTR-INTERFACE-NEXT: namespace traits |
| 102 | +// ATTR-INTERFACE-NEXT: /// Common trait for all layouts. |
| 103 | +// ATTR-INTERFACE-NEXT: class EncodingTrait; |
| 104 | +} |
| 105 | + |
| 106 | +def SimpleEncodingTrait : AttrInterface<"SimpleEncodingTrait"> { |
| 107 | + let cppNamespace = "a::traits"; |
| 108 | +// ATTR-INTERFACE: namespace a { |
| 109 | +// ATTR-INTERFACE-NEXT: namespace traits { |
| 110 | +// ATTR-INTERFACE-NEXT: class SimpleEncodingTrait; |
| 111 | +} |
| 112 | + |
| 113 | +def SimpleOpInterface : OpInterface<"SimpleOpInterface"> { |
| 114 | + let cppNamespace = "a::traits"; |
| 115 | + let description = [{ |
| 116 | + |
| 117 | + Simple Op Interface description |
| 118 | + }]; |
| 119 | +// OP-INTERFACE: namespace a { |
| 120 | +// OP-INTERFACE-NEXT: namespace traits { |
| 121 | +// OP-INTERFACE-NEXT: /// Simple Op Interface description |
| 122 | +// OP-INTERFACE-NEXT: class SimpleOpInterface; |
| 123 | +} |
| 124 | + |
| 125 | +def SimpleTypeInterface : TypeInterface<"SimpleTypeInterface"> { |
| 126 | + let description = [{ |
| 127 | + Simple Type Interface description |
| 128 | + }]; |
| 129 | +// TYPE-INTERFACE: /// Simple Type Interface description |
| 130 | +// TYPE-INTERFACE-NEXT: class SimpleTypeInterface; |
| 131 | +} |
| 132 | + |
| 133 | +def MyBitEnum: I32BitEnumAttr<"MyBitEnum", "An example bit enum", |
| 134 | + [I32BitEnumCaseBit<"Bit0", 0, "tagged">, |
| 135 | + I32BitEnumCaseBit<"Bit1", 1>]> { |
| 136 | + let genSpecializedAttr = 0; |
| 137 | +// ENUM: // An example bit enum |
| 138 | +// ENUM-NEXT: enum class MyBitEnum |
| 139 | +} |
0 commit comments