llvm-project
128 строк · 3.3 Кб
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
3
4include "mlir/IR/OpBase.td"
5include "mlir/IR/AttrTypeBase.td"
6include "mlir/Interfaces/SideEffectInterfaces.td"
7
8def Test_Dialect : Dialect {
9let name = "test";
10let summary = "Dialect of ops to test";
11let description = [{
12Dialect without a [TOC] here.
13TOC added by tool.
14}];
15let cppNamespace = "NS";
16}
17
18def OpGroupA : OpDocGroup {
19let summary = "Group of ops";
20let description = "Grouped for some reason.";
21}
22
23let opDocGroup = OpGroupA in {
24def ADOp : Op<Test_Dialect, "d", [NoMemoryEffect, SingleBlockImplicitTerminator<"YieldOp">]>;
25def AAOp : Op<Test_Dialect, "a", [NoMemoryEffect, SingleBlockImplicitTerminator<"YieldOp">]>;
26}
27
28def OpGroupB : OpDocGroup {
29let summary = "Other group of ops";
30let description = "Grouped for some other reason.";
31}
32
33let opDocGroup = OpGroupB in {
34def ACOp : Op<Test_Dialect, "c", [NoMemoryEffect, SingleBlockImplicitTerminator<"YieldOp">]>;
35def ABOp : Op<Test_Dialect, "b", [NoMemoryEffect, SingleBlockImplicitTerminator<"YieldOp">]>;
36}
37
38def AEOp : Op<Test_Dialect, "e", [NoMemoryEffect, SingleBlockImplicitTerminator<"YieldOp">]>;
39
40def TestAttr : DialectAttr<Test_Dialect, CPred<"true">> {
41let summary = "attribute summary";
42let description = "attribute description";
43}
44
45def TestType : DialectType<Test_Dialect, CPred<"true">> {
46let summary = "type summary";
47let description = "type description";
48}
49
50def TestAttrDef : AttrDef<Test_Dialect, "TestAttrDef"> {
51let mnemonic = "test_attr_def";
52}
53
54def TestAttrDefParams : AttrDef<Test_Dialect, "TestAttrDefParams"> {
55let mnemonic = "test_attr_def_params";
56let parameters = (ins "int":$value);
57
58let assemblyFormat = "`<` $value `>`";
59}
60
61def TestTypeDef : TypeDef<Test_Dialect, "TestTypeDef"> {
62let mnemonic = "test_type_def";
63}
64
65def TestTypeDefParams : TypeDef<Test_Dialect, "TestTypeDefParams"> {
66let mnemonic = "test_type_def_params";
67let parameters = (ins "int":$value);
68
69let assemblyFormat = "`<` $value `>`";
70}
71
72// CHECK: Dialect without a [TOC] here.
73// CHECK: TOC added by tool.
74// CHECK: [TOC]
75
76// CHECK-NOT: [TOC]
77// CHECK: test.e
78// CHECK: Group of ops
79// CHECK: test.a
80// CHECK: test.d
81// CHECK: Other group
82// CHECK: test.b
83// CHECK: test.c
84// CHECK: Traits: `SingleBlockImplicitTerminator<YieldOp>`, `SingleBlock`
85// CHECK: Interfaces: `NoMemoryEffect (MemoryEffectOpInterface)`
86// CHECK: Effects: `MemoryEffects::Effect{}`
87
88// CHECK: ## Attribute constraints
89// CHECK: ### attribute summary
90// CHECK: attribute description
91
92// CHECK: TestAttrDefAttr
93// CHECK: Syntax:
94// CHECK: #test.test_attr_def
95
96// CHECK: TestAttrDefParamsAttr
97// CHECK: Syntax:
98// CHECK: #test.test_attr_def_params
99
100// CHECK: ## Type constraints
101// CHECK: ### type summary
102// CHECK: type description
103
104// CHECK: TestTypeDefType
105// CHECK: Syntax:
106// CHECK: !test.test_type_def
107
108// CHECK: TestTypeDefParamsType
109// CHECK: Syntax:
110// CHECK: !test.test_type_def_params
111
112def Toc_Dialect : Dialect {
113let name = "test_toc";
114let summary = "Dialect of ops to test";
115let description = [{
116Dialect with
117
118[TOC]
119
120here.
121}];
122let cppNamespace = "NS";
123}
124def BOp : Op<Toc_Dialect, "b", []>;
125
126// CHECK_TOC: Dialect with
127// CHECK_TOC: [TOC]
128// CHECK_TOC: here.
129