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 ::llvm::LogicalResult __mlir_ods_local_attr_constraint_Ops1(
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 ::llvm::LogicalResult __mlir_ods_local_attr_constraint_Ops1(
35 ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) {
36 return __mlir_ods_local_attr_constraint_Ops1(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(IncludeOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
51
53 auto attr = getSymNameAttr();
54 return attr.getValue();
55}
56
58 auto attr = getPathAttr();
59 return attr.getValue();
60}
61
62} // namespace detail
64
65::llvm::LogicalResult IncludeOpAdaptor::verify(::mlir::Location loc) {
66 auto tblgen_path = getProperties().path; (void)tblgen_path;
67 if (!tblgen_path) return emitError(loc, "'include.from' op ""requires attribute 'path'");
68 auto tblgen_sym_name = getProperties().sym_name; (void)tblgen_sym_name;
69 if (!tblgen_sym_name) return emitError(loc, "'include.from' op ""requires attribute 'sym_name'");
70
71 if (tblgen_sym_name && !((::llvm::isa<::mlir::StringAttr>(tblgen_sym_name))))
72 return emitError(loc, "'include.from' op ""attribute 'sym_name' failed to satisfy constraint: string attribute");
73
74 if (tblgen_path && !((::llvm::isa<::mlir::StringAttr>(tblgen_path))))
75 return emitError(loc, "'include.from' op ""attribute 'path' failed to satisfy constraint: string attribute");
76 return ::mlir::success();
77}
78
79::llvm::LogicalResult IncludeOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
80 ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr);
81 if (!dict) {
82 emitError() << "expected DictionaryAttr to set properties";
83 return ::mlir::failure();
84 }
85
86 {
87 auto &propStorage = prop.path;
88 auto attr = dict.get("path");
89 if (attr) {
90 auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
91 if (convertedAttr) {
92 propStorage = convertedAttr;
93 } else {
94 emitError() << "Invalid attribute `path` in property conversion: " << attr;
95 return ::mlir::failure();
96 }
97 }
98 }
99
100 {
101 auto &propStorage = prop.sym_name;
102 auto attr = dict.get("sym_name");
103 if (attr) {
104 auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
105 if (convertedAttr) {
106 propStorage = convertedAttr;
107 } else {
108 emitError() << "Invalid attribute `sym_name` in property conversion: " << attr;
109 return ::mlir::failure();
110 }
111 }
112 }
113 return ::mlir::success();
114}
115
116::mlir::Attribute IncludeOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) {
117 ::mlir::SmallVector<::mlir::NamedAttribute> attrs;
118 ::mlir::Builder odsBuilder{ctx};
119
120 {
121 const auto &propStorage = prop.path;
122 if (propStorage)
123 attrs.push_back(odsBuilder.getNamedAttr("path",
124 propStorage));
125 }
126
127 {
128 const auto &propStorage = prop.sym_name;
129 if (propStorage)
130 attrs.push_back(odsBuilder.getNamedAttr("sym_name",
131 propStorage));
132 }
133
134 if (!attrs.empty())
135 return odsBuilder.getDictionaryAttr(attrs);
136 return {};
137}
138
139llvm::hash_code IncludeOp::computePropertiesHash(const Properties &prop) {
140 return llvm::hash_combine(
141 llvm::hash_value(prop.path.getAsOpaquePointer()),
142 llvm::hash_value(prop.sym_name.getAsOpaquePointer()));
143}
144
145std::optional<mlir::Attribute> IncludeOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
146 if (name == "path")
147 return prop.path;
148
149 if (name == "sym_name")
150 return prop.sym_name;
151 return std::nullopt;
152}
153
154void IncludeOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
155 if (name == "path") {
156 prop.path = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.path)>>(value);
157 return;
158 }
159
160 if (name == "sym_name") {
161 prop.sym_name = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.sym_name)>>(value);
162 return;
163 }
164}
165
166void IncludeOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
167 if (prop.path) attrs.append("path", prop.path);
168
169 if (prop.sym_name) attrs.append("sym_name", prop.sym_name);
170}
171
172::llvm::LogicalResult IncludeOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
173 {
174 ::mlir::Attribute attr = attrs.get(getPathAttrName(opName));
175 if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_Ops1(attr, "path", emitError)))
176 return ::mlir::failure();
177 }
178
179 {
180 ::mlir::Attribute attr = attrs.get(getSymNameAttrName(opName));
181 if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_Ops1(attr, "sym_name", emitError)))
182 return ::mlir::failure();
183 }
184 return ::mlir::success();
185}
186
187::llvm::LogicalResult IncludeOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) {
188 auto &prop = state.getOrAddProperties<Properties>(); (void)prop;
189 if (::mlir::failed(reader.readAttribute(prop.path)))
190 return ::mlir::failure();
191
192 if (::mlir::failed(reader.readAttribute(prop.sym_name)))
193 return ::mlir::failure();
194 return ::mlir::success();
195}
196
197void IncludeOp::writeProperties(::mlir::DialectBytecodeWriter &writer) {
198 auto &prop = getProperties(); (void)prop;
199 writer.writeAttribute(prop.path);
200 writer.writeAttribute(prop.sym_name);
201}
202
203::llvm::StringRef IncludeOp::getSymName() {
204 auto attr = getSymNameAttr();
205 return attr.getValue();
206}
207
208::llvm::StringRef IncludeOp::getPath() {
209 auto attr = getPathAttr();
210 return attr.getValue();
211}
212
213void IncludeOp::setSymName(::llvm::StringRef attrValue) {
214 getProperties().sym_name = ::mlir::Builder((*this)->getContext()).getStringAttr(attrValue);
215}
216
217void IncludeOp::setPath(::llvm::StringRef attrValue) {
218 getProperties().path = ::mlir::Builder((*this)->getContext()).getStringAttr(attrValue);
219}
220
221void IncludeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::StringAttr sym_name, ::mlir::StringAttr path) {
222 odsState.getOrAddProperties<Properties>().sym_name = sym_name;
223 odsState.getOrAddProperties<Properties>().path = path;
224}
225
226void IncludeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::StringAttr sym_name, ::mlir::StringAttr path) {
227 odsState.getOrAddProperties<Properties>().sym_name = sym_name;
228 odsState.getOrAddProperties<Properties>().path = path;
229 assert(resultTypes.size() == 0u && "mismatched number of results");
230 odsState.addTypes(resultTypes);
231}
232
233void IncludeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::llvm::StringRef sym_name, ::llvm::StringRef path) {
234 odsState.getOrAddProperties<Properties>().sym_name = odsBuilder.getStringAttr(sym_name);
235 odsState.getOrAddProperties<Properties>().path = odsBuilder.getStringAttr(path);
236}
237
238void IncludeOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::llvm::StringRef sym_name, ::llvm::StringRef path) {
239 odsState.getOrAddProperties<Properties>().sym_name = odsBuilder.getStringAttr(sym_name);
240 odsState.getOrAddProperties<Properties>().path = odsBuilder.getStringAttr(path);
241 assert(resultTypes.size() == 0u && "mismatched number of results");
242 odsState.addTypes(resultTypes);
243}
244
245void IncludeOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
246 assert(operands.size() == 0u && "mismatched number of parameters");
247 odsState.addOperands(operands);
248 odsState.addAttributes(attributes);
249 assert(resultTypes.size() == 0u && "mismatched number of return types");
250 odsState.addTypes(resultTypes);
251
252 if (!attributes.empty()) {
253 ::mlir::OpaqueProperties properties =
254 &odsState.getOrAddProperties<IncludeOp::Properties>();
255 std::optional<::mlir::RegisteredOperationName> info =
256 odsState.name.getRegisteredInfo();
257 if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties,
258 odsState.attributes.getDictionary(odsState.getContext()), nullptr)))
259 ::llvm::report_fatal_error("Property conversion failed.");
260 }
261}
262
263::llvm::LogicalResult IncludeOp::verifyInvariantsImpl() {
264 auto tblgen_path = getProperties().path; (void)tblgen_path;
265 if (!tblgen_path) return emitOpError("requires attribute 'path'");
266 auto tblgen_sym_name = getProperties().sym_name; (void)tblgen_sym_name;
267 if (!tblgen_sym_name) return emitOpError("requires attribute 'sym_name'");
268
269 if (::mlir::failed(__mlir_ods_local_attr_constraint_Ops1(*this, tblgen_sym_name, "sym_name")))
270 return ::mlir::failure();
271
272 if (::mlir::failed(__mlir_ods_local_attr_constraint_Ops1(*this, tblgen_path, "path")))
273 return ::mlir::failure();
274 return ::mlir::success();
275}
276
277::llvm::LogicalResult IncludeOp::verifyInvariants() {
278 return verifyInvariantsImpl();
279}
280
281::mlir::ParseResult IncludeOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
282 ::mlir::StringAttr pathAttr;
283 ::mlir::StringAttr sym_nameAttr;
284
285 if (parser.parseCustomAttributeWithFallback(pathAttr, parser.getBuilder().getType<::mlir::NoneType>())) {
286 return ::mlir::failure();
287 }
288 if (pathAttr) result.getOrAddProperties<IncludeOp::Properties>().path = pathAttr;
289 if (parser.parseKeyword("as"))
290 return ::mlir::failure();
291
292 if (parser.parseSymbolName(sym_nameAttr))
293 return ::mlir::failure();
294 if (sym_nameAttr) result.getOrAddProperties<IncludeOp::Properties>().sym_name = sym_nameAttr;
295 {
296 auto loc = parser.getCurrentLocation();(void)loc;
297 if (parser.parseOptionalAttrDict(result.attributes))
298 return ::mlir::failure();
299 if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() {
300 return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op ";
301 })))
302 return ::mlir::failure();
303 }
304 return ::mlir::success();
305}
306
307void IncludeOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
308 _odsPrinter << ' ';
309 _odsPrinter.printAttributeWithoutType(getPathAttr());
310 _odsPrinter << ' ' << "as";
311 _odsPrinter << ' ';
312 _odsPrinter.printSymbolName(getSymNameAttr().getValue());
313 ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
314 elidedAttrs.push_back("path");
315 elidedAttrs.push_back("sym_name");
316 _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
317}
318
319} // namespace include
320} // namespace llzk
321MLIR_DEFINE_EXPLICIT_TYPE_ID(::llzk::include::IncludeOp)
322
323
324#endif // GET_OP_CLASSES
325
MlirStringRef name
Definition Poly.cpp:48
::llvm::LogicalResult verify(::mlir::Location loc)
Definition Ops.cpp.inc:65
IncludeOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions={})
Definition Ops.h.inc:102
::mlir::StringAttr getPathAttrName()
Definition Ops.h.inc:151
::llvm::StringRef getSymName()
Definition Ops.cpp.inc:203
::llvm::LogicalResult verifyInvariantsImpl()
Definition Ops.cpp.inc:263
static llvm::hash_code computePropertiesHash(const Properties &prop)
Definition Ops.cpp.inc:139
FoldAdaptor::Properties Properties
Definition Ops.h.inc:145
::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state)
Definition Ops.cpp.inc:187
static std::optional< mlir::Attribute > getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name)
Definition Ops.cpp.inc:145
void setSymName(::llvm::StringRef attrValue)
Definition Ops.cpp.inc:213
void writeProperties(::mlir::DialectBytecodeWriter &writer)
Definition Ops.cpp.inc:197
::llvm::StringRef getPath()
Definition Ops.cpp.inc:208
::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result)
Definition Ops.cpp.inc:281
::mlir::StringAttr getPathAttr()
Definition Ops.h.inc:205
void print(::mlir::OpAsmPrinter &_odsPrinter)
Definition Ops.cpp.inc:307
::mlir::StringAttr getSymNameAttrName()
Definition Ops.h.inc:159
static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::StringAttr sym_name, ::mlir::StringAttr path)
Definition Ops.cpp.inc:221
::llvm::LogicalResult verifyInvariants()
Definition Ops.cpp.inc:277
::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop)
Definition Ops.cpp.inc:116
::mlir::StringAttr getSymNameAttr()
Definition Ops.h.inc:200
::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError)
Definition Ops.cpp.inc:172
::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError)
Definition Ops.cpp.inc:79
static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value)
Definition Ops.cpp.inc:154
void setPath(::llvm::StringRef attrValue)
Definition Ops.cpp.inc:217
static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs)
Definition Ops.cpp.inc:166
IncludeOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions={})
Definition Ops.h.inc:65
::std::optional<::mlir::OperationName > odsOpName
Definition Ops.h.inc:61