LLZK 3.0.0
An open-source IR for Zero Knowledge (ZK) circuits
Loading...
Searching...
No Matches
SMTInfoOps.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: SMTInfoOps.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
24
25static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_SMTInfoOps1(
26 ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
27 if (attr && !((::llvm::isa<::llzk::smt_info::KeywordAttr>(attr))))
28 return emitError() << "attribute '" << attrName
29 << "' failed to satisfy constraint: an SMT-LIB keyword";
30 return ::mlir::success();
31}
32static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_SMTInfoOps1(
33 ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) {
34 return __mlir_ods_local_attr_constraint_SMTInfoOps1(attr, attrName, [op]() {
35 return op->emitOpError();
36 });
37}
38
39static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_SMTInfoOps2(
40 ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
41 if (attr && !((true)))
42 return emitError() << "attribute '" << attrName
43 << "' failed to satisfy constraint: any attribute";
44 return ::mlir::success();
45}
46static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_SMTInfoOps2(
47 ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) {
48 return __mlir_ods_local_attr_constraint_SMTInfoOps2(attr, attrName, [op]() {
49 return op->emitOpError();
50 });
51}
52namespace llzk::smt_info {
53
54
55//===----------------------------------------------------------------------===//
56// ::llzk::smt_info::SMTInfoSetOp definitions
57//===----------------------------------------------------------------------===//
58
59namespace detail {
60
61SMTInfoSetOpGenericAdaptorBase::SMTInfoSetOpGenericAdaptorBase(SMTInfoSetOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
62
63::llzk::smt_info::KeywordAttr SMTInfoSetOpGenericAdaptorBase::getKey() {
64 auto attr = getKeyAttr();
65 return ::llvm::cast<::llzk::smt_info::KeywordAttr>(attr);
66}
67
69 auto attr = getValueAttr();
70 return attr;
71}
72
73
74} // namespace detail
76
77::llvm::LogicalResult SMTInfoSetOpAdaptor::verify(::mlir::Location loc) {
78 auto tblgen_key = getProperties().key; (void)tblgen_key;
79 if (!tblgen_key) return emitError(loc, "'smt_info.set' op requires attribute 'key'");
80 auto tblgen_value = getProperties().value; (void)tblgen_value;
81 if (!tblgen_value) return emitError(loc, "'smt_info.set' op requires attribute 'value'");
82
83 if (tblgen_key && !((::llvm::isa<::llzk::smt_info::KeywordAttr>(tblgen_key))))
84 return emitError(loc, "'smt_info.set' op attribute 'key' failed to satisfy constraint: an SMT-LIB keyword");
85
86 if (tblgen_value && !((true)))
87 return emitError(loc, "'smt_info.set' op attribute 'value' failed to satisfy constraint: any attribute");
88 return ::mlir::success();
89}
90
91::llvm::LogicalResult SMTInfoSetOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
92 ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr);
93 if (!dict) {
94 emitError() << "expected DictionaryAttr to set properties";
95 return ::mlir::failure();
96 }
97
98 {
99 auto &propStorage = prop.key;
100 auto attr = dict.get("key");
101 if (attr) {
102 auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
103 if (convertedAttr) {
104 propStorage = convertedAttr;
105 } else {
106 emitError() << "Invalid attribute `key` in property conversion: " << attr;
107 return ::mlir::failure();
108 }
109 }
110 }
111
112 {
113 auto &propStorage = prop.value;
114 auto attr = dict.get("value");
115 if (attr) {
116 auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
117 if (convertedAttr) {
118 propStorage = convertedAttr;
119 } else {
120 emitError() << "Invalid attribute `value` in property conversion: " << attr;
121 return ::mlir::failure();
122 }
123 }
124 }
125 return ::mlir::success();
126}
127
128::mlir::Attribute SMTInfoSetOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) {
129 ::mlir::SmallVector<::mlir::NamedAttribute> attrs;
130 ::mlir::Builder odsBuilder{ctx};
131
132 {
133 const auto &propStorage = prop.key;
134 if (propStorage)
135 attrs.push_back(odsBuilder.getNamedAttr("key",
136 propStorage));
137 }
138
139 {
140 const auto &propStorage = prop.value;
141 if (propStorage)
142 attrs.push_back(odsBuilder.getNamedAttr("value",
143 propStorage));
144 }
145
146 if (!attrs.empty())
147 return odsBuilder.getDictionaryAttr(attrs);
148 return {};
149}
150
152 using llvm::hash_value;
153 return llvm::hash_combine(
154 llvm::hash_value(prop.key.getAsOpaquePointer()),
155 llvm::hash_value(prop.value.getAsOpaquePointer()));
156}
157
158std::optional<mlir::Attribute> SMTInfoSetOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
159 if (name == "key")
160 return prop.key;
161
162 if (name == "value")
163 return prop.value;
164 return std::nullopt;
165}
166
167void SMTInfoSetOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
168 if (name == "key") {
169 prop.key = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.key)>>(value);
170 return;
171 }
172
173 if (name == "value") {
174 prop.value = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.value)>>(value);
175 return;
176 }
177}
178
179void SMTInfoSetOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
180 if (prop.key) attrs.append("key", prop.key);
181
182 if (prop.value) attrs.append("value", prop.value);
183}
184
185::llvm::LogicalResult SMTInfoSetOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
186 {
187 ::mlir::Attribute attr = attrs.get(getKeyAttrName(opName));
188 if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_SMTInfoOps1(attr, "key", emitError)))
189 return ::mlir::failure();
190 }
191
192 {
193 ::mlir::Attribute attr = attrs.get(getValueAttrName(opName));
194 if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_SMTInfoOps2(attr, "value", emitError)))
195 return ::mlir::failure();
196 }
197 return ::mlir::success();
198}
199
200::llvm::LogicalResult SMTInfoSetOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) {
201 auto &prop = state.getOrAddProperties<Properties>(); (void)prop;
202 if (::mlir::failed(reader.readAttribute(prop.key)))
203 return ::mlir::failure();
204
205 if (::mlir::failed(reader.readAttribute(prop.value)))
206 return ::mlir::failure();
207 return ::mlir::success();
208}
209
210void SMTInfoSetOp::writeProperties(::mlir::DialectBytecodeWriter &writer) {
211 auto &prop = getProperties(); (void)prop;
212 writer.writeAttribute(prop.key);
213 writer.writeAttribute(prop.value);
214}
215
216::llzk::smt_info::KeywordAttr SMTInfoSetOp::getKey() {
217 auto attr = getKeyAttr();
218 return ::llvm::cast<::llzk::smt_info::KeywordAttr>(attr);
219}
220
221::mlir::Attribute SMTInfoSetOp::getValue() {
222 auto attr = getValueAttr();
223 return attr;
224}
225
226void SMTInfoSetOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::llzk::smt_info::KeywordAttr key, ::mlir::Attribute value) {
227 odsState.getOrAddProperties<Properties>().key = key;
228 odsState.getOrAddProperties<Properties>().value = value;
229}
230
231SMTInfoSetOp SMTInfoSetOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::llzk::smt_info::KeywordAttr key, ::mlir::Attribute value) {
232 ::mlir::OperationState __state__(location, getOperationName());
233 build(builder, __state__, std::forward<decltype(key)>(key), std::forward<decltype(value)>(value));
234 auto __res__ = ::llvm::dyn_cast<SMTInfoSetOp>(builder.create(__state__));
235 assert(__res__ && "builder didn't return the right type");
236 return __res__;
237}
238
239SMTInfoSetOp SMTInfoSetOp::create(::mlir::ImplicitLocOpBuilder &builder, ::llzk::smt_info::KeywordAttr key, ::mlir::Attribute value) {
240 return create(builder, builder.getLoc(), std::forward<decltype(key)>(key), std::forward<decltype(value)>(value));
241}
242
243void SMTInfoSetOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::llzk::smt_info::KeywordAttr key, ::mlir::Attribute value) {
244 odsState.getOrAddProperties<Properties>().key = key;
245 odsState.getOrAddProperties<Properties>().value = value;
246 assert(resultTypes.size() == 0u && "mismatched number of results");
247 odsState.addTypes(resultTypes);
248}
249
250SMTInfoSetOp SMTInfoSetOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::llzk::smt_info::KeywordAttr key, ::mlir::Attribute value) {
251 ::mlir::OperationState __state__(location, getOperationName());
252 build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(key)>(key), std::forward<decltype(value)>(value));
253 auto __res__ = ::llvm::dyn_cast<SMTInfoSetOp>(builder.create(__state__));
254 assert(__res__ && "builder didn't return the right type");
255 return __res__;
256}
257
258SMTInfoSetOp SMTInfoSetOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::llzk::smt_info::KeywordAttr key, ::mlir::Attribute value) {
259 return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(key)>(key), std::forward<decltype(value)>(value));
260}
261
262void SMTInfoSetOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
263 assert(operands.size() == 0u && "mismatched number of parameters");
264 odsState.addOperands(operands);
265 odsState.addAttributes(attributes);
266 assert(resultTypes.size() == 0u && "mismatched number of return types");
267 odsState.addTypes(resultTypes);
268
269 if (!attributes.empty()) {
270 (void)odsState.getOrAddProperties<SMTInfoSetOp::Properties>();
271 ::mlir::PropertyRef properties = odsState.getRawProperties();
272 std::optional<::mlir::RegisteredOperationName> info =
273 odsState.name.getRegisteredInfo();
274 if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties,
275 odsState.attributes.getDictionary(odsState.getContext()), nullptr)))
276 ::llvm::report_fatal_error("Property conversion failed.");
277 }
278}
279
280SMTInfoSetOp SMTInfoSetOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
281 ::mlir::OperationState __state__(location, getOperationName());
282 build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
283 auto __res__ = ::llvm::dyn_cast<SMTInfoSetOp>(builder.create(__state__));
284 assert(__res__ && "builder didn't return the right type");
285 return __res__;
286}
287
288SMTInfoSetOp SMTInfoSetOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
289 return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
290}
291
292void SMTInfoSetOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) {
293 assert(operands.size() == 0u && "mismatched number of parameters");
294 odsState.addOperands(operands);
295 odsState.useProperties(const_cast<Properties&>(properties));
296 odsState.addAttributes(discardableAttributes);
297 assert(resultTypes.size() == 0u && "mismatched number of return types");
298 odsState.addTypes(resultTypes);
299}
300
301SMTInfoSetOp SMTInfoSetOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) {
302 ::mlir::OperationState __state__(location, getOperationName());
303 build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
304 auto __res__ = ::llvm::dyn_cast<SMTInfoSetOp>(builder.create(__state__));
305 assert(__res__ && "builder didn't return the right type");
306 return __res__;
307}
308
309SMTInfoSetOp SMTInfoSetOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) {
310 return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
311}
312
313::llvm::LogicalResult SMTInfoSetOp::verifyInvariantsImpl() {
314 auto tblgen_key = getProperties().key; (void)tblgen_key;
315 if (!tblgen_key) return emitOpError("requires attribute 'key'");
316 auto tblgen_value = getProperties().value; (void)tblgen_value;
317 if (!tblgen_value) return emitOpError("requires attribute 'value'");
318
319 if (::mlir::failed(__mlir_ods_local_attr_constraint_SMTInfoOps1(*this, tblgen_key, "key")))
320 return ::mlir::failure();
321
322 if (::mlir::failed(__mlir_ods_local_attr_constraint_SMTInfoOps2(*this, tblgen_value, "value")))
323 return ::mlir::failure();
324 return ::mlir::success();
325}
326
327::llvm::LogicalResult SMTInfoSetOp::verifyInvariants() {
328 if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify()))
329 return ::mlir::success();
330 return ::mlir::failure();
331}
332
333::llvm::LogicalResult SMTInfoSetOp::setPropertiesFromParsedAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
334 ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr);
335 if (!dict) {
336 emitError() << "expected DictionaryAttr to set properties";
337 return ::mlir::failure();
338 }
339 // keep track of used keys in the input dictionary to be able to error out
340 // if there are some unknown ones.
341 ::mlir::DenseSet<::mlir::StringAttr> usedKeys;
342 ::mlir::MLIRContext *ctx = dict.getContext();
343 (void)ctx;
344 {
345
346 auto &propStorage = prop.key;
347 auto keyAttrName = ::mlir::StringAttr::get(ctx, "key");
348 auto attr = dict.get(keyAttrName);
349 usedKeys.insert(keyAttrName);
350 if (attr || /*isRequired=*/true) {
351 if (!attr) {
352 emitError() << "expected key entry for key in DictionaryAttr to set "
353 "Properties.";
354 return ::mlir::failure();
355 }
356 auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
357 if (convertedAttr) {
358 propStorage = convertedAttr;
359 } else {
360 emitError() << "Invalid attribute `key` in property conversion: " << attr;
361 return ::mlir::failure();
362 }
363 }
364 }
365 {
366
367 auto &propStorage = prop.value;
368 auto valueAttrName = ::mlir::StringAttr::get(ctx, "value");
369 auto attr = dict.get(valueAttrName);
370 usedKeys.insert(valueAttrName);
371 if (attr || /*isRequired=*/true) {
372 if (!attr) {
373 emitError() << "expected key entry for value in DictionaryAttr to set "
374 "Properties.";
375 return ::mlir::failure();
376 }
377 auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
378 if (convertedAttr) {
379 propStorage = convertedAttr;
380 } else {
381 emitError() << "Invalid attribute `value` in property conversion: " << attr;
382 return ::mlir::failure();
383 }
384 }
385 }
386
387 for (::mlir::NamedAttribute attr : dict) {
388 if (!usedKeys.contains(attr.getName()))
389 return emitError() << "unknown key '" << attr.getName() <<
390 "' when parsing properties dictionary";
391 }
392 return ::mlir::success();
393}
394
395
396} // namespace llzk::smt_info
397MLIR_DEFINE_EXPLICIT_TYPE_ID(::llzk::smt_info::SMTInfoSetOp)
399
400
401#endif // GET_OP_CLASSES
402
::llvm::LogicalResult verify(::mlir::Location loc)
SMTInfoSetOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions={})
void writeProperties(::mlir::DialectBytecodeWriter &writer)
static SMTInfoSetOp create(::mlir::OpBuilder &builder, ::mlir::Location location, ::llzk::smt_info::KeywordAttr key, ::mlir::Attribute value)
::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError)
FoldAdaptor::Properties Properties
::mlir::StringAttr getValueAttrName()
static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs)
::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state)
::llvm::LogicalResult setPropertiesFromParsedAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError)
::mlir::Attribute getValueAttr()
::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop)
::llvm::LogicalResult verifyInvariants()
::llvm::LogicalResult verify()
::llvm::LogicalResult verifyInvariantsImpl()
static llvm::hash_code computePropertiesHash(const Properties &prop)
static constexpr ::llvm::StringLiteral getOperationName()
static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::llzk::smt_info::KeywordAttr key, ::mlir::Attribute value)
static std::optional< mlir::Attribute > getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name)
::llzk::smt_info::KeywordAttr getKeyAttr()
::llzk::smt_info::KeywordAttr getKey()
static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value)
::mlir::StringAttr getKeyAttrName()
::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError)
::std::optional<::mlir::OperationName > odsOpName
SMTInfoSetOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions={})