LLZK 2.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
15#endif // GET_OP_LIST
16
17#ifdef GET_OP_CLASSES
18#undef GET_OP_CLASSES
19
20
21//===----------------------------------------------------------------------===//
22// Local Utility Method Definitions
23//===----------------------------------------------------------------------===//
24
25namespace llzk {
26namespace cast {
27
28static ::llvm::LogicalResult __mlir_ods_local_type_constraint_Ops1(
29 ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind,
30 unsigned valueIndex) {
31 if (!((::llvm::isa<::llzk::felt::FeltType>(type)))) {
32 return op->emitOpError(valueKind) << " #" << valueIndex
33 << " must be finite field element, but got " << type;
34 }
35 return ::mlir::success();
36}
37
38static ::llvm::LogicalResult __mlir_ods_local_type_constraint_Ops2(
39 ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind,
40 unsigned valueIndex) {
41 if (!((::llvm::isa<::mlir::IndexType>(type)))) {
42 return op->emitOpError(valueKind) << " #" << valueIndex
43 << " must be index, but got " << type;
44 }
45 return ::mlir::success();
46}
47
48static ::llvm::LogicalResult __mlir_ods_local_type_constraint_Ops3(
49 ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind,
50 unsigned valueIndex) {
51 if (!(((type.isSignlessInteger(1))) || ((::llvm::isa<::mlir::IndexType>(type))))) {
52 return op->emitOpError(valueKind) << " #" << valueIndex
53 << " must be 1-bit signless integer or index, but got " << type;
54 }
55 return ::mlir::success();
56}
57} // namespace cast
58} // namespace llzk
59namespace llzk {
60namespace cast {
61
62//===----------------------------------------------------------------------===//
63// ::llzk::cast::FeltToIndexOp definitions
64//===----------------------------------------------------------------------===//
65
66namespace detail {
67} // namespace detail
69
70::llvm::LogicalResult FeltToIndexOpAdaptor::verify(::mlir::Location loc) {
71 return ::mlir::success();
72}
73
74void FeltToIndexOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value value) {
75 odsState.addOperands(value);
76 odsState.addTypes(result);
77}
78
79void FeltToIndexOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value value) {
80 odsState.addOperands(value);
81
82 ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes;
83 if (::mlir::succeeded(FeltToIndexOp::inferReturnTypes(odsBuilder.getContext(),
84 odsState.location, odsState.operands,
85 odsState.attributes.getDictionary(odsState.getContext()),
86 odsState.getRawProperties(),
87 odsState.regions, inferredReturnTypes)))
88 odsState.addTypes(inferredReturnTypes);
89 else
90 ::mlir::detail::reportFatalInferReturnTypesError(odsState);
91
92}
93
94void FeltToIndexOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value value) {
95 odsState.addOperands(value);
96 assert(resultTypes.size() == 1u && "mismatched number of results");
97 odsState.addTypes(resultTypes);
98}
99
100void FeltToIndexOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
101 assert(operands.size() == 1u && "mismatched number of parameters");
102 odsState.addOperands(operands);
103 odsState.addAttributes(attributes);
104 assert(resultTypes.size() == 1u && "mismatched number of return types");
105 odsState.addTypes(resultTypes);
106}
107
108void FeltToIndexOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
109 assert(operands.size() == 1u && "mismatched number of parameters");
110 odsState.addOperands(operands);
111 odsState.addAttributes(attributes);
112
113 ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes;
114 if (::mlir::succeeded(FeltToIndexOp::inferReturnTypes(odsBuilder.getContext(),
115 odsState.location, operands,
116 odsState.attributes.getDictionary(odsState.getContext()),
117 odsState.getRawProperties(),
118 odsState.regions, inferredReturnTypes))) {
119 assert(inferredReturnTypes.size() == 1u && "mismatched number of return types");
120 odsState.addTypes(inferredReturnTypes);
121 } else {
122 ::llvm::report_fatal_error("Failed to infer result type(s).");
123 }
124}
125
126::llvm::LogicalResult FeltToIndexOp::verifyInvariantsImpl() {
127 {
128 unsigned index = 0; (void)index;
129 auto valueGroup0 = getODSOperands(0);
130
131 for (auto v : valueGroup0) {
132 if (::mlir::failed(__mlir_ods_local_type_constraint_Ops1(*this, v.getType(), "operand", index++)))
133 return ::mlir::failure();
134 }
135 }
136 {
137 unsigned index = 0; (void)index;
138 auto valueGroup0 = getODSResults(0);
139
140 for (auto v : valueGroup0) {
141 if (::mlir::failed(__mlir_ods_local_type_constraint_Ops2(*this, v.getType(), "result", index++)))
142 return ::mlir::failure();
143 }
144 }
145 return ::mlir::success();
146}
147
148::llvm::LogicalResult FeltToIndexOp::verifyInvariants() {
149 return verifyInvariantsImpl();
150}
151
152::llvm::LogicalResult FeltToIndexOp::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) {
153 inferredReturnTypes.resize(1);
154 ::mlir::Builder odsBuilder(context);
155 ::mlir::Type odsInferredType0 = odsBuilder.getIndexType();
156 inferredReturnTypes[0] = odsInferredType0;
157 return ::mlir::success();
158}
159
160::mlir::ParseResult FeltToIndexOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
161 ::mlir::OpAsmParser::UnresolvedOperand valueRawOperand{};
162 ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> valueOperands(&valueRawOperand, 1); ::llvm::SMLoc valueOperandsLoc;
163 (void)valueOperandsLoc;
164 ::mlir::Type valueRawType{};
165 ::llvm::ArrayRef<::mlir::Type> valueTypes(&valueRawType, 1);
166
167 valueOperandsLoc = parser.getCurrentLocation();
168 if (parser.parseOperand(valueRawOperand))
169 return ::mlir::failure();
170 {
171 auto odsResult = parseInferredOrParsedType(parser, valueRawType, true);
172 if (odsResult) return ::mlir::failure();
173 }
174 {
175 auto loc = parser.getCurrentLocation();(void)loc;
176 if (parser.parseOptionalAttrDict(result.attributes))
177 return ::mlir::failure();
178 }
179 ::mlir::Type odsBuildableType0 = parser.getBuilder().getIndexType();
180 result.addTypes(odsBuildableType0);
181 if (parser.resolveOperands(valueOperands, valueTypes, valueOperandsLoc, result.operands))
182 return ::mlir::failure();
183 return ::mlir::success();
184}
185
186void FeltToIndexOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
187 _odsPrinter << ' ';
188 _odsPrinter << getValue();
189 printInferredOrParsedType(_odsPrinter, *this, getValue().getType(), true);
190 ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
191 _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
192}
193
194void FeltToIndexOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
195}
196
197} // namespace cast
198} // namespace llzk
199MLIR_DEFINE_EXPLICIT_TYPE_ID(::llzk::cast::FeltToIndexOp)
200
201namespace llzk {
202namespace cast {
203
204//===----------------------------------------------------------------------===//
205// ::llzk::cast::IntToFeltOp definitions
206//===----------------------------------------------------------------------===//
207
208namespace detail {
209} // namespace detail
211
212::llvm::LogicalResult IntToFeltOpAdaptor::verify(::mlir::Location loc) {
213 return ::mlir::success();
214}
215
216void IntToFeltOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value value) {
217 odsState.addOperands(value);
218 odsState.addTypes(result);
219}
220
221void IntToFeltOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Value value) {
222 odsState.addOperands(value);
223
224 ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes;
225 if (::mlir::succeeded(IntToFeltOp::inferReturnTypes(odsBuilder.getContext(),
226 odsState.location, odsState.operands,
227 odsState.attributes.getDictionary(odsState.getContext()),
228 odsState.getRawProperties(),
229 odsState.regions, inferredReturnTypes)))
230 odsState.addTypes(inferredReturnTypes);
231 else
232 ::mlir::detail::reportFatalInferReturnTypesError(odsState);
233
234}
235
236void IntToFeltOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value value) {
237 odsState.addOperands(value);
238 assert(resultTypes.size() == 1u && "mismatched number of results");
239 odsState.addTypes(resultTypes);
240}
241
242void IntToFeltOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
243 assert(operands.size() == 1u && "mismatched number of parameters");
244 odsState.addOperands(operands);
245 odsState.addAttributes(attributes);
246 assert(resultTypes.size() == 1u && "mismatched number of return types");
247 odsState.addTypes(resultTypes);
248}
249
250void IntToFeltOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
251 assert(operands.size() == 1u && "mismatched number of parameters");
252 odsState.addOperands(operands);
253 odsState.addAttributes(attributes);
254
255 ::llvm::SmallVector<::mlir::Type, 2> inferredReturnTypes;
256 if (::mlir::succeeded(IntToFeltOp::inferReturnTypes(odsBuilder.getContext(),
257 odsState.location, operands,
258 odsState.attributes.getDictionary(odsState.getContext()),
259 odsState.getRawProperties(),
260 odsState.regions, inferredReturnTypes))) {
261 assert(inferredReturnTypes.size() == 1u && "mismatched number of return types");
262 odsState.addTypes(inferredReturnTypes);
263 } else {
264 ::llvm::report_fatal_error("Failed to infer result type(s).");
265 }
266}
267
268::llvm::LogicalResult IntToFeltOp::verifyInvariantsImpl() {
269 {
270 unsigned index = 0; (void)index;
271 auto valueGroup0 = getODSOperands(0);
272
273 for (auto v : valueGroup0) {
274 if (::mlir::failed(__mlir_ods_local_type_constraint_Ops3(*this, v.getType(), "operand", index++)))
275 return ::mlir::failure();
276 }
277 }
278 {
279 unsigned index = 0; (void)index;
280 auto valueGroup0 = getODSResults(0);
281
282 for (auto v : valueGroup0) {
283 if (::mlir::failed(__mlir_ods_local_type_constraint_Ops1(*this, v.getType(), "result", index++)))
284 return ::mlir::failure();
285 }
286 }
287 return ::mlir::success();
288}
289
290::llvm::LogicalResult IntToFeltOp::verifyInvariants() {
291 return verifyInvariantsImpl();
292}
293
294::llvm::LogicalResult IntToFeltOp::inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location> location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type>&inferredReturnTypes) {
295 inferredReturnTypes.resize(1);
296 ::mlir::Builder odsBuilder(context);
297 ::mlir::Type odsInferredType0 = ::llzk::felt::FeltType::get(odsBuilder.getContext());
298 inferredReturnTypes[0] = odsInferredType0;
299 return ::mlir::success();
300}
301
302::mlir::ParseResult IntToFeltOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
303 ::mlir::OpAsmParser::UnresolvedOperand valueRawOperand{};
304 ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> valueOperands(&valueRawOperand, 1); ::llvm::SMLoc valueOperandsLoc;
305 (void)valueOperandsLoc;
306 ::mlir::Type valueRawType{};
307 ::llvm::ArrayRef<::mlir::Type> valueTypes(&valueRawType, 1);
308 ::mlir::Type resultRawType{};
309 ::llvm::ArrayRef<::mlir::Type> resultTypes(&resultRawType, 1);
310
311 valueOperandsLoc = parser.getCurrentLocation();
312 if (parser.parseOperand(valueRawOperand))
313 return ::mlir::failure();
314 if (parser.parseColon())
315 return ::mlir::failure();
316
317 {
318 ::mlir::Type type;
319 if (parser.parseCustomTypeWithFallback(type))
320 return ::mlir::failure();
321 valueRawType = type;
322 }
323 {
324 auto odsResult = parseInferredOrParsedType(parser, resultRawType, false);
325 if (odsResult) return ::mlir::failure();
326 }
327 {
328 auto loc = parser.getCurrentLocation();(void)loc;
329 if (parser.parseOptionalAttrDict(result.attributes))
330 return ::mlir::failure();
331 }
332 result.addTypes(resultTypes);
333 if (parser.resolveOperands(valueOperands, valueTypes, valueOperandsLoc, result.operands))
334 return ::mlir::failure();
335 return ::mlir::success();
336}
337
338void IntToFeltOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
339 _odsPrinter << ' ';
340 _odsPrinter << getValue();
341 _odsPrinter << ' ' << ":";
342 _odsPrinter << ' ';
343 {
344 auto type = getValue().getType();
345 if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type))
346 _odsPrinter.printStrippedAttrOrType(validType);
347 else
348 _odsPrinter << type;
349 }
350 printInferredOrParsedType(_odsPrinter, *this, getResult().getType(), false);
351 ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
352 _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
353}
354
355void IntToFeltOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
356}
357
358} // namespace cast
359} // namespace llzk
360MLIR_DEFINE_EXPLICIT_TYPE_ID(::llzk::cast::IntToFeltOp)
361
362
363#endif // GET_OP_CLASSES
364
::llvm::LogicalResult verify(::mlir::Location loc)
Definition Ops.cpp.inc:70
FeltToIndexOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs={}, const ::mlir::EmptyProperties &properties={}, ::mlir::RegionRange regions={})
Definition Ops.h.inc:59
FeltToIndexOpAdaptor(FeltToIndexOp op)
Definition Ops.cpp.inc:68
::llvm::LogicalResult verifyInvariants()
Definition Ops.cpp.inc:148
void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect > > &effects)
Definition Ops.cpp.inc:194
static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value value)
Definition Ops.cpp.inc:74
::mlir::TypedValue<::llzk::felt::FeltType > getValue()
Definition Ops.h.inc:122
void print(::mlir::OpAsmPrinter &_odsPrinter)
Definition Ops.cpp.inc:186
::mlir::Operation::result_range getODSResults(unsigned index)
Definition Ops.h.inc:135
::llvm::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location > location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type > &inferredReturnTypes)
Definition Ops.cpp.inc:152
::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result)
Definition Ops.cpp.inc:160
::mlir::Operation::operand_range getODSOperands(unsigned index)
Definition Ops.h.inc:116
::llvm::LogicalResult verifyInvariantsImpl()
Definition Ops.cpp.inc:126
::llvm::LogicalResult verify(::mlir::Location loc)
Definition Ops.cpp.inc:212
IntToFeltOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs={}, const ::mlir::EmptyProperties &properties={}, ::mlir::RegionRange regions={})
Definition Ops.h.inc:223
IntToFeltOpAdaptor(IntToFeltOp op)
Definition Ops.cpp.inc:210
void print(::mlir::OpAsmPrinter &_odsPrinter)
Definition Ops.cpp.inc:338
::llvm::LogicalResult verifyInvariantsImpl()
Definition Ops.cpp.inc:268
::llvm::LogicalResult inferReturnTypes(::mlir::MLIRContext *context, ::std::optional<::mlir::Location > location, ::mlir::ValueRange operands, ::mlir::DictionaryAttr attributes, ::mlir::OpaqueProperties properties, ::mlir::RegionRange regions, ::llvm::SmallVectorImpl<::mlir::Type > &inferredReturnTypes)
Definition Ops.cpp.inc:294
void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect > > &effects)
Definition Ops.cpp.inc:355
::mlir::Operation::operand_range getODSOperands(unsigned index)
Definition Ops.h.inc:280
::mlir::TypedValue<::llzk::felt::FeltType > getResult()
Definition Ops.h.inc:305
::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result)
Definition Ops.cpp.inc:302
static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value value)
Definition Ops.cpp.inc:216
::mlir::Operation::result_range getODSResults(unsigned index)
Definition Ops.h.inc:299
::llvm::LogicalResult verifyInvariants()
Definition Ops.cpp.inc:290
::mlir::TypedValue<::mlir::Type > getValue()
Definition Ops.h.inc:286
static FeltType get(::mlir::MLIRContext *context, ::mlir::StringAttr fieldName)
Definition Types.cpp.inc:67