LLZK 3.0.0
An open-source IR for Zero Knowledge (ZK) circuits
Loading...
Searching...
No Matches
Attrs.cpp.inc
Go to the documentation of this file.
1/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\
2|* *|
3|* AttrDef Definitions *|
4|* *|
5|* Automatically generated file, do not edit! *|
6|* *|
7\*===----------------------------------------------------------------------===*/
8
9#ifdef GET_ATTRDEF_LIST
10#undef GET_ATTRDEF_LIST
11
12::llzk::PublicAttr,
13::llzk::LoopBoundsAttr
14
15#endif // GET_ATTRDEF_LIST
16
17#ifdef GET_ATTRDEF_CLASSES
18#undef GET_ATTRDEF_CLASSES
19
20static ::mlir::OptionalParseResult generatedAttributeParser(::mlir::AsmParser &parser, ::llvm::StringRef *mnemonic, ::mlir::Type type, ::mlir::Attribute &value) {
21 return ::mlir::AsmParser::KeywordSwitch<::mlir::OptionalParseResult>(parser)
22 .Case(::llzk::PublicAttr::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) {
23 value = ::llzk::PublicAttr::get(parser.getContext());
24 return ::mlir::success(!!value);
25 })
26 .Case(::llzk::LoopBoundsAttr::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) {
27 value = ::llzk::LoopBoundsAttr::parse(parser, type);
28 return ::mlir::success(!!value);
29 })
30 .Default([&](llvm::StringRef keyword, llvm::SMLoc) {
31 *mnemonic = keyword;
32 return std::nullopt;
33 });
34}
35
36static ::llvm::LogicalResult generatedAttributePrinter(::mlir::Attribute def, ::mlir::AsmPrinter &printer) {
37 return ::llvm::TypeSwitch<::mlir::Attribute, ::llvm::LogicalResult>(def) .Case<::llzk::PublicAttr>([&](auto t) {
38 printer << ::llzk::PublicAttr::getMnemonic();
39 return ::mlir::success();
40 })
41 .Case<::llzk::LoopBoundsAttr>([&](auto t) {
42 printer << ::llzk::LoopBoundsAttr::getMnemonic();
43t.print(printer);
44 return ::mlir::success();
45 })
46 .Default([](auto) { return ::mlir::failure(); });
47}
48
49namespace llzk {
50
51
52} // namespace llzk
53MLIR_DEFINE_EXPLICIT_TYPE_ID(::llzk::PublicAttr)
54namespace llzk {
55
56namespace detail {
57
58struct LoopBoundsAttrStorage : public ::mlir::AttributeStorage {
59 using KeyTy = std::tuple<::llzk::DynamicAPIntValue, ::llzk::DynamicAPIntValue, ::llzk::DynamicAPIntValue>;
60 LoopBoundsAttrStorage(::llzk::DynamicAPIntValue lower, ::llzk::DynamicAPIntValue upper, ::llzk::DynamicAPIntValue step) : lower(std::move(lower)), upper(std::move(upper)), step(std::move(step)) {}
61
62 KeyTy getAsKey() const {
63 return KeyTy(lower, upper, step);
64 }
65
66 bool operator==(const KeyTy &tblgenKey) const {
67 return (lower == std::get<0>(tblgenKey)) && (upper == std::get<1>(tblgenKey)) && (step == std::get<2>(tblgenKey));
68 }
69
70 static ::llvm::hash_code hashKey(const KeyTy &tblgenKey) {
71 return ::llvm::hash_combine(std::get<0>(tblgenKey), std::get<1>(tblgenKey), std::get<2>(tblgenKey));
72 }
73
74 static LoopBoundsAttrStorage *construct(::mlir::AttributeStorageAllocator &allocator, KeyTy &&tblgenKey) {
75 auto lower = std::move(std::get<0>(tblgenKey));
76 auto upper = std::move(std::get<1>(tblgenKey));
77 auto step = std::move(std::get<2>(tblgenKey));
78 return new (allocator.allocate<LoopBoundsAttrStorage>()) LoopBoundsAttrStorage(std::move(lower), std::move(upper), std::move(step));
79 }
80
81 ::llzk::DynamicAPIntValue lower;
82 ::llzk::DynamicAPIntValue upper;
83 ::llzk::DynamicAPIntValue step;
84};
85
86} // namespace detail
87LoopBoundsAttr LoopBoundsAttr::get(::mlir::MLIRContext *context, ::llzk::DynamicAPIntValue lower, ::llzk::DynamicAPIntValue upper, ::llzk::DynamicAPIntValue step) {
88 return Base::get(context, std::move(lower), std::move(upper), std::move(step));
89}
90
91LoopBoundsAttr LoopBoundsAttr::get(::mlir::MLIRContext *context, const ::llvm::DynamicAPInt &lower, const ::llvm::DynamicAPInt &upper, const ::llvm::DynamicAPInt &step) {
92 return Base::get(context,
93 ::llzk::DynamicAPIntValue(lower),
94 ::llzk::DynamicAPIntValue(upper),
95 ::llzk::DynamicAPIntValue(step));
96}
97
98::mlir::Attribute LoopBoundsAttr::parse(::mlir::AsmParser &odsParser, ::mlir::Type odsType) {
99 ::mlir::Builder odsBuilder(odsParser.getContext());
100 ::llvm::SMLoc odsLoc = odsParser.getCurrentLocation();
101 (void) odsLoc;
102 ::mlir::FailureOr<::llzk::DynamicAPIntValue> _result_lower;
103 ::mlir::FailureOr<::llzk::DynamicAPIntValue> _result_upper;
104 ::mlir::FailureOr<::llzk::DynamicAPIntValue> _result_step;
105 // Parse literal '<'
106 if (odsParser.parseLess()) return {};
107
108 // Parse variable 'lower'
109 _result_lower = ::llzk::parseDynamicAPIntValue(odsParser);
110 if (::mlir::failed(_result_lower)) {
111 odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse LLZK_LoopBoundsAttr parameter 'lower' which is to be a `::llzk::DynamicAPIntValue`");
112 return {};
113 }
114 // Parse literal 'to'
115 if (odsParser.parseKeyword("to")) return {};
116
117 // Parse variable 'upper'
118 _result_upper = ::llzk::parseDynamicAPIntValue(odsParser);
119 if (::mlir::failed(_result_upper)) {
120 odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse LLZK_LoopBoundsAttr parameter 'upper' which is to be a `::llzk::DynamicAPIntValue`");
121 return {};
122 }
123 // Parse literal 'step'
124 if (odsParser.parseKeyword("step")) return {};
125
126 // Parse variable 'step'
127 _result_step = ::llzk::parseDynamicAPIntValue(odsParser);
128 if (::mlir::failed(_result_step)) {
129 odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse LLZK_LoopBoundsAttr parameter 'step' which is to be a `::llzk::DynamicAPIntValue`");
130 return {};
131 }
132 // Parse literal '>'
133 if (odsParser.parseGreater()) return {};
134 assert(::mlir::succeeded(_result_lower));
135 assert(::mlir::succeeded(_result_upper));
136 assert(::mlir::succeeded(_result_step));
137 return LoopBoundsAttr::get(odsParser.getContext(),
138 ::llzk::DynamicAPIntValue((*_result_lower)),
139 ::llzk::DynamicAPIntValue((*_result_upper)),
140 ::llzk::DynamicAPIntValue((*_result_step)));
141}
142
143void LoopBoundsAttr::print(::mlir::AsmPrinter &odsPrinter) const {
144 ::mlir::Builder odsBuilder(getContext());
145 odsPrinter << "<";
146 odsPrinter << getLower();
147 odsPrinter << ' ' << "to";
148 odsPrinter << ' ';
149 odsPrinter << getUpper();
150 odsPrinter << ' ' << "step";
151 odsPrinter << ' ';
152 odsPrinter << getStep();
153 odsPrinter << ">";
154}
155
156const ::llvm::DynamicAPInt &LoopBoundsAttr::getLower() const {
157 return getImpl()->lower;
158}
159
160const ::llvm::DynamicAPInt &LoopBoundsAttr::getUpper() const {
161 return getImpl()->upper;
162}
163
164const ::llvm::DynamicAPInt &LoopBoundsAttr::getStep() const {
165 return getImpl()->step;
166}
167
168
169} // namespace llzk
170MLIR_DEFINE_EXPLICIT_TYPE_ID(::llzk::LoopBoundsAttr)
171namespace llzk {
172
173
175::mlir::Attribute LLZKDialect::parseAttribute(::mlir::DialectAsmParser &parser,
176 ::mlir::Type type) const {
177 ::llvm::SMLoc typeLoc = parser.getCurrentLocation();
178 ::llvm::StringRef attrTag;
179 {
180 ::mlir::Attribute attr;
181 auto parseResult = generatedAttributeParser(parser, &attrTag, type, attr);
182 if (parseResult.has_value())
183 return attr;
184 }
185
186 parser.emitError(typeLoc) << "unknown attribute `"
187 << attrTag << "` in dialect `" << getNamespace() << "`";
188 return {};
189}
191void LLZKDialect::printAttribute(::mlir::Attribute attr,
192 ::mlir::DialectAsmPrinter &printer) const {
193 if (::mlir::succeeded(generatedAttributePrinter(attr, printer)))
194 return;
195
196}
197
198} // namespace llzk
199
200#endif // GET_ATTRDEF_CLASSES
201
::mlir::Attribute parseAttribute(::mlir::DialectAsmParser &parser, ::mlir::Type type) const override
Parse an attribute registered to this dialect.
void printAttribute(::mlir::Attribute attr, ::mlir::DialectAsmPrinter &os) const override
Print an attribute registered to this dialect.
Provides the necessary information to the RemoveUnusedDiscardableAllocations pass about operations th...
Definition Ops.cpp.inc:41
mlir::FailureOr< DynamicAPIntValue > parseDynamicAPIntValue(mlir::AsmParser &parser)
Parse MLIR's signed integer literal and discard its encoding width.