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
16#endif // GET_OP_LIST
17
18#ifdef GET_OP_CLASSES
19#undef GET_OP_CLASSES
20
21
22//===----------------------------------------------------------------------===//
23// Local Utility Method Definitions
24//===----------------------------------------------------------------------===//
25
26namespace llzk {
27namespace global {
28
29static ::mlir::LogicalResult __mlir_ods_local_type_constraint_Ops0(
30 ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind,
31 unsigned valueIndex) {
32 if (!((::llzk::isValidGlobalType(type)))) {
33 return op->emitOpError(valueKind) << " #" << valueIndex
34 << " must be any LLZK type except non-constant types, but got " << type;
35 }
36 return ::mlir::success();
37}
38
39static ::mlir::LogicalResult __mlir_ods_local_attr_constraint_Ops0(
40 ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
41 if (attr && !((::llvm::isa<::mlir::StringAttr>(attr))))
42 return emitError() << "attribute '" << attrName
43 << "' failed to satisfy constraint: string attribute";
44 return ::mlir::success();
45}
46static ::mlir::LogicalResult __mlir_ods_local_attr_constraint_Ops0(
47 ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) {
48 return __mlir_ods_local_attr_constraint_Ops0(attr, attrName, [op]() {
49 return op->emitOpError();
50 });
51}
52
53static ::mlir::LogicalResult __mlir_ods_local_attr_constraint_Ops1(
54 ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
55 if (attr && !((::llvm::isa<::mlir::UnitAttr>(attr))))
56 return emitError() << "attribute '" << attrName
57 << "' failed to satisfy constraint: unit attribute";
58 return ::mlir::success();
59}
60static ::mlir::LogicalResult __mlir_ods_local_attr_constraint_Ops1(
61 ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) {
62 return __mlir_ods_local_attr_constraint_Ops1(attr, attrName, [op]() {
63 return op->emitOpError();
64 });
65}
66
67static ::mlir::LogicalResult __mlir_ods_local_attr_constraint_Ops2(
68 ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
69 if (attr && !(((::llvm::isa<::mlir::TypeAttr>(attr))) && ((::llvm::isa<::mlir::Type>(::llvm::cast<::mlir::TypeAttr>(attr).getValue()))) && ((::llzk::isValidGlobalType(::llvm::cast<::mlir::TypeAttr>(attr).getValue())))))
70 return emitError() << "attribute '" << attrName
71 << "' failed to satisfy constraint: type attribute of any LLZK type except non-constant types";
72 return ::mlir::success();
73}
74static ::mlir::LogicalResult __mlir_ods_local_attr_constraint_Ops2(
75 ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) {
76 return __mlir_ods_local_attr_constraint_Ops2(attr, attrName, [op]() {
77 return op->emitOpError();
78 });
79}
80
81static ::mlir::LogicalResult __mlir_ods_local_attr_constraint_Ops3(
82 ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
83 if (attr && !((true)))
84 return emitError() << "attribute '" << attrName
85 << "' failed to satisfy constraint: any attribute";
86 return ::mlir::success();
87}
88static ::mlir::LogicalResult __mlir_ods_local_attr_constraint_Ops3(
89 ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) {
90 return __mlir_ods_local_attr_constraint_Ops3(attr, attrName, [op]() {
91 return op->emitOpError();
92 });
93}
94
95static ::mlir::LogicalResult __mlir_ods_local_attr_constraint_Ops4(
96 ::mlir::Attribute attr, ::llvm::StringRef attrName, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
97 if (attr && !((::llvm::isa<::mlir::SymbolRefAttr>(attr))))
98 return emitError() << "attribute '" << attrName
99 << "' failed to satisfy constraint: symbol reference attribute";
100 return ::mlir::success();
101}
102static ::mlir::LogicalResult __mlir_ods_local_attr_constraint_Ops4(
103 ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) {
104 return __mlir_ods_local_attr_constraint_Ops4(attr, attrName, [op]() {
105 return op->emitOpError();
106 });
107}
108} // namespace global
109} // namespace llzk
110namespace llzk {
111namespace global {
112
113//===----------------------------------------------------------------------===//
114// ::llzk::global::GlobalDefOp definitions
115//===----------------------------------------------------------------------===//
116
117namespace detail {
118GlobalDefOpGenericAdaptorBase::GlobalDefOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs)
119 odsOpName.emplace("global.def", odsAttrs.getContext());
120}
121
123
124std::pair<unsigned, unsigned> GlobalDefOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) {
125 return {index, 1};
126}
127
129 return odsAttrs;
130}
131
133 auto attr = ::llvm::cast<::mlir::StringAttr>(getProperties().sym_name);
134 return attr;
135}
136
138 auto attr = getSymNameAttr();
139 return attr.getValue();
140}
141
143 auto attr = ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(getProperties().constant);
144 if (!attr)
145 attr = ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr);
146 return attr;
147}
148
150 auto attr = getConstantAttr();
151 if (!attr)
152 return ((false) ? ::mlir::Builder(odsAttrs.getContext()).getUnitAttr() : nullptr) != nullptr;
153 return attr != nullptr;
154}
155
157 auto attr = ::llvm::cast<::mlir::TypeAttr>(getProperties().type);
158 return attr;
159}
160
162 auto attr = getTypeAttr();
163 return ::llvm::cast<::mlir::Type>(attr.getValue());
164}
165
167 auto attr = ::llvm::dyn_cast_or_null<::mlir::Attribute>(getProperties().initial_value);
168 return attr;
169}
170
172 auto attr = getInitialValueAttr();
173 return attr;
174}
175
176} // namespace detail
178
179::mlir::LogicalResult GlobalDefOpAdaptor::verify(::mlir::Location loc) {
180 auto tblgen_constant = getProperties().constant; (void)tblgen_constant;
181 auto tblgen_initial_value = getProperties().initial_value; (void)tblgen_initial_value;
182 auto tblgen_sym_name = getProperties().sym_name; (void)tblgen_sym_name;
183 if (!tblgen_sym_name) return emitError(loc, "'global.def' op ""requires attribute 'sym_name'");
184 auto tblgen_type = getProperties().type; (void)tblgen_type;
185 if (!tblgen_type) return emitError(loc, "'global.def' op ""requires attribute 'type'");
186
187 if (tblgen_sym_name && !((::llvm::isa<::mlir::StringAttr>(tblgen_sym_name))))
188 return emitError(loc, "'global.def' op ""attribute 'sym_name' failed to satisfy constraint: string attribute");
189
190 if (tblgen_constant && !((::llvm::isa<::mlir::UnitAttr>(tblgen_constant))))
191 return emitError(loc, "'global.def' op ""attribute 'constant' failed to satisfy constraint: unit attribute");
192
193 if (tblgen_type && !(((::llvm::isa<::mlir::TypeAttr>(tblgen_type))) && ((::llvm::isa<::mlir::Type>(::llvm::cast<::mlir::TypeAttr>(tblgen_type).getValue()))) && ((::llzk::isValidGlobalType(::llvm::cast<::mlir::TypeAttr>(tblgen_type).getValue())))))
194 return emitError(loc, "'global.def' op ""attribute 'type' failed to satisfy constraint: type attribute of any LLZK type except non-constant types");
195
196 if (tblgen_initial_value && !((true)))
197 return emitError(loc, "'global.def' op ""attribute 'initial_value' failed to satisfy constraint: any attribute");
198 return ::mlir::success();
199}
200
201std::pair<unsigned, unsigned> GlobalDefOp::getODSOperandIndexAndLength(unsigned index) {
202 return {index, 1};
203}
204
205::mlir::Operation::operand_range GlobalDefOp::getODSOperands(unsigned index) {
206 auto valueRange = getODSOperandIndexAndLength(index);
207 return {std::next(getOperation()->operand_begin(), valueRange.first),
208 std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)};
209}
210
211std::pair<unsigned, unsigned> GlobalDefOp::getODSResultIndexAndLength(unsigned index) {
212 return {index, 1};
213}
214
215::mlir::Operation::result_range GlobalDefOp::getODSResults(unsigned index) {
216 auto valueRange = getODSResultIndexAndLength(index);
217 return {std::next(getOperation()->result_begin(), valueRange.first),
218 std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)};
219}
220
221::mlir::LogicalResult GlobalDefOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
222 ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr);
223 if (!dict) {
224 emitError() << "expected DictionaryAttr to set properties";
225 return ::mlir::failure();
226 }
227
228 {
229 auto &propStorage = prop.constant;
230 auto attr = dict.get("constant");
231 if (attr || /*isRequired=*/false) {
232 if (!attr) {
233 emitError() << "expected key entry for constant in DictionaryAttr to set "
234 "Properties.";
235 return ::mlir::failure();
236 }
237 auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
238 if (convertedAttr) {
239 propStorage = convertedAttr;
240 } else {
241 emitError() << "Invalid attribute `constant` in property conversion: " << attr;
242 return ::mlir::failure();
243 }
244 }
245 }
246
247 {
248 auto &propStorage = prop.initial_value;
249 auto attr = dict.get("initial_value");
250 if (attr || /*isRequired=*/false) {
251 if (!attr) {
252 emitError() << "expected key entry for initial_value in DictionaryAttr to set "
253 "Properties.";
254 return ::mlir::failure();
255 }
256 auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
257 if (convertedAttr) {
258 propStorage = convertedAttr;
259 } else {
260 emitError() << "Invalid attribute `initial_value` in property conversion: " << attr;
261 return ::mlir::failure();
262 }
263 }
264 }
265
266 {
267 auto &propStorage = prop.sym_name;
268 auto attr = dict.get("sym_name");
269 if (attr || /*isRequired=*/true) {
270 if (!attr) {
271 emitError() << "expected key entry for sym_name in DictionaryAttr to set "
272 "Properties.";
273 return ::mlir::failure();
274 }
275 auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
276 if (convertedAttr) {
277 propStorage = convertedAttr;
278 } else {
279 emitError() << "Invalid attribute `sym_name` in property conversion: " << attr;
280 return ::mlir::failure();
281 }
282 }
283 }
284
285 {
286 auto &propStorage = prop.type;
287 auto attr = dict.get("type");
288 if (attr || /*isRequired=*/true) {
289 if (!attr) {
290 emitError() << "expected key entry for type in DictionaryAttr to set "
291 "Properties.";
292 return ::mlir::failure();
293 }
294 auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
295 if (convertedAttr) {
296 propStorage = convertedAttr;
297 } else {
298 emitError() << "Invalid attribute `type` in property conversion: " << attr;
299 return ::mlir::failure();
300 }
301 }
302 }
303 return ::mlir::success();
304}
305
306::mlir::Attribute GlobalDefOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) {
307 ::mlir::SmallVector<::mlir::NamedAttribute> attrs;
308 ::mlir::Builder odsBuilder{ctx};
309
310 {
311 const auto &propStorage = prop.constant;
312 if (propStorage)
313 attrs.push_back(odsBuilder.getNamedAttr("constant",
314 propStorage));
315 }
316
317 {
318 const auto &propStorage = prop.initial_value;
319 if (propStorage)
320 attrs.push_back(odsBuilder.getNamedAttr("initial_value",
321 propStorage));
322 }
323
324 {
325 const auto &propStorage = prop.sym_name;
326 if (propStorage)
327 attrs.push_back(odsBuilder.getNamedAttr("sym_name",
328 propStorage));
329 }
330
331 {
332 const auto &propStorage = prop.type;
333 if (propStorage)
334 attrs.push_back(odsBuilder.getNamedAttr("type",
335 propStorage));
336 }
337
338 if (!attrs.empty())
339 return odsBuilder.getDictionaryAttr(attrs);
340 return {};
341}
342
343llvm::hash_code GlobalDefOp::computePropertiesHash(const Properties &prop) {
344 return llvm::hash_combine(
345 llvm::hash_value(prop.constant.getAsOpaquePointer()),
346 llvm::hash_value(prop.initial_value.getAsOpaquePointer()),
347 llvm::hash_value(prop.sym_name.getAsOpaquePointer()),
348 llvm::hash_value(prop.type.getAsOpaquePointer()));
349}
350
351std::optional<mlir::Attribute> GlobalDefOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
352 if (name == "constant")
353 return prop.constant;
354
355 if (name == "initial_value")
356 return prop.initial_value;
357
358 if (name == "sym_name")
359 return prop.sym_name;
360
361 if (name == "type")
362 return prop.type;
363 return std::nullopt;
364}
365
366void GlobalDefOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
367 if (name == "constant") {
368 prop.constant = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.constant)>>(value);
369 return;
370 }
371
372 if (name == "initial_value") {
373 prop.initial_value = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.initial_value)>>(value);
374 return;
375 }
376
377 if (name == "sym_name") {
378 prop.sym_name = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.sym_name)>>(value);
379 return;
380 }
381
382 if (name == "type") {
383 prop.type = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.type)>>(value);
384 return;
385 }
386}
387
388void GlobalDefOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
389 if (prop.constant) attrs.append("constant", prop.constant);
390
391 if (prop.initial_value) attrs.append("initial_value", prop.initial_value);
392
393 if (prop.sym_name) attrs.append("sym_name", prop.sym_name);
394
395 if (prop.type) attrs.append("type", prop.type);
396}
397
398::mlir::LogicalResult GlobalDefOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
399 {
400 ::mlir::Attribute attr = attrs.get(getConstantAttrName(opName));
401 if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_Ops1(attr, "constant", emitError)))
402 return ::mlir::failure();
403 }
404
405 {
406 ::mlir::Attribute attr = attrs.get(getInitialValueAttrName(opName));
407 if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_Ops3(attr, "initial_value", emitError)))
408 return ::mlir::failure();
409 }
410
411 {
412 ::mlir::Attribute attr = attrs.get(getSymNameAttrName(opName));
413 if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_Ops0(attr, "sym_name", emitError)))
414 return ::mlir::failure();
415 }
416
417 {
418 ::mlir::Attribute attr = attrs.get(getTypeAttrName(opName));
419 if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_Ops2(attr, "type", emitError)))
420 return ::mlir::failure();
421 }
422 return ::mlir::success();
423}
424
425::mlir::LogicalResult GlobalDefOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) {
426 auto &prop = state.getOrAddProperties<Properties>(); (void)prop;
427 if (::mlir::failed(reader.readOptionalAttribute(prop.constant)))
428 return ::mlir::failure();
429
430 if (::mlir::failed(reader.readOptionalAttribute(prop.initial_value)))
431 return ::mlir::failure();
432
433 if (::mlir::failed(reader.readAttribute(prop.sym_name)))
434 return ::mlir::failure();
435
436 if (::mlir::failed(reader.readAttribute(prop.type)))
437 return ::mlir::failure();
438 return ::mlir::success();
439}
440
441void GlobalDefOp::writeProperties(::mlir::DialectBytecodeWriter &writer) {
442 auto &prop = getProperties(); (void)prop;
443
444 writer.writeOptionalAttribute(prop.constant);
445
446 writer.writeOptionalAttribute(prop.initial_value);
447 writer.writeAttribute(prop.sym_name);
448 writer.writeAttribute(prop.type);
449}
450
451::mlir::StringAttr GlobalDefOp::getSymNameAttr() {
452 return ::llvm::cast<::mlir::StringAttr>(getProperties().sym_name);
453}
454
455::llvm::StringRef GlobalDefOp::getSymName() {
456 auto attr = getSymNameAttr();
457 return attr.getValue();
458}
459
461 return ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(getProperties().constant);
462}
463
465 auto attr = getConstantAttr();
466 if (!attr)
467 return ((false) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr) != nullptr;
468 return attr != nullptr;
469}
470
471::mlir::TypeAttr GlobalDefOp::getTypeAttr() {
472 return ::llvm::cast<::mlir::TypeAttr>(getProperties().type);
473}
474
475::mlir::Type GlobalDefOp::getType() {
476 auto attr = getTypeAttr();
477 return ::llvm::cast<::mlir::Type>(attr.getValue());
478}
479
481 return ::llvm::dyn_cast_or_null<::mlir::Attribute>(getProperties().initial_value);
482}
483
484::mlir::Attribute GlobalDefOp::getInitialValue() {
485 auto attr = getInitialValueAttr();
486 return attr;
487}
488
489void GlobalDefOp::setSymNameAttr(::mlir::StringAttr attr) {
490 (*this)->setAttr(getSymNameAttrName(), attr);
491}
492
493void GlobalDefOp::setSymName(::llvm::StringRef attrValue) {
494 (*this)->setAttr(getSymNameAttrName(), ::mlir::Builder((*this)->getContext()).getStringAttr(attrValue));
495}
496
497void GlobalDefOp::setConstantAttr(::mlir::UnitAttr attr) {
498 (*this)->setAttr(getConstantAttrName(), attr);
499}
500
501void GlobalDefOp::setConstant(bool attrValue) {
502 if (attrValue)
503 return (*this)->setAttr(getConstantAttrName(), ((attrValue) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() : nullptr));
504 (*this)->removeAttr(getConstantAttrName());
505}
506
507void GlobalDefOp::setTypeAttr(::mlir::TypeAttr attr) {
508 (*this)->setAttr(getTypeAttrName(), attr);
509}
510
511void GlobalDefOp::setType(::mlir::Type attrValue) {
512 (*this)->setAttr(getTypeAttrName(), ::mlir::TypeAttr::get(attrValue));
513}
514
515void GlobalDefOp::setInitialValueAttr(::mlir::Attribute attr) {
516 (*this)->setAttr(getInitialValueAttrName(), attr);
517}
518
520 auto &attr = getProperties().constant;
521 attr = {};
522 return attr;
523}
524
525void GlobalDefOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::StringAttr sym_name, /*optional*/::mlir::UnitAttr constant, ::mlir::TypeAttr type, ::mlir::Attribute initial_value) {
526 odsState.getOrAddProperties<Properties>().sym_name = sym_name;
527 if (constant) {
528 odsState.getOrAddProperties<Properties>().constant = constant;
529 }
530 odsState.getOrAddProperties<Properties>().type = type;
531 if (initial_value) {
532 odsState.getOrAddProperties<Properties>().initial_value = initial_value;
533 }
534}
535
536void GlobalDefOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::StringAttr sym_name, /*optional*/::mlir::UnitAttr constant, ::mlir::TypeAttr type, ::mlir::Attribute initial_value) {
537 odsState.getOrAddProperties<Properties>().sym_name = sym_name;
538 if (constant) {
539 odsState.getOrAddProperties<Properties>().constant = constant;
540 }
541 odsState.getOrAddProperties<Properties>().type = type;
542 if (initial_value) {
543 odsState.getOrAddProperties<Properties>().initial_value = initial_value;
544 }
545 assert(resultTypes.size() == 0u && "mismatched number of results");
546 odsState.addTypes(resultTypes);
547}
548
549void GlobalDefOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::llvm::StringRef sym_name, /*optional*/bool constant, ::mlir::Type type, ::mlir::Attribute initial_value) {
550 odsState.getOrAddProperties<Properties>().sym_name = odsBuilder.getStringAttr(sym_name);
551 if (constant) {
552 odsState.getOrAddProperties<Properties>().constant = ((constant) ? odsBuilder.getUnitAttr() : nullptr);
553 }
554 odsState.getOrAddProperties<Properties>().type = ::mlir::TypeAttr::get(type);
555 odsState.getOrAddProperties<Properties>().initial_value = initial_value;
556}
557
558void GlobalDefOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::llvm::StringRef sym_name, /*optional*/bool constant, ::mlir::Type type, ::mlir::Attribute initial_value) {
559 odsState.getOrAddProperties<Properties>().sym_name = odsBuilder.getStringAttr(sym_name);
560 if (constant) {
561 odsState.getOrAddProperties<Properties>().constant = ((constant) ? odsBuilder.getUnitAttr() : nullptr);
562 }
563 odsState.getOrAddProperties<Properties>().type = ::mlir::TypeAttr::get(type);
564 odsState.getOrAddProperties<Properties>().initial_value = initial_value;
565 assert(resultTypes.size() == 0u && "mismatched number of results");
566 odsState.addTypes(resultTypes);
567}
568
569void GlobalDefOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
570 assert(operands.size() == 0u && "mismatched number of parameters");
571 odsState.addOperands(operands);
572 odsState.addAttributes(attributes);
573 assert(resultTypes.size() == 0u && "mismatched number of return types");
574 odsState.addTypes(resultTypes);
575}
576
577void GlobalDefOp::populateDefaultProperties(::mlir::OperationName opName, Properties &properties) {
578 ::mlir::Builder odsBuilder(opName.getContext());
579 if (!properties.initial_value)
580 properties.initial_value = nullptr;
581}
582
583::mlir::LogicalResult GlobalDefOp::verifyInvariantsImpl() {
584 auto tblgen_constant = getProperties().constant; (void)tblgen_constant;
585 auto tblgen_initial_value = getProperties().initial_value; (void)tblgen_initial_value;
586 auto tblgen_sym_name = getProperties().sym_name; (void)tblgen_sym_name;
587 if (!tblgen_sym_name) return emitOpError("requires attribute 'sym_name'");
588 auto tblgen_type = getProperties().type; (void)tblgen_type;
589 if (!tblgen_type) return emitOpError("requires attribute 'type'");
590
591 if (::mlir::failed(__mlir_ods_local_attr_constraint_Ops0(*this, tblgen_sym_name, "sym_name")))
592 return ::mlir::failure();
593
594 if (::mlir::failed(__mlir_ods_local_attr_constraint_Ops1(*this, tblgen_constant, "constant")))
595 return ::mlir::failure();
596
597 if (::mlir::failed(__mlir_ods_local_attr_constraint_Ops2(*this, tblgen_type, "type")))
598 return ::mlir::failure();
599
600 if (::mlir::failed(__mlir_ods_local_attr_constraint_Ops3(*this, tblgen_initial_value, "initial_value")))
601 return ::mlir::failure();
602 return ::mlir::success();
603}
604
605::mlir::LogicalResult GlobalDefOp::verifyInvariants() {
606 if(::mlir::succeeded(verifyInvariantsImpl()) && ::mlir::succeeded(verify()))
607 return ::mlir::success();
608 return ::mlir::failure();
609}
610
611::mlir::ParseResult GlobalDefOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
612 ::mlir::StringAttr sym_nameAttr;
613 ::mlir::TypeAttr typeAttr;
614 ::mlir::Attribute initial_valueAttr;
615 if (::mlir::succeeded(parser.parseOptionalKeyword("const"))) {
616 result.getOrAddProperties<GlobalDefOp::Properties>().constant = parser.getBuilder().getUnitAttr(); }
617
618 if (parser.parseSymbolName(sym_nameAttr))
619 return ::mlir::failure();
620 if (sym_nameAttr) result.getOrAddProperties<GlobalDefOp::Properties>().sym_name = sym_nameAttr;
621 if (parser.parseColon())
622 return ::mlir::failure();
623
624 if (parser.parseCustomAttributeWithFallback(typeAttr, parser.getBuilder().getType<::mlir::NoneType>())) {
625 return ::mlir::failure();
626 }
627 if (typeAttr) result.getOrAddProperties<GlobalDefOp::Properties>().type = typeAttr;
628 {
629 auto odsResult = parseGlobalInitialValue(parser, initial_valueAttr, typeAttr);
630 if (odsResult) return ::mlir::failure();
631 if (initial_valueAttr)
632 result.getOrAddProperties<GlobalDefOp::Properties>().initial_value = initial_valueAttr;
633 }
634 {
635 auto loc = parser.getCurrentLocation();(void)loc;
636 if (parser.parseOptionalAttrDict(result.attributes))
637 return ::mlir::failure();
638 if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() {
639 return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op ";
640 })))
641 return ::mlir::failure();
642 }
643 return ::mlir::success();
644}
645
646void GlobalDefOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
647 if (getConstantAttr()) {
648 _odsPrinter << ' ' << "const";
649 }
650 _odsPrinter << ' ';
651 _odsPrinter.printSymbolName(getSymNameAttr().getValue());
652 _odsPrinter << ' ' << ":";
653 _odsPrinter << ' ';
654 _odsPrinter.printAttributeWithoutType(getTypeAttr());
656 ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
657 elidedAttrs.push_back("constant");
658 elidedAttrs.push_back("sym_name");
659 elidedAttrs.push_back("type");
660 elidedAttrs.push_back("initial_value");
661 {
662 ::mlir::Builder odsBuilder(getContext());
663 ::mlir::Attribute attr = getConstantAttr();
664 if(attr && (attr == ((false) ? odsBuilder.getUnitAttr() : nullptr)))
665 elidedAttrs.push_back("constant");
666 }
667 {
668 ::mlir::Builder odsBuilder(getContext());
669 ::mlir::Attribute attr = getInitialValueAttr();
670 if(attr && (attr == nullptr))
671 elidedAttrs.push_back("initial_value");
672 }
673 _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
674}
675
676} // namespace global
677} // namespace llzk
678MLIR_DEFINE_EXPLICIT_TYPE_ID(::llzk::global::GlobalDefOp)
679
680namespace llzk {
681namespace global {
682
683//===----------------------------------------------------------------------===//
684// ::llzk::global::GlobalReadOp definitions
685//===----------------------------------------------------------------------===//
686
687namespace detail {
688GlobalReadOpGenericAdaptorBase::GlobalReadOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs)
689 odsOpName.emplace("global.read", odsAttrs.getContext());
690}
691
693
694std::pair<unsigned, unsigned> GlobalReadOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) {
695 return {index, 1};
696}
697
699 return odsAttrs;
700}
701
703 auto attr = ::llvm::cast<::mlir::SymbolRefAttr>(getProperties().name_ref);
704 return attr;
705}
706
708 auto attr = getNameRefAttr();
709 return attr;
710}
711
712} // namespace detail
714
715::mlir::LogicalResult GlobalReadOpAdaptor::verify(::mlir::Location loc) {
716 auto tblgen_name_ref = getProperties().name_ref; (void)tblgen_name_ref;
717 if (!tblgen_name_ref) return emitError(loc, "'global.read' op ""requires attribute 'name_ref'");
718
719 if (tblgen_name_ref && !((::llvm::isa<::mlir::SymbolRefAttr>(tblgen_name_ref))))
720 return emitError(loc, "'global.read' op ""attribute 'name_ref' failed to satisfy constraint: symbol reference attribute");
721 return ::mlir::success();
722}
723
724std::pair<unsigned, unsigned> GlobalReadOp::getODSOperandIndexAndLength(unsigned index) {
725 return {index, 1};
726}
727
728::mlir::Operation::operand_range GlobalReadOp::getODSOperands(unsigned index) {
729 auto valueRange = getODSOperandIndexAndLength(index);
730 return {std::next(getOperation()->operand_begin(), valueRange.first),
731 std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)};
732}
733
734std::pair<unsigned, unsigned> GlobalReadOp::getODSResultIndexAndLength(unsigned index) {
735 return {index, 1};
736}
737
738::mlir::Operation::result_range GlobalReadOp::getODSResults(unsigned index) {
739 auto valueRange = getODSResultIndexAndLength(index);
740 return {std::next(getOperation()->result_begin(), valueRange.first),
741 std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)};
742}
743
744::mlir::Value GlobalReadOp::getVal() {
745 return ::llvm::cast<::mlir::Value>(*getODSResults(0).begin());
746}
747
748::mlir::LogicalResult GlobalReadOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
749 ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr);
750 if (!dict) {
751 emitError() << "expected DictionaryAttr to set properties";
752 return ::mlir::failure();
753 }
754
755 {
756 auto &propStorage = prop.name_ref;
757 auto attr = dict.get("name_ref");
758 if (attr || /*isRequired=*/true) {
759 if (!attr) {
760 emitError() << "expected key entry for name_ref in DictionaryAttr to set "
761 "Properties.";
762 return ::mlir::failure();
763 }
764 auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
765 if (convertedAttr) {
766 propStorage = convertedAttr;
767 } else {
768 emitError() << "Invalid attribute `name_ref` in property conversion: " << attr;
769 return ::mlir::failure();
770 }
771 }
772 }
773 return ::mlir::success();
774}
775
776::mlir::Attribute GlobalReadOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) {
777 ::mlir::SmallVector<::mlir::NamedAttribute> attrs;
778 ::mlir::Builder odsBuilder{ctx};
779
780 {
781 const auto &propStorage = prop.name_ref;
782 if (propStorage)
783 attrs.push_back(odsBuilder.getNamedAttr("name_ref",
784 propStorage));
785 }
786
787 if (!attrs.empty())
788 return odsBuilder.getDictionaryAttr(attrs);
789 return {};
790}
791
793 return llvm::hash_combine(
794 llvm::hash_value(prop.name_ref.getAsOpaquePointer()));
795}
796
797std::optional<mlir::Attribute> GlobalReadOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
798 if (name == "name_ref")
799 return prop.name_ref;
800 return std::nullopt;
801}
802
803void GlobalReadOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
804 if (name == "name_ref") {
805 prop.name_ref = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.name_ref)>>(value);
806 return;
807 }
808}
809
810void GlobalReadOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
811 if (prop.name_ref) attrs.append("name_ref", prop.name_ref);
812}
813
814::mlir::LogicalResult GlobalReadOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
815 {
816 ::mlir::Attribute attr = attrs.get(getNameRefAttrName(opName));
817 if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_Ops4(attr, "name_ref", emitError)))
818 return ::mlir::failure();
819 }
820 return ::mlir::success();
821}
822
823::mlir::LogicalResult GlobalReadOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) {
824 auto &prop = state.getOrAddProperties<Properties>(); (void)prop;
825 if (::mlir::failed(reader.readAttribute(prop.name_ref)))
826 return ::mlir::failure();
827 return ::mlir::success();
828}
829
830void GlobalReadOp::writeProperties(::mlir::DialectBytecodeWriter &writer) {
831 auto &prop = getProperties(); (void)prop;
832 writer.writeAttribute(prop.name_ref);
833}
834
835::mlir::SymbolRefAttr GlobalReadOp::getNameRefAttr() {
836 return ::llvm::cast<::mlir::SymbolRefAttr>(getProperties().name_ref);
837}
838
839::mlir::SymbolRefAttr GlobalReadOp::getNameRef() {
840 auto attr = getNameRefAttr();
841 return attr;
842}
843
844void GlobalReadOp::setNameRefAttr(::mlir::SymbolRefAttr attr) {
845 (*this)->setAttr(getNameRefAttrName(), attr);
846}
847
848void GlobalReadOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type val, ::mlir::SymbolRefAttr name_ref) {
849 odsState.getOrAddProperties<Properties>().name_ref = name_ref;
850 odsState.addTypes(val);
851}
852
853void GlobalReadOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::SymbolRefAttr name_ref) {
854 odsState.getOrAddProperties<Properties>().name_ref = name_ref;
855 assert(resultTypes.size() == 1u && "mismatched number of results");
856 odsState.addTypes(resultTypes);
857}
858
859void GlobalReadOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
860 assert(operands.size() == 0u && "mismatched number of parameters");
861 odsState.addOperands(operands);
862 odsState.addAttributes(attributes);
863 assert(resultTypes.size() == 1u && "mismatched number of return types");
864 odsState.addTypes(resultTypes);
865}
866
867::mlir::LogicalResult GlobalReadOp::verifyInvariantsImpl() {
868 auto tblgen_name_ref = getProperties().name_ref; (void)tblgen_name_ref;
869 if (!tblgen_name_ref) return emitOpError("requires attribute 'name_ref'");
870
871 if (::mlir::failed(__mlir_ods_local_attr_constraint_Ops4(*this, tblgen_name_ref, "name_ref")))
872 return ::mlir::failure();
873 {
874 unsigned index = 0; (void)index;
875 auto valueGroup0 = getODSResults(0);
876
877 for (auto v : valueGroup0) {
878 if (::mlir::failed(__mlir_ods_local_type_constraint_Ops0(*this, v.getType(), "result", index++)))
879 return ::mlir::failure();
880 }
881 }
882 return ::mlir::success();
883}
884
885::mlir::LogicalResult GlobalReadOp::verifyInvariants() {
886 return verifyInvariantsImpl();
887}
888
889::mlir::ParseResult GlobalReadOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
890 ::mlir::SymbolRefAttr name_refAttr;
891 ::mlir::Type valRawTypes[1];
892 ::llvm::ArrayRef<::mlir::Type> valTypes(valRawTypes);
893
894 if (parser.parseCustomAttributeWithFallback(name_refAttr, parser.getBuilder().getType<::mlir::NoneType>())) {
895 return ::mlir::failure();
896 }
897 if (name_refAttr) result.getOrAddProperties<GlobalReadOp::Properties>().name_ref = name_refAttr;
898 if (parser.parseColon())
899 return ::mlir::failure();
900
901 {
902 ::mlir::Type type;
903 if (parser.parseCustomTypeWithFallback(type))
904 return ::mlir::failure();
905 valRawTypes[0] = type;
906 }
907 {
908 auto loc = parser.getCurrentLocation();(void)loc;
909 if (parser.parseOptionalAttrDict(result.attributes))
910 return ::mlir::failure();
911 if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() {
912 return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op ";
913 })))
914 return ::mlir::failure();
915 }
916 result.addTypes(valTypes);
917 return ::mlir::success();
918}
919
920void GlobalReadOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
921 _odsPrinter << ' ';
922 _odsPrinter.printAttributeWithoutType(getNameRefAttr());
923 _odsPrinter << ' ' << ":";
924 _odsPrinter << ' ';
925 {
926 auto type = getVal().getType();
927 if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type))
928 _odsPrinter.printStrippedAttrOrType(validType);
929 else
930 _odsPrinter << type;
931 }
932 ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
933 elidedAttrs.push_back("name_ref");
934 _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
935}
936
937} // namespace global
938} // namespace llzk
939MLIR_DEFINE_EXPLICIT_TYPE_ID(::llzk::global::GlobalReadOp)
940
941namespace llzk {
942namespace global {
943
944//===----------------------------------------------------------------------===//
945// ::llzk::global::GlobalWriteOp definitions
946//===----------------------------------------------------------------------===//
947
948namespace detail {
949GlobalWriteOpGenericAdaptorBase::GlobalWriteOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions) : odsAttrs(attrs), properties(properties), odsRegions(regions) { if (odsAttrs)
950 odsOpName.emplace("global.write", odsAttrs.getContext());
951}
952
954
955std::pair<unsigned, unsigned> GlobalWriteOpGenericAdaptorBase::getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize) {
956 return {index, 1};
957}
958
960 return odsAttrs;
961}
962
964 auto attr = ::llvm::cast<::mlir::SymbolRefAttr>(getProperties().name_ref);
965 return attr;
966}
967
969 auto attr = getNameRefAttr();
970 return attr;
971}
972
973} // namespace detail
975
976::mlir::LogicalResult GlobalWriteOpAdaptor::verify(::mlir::Location loc) {
977 auto tblgen_name_ref = getProperties().name_ref; (void)tblgen_name_ref;
978 if (!tblgen_name_ref) return emitError(loc, "'global.write' op ""requires attribute 'name_ref'");
979
980 if (tblgen_name_ref && !((::llvm::isa<::mlir::SymbolRefAttr>(tblgen_name_ref))))
981 return emitError(loc, "'global.write' op ""attribute 'name_ref' failed to satisfy constraint: symbol reference attribute");
982 return ::mlir::success();
983}
984
985std::pair<unsigned, unsigned> GlobalWriteOp::getODSOperandIndexAndLength(unsigned index) {
986 return {index, 1};
987}
988
989::mlir::Operation::operand_range GlobalWriteOp::getODSOperands(unsigned index) {
990 auto valueRange = getODSOperandIndexAndLength(index);
991 return {std::next(getOperation()->operand_begin(), valueRange.first),
992 std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)};
993}
994
995::mlir::Value GlobalWriteOp::getVal() {
996 return ::llvm::cast<::mlir::Value>(*getODSOperands(0).begin());
997}
998
999::mlir::OpOperand &GlobalWriteOp::getValMutable() {
1000 auto range = getODSOperandIndexAndLength(0);
1001 return getOperation()->getOpOperand(range.first);
1002}
1003
1004std::pair<unsigned, unsigned> GlobalWriteOp::getODSResultIndexAndLength(unsigned index) {
1005 return {index, 1};
1006}
1007
1008::mlir::Operation::result_range GlobalWriteOp::getODSResults(unsigned index) {
1009 auto valueRange = getODSResultIndexAndLength(index);
1010 return {std::next(getOperation()->result_begin(), valueRange.first),
1011 std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)};
1012}
1013
1014::mlir::LogicalResult GlobalWriteOp::setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
1015 ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr);
1016 if (!dict) {
1017 emitError() << "expected DictionaryAttr to set properties";
1018 return ::mlir::failure();
1019 }
1020
1021 {
1022 auto &propStorage = prop.name_ref;
1023 auto attr = dict.get("name_ref");
1024 if (attr || /*isRequired=*/true) {
1025 if (!attr) {
1026 emitError() << "expected key entry for name_ref in DictionaryAttr to set "
1027 "Properties.";
1028 return ::mlir::failure();
1029 }
1030 auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<decltype(propStorage)>>(attr);
1031 if (convertedAttr) {
1032 propStorage = convertedAttr;
1033 } else {
1034 emitError() << "Invalid attribute `name_ref` in property conversion: " << attr;
1035 return ::mlir::failure();
1036 }
1037 }
1038 }
1039 return ::mlir::success();
1040}
1041
1042::mlir::Attribute GlobalWriteOp::getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop) {
1043 ::mlir::SmallVector<::mlir::NamedAttribute> attrs;
1044 ::mlir::Builder odsBuilder{ctx};
1045
1046 {
1047 const auto &propStorage = prop.name_ref;
1048 if (propStorage)
1049 attrs.push_back(odsBuilder.getNamedAttr("name_ref",
1050 propStorage));
1051 }
1052
1053 if (!attrs.empty())
1054 return odsBuilder.getDictionaryAttr(attrs);
1055 return {};
1056}
1057
1059 return llvm::hash_combine(
1060 llvm::hash_value(prop.name_ref.getAsOpaquePointer()));
1061}
1062
1063std::optional<mlir::Attribute> GlobalWriteOp::getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name) {
1064 if (name == "name_ref")
1065 return prop.name_ref;
1066 return std::nullopt;
1067}
1068
1069void GlobalWriteOp::setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value) {
1070 if (name == "name_ref") {
1071 prop.name_ref = ::llvm::dyn_cast_or_null<std::remove_reference_t<decltype(prop.name_ref)>>(value);
1072 return;
1073 }
1074}
1075
1076void GlobalWriteOp::populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs) {
1077 if (prop.name_ref) attrs.append("name_ref", prop.name_ref);
1078}
1079
1080::mlir::LogicalResult GlobalWriteOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
1081 {
1082 ::mlir::Attribute attr = attrs.get(getNameRefAttrName(opName));
1083 if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_Ops4(attr, "name_ref", emitError)))
1084 return ::mlir::failure();
1085 }
1086 return ::mlir::success();
1087}
1088
1089::mlir::LogicalResult GlobalWriteOp::readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state) {
1090 auto &prop = state.getOrAddProperties<Properties>(); (void)prop;
1091 if (::mlir::failed(reader.readAttribute(prop.name_ref)))
1092 return ::mlir::failure();
1093 return ::mlir::success();
1094}
1095
1096void GlobalWriteOp::writeProperties(::mlir::DialectBytecodeWriter &writer) {
1097 auto &prop = getProperties(); (void)prop;
1098 writer.writeAttribute(prop.name_ref);
1099}
1100
1101::mlir::SymbolRefAttr GlobalWriteOp::getNameRefAttr() {
1102 return ::llvm::cast<::mlir::SymbolRefAttr>(getProperties().name_ref);
1103}
1104
1105::mlir::SymbolRefAttr GlobalWriteOp::getNameRef() {
1106 auto attr = getNameRefAttr();
1107 return attr;
1108}
1109
1110void GlobalWriteOp::setNameRefAttr(::mlir::SymbolRefAttr attr) {
1111 (*this)->setAttr(getNameRefAttrName(), attr);
1112}
1113
1114void GlobalWriteOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::SymbolRefAttr name_ref, ::mlir::Value val) {
1115 odsState.addOperands(val);
1116 odsState.getOrAddProperties<Properties>().name_ref = name_ref;
1117}
1118
1119void GlobalWriteOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::SymbolRefAttr name_ref, ::mlir::Value val) {
1120 odsState.addOperands(val);
1121 odsState.getOrAddProperties<Properties>().name_ref = name_ref;
1122 assert(resultTypes.size() == 0u && "mismatched number of results");
1123 odsState.addTypes(resultTypes);
1124}
1125
1126void GlobalWriteOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
1127 assert(operands.size() == 1u && "mismatched number of parameters");
1128 odsState.addOperands(operands);
1129 odsState.addAttributes(attributes);
1130 assert(resultTypes.size() == 0u && "mismatched number of return types");
1131 odsState.addTypes(resultTypes);
1132}
1133
1135 auto tblgen_name_ref = getProperties().name_ref; (void)tblgen_name_ref;
1136 if (!tblgen_name_ref) return emitOpError("requires attribute 'name_ref'");
1137
1138 if (::mlir::failed(__mlir_ods_local_attr_constraint_Ops4(*this, tblgen_name_ref, "name_ref")))
1139 return ::mlir::failure();
1140 {
1141 unsigned index = 0; (void)index;
1142 auto valueGroup0 = getODSOperands(0);
1143
1144 for (auto v : valueGroup0) {
1145 if (::mlir::failed(__mlir_ods_local_type_constraint_Ops0(*this, v.getType(), "operand", index++)))
1146 return ::mlir::failure();
1147 }
1148 }
1149 return ::mlir::success();
1150}
1151
1152::mlir::LogicalResult GlobalWriteOp::verifyInvariants() {
1153 return verifyInvariantsImpl();
1154}
1155
1156::mlir::ParseResult GlobalWriteOp::parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result) {
1157 ::mlir::SymbolRefAttr name_refAttr;
1158 ::mlir::OpAsmParser::UnresolvedOperand valRawOperands[1];
1159 ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> valOperands(valRawOperands); ::llvm::SMLoc valOperandsLoc;
1160 (void)valOperandsLoc;
1161 ::mlir::Type valRawTypes[1];
1162 ::llvm::ArrayRef<::mlir::Type> valTypes(valRawTypes);
1163
1164 if (parser.parseCustomAttributeWithFallback(name_refAttr, parser.getBuilder().getType<::mlir::NoneType>())) {
1165 return ::mlir::failure();
1166 }
1167 if (name_refAttr) result.getOrAddProperties<GlobalWriteOp::Properties>().name_ref = name_refAttr;
1168 if (parser.parseEqual())
1169 return ::mlir::failure();
1170
1171 valOperandsLoc = parser.getCurrentLocation();
1172 if (parser.parseOperand(valRawOperands[0]))
1173 return ::mlir::failure();
1174 if (parser.parseColon())
1175 return ::mlir::failure();
1176
1177 {
1178 ::mlir::Type type;
1179 if (parser.parseCustomTypeWithFallback(type))
1180 return ::mlir::failure();
1181 valRawTypes[0] = type;
1182 }
1183 {
1184 auto loc = parser.getCurrentLocation();(void)loc;
1185 if (parser.parseOptionalAttrDict(result.attributes))
1186 return ::mlir::failure();
1187 if (failed(verifyInherentAttrs(result.name, result.attributes, [&]() {
1188 return parser.emitError(loc) << "'" << result.name.getStringRef() << "' op ";
1189 })))
1190 return ::mlir::failure();
1191 }
1192 if (parser.resolveOperands(valOperands, valTypes, valOperandsLoc, result.operands))
1193 return ::mlir::failure();
1194 return ::mlir::success();
1195}
1196
1197void GlobalWriteOp::print(::mlir::OpAsmPrinter &_odsPrinter) {
1198 _odsPrinter << ' ';
1199 _odsPrinter.printAttributeWithoutType(getNameRefAttr());
1200 _odsPrinter << ' ' << "=";
1201 _odsPrinter << ' ';
1202 _odsPrinter << getVal();
1203 _odsPrinter << ' ' << ":";
1204 _odsPrinter << ' ';
1205 {
1206 auto type = getVal().getType();
1207 if (auto validType = ::llvm::dyn_cast<::mlir::Type>(type))
1208 _odsPrinter.printStrippedAttrOrType(validType);
1209 else
1210 _odsPrinter << type;
1211 }
1212 ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
1213 elidedAttrs.push_back("name_ref");
1214 _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
1215}
1216
1217} // namespace global
1218} // namespace llzk
1219MLIR_DEFINE_EXPLICIT_TYPE_ID(::llzk::global::GlobalWriteOp)
1220
1221
1222#endif // GET_OP_CLASSES
1223
GlobalDefOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs=nullptr, const Properties &properties={}, ::mlir::RegionRange regions={})
Definition Ops.h.inc:131
GlobalDefOpAdaptor(GlobalDefOp op)
Definition Ops.cpp.inc:177
::mlir::LogicalResult verify(::mlir::Location loc)
Definition Ops.cpp.inc:179
void setInitialValueAttr(::mlir::Attribute attr)
Definition Ops.cpp.inc:515
static void populateDefaultProperties(::mlir::OperationName opName, Properties &properties)
Definition Ops.cpp.inc:577
::mlir::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError)
Definition Ops.cpp.inc:221
FoldAdaptor::Properties Properties
Definition Ops.h.inc:170
::mlir::Attribute getInitialValue()
Definition Ops.cpp.inc:484
void setType(::mlir::Type attrValue)
Definition Ops.cpp.inc:511
::mlir::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state)
Definition Ops.cpp.inc:425
::mlir::LogicalResult verifyInvariantsImpl()
Definition Ops.cpp.inc:583
::mlir::Type getType()
Definition Ops.cpp.inc:475
::mlir::Attribute removeConstantAttr()
Definition Ops.cpp.inc:519
std::pair< unsigned, unsigned > getODSResultIndexAndLength(unsigned index)
Definition Ops.cpp.inc:211
void setTypeAttr(::mlir::TypeAttr attr)
Definition Ops.cpp.inc:507
::mlir::ParseResult parseGlobalInitialValue(::mlir::OpAsmParser &parser, ::mlir::Attribute &initialValue, ::mlir::TypeAttr typeAttr)
Definition Ops.cpp:36
::mlir::UnitAttr getConstantAttr()
Definition Ops.cpp.inc:460
static std::optional< mlir::Attribute > getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name)
Definition Ops.cpp.inc:351
static void printGlobalInitialValue(::mlir::OpAsmPrinter &printer, GlobalDefOp op, ::mlir::Attribute initialValue, ::mlir::TypeAttr typeAttr)
Definition Ops.cpp:62
::llvm::StringRef getSymName()
Definition Ops.cpp.inc:455
std::pair< unsigned, unsigned > getODSOperandIndexAndLength(unsigned index)
Definition Ops.cpp.inc:201
::mlir::StringAttr getSymNameAttrName()
Definition Ops.h.inc:192
::mlir::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError)
Definition Ops.cpp.inc:398
::mlir::Attribute getInitialValueAttr()
Definition Ops.cpp.inc:480
::mlir::Operation::result_range getODSResults(unsigned index)
Definition Ops.cpp.inc:215
::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop)
Definition Ops.cpp.inc:306
void setSymName(::llvm::StringRef attrValue)
Definition Ops.cpp.inc:493
void writeProperties(::mlir::DialectBytecodeWriter &writer)
Definition Ops.cpp.inc:441
void print(::mlir::OpAsmPrinter &_odsPrinter)
Definition Ops.cpp.inc:646
::mlir::StringAttr getTypeAttrName()
Definition Ops.h.inc:200
void setConstant(bool attrValue)
Definition Ops.cpp.inc:501
void setConstantAttr(::mlir::UnitAttr attr)
Definition Ops.cpp.inc:497
::mlir::TypeAttr getTypeAttr()
Definition Ops.cpp.inc:471
static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs)
Definition Ops.cpp.inc:388
static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::StringAttr sym_name, ::mlir::UnitAttr constant, ::mlir::TypeAttr type, ::mlir::Attribute initial_value=nullptr)
Definition Ops.cpp.inc:525
::mlir::StringAttr getInitialValueAttrName()
Definition Ops.h.inc:184
::mlir::LogicalResult verify()
Definition Ops.cpp:168
::mlir::LogicalResult verifyInvariants()
Definition Ops.cpp.inc:605
static llvm::hash_code computePropertiesHash(const Properties &prop)
Definition Ops.cpp.inc:343
::mlir::StringAttr getConstantAttrName()
Definition Ops.h.inc:176
::mlir::StringAttr getSymNameAttr()
Definition Ops.cpp.inc:451
static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value)
Definition Ops.cpp.inc:366
::mlir::Operation::operand_range getODSOperands(unsigned index)
Definition Ops.cpp.inc:205
::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result)
Definition Ops.cpp.inc:611
void setSymNameAttr(::mlir::StringAttr attr)
Definition Ops.cpp.inc:489
::mlir::LogicalResult verify(::mlir::Location loc)
Definition Ops.cpp.inc:715
GlobalReadOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs=nullptr, const Properties &properties={}, ::mlir::RegionRange regions={})
Definition Ops.h.inc:335
GlobalReadOpAdaptor(GlobalReadOp op)
Definition Ops.cpp.inc:713
::mlir::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError)
Definition Ops.cpp.inc:814
static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type val, ::mlir::SymbolRefAttr name_ref)
Definition Ops.cpp.inc:848
::mlir::StringAttr getNameRefAttrName()
Definition Ops.h.inc:380
void writeProperties(::mlir::DialectBytecodeWriter &writer)
Definition Ops.cpp.inc:830
FoldAdaptor::Properties Properties
Definition Ops.h.inc:374
::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop)
Definition Ops.cpp.inc:776
::mlir::SymbolRefAttr getNameRefAttr()
Definition Ops.cpp.inc:835
std::pair< unsigned, unsigned > getODSOperandIndexAndLength(unsigned index)
Definition Ops.cpp.inc:724
::mlir::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError)
Definition Ops.cpp.inc:748
void print(::mlir::OpAsmPrinter &_odsPrinter)
Definition Ops.cpp.inc:920
::mlir::Operation::operand_range getODSOperands(unsigned index)
Definition Ops.cpp.inc:728
::mlir::Operation::result_range getODSResults(unsigned index)
Definition Ops.cpp.inc:738
static llvm::hash_code computePropertiesHash(const Properties &prop)
Definition Ops.cpp.inc:792
::mlir::LogicalResult verifyInvariantsImpl()
Definition Ops.cpp.inc:867
::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result)
Definition Ops.cpp.inc:889
::mlir::LogicalResult verifyInvariants()
Definition Ops.cpp.inc:885
void setNameRefAttr(::mlir::SymbolRefAttr attr)
Definition Ops.cpp.inc:844
static std::optional< mlir::Attribute > getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name)
Definition Ops.cpp.inc:797
static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value)
Definition Ops.cpp.inc:803
std::pair< unsigned, unsigned > getODSResultIndexAndLength(unsigned index)
Definition Ops.cpp.inc:734
::mlir::Value getVal()
Definition Ops.cpp.inc:744
::mlir::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state)
Definition Ops.cpp.inc:823
::mlir::SymbolRefAttr getNameRef()
Definition Ops.cpp.inc:839
static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs)
Definition Ops.cpp.inc:810
GlobalWriteOpAdaptor(GlobalWriteOp op)
Definition Ops.cpp.inc:974
GlobalWriteOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs=nullptr, const Properties &properties={}, ::mlir::RegionRange regions={})
Definition Ops.h.inc:495
::mlir::LogicalResult verify(::mlir::Location loc)
Definition Ops.cpp.inc:976
static llvm::hash_code computePropertiesHash(const Properties &prop)
Definition Ops.cpp.inc:1058
::mlir::LogicalResult verifyInvariantsImpl()
Definition Ops.cpp.inc:1134
::mlir::StringAttr getNameRefAttrName()
Definition Ops.h.inc:544
::mlir::Operation::operand_range getODSOperands(unsigned index)
Definition Ops.cpp.inc:989
::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result)
Definition Ops.cpp.inc:1156
::mlir::SymbolRefAttr getNameRefAttr()
Definition Ops.cpp.inc:1101
static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs)
Definition Ops.cpp.inc:1076
void print(::mlir::OpAsmPrinter &_odsPrinter)
Definition Ops.cpp.inc:1197
::mlir::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state)
Definition Ops.cpp.inc:1089
std::pair< unsigned, unsigned > getODSOperandIndexAndLength(unsigned index)
Definition Ops.cpp.inc:985
FoldAdaptor::Properties Properties
Definition Ops.h.inc:538
void setNameRefAttr(::mlir::SymbolRefAttr attr)
Definition Ops.cpp.inc:1110
::mlir::OpOperand & getValMutable()
Definition Ops.cpp.inc:999
::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop)
Definition Ops.cpp.inc:1042
::mlir::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError)
Definition Ops.cpp.inc:1014
::mlir::LogicalResult verifyInvariants()
Definition Ops.cpp.inc:1152
static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::SymbolRefAttr name_ref, ::mlir::Value val)
Definition Ops.cpp.inc:1114
static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value)
Definition Ops.cpp.inc:1069
std::pair< unsigned, unsigned > getODSResultIndexAndLength(unsigned index)
Definition Ops.cpp.inc:1004
void writeProperties(::mlir::DialectBytecodeWriter &writer)
Definition Ops.cpp.inc:1096
::mlir::Operation::result_range getODSResults(unsigned index)
Definition Ops.cpp.inc:1008
static std::optional< mlir::Attribute > getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name)
Definition Ops.cpp.inc:1063
::mlir::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError)
Definition Ops.cpp.inc:1080
::mlir::SymbolRefAttr getNameRef()
Definition Ops.cpp.inc:1105
std::pair< unsigned, unsigned > getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize)
Definition Ops.cpp.inc:124
::std::optional<::mlir::OperationName > odsOpName
Definition Ops.h.inc:102
GlobalDefOpGenericAdaptorBase(::mlir::DictionaryAttr attrs=nullptr, const Properties &properties={}, ::mlir::RegionRange regions={})
Definition Ops.cpp.inc:118
GlobalReadOpGenericAdaptorBase(::mlir::DictionaryAttr attrs=nullptr, const Properties &properties={}, ::mlir::RegionRange regions={})
Definition Ops.cpp.inc:688
::std::optional<::mlir::OperationName > odsOpName
Definition Ops.h.inc:312
std::pair< unsigned, unsigned > getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize)
Definition Ops.cpp.inc:694
std::pair< unsigned, unsigned > getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize)
Definition Ops.cpp.inc:955
::std::optional<::mlir::OperationName > odsOpName
Definition Ops.h.inc:472
GlobalWriteOpGenericAdaptorBase(::mlir::DictionaryAttr attrs=nullptr, const Properties &properties={}, ::mlir::RegionRange regions={})
Definition Ops.cpp.inc:949
bool isValidGlobalType(Type type)