1 // RUN: mlir-tblgen -gen-dialect-doc -I %S/../../include -dialect=test %s | FileCheck %s
2 // RUN: mlir-tblgen -gen-dialect-doc -I %S/../../include -dialect=test_toc %s | FileCheck %s --check-prefix=CHECK_TOC
4 include "mlir/IR/OpBase.td"
5 include "mlir/IR/AttrTypeBase.td"
6 include "mlir/IR/EnumAttr.td"
7 include "mlir/Interfaces/SideEffectInterfaces.td"
9 def Test_Dialect : Dialect {
11 let summary = "Dialect of ops to test";
13 Dialect without a [TOC] here.
16 let cppNamespace = "NS";
19 def OpGroupA : OpDocGroup {
20 let summary = "Group of ops";
21 let description = "Grouped for some reason.";
24 let opDocGroup = OpGroupA in {
25 def ADOp : Op<Test_Dialect, "d", [NoMemoryEffect, SingleBlockImplicitTerminator<"YieldOp">]>;
26 def AAOp : Op<Test_Dialect, "a", [NoMemoryEffect, SingleBlockImplicitTerminator<"YieldOp">]>;
29 def OpGroupB : OpDocGroup {
30 let summary = "Other group of ops";
31 let description = "Grouped for some other reason.";
34 let opDocGroup = OpGroupB in {
35 def ACOp : Op<Test_Dialect, "c", [NoMemoryEffect, SingleBlockImplicitTerminator<"YieldOp">]>;
36 def ABOp : Op<Test_Dialect, "b", [NoMemoryEffect, SingleBlockImplicitTerminator<"YieldOp">]>;
39 def AEOp : Op<Test_Dialect, "e", [NoMemoryEffect, SingleBlockImplicitTerminator<"YieldOp">]>;
41 def TestAttr : DialectAttr<Test_Dialect, CPred<"true">> {
42 let summary = "attribute summary";
43 let description = "attribute description";
46 def TestType : DialectType<Test_Dialect, CPred<"true">> {
47 let summary = "type summary";
48 let description = "type description";
51 def TestAttrDef : AttrDef<Test_Dialect, "TestAttrDef"> {
52 let mnemonic = "test_attr_def";
55 def TestAttrDefParams : AttrDef<Test_Dialect, "TestAttrDefParams"> {
56 let mnemonic = "test_attr_def_params";
57 let parameters = (ins "int":$value);
59 let assemblyFormat = "`<` $value `>`";
62 def TestTypeDef : TypeDef<Test_Dialect, "TestTypeDef"> {
63 let mnemonic = "test_type_def";
66 def TestTypeDefParams : TypeDef<Test_Dialect, "TestTypeDefParams"> {
67 let mnemonic = "test_type_def_params";
68 let parameters = (ins "int":$value);
70 let assemblyFormat = "`<` $value `>`";
74 I32EnumAttr<"TestEnum",
76 I32EnumAttrCase<"First", 0, "first">,
77 I32EnumAttrCase<"Second", 1, "second">,
78 I32EnumAttrCase<"Third", 2, "third">]> {
79 let genSpecializedAttr = 1;
80 let cppNamespace = "NS";
83 // CHECK: Dialect without a [TOC] here.
84 // CHECK: TOC added by tool.
89 // CHECK: Group of ops
95 // CHECK: Traits: `SingleBlockImplicitTerminator<YieldOp>`, `SingleBlock`
96 // CHECK: Interfaces: `NoMemoryEffect (MemoryEffectOpInterface)`
97 // CHECK: Effects: `MemoryEffects::Effect{}`
99 // CHECK: ## Attribute constraints
100 // CHECK: ### attribute summary
101 // CHECK: attribute description
103 // CHECK: TestAttrDefAttr
105 // CHECK: #test.test_attr_def
107 // CHECK: TestAttrDefParamsAttr
109 // CHECK: #test.test_attr_def_params
111 // CHECK: ## Type constraints
112 // CHECK: ### type summary
113 // CHECK: type description
115 // CHECK: TestTypeDefType
117 // CHECK: !test.test_type_def
119 // CHECK: TestTypeDefParamsType
121 // CHECK: !test.test_type_def_params
124 // CHECK: ### TestEnum
125 // CHECK: enum summary
126 // CHECK: #### Cases:
127 // CHECK: | Symbol | Value | String |
128 // CHECK: | :----: | :---: | ------ |
129 // CHECK: | First | `0` | first |
130 // CHECK: | Second | `1` | second |
131 // CHECK: | Third | `2` | third |
133 def Toc_Dialect : Dialect {
134 let name = "test_toc";
135 let summary = "Dialect of ops to test";
143 let cppNamespace = "NS";
145 def BOp : Op<Toc_Dialect, "b", []>;
147 // CHECK_TOC: Dialect with