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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
|
//===- TestFormatUtils.h - MLIR Test Dialect Assembly Format Utilities ----===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#ifndef MLIR_TESTFORMATUTILS_H
#define MLIR_TESTFORMATUTILS_H
#include "mlir/IR/OpImplementation.h"
namespace test {
//===----------------------------------------------------------------------===//
// CustomDirectiveOperands
//===----------------------------------------------------------------------===//
mlir::ParseResult parseCustomDirectiveOperands(
mlir::OpAsmParser &parser, mlir::OpAsmParser::UnresolvedOperand &operand,
std::optional<mlir::OpAsmParser::UnresolvedOperand> &optOperand,
llvm::SmallVectorImpl<mlir::OpAsmParser::UnresolvedOperand> &varOperands);
void printCustomDirectiveOperands(mlir::OpAsmPrinter &printer,
mlir::Operation *, mlir::Value operand,
mlir::Value optOperand,
mlir::OperandRange varOperands);
//===----------------------------------------------------------------------===//
// CustomDirectiveResults
//===----------------------------------------------------------------------===//
mlir::ParseResult
parseCustomDirectiveResults(mlir::OpAsmParser &parser, mlir::Type &operandType,
mlir::Type &optOperandType,
llvm::SmallVectorImpl<mlir::Type> &varOperandTypes);
void printCustomDirectiveResults(mlir::OpAsmPrinter &printer, mlir::Operation *,
mlir::Type operandType,
mlir::Type optOperandType,
mlir::TypeRange varOperandTypes);
//===----------------------------------------------------------------------===//
// CustomDirectiveWithTypeRefs
//===----------------------------------------------------------------------===//
mlir::ParseResult parseCustomDirectiveWithTypeRefs(
mlir::OpAsmParser &parser, mlir::Type operandType,
mlir::Type optOperandType,
const llvm::SmallVectorImpl<mlir::Type> &varOperandTypes);
void printCustomDirectiveWithTypeRefs(mlir::OpAsmPrinter &printer,
mlir::Operation *op,
mlir::Type operandType,
mlir::Type optOperandType,
mlir::TypeRange varOperandTypes);
//===----------------------------------------------------------------------===//
// CustomDirectiveOperandsAndTypes
//===----------------------------------------------------------------------===//
mlir::ParseResult parseCustomDirectiveOperandsAndTypes(
mlir::OpAsmParser &parser, mlir::OpAsmParser::UnresolvedOperand &operand,
std::optional<mlir::OpAsmParser::UnresolvedOperand> &optOperand,
llvm::SmallVectorImpl<mlir::OpAsmParser::UnresolvedOperand> &varOperands,
mlir::Type &operandType, mlir::Type &optOperandType,
llvm::SmallVectorImpl<mlir::Type> &varOperandTypes);
void printCustomDirectiveOperandsAndTypes(
mlir::OpAsmPrinter &printer, mlir::Operation *op, mlir::Value operand,
mlir::Value optOperand, mlir::OperandRange varOperands,
mlir::Type operandType, mlir::Type optOperandType,
mlir::TypeRange varOperandTypes);
//===----------------------------------------------------------------------===//
// CustomDirectiveRegions
//===----------------------------------------------------------------------===//
mlir::ParseResult parseCustomDirectiveRegions(
mlir::OpAsmParser &parser, mlir::Region ®ion,
llvm::SmallVectorImpl<std::unique_ptr<mlir::Region>> &varRegions);
void printCustomDirectiveRegions(
mlir::OpAsmPrinter &printer, mlir::Operation *, mlir::Region ®ion,
llvm::MutableArrayRef<mlir::Region> varRegions);
//===----------------------------------------------------------------------===//
// CustomDirectiveSuccessors
//===----------------------------------------------------------------------===//
mlir::ParseResult parseCustomDirectiveSuccessors(
mlir::OpAsmParser &parser, mlir::Block *&successor,
llvm::SmallVectorImpl<mlir::Block *> &varSuccessors);
void printCustomDirectiveSuccessors(mlir::OpAsmPrinter &printer,
mlir::Operation *, mlir::Block *successor,
mlir::SuccessorRange varSuccessors);
//===----------------------------------------------------------------------===//
// CustomDirectiveAttributes
//===----------------------------------------------------------------------===//
mlir::ParseResult parseCustomDirectiveAttributes(mlir::OpAsmParser &parser,
mlir::IntegerAttr &attr,
mlir::IntegerAttr &optAttr);
void printCustomDirectiveAttributes(mlir::OpAsmPrinter &printer,
mlir::Operation *,
mlir::Attribute attribute,
mlir::Attribute optAttribute);
//===----------------------------------------------------------------------===//
// CustomDirectiveAttrDict
//===----------------------------------------------------------------------===//
mlir::ParseResult parseCustomDirectiveAttrDict(mlir::OpAsmParser &parser,
mlir::NamedAttrList &attrs);
void printCustomDirectiveAttrDict(mlir::OpAsmPrinter &printer,
mlir::Operation *op,
mlir::DictionaryAttr attrs);
//===----------------------------------------------------------------------===//
// CustomDirectiveOptionalOperandRef
//===----------------------------------------------------------------------===//
mlir::ParseResult parseCustomDirectiveOptionalOperandRef(
mlir::OpAsmParser &parser,
std::optional<mlir::OpAsmParser::UnresolvedOperand> &optOperand);
void printCustomDirectiveOptionalOperandRef(mlir::OpAsmPrinter &printer,
mlir::Operation *op,
mlir::Value optOperand);
//===----------------------------------------------------------------------===//
// CustomDirectiveOptionalOperand
//===----------------------------------------------------------------------===//
mlir::ParseResult parseCustomOptionalOperand(
mlir::OpAsmParser &parser,
std::optional<mlir::OpAsmParser::UnresolvedOperand> &optOperand);
void printCustomOptionalOperand(mlir::OpAsmPrinter &printer, mlir::Operation *,
mlir::Value optOperand);
//===----------------------------------------------------------------------===//
// CustomDirectiveSwitchCases
//===----------------------------------------------------------------------===//
mlir::ParseResult parseSwitchCases(
mlir::OpAsmParser &p, mlir::DenseI64ArrayAttr &cases,
llvm::SmallVectorImpl<std::unique_ptr<mlir::Region>> &caseRegions);
void printSwitchCases(mlir::OpAsmPrinter &p, mlir::Operation *op,
mlir::DenseI64ArrayAttr cases,
mlir::RegionRange caseRegions);
//===----------------------------------------------------------------------===//
// CustomUsingPropertyInCustom
//===----------------------------------------------------------------------===//
bool parseUsingPropertyInCustom(mlir::OpAsmParser &parser,
llvm::SmallVector<int64_t> &value);
void printUsingPropertyInCustom(mlir::OpAsmPrinter &printer,
mlir::Operation *op,
llvm::ArrayRef<int64_t> value);
//===----------------------------------------------------------------------===//
// CustomDirectiveIntProperty
//===----------------------------------------------------------------------===//
bool parseIntProperty(mlir::OpAsmParser &parser, int64_t &value);
void printIntProperty(mlir::OpAsmPrinter &printer, mlir::Operation *op,
int64_t value);
//===----------------------------------------------------------------------===//
// CustomDirectiveSumProperty
//===----------------------------------------------------------------------===//
bool parseSumProperty(mlir::OpAsmParser &parser, int64_t &second,
int64_t first);
void printSumProperty(mlir::OpAsmPrinter &printer, mlir::Operation *op,
int64_t second, int64_t first);
//===----------------------------------------------------------------------===//
// CustomDirectiveOptionalCustomParser
//===----------------------------------------------------------------------===//
mlir::OptionalParseResult parseOptionalCustomParser(mlir::AsmParser &p,
mlir::IntegerAttr &result);
void printOptionalCustomParser(mlir::AsmPrinter &p, mlir::Operation *,
mlir::IntegerAttr result);
//===----------------------------------------------------------------------===//
// CustomDirectiveAttrElideType
//===----------------------------------------------------------------------===//
mlir::ParseResult parseAttrElideType(mlir::AsmParser &parser,
mlir::TypeAttr type,
mlir::Attribute &attr);
void printAttrElideType(mlir::AsmPrinter &printer, mlir::Operation *op,
mlir::TypeAttr type, mlir::Attribute attr);
//===----------------------------------------------------------------------===//
// CustomDirectiveDummyRegionRef
//===----------------------------------------------------------------------===//
mlir::ParseResult parseDummyRegionRef(mlir::OpAsmParser &parser,
mlir::Region ®ion);
void printDummyRegionRef(mlir::OpAsmPrinter &printer, mlir::Operation *op,
mlir::Region ®ion);
//===----------------------------------------------------------------------===//
// CustomDirectiveDummySuccessorRef
//===----------------------------------------------------------------------===//
mlir::ParseResult parseDummySuccessorRef(mlir::OpAsmParser &parser,
mlir::Block *successor);
void printDummySuccessorRef(mlir::OpAsmPrinter &printer, mlir::Operation *op,
mlir::Block *successor);
} // end namespace test
#endif // MLIR_TESTFORMATUTILS_H
|