LLZK 0.1.0
Veridise's ZK Language IR
Loading...
Searching...
No Matches
Ops.cpp.inc
Go to the documentation of this file.
1/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\
2|* *|
3|* Op Definitions *|
4|* *|
5|* Automatically generated file, do not edit! *|
6|* From: Ops.td *|
7|* *|
8\*===----------------------------------------------------------------------===*/
9
10#ifdef GET_OP_LIST
11#undef GET_OP_LIST
12
14#endif // GET_OP_LIST
15
16#ifdef GET_OP_CLASSES
17#undef GET_OP_CLASSES
18
19
20//===----------------------------------------------------------------------===//
21// Local Utility Method Definitions
22//===----------------------------------------------------------------------===//
23
24namespace llzk {
25namespace include {
26
27static ::mlir::LogicalResult __mlir_ods_local_attr_constraint_Ops0(
28 ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
29 if (attr && !((::llvm::isa<::mlir::StringAttr>(attr))))
30 return emitError() << "attribute '" << attrName
31 << "' failed to satisfy constraint: string attribute";
32 return ::mlir::success();
33}
34static ::mlir::LogicalResult __mlir_ods_local_attr_constraint_Ops0(
35 ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) {
36 return __mlir_ods_local_attr_constraint_Ops0(attr, attrName, [op]() {
37 return op->emitOpError();
38 });
39}
40} // namespace include
41} // namespace llzk
42namespace llzk {
43namespace include {
44
45//===----------------------------------------------------------------------===//
46// ::llzk::include::IncludeOp definitions
47//===----------------------------------------------------------------------===//
48
49namespace detail {
50IncludeOpGenericAdaptorBase::IncludeOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs)
51 odsOpName.emplace("include.from", odsAttrs.getContext());
52}
53
54IncludeOpGenericAdaptorBase::IncludeOpGenericAdaptorBase(IncludeOp op) : IncludeOpGenericAdaptorBase(op->getDiscardableAttrDictionary(), op.getProperties(), op->getRegions()) {}
55
56std::pair<unsigned, unsigned> IncludeOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) {
57 return {index, 1};
58}
59
61 return odsAttrs;
62}
63
65 auto attr = ::llvm::cast<::mlir::StringAttr>(getProperties().sym_name);
66 return attr;
67}
68
70 auto attr = getSymNameAttr();
71 return attr.getValue();
72}
73
75 auto attr = ::llvm::cast<::mlir::StringAttr>(getProperties().path);
76 return attr;
77}
78
80 auto attr = getPathAttr();
81 return attr.getValue();
82}
83
84} // namespace detail
86
87::mlir::LogicalResult IncludeOpAdaptor::verify(::mlir::Location loc) {
88 auto tblgen_path = getProperties().path; (void)tblgen_path;
89 if (!tblgen_path) return emitError(loc, "'include.from' op ""requires attribute 'path'");
90 auto tblgen_sym_name = getProperties().sym_name; (void)tblgen_sym_name;
91 if (!tblgen_sym_name) return emitError(loc, "'include.from' op ""requires attribute 'sym_name'");
92
93 if (tblgen_sym_name && !((::llvm::isa<::mlir::StringAttr>(tblgen_sym_name))))
94 return emitError(loc, "'include.from' op ""attribute 'sym_name' failed to satisfy constraint: string attribute");
95
96 if (tblgen_path && !((::llvm::isa<::mlir::StringAttr>(tblgen_path))))
97 return emitError(loc, "'include.from' op ""attribute 'path' failed to satisfy constraint: string attribute");
98 return ::mlir::success();
99}
100
101std::pair<unsigned, unsigned> IncludeOp::getODSOperandIndexAndLength(unsigned index) {
102 return {index, 1};
103}
104
105::mlir::Operation::operand_range IncludeOp::getODSOperands(unsigned index) {
106 auto valueRange = getODSOperandIndexAndLength(index);
107 return {std::next(getOperation()->operand_begin(), valueRange.first),
108 std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)};
109}
110
111std::pair<unsigned, unsigned> IncludeOp::getODSResultIndexAndLength(unsigned index) {
112 return {index, 1};
113}
114
115::mlir::Operation::result_range IncludeOp::getODSResults(unsigned index) {
116 auto valueRange = getODSResultIndexAndLength(index);
117 return {std::next(getOperation()->result_begin(), valueRange.first),
118 std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)};
119}
120
121::mlir::LogicalResult IncludeOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
122 ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr);
123 if (!dict) {
124 emitError() << "expected DictionaryAttr to set properties";
125 return ::mlir::failure();
126 }
127
128 {
129 auto &propStorage = prop.path;
130 auto attr = dict.get("path");
131 if (attr || /*isRequired=*/true) {
132 if (!attr) {
133 emitError() << "expected key entry for path in DictionaryAttr to set "
134 "Properties.";
135 return ::mlir::failure();
136 }
137 auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
138 if (convertedAttr) {
139 propStorage = convertedAttr;
140 } else {
141 emitError() << "Invalid attribute `path` in property conversion: " << attr;
142 return ::mlir::failure();
143 }
144 }
145 }
146
147 {
148 auto &propStorage = prop.sym_name;
149 auto attr = dict.get("sym_name");
150 if (attr || /*isRequired=*/true) {
151 if (!attr) {
152 emitError() << "expected key entry for sym_name in DictionaryAttr to set "
153 "Properties.";
154 return ::mlir::failure();
155 }
156 auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
157 if (convertedAttr) {
158 propStorage = convertedAttr;
159 } else {
160 emitError() << "Invalid attribute `sym_name` in property conversion: " << attr;
161 return ::mlir::failure();
162 }
163 }
164 }
165 return ::mlir::success();
166}
167
168::mlir::Attribute IncludeOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) {
169 ::mlir::SmallVector<::mlir::NamedAttribute> attrs;
170 ::mlir::Builder odsBuilder{ctx};
171
172 {
173 const auto &propStorage = prop.path;
174 if (propStorage)
175 attrs.push_back(odsBuilder.getNamedAttr("path",
176 propStorage));
177 }
178
179 {
180 const auto &propStorage = prop.sym_name;
181 if (propStorage)
182 attrs.push_back(odsBuilder.getNamedAttr("sym_name",
183 propStorage));
184 }
185
186 if (!attrs.empty())
187 return odsBuilder.getDictionaryAttr(attrs);
188 return {};
189}
190
191llvm::hash_code IncludeOp::computePropertiesHash(const Properties &prop) {
192 return llvm::hash_combine(
193 llvm::hash_value(prop.path.getAsOpaquePointer()),
194 llvm::hash_value(prop.sym_name.getAsOpaquePointer()));
195}
196
197std::optional<mlir::Attribute> IncludeOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
198 if (name == "path")
199 return prop.path;
200
201 if (name == "sym_name")
202 return prop.sym_name;
203 return std::nullopt;
204}
205
206void IncludeOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
207 if (name == "path") {
208 prop.path = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.path)>>(value);
209 return;
210 }
211
212 if (name == "sym_name") {
213 prop.sym_name = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.sym_name)>>(value);
214 return;
215 }
216}
217
218void IncludeOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
219 if (prop.path) attrs.append("path", prop.path);
220
221 if (prop.sym_name) attrs.append("sym_name", prop.sym_name);
222}
223
224::mlir::LogicalResult IncludeOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
225 {
226 ::mlir::Attribute attr = attrs.get(getPathAttrName(opName));
227 if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_Ops0(attr, "path", emitError)))
228 return ::mlir::failure();
229 }
230
231 {
232 ::mlir::Attribute attr = attrs.get(getSymNameAttrName(opName));
233 if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_Ops0(attr, "sym_name", emitError)))
234 return ::mlir::failure();
235 }
236 return ::mlir::success();
237}
238
239::mlir::LogicalResult IncludeOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) {
240 auto &prop = state.getOrAddProperties<Properties>(); (void)prop;
241 if (::mlir::failed(reader.readAttribute(prop.path)))
242 return ::mlir::failure();
243
244 if (::mlir::failed(reader.readAttribute(prop.sym_name)))
245 return ::mlir::failure();
246 return ::mlir::success();
247}
248
249void IncludeOp::writeProperties(::mlir::DialectBytecodeWriter &writer) {
250 auto &prop = getProperties(); (void)prop;
251 writer.writeAttribute(prop.path);
252 writer.writeAttribute(prop.sym_name);
253}
254
255::mlir::StringAttr IncludeOp::getSymNameAttr() {
256 return ::llvm::cast<::mlir::StringAttr>(getProperties().sym_name);
257}
258
259::llvm::StringRef IncludeOp::getSymName() {
260 auto attr = getSymNameAttr();
261 return attr.getValue();
262}
263
264::mlir::StringAttr IncludeOp::getPathAttr() {
265 return ::llvm::cast<::mlir::StringAttr>(getProperties().path);
266}
267
268::llvm::StringRef IncludeOp::getPath() {
269 auto attr = getPathAttr();
270 return attr.getValue();
271}
272
273void IncludeOp::setSymNameAttr(::mlir::StringAttr attr) {
274 (*this)->setAttr(getSymNameAttrName(), attr);
275}
276
277void IncludeOp::setSymName(::llvm::StringRef attrValue) {
278 (*this)->setAttr(getSymNameAttrName(), ::mlir::Builder((*this)->getContext()).getStringAttr(attrValue));
279}
280
281void IncludeOp::setPathAttr(::mlir::StringAttr attr) {
282 (*this)->setAttr(getPathAttrName(), attr);
283}
284
285void IncludeOp::setPath(::llvm::StringRef attrValue) {
286 (*this)->setAttr(getPathAttrName(), ::mlir::Builder((*this)->getContext()).getStringAttr(attrValue));
287}
288
289void IncludeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::StringAttr sym_name, ::mlir::StringAttr path) {
290 odsState.getOrAddProperties<Properties>().sym_name = sym_name;
291 odsState.getOrAddProperties<Properties>().path = path;
292}
293
294void IncludeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::StringAttr sym_name, ::mlir::StringAttr path) {
295 odsState.getOrAddProperties<Properties>().sym_name = sym_name;
296 odsState.getOrAddProperties<Properties>().path = path;
297 assert(resultTypes.size() == 0u && "mismatched number of results");
298 odsState.addTypes(resultTypes);
299}
300
301void IncludeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::llvm::StringRef sym_name, ::llvm::StringRef path) {
302 odsState.getOrAddProperties<Properties>().sym_name = odsBuilder.getStringAttr(sym_name);
303 odsState.getOrAddProperties<Properties>().path = odsBuilder.getStringAttr(path);
304}
305
306void IncludeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::llvm::StringRef sym_name, ::llvm::StringRef path) {
307 odsState.getOrAddProperties<Properties>().sym_name = odsBuilder.getStringAttr(sym_name);
308 odsState.getOrAddProperties<Properties>().path = odsBuilder.getStringAttr(path);
309 assert(resultTypes.size() == 0u && "mismatched number of results");
310 odsState.addTypes(resultTypes);
311}
312
313void IncludeOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
314 assert(operands.size() == 0u && "mismatched number of parameters");
315 odsState.addOperands(operands);
316 odsState.addAttributes(attributes);
317 assert(resultTypes.size() == 0u && "mismatched number of return types");
318 odsState.addTypes(resultTypes);
319}
320
321::mlir::LogicalResult IncludeOp::verifyInvariantsImpl() {
322 auto tblgen_path = getProperties().path; (void)tblgen_path;
323 if (!tblgen_path) return emitOpError("requires attribute 'path'");
324 auto tblgen_sym_name = getProperties().sym_name; (void)tblgen_sym_name;
325 if (!tblgen_sym_name) return emitOpError("requires attribute 'sym_name'");
326
327 if (::mlir::failed(__mlir_ods_local_attr_constraint_Ops0(*this, tblgen_sym_name, "sym_name")))
328 return ::mlir::failure();
329
330 if (::mlir::failed(__mlir_ods_local_attr_constraint_Ops0(*this, tblgen_path, "path")))
331 return ::mlir::failure();
332 return ::mlir::success();
333}
334
335::mlir::LogicalResult IncludeOp::verifyInvariants() {
336 return verifyInvariantsImpl();
337}
338
339::mlir::ParseResult IncludeOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
340 ::mlir::StringAttr pathAttr;
341 ::mlir::StringAttr sym_nameAttr;
342
343 if (parser.parseCustomAttributeWithFallback(pathAttr, parser.getBuilder().getType<::mlir::NoneType>())) {
344 return ::mlir::failure();
345 }
346 if (pathAttr) result.getOrAddProperties<IncludeOp::Properties>().path = pathAttr;
347 if (parser.parseKeyword("as"))
348 return ::mlir::failure();
349
350 if (parser.parseSymbolName(sym_nameAttr))
351 return ::mlir::failure();
352 if (sym_nameAttr) result.getOrAddProperties<IncludeOp::Properties>().sym_name = sym_nameAttr;
353 {
354 auto loc = parser.getCurrentLocation();(void)loc;
355 if (parser.parseOptionalAttrDict(result.attributes))
356 return ::mlir::failure();
357 if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() {
358 return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op ";
359 })))
360 return ::mlir::failure();
361 }
362 return ::mlir::success();
363}
364
365void IncludeOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
366 _odsPrinter << ' ';
367 _odsPrinter.printAttributeWithoutType(getPathAttr());
368 _odsPrinter << ' ' << "as";
369 _odsPrinter << ' ';
370 _odsPrinter.printSymbolName(getSymNameAttr().getValue());
371 ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
372 elidedAttrs.push_back("path");
373 elidedAttrs.push_back("sym_name");
374 _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
375}
376
377} // namespace include
378} // namespace llzk
379MLIR_DEFINE_EXPLICIT_TYPE_ID(::llzk::include::IncludeOp)
380
381
382#endif // GET_OP_CLASSES
383
IncludeOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs=nullptr, const Properties &properties={}, ::mlir::RegionRange regions={})
Definition Ops.h.inc:95
::mlir::LogicalResult verify(::mlir::Location loc)
Definition Ops.cpp.inc:87
::mlir::StringAttr getPathAttrName()
Definition Ops.h.inc:140
void setPathAttr(::mlir::StringAttr attr)
Definition Ops.cpp.inc:281
::mlir::LogicalResult verifyInvariants()
Definition Ops.cpp.inc:335
::llvm::StringRef getSymName()
Definition Ops.cpp.inc:259
std::pair< unsigned, unsigned > getODSOperandIndexAndLength(unsigned index)
Definition Ops.cpp.inc:101
static llvm::hash_code computePropertiesHash(const Properties &prop)
Definition Ops.cpp.inc:191
FoldAdaptor::Properties Properties
Definition Ops.h.inc:134
static std::optional< mlir::Attribute > getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name)
Definition Ops.cpp.inc:197
void setSymName(::llvm::StringRef attrValue)
Definition Ops.cpp.inc:277
::mlir::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError)
Definition Ops.cpp.inc:121
void writeProperties(::mlir::DialectBytecodeWriter &writer)
Definition Ops.cpp.inc:249
::llvm::StringRef getPath()
Definition Ops.cpp.inc:268
::mlir::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state)
Definition Ops.cpp.inc:239
::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result)
Definition Ops.cpp.inc:339
::mlir::StringAttr getSymNameAttr()
Definition Ops.cpp.inc:255
void print(::mlir::OpAsmPrinter &_odsPrinter)
Definition Ops.cpp.inc:365
::mlir::StringAttr getSymNameAttrName()
Definition Ops.h.inc:148
static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::StringAttr sym_name, ::mlir::StringAttr path)
Definition Ops.cpp.inc:289
::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop)
Definition Ops.cpp.inc:168
void setSymNameAttr(::mlir::StringAttr attr)
Definition Ops.cpp.inc:273
::mlir::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError)
Definition Ops.cpp.inc:224
std::pair< unsigned, unsigned > getODSResultIndexAndLength(unsigned index)
Definition Ops.cpp.inc:111
::mlir::StringAttr getPathAttr()
Definition Ops.cpp.inc:264
::mlir::Operation::result_range getODSResults(unsigned index)
Definition Ops.cpp.inc:115
static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value)
Definition Ops.cpp.inc:206
::mlir::Operation::operand_range getODSOperands(unsigned index)
Definition Ops.cpp.inc:105
void setPath(::llvm::StringRef attrValue)
Definition Ops.cpp.inc:285
static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs)
Definition Ops.cpp.inc:218
::mlir::LogicalResult verifyInvariantsImpl()
Definition Ops.cpp.inc:321
std::pair< unsigned, unsigned > getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize)
Definition Ops.cpp.inc:56
::std::optional<::mlir::OperationName > odsOpName
Definition Ops.h.inc:70
IncludeOpGenericAdaptorBase(::mlir::DictionaryAttr attrs=nullptr, const Properties &properties={}, ::mlir::RegionRange regions={})
Definition Ops.cpp.inc:50