LLZK 3.0.0
An open-source IR for Zero Knowledge (ZK) circuits
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
24
25static ::llvm::LogicalResult __mlir_ods_local_type_constraint_Ops1(
26 ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind,
27 unsigned valueIndex) {
28 if (!((::llvm::isa<::llzk::string::StringType>(type)))) {
29 return op->emitOpError(valueKind) << " #" << valueIndex
30 << " must be string type, but got " << type;
31 }
32 return ::mlir::success();
33}
34
35static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_Ops1(
36 ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
37 if (attr && !((::llvm::isa<::mlir::StringAttr>(attr))))
38 return emitError() << "attribute '" << attrName
39 << "' failed to satisfy constraint: string attribute";
40 return ::mlir::success();
41}
42static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_Ops1(
43 ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) {
44 return __mlir_ods_local_attr_constraint_Ops1(attr, attrName, [op]() {
45 return op->emitOpError();
46 });
47}
48namespace llzk::string {
49
50
51//===----------------------------------------------------------------------===//
52// ::llzk::string::LitStringOp definitions
53//===----------------------------------------------------------------------===//
54
55namespace detail {
56
57LitStringOpGenericAdaptorBase::LitStringOpGenericAdaptorBase(LitStringOp op) : odsAttrs(op->getRawDictionaryAttrs()), odsOpName(op->getName()), properties(op.getProperties()), odsRegions(op->getRegions()) {}
58
60 auto attr = getValueAttr();
61 return attr.getValue();
62}
63
64
65} // namespace detail
67
68::llvm::LogicalResult LitStringOpAdaptor::verify(::mlir::Location loc) {
69 auto tblgen_value = getProperties().value; (void)tblgen_value;
70 if (!tblgen_value) return emitError(loc, "'string.new' op requires attribute 'value'");
71
72 if (tblgen_value && !((::llvm::isa<::mlir::StringAttr>(tblgen_value))))
73 return emitError(loc, "'string.new' op attribute 'value' failed to satisfy constraint: string attribute");
74 return ::mlir::success();
75}
76
77::llvm::LogicalResult LitStringOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
78 ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr);
79 if (!dict) {
80 emitError() << "expected DictionaryAttr to set properties";
81 return ::mlir::failure();
82 }
83
84 {
85 auto &propStorage = prop.value;
86 auto attr = dict.get("value");
87 if (attr) {
88 auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
89 if (convertedAttr) {
90 propStorage = convertedAttr;
91 } else {
92 emitError() << "Invalid attribute `value` in property conversion: " << attr;
93 return ::mlir::failure();
94 }
95 }
96 }
97 return ::mlir::success();
98}
99
100::mlir::Attribute LitStringOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) {
101 ::mlir::SmallVector<::mlir::NamedAttribute> attrs;
102 ::mlir::Builder odsBuilder{ctx};
103
104 {
105 const auto &propStorage = prop.value;
106 if (propStorage)
107 attrs.push_back(odsBuilder.getNamedAttr("value",
108 propStorage));
109 }
110
111 if (!attrs.empty())
112 return odsBuilder.getDictionaryAttr(attrs);
113 return {};
114}
115
116llvm::hash_code LitStringOp::computePropertiesHash(const Properties &prop) {
117 using llvm::hash_value;
118 return llvm::hash_combine(
119 llvm::hash_value(prop.value.getAsOpaquePointer()));
120}
121
122std::optional<mlir::Attribute> LitStringOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
123 if (name == "value")
124 return prop.value;
125 return std::nullopt;
126}
127
128void LitStringOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
129 if (name == "value") {
130 prop.value = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.value)>>(value);
131 return;
132 }
133}
134
135void LitStringOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
136 if (prop.value) attrs.append("value", prop.value);
137}
138
139::llvm::LogicalResult LitStringOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
140 {
141 ::mlir::Attribute attr = attrs.get(getValueAttrName(opName));
142 if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_Ops1(attr, "value", emitError)))
143 return ::mlir::failure();
144 }
145 return ::mlir::success();
146}
147
148::llvm::LogicalResult LitStringOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) {
149 auto &prop = state.getOrAddProperties<Properties>(); (void)prop;
150 if (::mlir::failed(reader.readAttribute(prop.value)))
151 return ::mlir::failure();
152 return ::mlir::success();
153}
154
155void LitStringOp::writeProperties(::mlir::DialectBytecodeWriter &writer) {
156 auto &prop = getProperties(); (void)prop;
157 writer.writeAttribute(prop.value);
158}
159
160::llvm::StringRef LitStringOp::getValue() {
161 auto attr = getValueAttr();
162 return attr.getValue();
163}
164
165void LitStringOp::setValue(::llvm::StringRef attrValue) {
166 getProperties().value = ::mlir::Builder((*this)->getContext()).getStringAttr(attrValue);
167}
168
169void LitStringOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::StringAttr value) {
170 odsState.getOrAddProperties<Properties>().value = value;
171 odsState.addTypes(result);
172}
173
174LitStringOp LitStringOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type result, ::mlir::StringAttr value) {
175 ::mlir::OperationState __state__(location, getOperationName());
176 build(builder, __state__, std::forward<decltype(result)>(result), std::forward<decltype(value)>(value));
177 auto __res__ = ::llvm::dyn_cast<LitStringOp>(builder.create(__state__));
178 assert(__res__ && "builder didn't return the right type");
179 return __res__;
180}
181
182LitStringOp LitStringOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type result, ::mlir::StringAttr value) {
183 return create(builder, builder.getLoc(), std::forward<decltype(result)>(result), std::forward<decltype(value)>(value));
184}
185
186void LitStringOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::StringAttr value) {
187 odsState.getOrAddProperties<Properties>().value = value;
188 assert(resultTypes.size() == 1u && "mismatched number of results");
189 odsState.addTypes(resultTypes);
190}
191
192LitStringOp LitStringOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::StringAttr value) {
193 ::mlir::OperationState __state__(location, getOperationName());
194 build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(value)>(value));
195 auto __res__ = ::llvm::dyn_cast<LitStringOp>(builder.create(__state__));
196 assert(__res__ && "builder didn't return the right type");
197 return __res__;
198}
199
200LitStringOp LitStringOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::StringAttr value) {
201 return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(value)>(value));
202}
203
204void LitStringOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::llvm::StringRef value) {
205 odsState.getOrAddProperties<Properties>().value = odsBuilder.getStringAttr(value);
206 odsState.addTypes(result);
207}
208
209LitStringOp LitStringOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type result, ::llvm::StringRef value) {
210 ::mlir::OperationState __state__(location, getOperationName());
211 build(builder, __state__, std::forward<decltype(result)>(result), std::forward<decltype(value)>(value));
212 auto __res__ = ::llvm::dyn_cast<LitStringOp>(builder.create(__state__));
213 assert(__res__ && "builder didn't return the right type");
214 return __res__;
215}
216
217LitStringOp LitStringOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::Type result, ::llvm::StringRef value) {
218 return create(builder, builder.getLoc(), std::forward<decltype(result)>(result), std::forward<decltype(value)>(value));
219}
220
221void LitStringOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::llvm::StringRef value) {
222 odsState.getOrAddProperties<Properties>().value = odsBuilder.getStringAttr(value);
223 assert(resultTypes.size() == 1u && "mismatched number of results");
224 odsState.addTypes(resultTypes);
225}
226
227LitStringOp LitStringOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::llvm::StringRef value) {
228 ::mlir::OperationState __state__(location, getOperationName());
229 build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(value)>(value));
230 auto __res__ = ::llvm::dyn_cast<LitStringOp>(builder.create(__state__));
231 assert(__res__ && "builder didn't return the right type");
232 return __res__;
233}
234
235LitStringOp LitStringOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::llvm::StringRef value) {
236 return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(value)>(value));
237}
238
239void LitStringOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
240 assert(operands.size() == 0u && "mismatched number of parameters");
241 odsState.addOperands(operands);
242 odsState.addAttributes(attributes);
243 assert(resultTypes.size() == 1u && "mismatched number of return types");
244 odsState.addTypes(resultTypes);
245
246 if (!attributes.empty()) {
247 (void)odsState.getOrAddProperties<LitStringOp::Properties>();
248 ::mlir::PropertyRef properties = odsState.getRawProperties();
249 std::optional<::mlir::RegisteredOperationName> info =
250 odsState.name.getRegisteredInfo();
251 if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties,
252 odsState.attributes.getDictionary(odsState.getContext()), nullptr)))
253 ::llvm::report_fatal_error("Property conversion failed.");
254 }
255}
256
257LitStringOp LitStringOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
258 ::mlir::OperationState __state__(location, getOperationName());
259 build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
260 auto __res__ = ::llvm::dyn_cast<LitStringOp>(builder.create(__state__));
261 assert(__res__ && "builder didn't return the right type");
262 return __res__;
263}
264
265LitStringOp LitStringOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
266 return create(builder, builder.getLoc(), std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(attributes)>(attributes));
267}
268
269void LitStringOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) {
270 assert(operands.size() == 0u && "mismatched number of parameters");
271 odsState.addOperands(operands);
272 odsState.useProperties(const_cast<Properties&>(properties));
273 odsState.addAttributes(discardableAttributes);
274 assert(resultTypes.size() == 1u && "mismatched number of return types");
275 odsState.addTypes(resultTypes);
276}
277
278LitStringOp LitStringOp::create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) {
279 ::mlir::OperationState __state__(location, getOperationName());
280 build(builder, __state__, std::forward<decltype(resultTypes)>(resultTypes), std::forward<decltype(operands)>(operands), std::forward<decltype(properties)>(properties), std::forward<decltype(discardableAttributes)>(discardableAttributes));
281 auto __res__ = ::llvm::dyn_cast<LitStringOp>(builder.create(__state__));
282 assert(__res__ && "builder didn't return the right type");
283 return __res__;
284}
285
286LitStringOp LitStringOp::create(::mlir::ImplicitLocOpBuilder &builder, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, const Properties &properties, ::llvm::ArrayRef<::mlir::NamedAttribute> discardableAttributes) {
287 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));
288}
289
290::llvm::LogicalResult LitStringOp::verifyInvariantsImpl() {
291 auto tblgen_value = getProperties().value; (void)tblgen_value;
292 if (!tblgen_value) return emitOpError("requires attribute 'value'");
293
294 if (::mlir::failed(__mlir_ods_local_attr_constraint_Ops1(*this, tblgen_value, "value")))
295 return ::mlir::failure();
296 {
297 unsigned index = 0; (void)index;
298 auto valueGroup0 = getODSResults(0);
299
300 for (auto v : valueGroup0) {
301 if (::mlir::failed(__mlir_ods_local_type_constraint_Ops1(*this, v.getType(), "result", index++)))
302 return ::mlir::failure();
303 }
304 }
305 return ::mlir::success();
306}
307
308::llvm::LogicalResult LitStringOp::verifyInvariants() {
309 return verifyInvariantsImpl();
310}
311
312::mlir::ParseResult LitStringOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
313 ::mlir::StringAttr valueAttr;
314
315 if (parser.parseCustomAttributeWithFallback(valueAttr, parser.getBuilder().getType<::mlir::NoneType>())) {
316 return ::mlir::failure();
317 }
318 if (valueAttr) result.getOrAddProperties<LitStringOp::Properties>().value = valueAttr;
319 {
320 auto loc = parser.getCurrentLocation();(void)loc;
321 if (parser.parseOptionalAttrDict(result.attributes))
322 return ::mlir::failure();
323 if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() {
324 return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op ";
325 })))
326 return ::mlir::failure();
327 }
328 ::mlir::Type odsBuildableType0 = parser.getBuilder().getType<::llzk::string::StringType>();
329 result.addTypes(odsBuildableType0);
330 return ::mlir::success();
331}
332
333void LitStringOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
334 _odsPrinter << ' ';
335 _odsPrinter.printAttributeWithoutType(getValueAttr());
336 ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
337 elidedAttrs.push_back("value");
338 _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
339}
340
341void LitStringOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
342}
343
344
345} // namespace llzk::string
346MLIR_DEFINE_EXPLICIT_TYPE_ID(::llzk::string::LitStringOp)
348
349
350#endif // GET_OP_CLASSES
351
LitStringOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions={})
Definition Ops.h.inc:88
LitStringOpAdaptor(LitStringOp op)
Definition Ops.cpp.inc:66
::llvm::LogicalResult verify(::mlir::Location loc)
Definition Ops.cpp.inc:68
static llvm::hash_code computePropertiesHash(const Properties &prop)
Definition Ops.cpp.inc:116
static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::StringAttr value)
Definition Ops.cpp.inc:169
void print(::mlir::OpAsmPrinter &_odsPrinter)
Definition Ops.cpp.inc:333
void writeProperties(::mlir::DialectBytecodeWriter &writer)
Definition Ops.cpp.inc:155
::llvm::LogicalResult verifyInvariantsImpl()
Definition Ops.cpp.inc:290
static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs)
Definition Ops.cpp.inc:135
::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result)
Definition Ops.cpp.inc:312
static std::optional< mlir::Attribute > getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name)
Definition Ops.cpp.inc:122
void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect > > &effects)
Definition Ops.cpp.inc:341
::mlir::Operation::result_range getODSResults(unsigned index)
Definition Ops.h.inc:163
static LitStringOp create(::mlir::OpBuilder &builder, ::mlir::Location location, ::mlir::Type result, ::mlir::StringAttr value)
Definition Ops.cpp.inc:174
::mlir::StringAttr getValueAttr()
Definition Ops.h.inc:182
static constexpr ::llvm::StringLiteral getOperationName()
Definition Ops.h.inc:145
void setValue(::llvm::StringRef attrValue)
Definition Ops.cpp.inc:165
::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state)
Definition Ops.cpp.inc:148
::llvm::LogicalResult verifyInvariants()
Definition Ops.cpp.inc:308
::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError)
Definition Ops.cpp.inc:139
::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop)
Definition Ops.cpp.inc:100
::mlir::StringAttr getValueAttrName()
Definition Ops.h.inc:137
static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value)
Definition Ops.cpp.inc:128
FoldAdaptor::Properties Properties
Definition Ops.h.inc:131
::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError)
Definition Ops.cpp.inc:77
::llvm::StringRef getValue()
Definition Ops.cpp.inc:160
::std::optional<::mlir::OperationName > odsOpName
Definition Ops.h.inc:52
LitStringOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions={})
Definition Ops.h.inc:56