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