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
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 ::mlir::LogicalResult __mlir_ods_local_type_constraint_Ops0(
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 ::mlir::LogicalResult __mlir_ods_local_type_constraint_Ops1(
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 ::mlir::LogicalResult __mlir_ods_local_type_constraint_Ops2(
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 {
67FeltToIndexOpGenericAdaptorBase::FeltToIndexOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const ::mlir::EmptyProperties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), odsRegions(regions) { if (odsAttrs)
68 odsOpName.emplace("cast.toindex", odsAttrs.getContext());
69}
70
71FeltToIndexOpGenericAdaptorBase::FeltToIndexOpGenericAdaptorBase(FeltToIndexOp op) : FeltToIndexOpGenericAdaptorBase(op->getAttrDictionary(), op.getProperties(), op->getRegions()) {}
72
73std::pair<unsigned, unsigned> FeltToIndexOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) {
74 return {index, 1};
75}
76
78 return odsAttrs;
79}
80
81} // namespace detail
83
84::mlir::LogicalResult FeltToIndexOpAdaptor::verify(::mlir::Location loc) {
85 return ::mlir::success();
86}
87
88std::pair<unsigned, unsigned> FeltToIndexOp::getODSOperandIndexAndLength(unsigned index) {
89 return {index, 1};
90}
91
92::mlir::Operation::operand_range FeltToIndexOp::getODSOperands(unsigned index) {
93 auto valueRange = getODSOperandIndexAndLength(index);
94 return {std::next(getOperation()->operand_begin(), valueRange.first),
95 std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)};
96}
97
98::mlir::TypedValue<::llzk::felt::FeltType> FeltToIndexOp::getValue() {
99 return ::llvm::cast<::mlir::TypedValue<::llzk::felt::FeltType>>(*getODSOperands(0).begin());
100}
101
102::mlir::OpOperand &FeltToIndexOp::getValueMutable() {
103 auto range = getODSOperandIndexAndLength(0);
104 return getOperation()->getOpOperand(range.first);
105}
106
107std::pair<unsigned, unsigned> FeltToIndexOp::getODSResultIndexAndLength(unsigned index) {
108 return {index, 1};
109}
110
111::mlir::Operation::result_range FeltToIndexOp::getODSResults(unsigned index) {
112 auto valueRange = getODSResultIndexAndLength(index);
113 return {std::next(getOperation()->result_begin(), valueRange.first),
114 std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)};
115}
116
117::mlir::TypedValue<::mlir::IndexType> FeltToIndexOp::getResult() {
118 return ::llvm::cast<::mlir::TypedValue<::mlir::IndexType>>(*getODSResults(0).begin());
119}
120
121void FeltToIndexOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value value) {
122 odsState.addOperands(value);
123 odsState.addTypes(result);
124}
125
126void FeltToIndexOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value value) {
127 odsState.addOperands(value);
128 assert(resultTypes.size() == 1u && "mismatched number of results");
129 odsState.addTypes(resultTypes);
130}
131
132void FeltToIndexOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
133 assert(operands.size() == 1u && "mismatched number of parameters");
134 odsState.addOperands(operands);
135 odsState.addAttributes(attributes);
136 assert(resultTypes.size() == 1u && "mismatched number of return types");
137 odsState.addTypes(resultTypes);
138}
139
140::mlir::LogicalResult FeltToIndexOp::verifyInvariantsImpl() {
141 {
142 unsigned index = 0; (void)index;
143 auto valueGroup0 = getODSOperands(0);
144
145 for (auto v : valueGroup0) {
146 if (::mlir::failed(__mlir_ods_local_type_constraint_Ops0(*this, v.getType(), "operand", index++)))
147 return ::mlir::failure();
148 }
149 }
150 {
151 unsigned index = 0; (void)index;
152 auto valueGroup0 = getODSResults(0);
153
154 for (auto v : valueGroup0) {
155 if (::mlir::failed(__mlir_ods_local_type_constraint_Ops1(*this, v.getType(), "result", index++)))
156 return ::mlir::failure();
157 }
158 }
159 return ::mlir::success();
160}
161
162::mlir::LogicalResult FeltToIndexOp::verifyInvariants() {
163 if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify()))
164 return ::mlir::success();
165 return ::mlir::failure();
166}
167
168::mlir::ParseResult FeltToIndexOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
169 ::mlir::OpAsmParser::UnresolvedOperand valueRawOperands[1];
170 ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> valueOperands(valueRawOperands); ::llvm::SMLoc valueOperandsLoc;
171 (void)valueOperandsLoc;
172
173 valueOperandsLoc = parser.getCurrentLocation();
174 if (parser.parseOperand(valueRawOperands[0]))
175 return ::mlir::failure();
176 {
177 auto loc = parser.getCurrentLocation();(void)loc;
178 if (parser.parseOptionalAttrDict(result.attributes))
179 return ::mlir::failure();
180 }
181 ::mlir::Type odsBuildableType0 = parser.getBuilder().getIndexType();
182 ::mlir::Type odsBuildableType1 = parser.getBuilder().getType<::llzk::felt::FeltType>();
183 result.addTypes(odsBuildableType0);
184 if (parser.resolveOperands(valueOperands, odsBuildableType1, valueOperandsLoc, result.operands))
185 return ::mlir::failure();
186 return ::mlir::success();
187}
188
189void FeltToIndexOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
190 _odsPrinter << ' ';
191 _odsPrinter << getValue();
192 ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
193 _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
194}
195
196void FeltToIndexOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
197}
198
199} // namespace cast
200} // namespace llzk
201MLIR_DEFINE_EXPLICIT_TYPE_ID(::llzk::cast::FeltToIndexOp)
202
203namespace llzk {
204namespace cast {
205
206//===----------------------------------------------------------------------===//
207// ::llzk::cast::IntToFeltOp definitions
208//===----------------------------------------------------------------------===//
209
210namespace detail {
211IntToFeltOpGenericAdaptorBase::IntToFeltOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const ::mlir::EmptyProperties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), odsRegions(regions) { if (odsAttrs)
212 odsOpName.emplace("cast.tofelt", odsAttrs.getContext());
213}
214
215IntToFeltOpGenericAdaptorBase::IntToFeltOpGenericAdaptorBase(IntToFeltOp op) : IntToFeltOpGenericAdaptorBase(op->getAttrDictionary(), op.getProperties(), op->getRegions()) {}
216
217std::pair<unsigned, unsigned> IntToFeltOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) {
218 return {index, 1};
219}
220
222 return odsAttrs;
223}
224
225} // namespace detail
227
228::mlir::LogicalResult IntToFeltOpAdaptor::verify(::mlir::Location loc) {
229 return ::mlir::success();
230}
231
232std::pair<unsigned, unsigned> IntToFeltOp::getODSOperandIndexAndLength(unsigned index) {
233 return {index, 1};
234}
235
236::mlir::Operation::operand_range IntToFeltOp::getODSOperands(unsigned index) {
237 auto valueRange = getODSOperandIndexAndLength(index);
238 return {std::next(getOperation()->operand_begin(), valueRange.first),
239 std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)};
240}
241
242::mlir::Value IntToFeltOp::getValue() {
243 return ::llvm::cast<::mlir::Value>(*getODSOperands(0).begin());
244}
245
246::mlir::OpOperand &IntToFeltOp::getValueMutable() {
247 auto range = getODSOperandIndexAndLength(0);
248 return getOperation()->getOpOperand(range.first);
249}
250
251std::pair<unsigned, unsigned> IntToFeltOp::getODSResultIndexAndLength(unsigned index) {
252 return {index, 1};
253}
254
255::mlir::Operation::result_range IntToFeltOp::getODSResults(unsigned index) {
256 auto valueRange = getODSResultIndexAndLength(index);
257 return {std::next(getOperation()->result_begin(), valueRange.first),
258 std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)};
259}
260
261::mlir::TypedValue<::llzk::felt::FeltType> IntToFeltOp::getResult() {
262 return ::llvm::cast<::mlir::TypedValue<::llzk::felt::FeltType>>(*getODSResults(0).begin());
263}
264
265void IntToFeltOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value value) {
266 odsState.addOperands(value);
267 odsState.addTypes(result);
268}
269
270void IntToFeltOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::Value value) {
271 odsState.addOperands(value);
272 assert(resultTypes.size() == 1u && "mismatched number of results");
273 odsState.addTypes(resultTypes);
274}
275
276void IntToFeltOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
277 assert(operands.size() == 1u && "mismatched number of parameters");
278 odsState.addOperands(operands);
279 odsState.addAttributes(attributes);
280 assert(resultTypes.size() == 1u && "mismatched number of return types");
281 odsState.addTypes(resultTypes);
282}
283
284::mlir::LogicalResult IntToFeltOp::verifyInvariantsImpl() {
285 {
286 unsigned index = 0; (void)index;
287 auto valueGroup0 = getODSOperands(0);
288
289 for (auto v : valueGroup0) {
290 if (::mlir::failed(__mlir_ods_local_type_constraint_Ops2(*this, v.getType(), "operand", index++)))
291 return ::mlir::failure();
292 }
293 }
294 {
295 unsigned index = 0; (void)index;
296 auto valueGroup0 = getODSResults(0);
297
298 for (auto v : valueGroup0) {
299 if (::mlir::failed(__mlir_ods_local_type_constraint_Ops0(*this, v.getType(), "result", index++)))
300 return ::mlir::failure();
301 }
302 }
303 return ::mlir::success();
304}
305
306::mlir::LogicalResult IntToFeltOp::verifyInvariants() {
307 return verifyInvariantsImpl();
308}
309
310::mlir::ParseResult IntToFeltOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
311 ::mlir::OpAsmParser::UnresolvedOperand valueRawOperands[1];
312 ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> valueOperands(valueRawOperands); ::llvm::SMLoc valueOperandsLoc;
313 (void)valueOperandsLoc;
314 ::mlir::Type valueRawTypes[1];
315 ::llvm::ArrayRef<::mlir::Type> valueTypes(valueRawTypes);
316
317 valueOperandsLoc = parser.getCurrentLocation();
318 if (parser.parseOperand(valueRawOperands[0]))
319 return ::mlir::failure();
320 if (parser.parseColon())
321 return ::mlir::failure();
322
323 {
324 ::mlir::Type type;
325 if (parser.parseCustomTypeWithFallback(type))
326 return ::mlir::failure();
327 valueRawTypes[0] = type;
328 }
329 {
330 auto loc = parser.getCurrentLocation();(void)loc;
331 if (parser.parseOptionalAttrDict(result.attributes))
332 return ::mlir::failure();
333 }
334 ::mlir::Type odsBuildableType0 = parser.getBuilder().getType<::llzk::felt::FeltType>();
335 result.addTypes(odsBuildableType0);
336 if (parser.resolveOperands(valueOperands, valueTypes, valueOperandsLoc, result.operands))
337 return ::mlir::failure();
338 return ::mlir::success();
339}
340
341void IntToFeltOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
342 _odsPrinter << ' ';
343 _odsPrinter << getValue();
344 _odsPrinter << ' ' << ":";
345 _odsPrinter << ' ';
346 {
347 auto type = getValue().getType();
348 if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type))
349 _odsPrinter.printStrippedAttrOrType(validType);
350 else
351 _odsPrinter << type;
352 }
353 ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
354 _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
355}
356
357void IntToFeltOp::getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect>> &effects) {
358}
359
360} // namespace cast
361} // namespace llzk
362MLIR_DEFINE_EXPLICIT_TYPE_ID(::llzk::cast::IntToFeltOp)
363
364
365#endif // GET_OP_CLASSES
366
::mlir::LogicalResult verify(::mlir::Location loc)
Definition Ops.cpp.inc:84
FeltToIndexOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs=nullptr, const ::mlir::EmptyProperties &properties={}, ::mlir::RegionRange regions={})
Definition Ops.h.inc:60
FeltToIndexOpAdaptor(FeltToIndexOp op)
Definition Ops.cpp.inc:82
::mlir::OpOperand & getValueMutable()
Definition Ops.cpp.inc:102
::mlir::TypedValue<::mlir::IndexType > getResult()
Definition Ops.cpp.inc:117
::mlir::Operation::operand_range getODSOperands(unsigned index)
Definition Ops.cpp.inc:92
::mlir::Operation::result_range getODSResults(unsigned index)
Definition Ops.cpp.inc:111
void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect > > &effects)
Definition Ops.cpp.inc:196
::mlir::LogicalResult verify()
Definition Ops.cpp:28
static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value value)
Definition Ops.cpp.inc:121
std::pair< unsigned, unsigned > getODSResultIndexAndLength(unsigned index)
Definition Ops.cpp.inc:107
std::pair< unsigned, unsigned > getODSOperandIndexAndLength(unsigned index)
Definition Ops.cpp.inc:88
void print(::mlir::OpAsmPrinter &_odsPrinter)
Definition Ops.cpp.inc:189
::mlir::LogicalResult verifyInvariants()
Definition Ops.cpp.inc:162
::mlir::LogicalResult verifyInvariantsImpl()
Definition Ops.cpp.inc:140
::mlir::TypedValue<::llzk::felt::FeltType > getValue()
Definition Ops.cpp.inc:98
::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result)
Definition Ops.cpp.inc:168
IntToFeltOpAdaptor(IntToFeltOp op)
Definition Ops.cpp.inc:226
IntToFeltOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs=nullptr, const ::mlir::EmptyProperties &properties={}, ::mlir::RegionRange regions={})
Definition Ops.h.inc:161
::mlir::LogicalResult verify(::mlir::Location loc)
Definition Ops.cpp.inc:228
::mlir::LogicalResult verifyInvariantsImpl()
Definition Ops.cpp.inc:284
void print(::mlir::OpAsmPrinter &_odsPrinter)
Definition Ops.cpp.inc:341
::mlir::Operation::operand_range getODSOperands(unsigned index)
Definition Ops.cpp.inc:236
void getEffects(::llvm::SmallVectorImpl<::mlir::SideEffects::EffectInstance<::mlir::MemoryEffects::Effect > > &effects)
Definition Ops.cpp.inc:357
std::pair< unsigned, unsigned > getODSOperandIndexAndLength(unsigned index)
Definition Ops.cpp.inc:232
::mlir::LogicalResult verifyInvariants()
Definition Ops.cpp.inc:306
std::pair< unsigned, unsigned > getODSResultIndexAndLength(unsigned index)
Definition Ops.cpp.inc:251
::mlir::TypedValue<::llzk::felt::FeltType > getResult()
Definition Ops.cpp.inc:261
::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result)
Definition Ops.cpp.inc:310
static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type result, ::mlir::Value value)
Definition Ops.cpp.inc:265
::mlir::Operation::result_range getODSResults(unsigned index)
Definition Ops.cpp.inc:255
::mlir::OpOperand & getValueMutable()
Definition Ops.cpp.inc:246
::mlir::Value getValue()
Definition Ops.cpp.inc:242
::std::optional<::mlir::OperationName > odsOpName
Definition Ops.h.inc:44
FeltToIndexOpGenericAdaptorBase(::mlir::DictionaryAttr attrs=nullptr, const ::mlir::EmptyProperties &properties={}, ::mlir::RegionRange regions={})
Definition Ops.cpp.inc:67
std::pair< unsigned, unsigned > getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize)
Definition Ops.cpp.inc:73
::std::optional<::mlir::OperationName > odsOpName
Definition Ops.h.inc:145
IntToFeltOpGenericAdaptorBase(::mlir::DictionaryAttr attrs=nullptr, const ::mlir::EmptyProperties &properties={}, ::mlir::RegionRange regions={})
Definition Ops.cpp.inc:211
std::pair< unsigned, unsigned > getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize)
Definition Ops.cpp.inc:217