29static ::llvm::LogicalResult __mlir_ods_local_type_constraint_Ops1(
30 ::mlir::Operation *op, ::mlir::Type type, ::llvm::StringRef valueKind,
31 unsigned valueIndex) {
33 return op->emitOpError(valueKind) <<
" #" << valueIndex
34 <<
" must be any LLZK type except non-constant types, but got " << type;
36 return ::mlir::success();
39static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_Ops1(
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();
46static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_Ops1(
47 ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) {
48 return __mlir_ods_local_attr_constraint_Ops1(attr, attrName, [op]() {
49 return op->emitOpError();
53static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_Ops2(
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();
60static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_Ops2(
61 ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) {
62 return __mlir_ods_local_attr_constraint_Ops2(attr, attrName, [op]() {
63 return op->emitOpError();
67static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_Ops3(
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();
74static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_Ops3(
75 ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) {
76 return __mlir_ods_local_attr_constraint_Ops3(attr, attrName, [op]() {
77 return op->emitOpError();
81static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_Ops4(
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();
88static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_Ops4(
89 ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) {
90 return __mlir_ods_local_attr_constraint_Ops4(attr, attrName, [op]() {
91 return op->emitOpError();
95static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_Ops5(
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();
102static ::llvm::LogicalResult __mlir_ods_local_attr_constraint_Ops5(
103 ::mlir::Operation *op, ::mlir::Attribute attr, ::llvm::StringRef attrName) {
104 return __mlir_ods_local_attr_constraint_Ops5(attr, attrName, [op]() {
105 return op->emitOpError();
122 return attr.getValue();
126 auto attr = ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(
getProperties().constant);
128 attr = ((
false) ? ::mlir::Builder(
odsAttrs.getContext()).getUnitAttr() :
nullptr);
135 return ((
false) ? ::mlir::Builder(
odsAttrs.getContext()).getUnitAttr() :
nullptr) !=
nullptr;
136 return attr !=
nullptr;
141 return ::llvm::cast<::mlir::Type>(attr.getValue());
145 auto attr = ::llvm::dyn_cast_or_null<::mlir::Attribute>(
getProperties().initial_value);
161 if (!tblgen_sym_name)
return emitError(loc,
"'global.def' op ""requires attribute 'sym_name'");
163 if (!tblgen_type)
return emitError(loc,
"'global.def' op ""requires attribute 'type'");
165 if (tblgen_sym_name && !((::llvm::isa<::mlir::StringAttr>(tblgen_sym_name))))
166 return emitError(loc,
"'global.def' op ""attribute 'sym_name' failed to satisfy constraint: string attribute");
168 if (tblgen_constant && !((::llvm::isa<::mlir::UnitAttr>(tblgen_constant))))
169 return emitError(loc,
"'global.def' op ""attribute 'constant' failed to satisfy constraint: unit attribute");
171 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())))))
172 return emitError(loc,
"'global.def' op ""attribute 'type' failed to satisfy constraint: type attribute of any LLZK type except non-constant types");
174 if (tblgen_initial_value && !((
true)))
175 return emitError(loc,
"'global.def' op ""attribute 'initial_value' failed to satisfy constraint: any attribute");
176 return ::mlir::success();
180 ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr);
182 emitError() <<
"expected DictionaryAttr to set properties";
183 return ::mlir::failure();
188 auto attr = dict.get(
"constant");
190 auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<
decltype(propStorage)>>(attr);
192 propStorage = convertedAttr;
194 emitError() <<
"Invalid attribute `constant` in property conversion: " << attr;
195 return ::mlir::failure();
202 auto attr = dict.get(
"initial_value");
204 auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<
decltype(propStorage)>>(attr);
206 propStorage = convertedAttr;
208 emitError() <<
"Invalid attribute `initial_value` in property conversion: " << attr;
209 return ::mlir::failure();
216 auto attr = dict.get(
"sym_name");
218 auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<
decltype(propStorage)>>(attr);
220 propStorage = convertedAttr;
222 emitError() <<
"Invalid attribute `sym_name` in property conversion: " << attr;
223 return ::mlir::failure();
229 auto &propStorage = prop.
type;
230 auto attr = dict.get(
"type");
232 auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<
decltype(propStorage)>>(attr);
234 propStorage = convertedAttr;
236 emitError() <<
"Invalid attribute `type` in property conversion: " << attr;
237 return ::mlir::failure();
241 return ::mlir::success();
245 ::mlir::SmallVector<::mlir::NamedAttribute> attrs;
246 ::mlir::Builder odsBuilder{ctx};
249 const auto &propStorage = prop.
constant;
251 attrs.push_back(odsBuilder.getNamedAttr(
"constant",
258 attrs.push_back(odsBuilder.getNamedAttr(
"initial_value",
263 const auto &propStorage = prop.
sym_name;
265 attrs.push_back(odsBuilder.getNamedAttr(
"sym_name",
270 const auto &propStorage = prop.
type;
272 attrs.push_back(odsBuilder.getNamedAttr(
"type",
277 return odsBuilder.getDictionaryAttr(attrs);
282 return llvm::hash_combine(
283 llvm::hash_value(prop.
constant.getAsOpaquePointer()),
285 llvm::hash_value(prop.
sym_name.getAsOpaquePointer()),
286 llvm::hash_value(prop.
type.getAsOpaquePointer()));
290 if (
name ==
"constant")
293 if (
name ==
"initial_value")
296 if (
name ==
"sym_name")
305 if (
name ==
"constant") {
306 prop.
constant = ::llvm::dyn_cast_or_null<std::remove_reference_t<
decltype(prop.
constant)>>(value);
310 if (
name ==
"initial_value") {
315 if (
name ==
"sym_name") {
316 prop.
sym_name = ::llvm::dyn_cast_or_null<std::remove_reference_t<
decltype(prop.
sym_name)>>(value);
320 if (
name ==
"type") {
321 prop.
type = ::llvm::dyn_cast_or_null<std::remove_reference_t<
decltype(prop.
type)>>(value);
333 if (prop.
type) attrs.append(
"type", prop.
type);
336::llvm::LogicalResult
GlobalDefOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
339 if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_Ops2(attr,
"constant", emitError)))
340 return ::mlir::failure();
345 if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_Ops4(attr,
"initial_value", emitError)))
346 return ::mlir::failure();
351 if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_Ops1(attr,
"sym_name", emitError)))
352 return ::mlir::failure();
357 if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_Ops3(attr,
"type", emitError)))
358 return ::mlir::failure();
360 return ::mlir::success();
364 auto &prop = state.getOrAddProperties<
Properties>(); (void)prop;
365 if (::mlir::failed(reader.readOptionalAttribute(prop.
constant)))
366 return ::mlir::failure();
368 if (::mlir::failed(reader.readOptionalAttribute(prop.
initial_value)))
369 return ::mlir::failure();
371 if (::mlir::failed(reader.readAttribute(prop.
sym_name)))
372 return ::mlir::failure();
374 if (::mlir::failed(reader.readAttribute(prop.
type)))
375 return ::mlir::failure();
376 return ::mlir::success();
380 auto &prop = getProperties(); (void)prop;
382 writer.writeOptionalAttribute(prop.
constant);
385 writer.writeAttribute(prop.
sym_name);
386 writer.writeAttribute(prop.
type);
391 return attr.getValue();
397 return ((
false) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() :
nullptr) !=
nullptr;
398 return attr !=
nullptr;
403 return ::llvm::cast<::mlir::Type>(attr.getValue());
412 getProperties().sym_name = ::mlir::Builder((*this)->getContext()).getStringAttr(attrValue);
416 auto &odsProp = getProperties().constant;
418 odsProp = ((attrValue) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() :
nullptr);
424 getProperties().type = ::mlir::TypeAttr::get(attrValue);
427void GlobalDefOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::StringAttr sym_name, ::mlir::UnitAttr constant, ::mlir::TypeAttr type, ::mlir::Attribute initial_value) {
428 odsState.getOrAddProperties<
Properties>().sym_name = sym_name;
430 odsState.getOrAddProperties<
Properties>().constant = constant;
432 odsState.getOrAddProperties<
Properties>().type = type;
434 odsState.getOrAddProperties<
Properties>().initial_value = initial_value;
438void GlobalDefOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::StringAttr sym_name, ::mlir::UnitAttr constant, ::mlir::TypeAttr type, ::mlir::Attribute initial_value) {
439 odsState.getOrAddProperties<
Properties>().sym_name = sym_name;
441 odsState.getOrAddProperties<
Properties>().constant = constant;
443 odsState.getOrAddProperties<
Properties>().type = type;
445 odsState.getOrAddProperties<
Properties>().initial_value = initial_value;
447 assert(resultTypes.size() == 0u &&
"mismatched number of results");
448 odsState.addTypes(resultTypes);
451void GlobalDefOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::llvm::StringRef sym_name,
bool constant, ::mlir::Type type, ::mlir::Attribute initial_value) {
452 odsState.getOrAddProperties<
Properties>().sym_name = odsBuilder.getStringAttr(sym_name);
454 odsState.getOrAddProperties<
Properties>().constant = ((constant) ? odsBuilder.getUnitAttr() :
nullptr);
456 odsState.getOrAddProperties<
Properties>().type = ::mlir::TypeAttr::get(type);
457 odsState.getOrAddProperties<
Properties>().initial_value = initial_value;
460void GlobalDefOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::llvm::StringRef sym_name,
bool constant, ::mlir::Type type, ::mlir::Attribute initial_value) {
461 odsState.getOrAddProperties<
Properties>().sym_name = odsBuilder.getStringAttr(sym_name);
463 odsState.getOrAddProperties<
Properties>().constant = ((constant) ? odsBuilder.getUnitAttr() :
nullptr);
465 odsState.getOrAddProperties<
Properties>().type = ::mlir::TypeAttr::get(type);
466 odsState.getOrAddProperties<
Properties>().initial_value = initial_value;
467 assert(resultTypes.size() == 0u &&
"mismatched number of results");
468 odsState.addTypes(resultTypes);
471void GlobalDefOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
472 assert(operands.size() == 0u &&
"mismatched number of parameters");
473 odsState.addOperands(operands);
474 odsState.addAttributes(attributes);
475 assert(resultTypes.size() == 0u &&
"mismatched number of return types");
476 odsState.addTypes(resultTypes);
478 if (!attributes.empty()) {
479 ::mlir::OpaqueProperties properties =
481 std::optional<::mlir::RegisteredOperationName> info =
482 odsState.name.getRegisteredInfo();
483 if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties,
484 odsState.attributes.getDictionary(odsState.getContext()),
nullptr)))
485 ::llvm::report_fatal_error(
"Property conversion failed.");
490 ::mlir::Builder odsBuilder(opName.getContext());
496 auto tblgen_constant = getProperties().constant; (void)tblgen_constant;
497 auto tblgen_initial_value = getProperties().initial_value; (void)tblgen_initial_value;
498 auto tblgen_sym_name = getProperties().sym_name; (void)tblgen_sym_name;
499 if (!tblgen_sym_name)
return emitOpError(
"requires attribute 'sym_name'");
500 auto tblgen_type = getProperties().type; (void)tblgen_type;
501 if (!tblgen_type)
return emitOpError(
"requires attribute 'type'");
503 if (::mlir::failed(__mlir_ods_local_attr_constraint_Ops1(*
this, tblgen_sym_name,
"sym_name")))
504 return ::mlir::failure();
506 if (::mlir::failed(__mlir_ods_local_attr_constraint_Ops2(*
this, tblgen_constant,
"constant")))
507 return ::mlir::failure();
509 if (::mlir::failed(__mlir_ods_local_attr_constraint_Ops3(*
this, tblgen_type,
"type")))
510 return ::mlir::failure();
512 if (::mlir::failed(__mlir_ods_local_attr_constraint_Ops4(*
this, tblgen_initial_value,
"initial_value")))
513 return ::mlir::failure();
514 return ::mlir::success();
519 return ::mlir::success();
520 return ::mlir::failure();
524 ::mlir::StringAttr sym_nameAttr;
525 ::mlir::TypeAttr typeAttr;
526 ::mlir::Attribute initial_valueAttr;
527 if (::mlir::succeeded(parser.parseOptionalKeyword(
"const"))) {
530 if (parser.parseSymbolName(sym_nameAttr))
531 return ::mlir::failure();
533 if (parser.parseColon())
534 return ::mlir::failure();
536 if (parser.parseCustomAttributeWithFallback(typeAttr, parser.getBuilder().getType<::mlir::NoneType>())) {
537 return ::mlir::failure();
542 if (odsResult) return ::mlir::failure();
543 if (initial_valueAttr)
547 auto loc = parser.getCurrentLocation();(void)loc;
548 if (parser.parseOptionalAttrDict(result.attributes))
549 return ::mlir::failure();
551 return parser.emitError(loc) <<
"'" << result.name.getStringRef() <<
"' op ";
553 return ::mlir::failure();
555 return ::mlir::success();
560 _odsPrinter <<
' ' <<
"const";
564 _odsPrinter <<
' ' <<
":";
566 _odsPrinter.printAttributeWithoutType(
getTypeAttr());
568 ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
569 elidedAttrs.push_back(
"constant");
570 elidedAttrs.push_back(
"sym_name");
571 elidedAttrs.push_back(
"type");
572 elidedAttrs.push_back(
"initial_value");
574 ::mlir::Builder odsBuilder(getContext());
576 if(attr && (attr == ((
false) ? odsBuilder.getUnitAttr() :
nullptr)))
577 elidedAttrs.push_back(
"constant");
580 ::mlir::Builder odsBuilder(getContext());
582 if(attr && (attr ==
nullptr))
583 elidedAttrs.push_back(
"initial_value");
585 _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
612 if (!tblgen_name_ref)
return emitError(loc,
"'global.read' op ""requires attribute 'name_ref'");
614 if (tblgen_name_ref && !((::llvm::isa<::mlir::SymbolRefAttr>(tblgen_name_ref))))
615 return emitError(loc,
"'global.read' op ""attribute 'name_ref' failed to satisfy constraint: symbol reference attribute");
616 return ::mlir::success();
620 ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr);
622 emitError() <<
"expected DictionaryAttr to set properties";
623 return ::mlir::failure();
628 auto attr = dict.get(
"name_ref");
630 auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<
decltype(propStorage)>>(attr);
632 propStorage = convertedAttr;
634 emitError() <<
"Invalid attribute `name_ref` in property conversion: " << attr;
635 return ::mlir::failure();
639 return ::mlir::success();
643 ::mlir::SmallVector<::mlir::NamedAttribute> attrs;
644 ::mlir::Builder odsBuilder{ctx};
647 const auto &propStorage = prop.
name_ref;
649 attrs.push_back(odsBuilder.getNamedAttr(
"name_ref",
654 return odsBuilder.getDictionaryAttr(attrs);
659 return llvm::hash_combine(
660 llvm::hash_value(prop.
name_ref.getAsOpaquePointer()));
664 if (
name ==
"name_ref")
670 if (
name ==
"name_ref") {
671 prop.
name_ref = ::llvm::dyn_cast_or_null<std::remove_reference_t<
decltype(prop.
name_ref)>>(value);
680::llvm::LogicalResult
GlobalReadOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
683 if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_Ops5(attr,
"name_ref", emitError)))
684 return ::mlir::failure();
686 return ::mlir::success();
690 auto &prop = state.getOrAddProperties<
Properties>(); (void)prop;
691 if (::mlir::failed(reader.readAttribute(prop.
name_ref)))
692 return ::mlir::failure();
693 return ::mlir::success();
697 auto &prop = getProperties(); (void)prop;
698 writer.writeAttribute(prop.
name_ref);
706void GlobalReadOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type val, ::mlir::SymbolRefAttr name_ref) {
707 odsState.getOrAddProperties<
Properties>().name_ref = name_ref;
708 odsState.addTypes(val);
711void GlobalReadOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::SymbolRefAttr name_ref) {
712 odsState.getOrAddProperties<
Properties>().name_ref = name_ref;
713 assert(resultTypes.size() == 1u &&
"mismatched number of results");
714 odsState.addTypes(resultTypes);
717void GlobalReadOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
718 assert(operands.size() == 0u &&
"mismatched number of parameters");
719 odsState.addOperands(operands);
720 odsState.addAttributes(attributes);
721 assert(resultTypes.size() == 1u &&
"mismatched number of return types");
722 odsState.addTypes(resultTypes);
724 if (!attributes.empty()) {
725 ::mlir::OpaqueProperties properties =
727 std::optional<::mlir::RegisteredOperationName> info =
728 odsState.name.getRegisteredInfo();
729 if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties,
730 odsState.attributes.getDictionary(odsState.getContext()),
nullptr)))
731 ::llvm::report_fatal_error(
"Property conversion failed.");
736 auto tblgen_name_ref = getProperties().name_ref; (void)tblgen_name_ref;
737 if (!tblgen_name_ref)
return emitOpError(
"requires attribute 'name_ref'");
739 if (::mlir::failed(__mlir_ods_local_attr_constraint_Ops5(*
this, tblgen_name_ref,
"name_ref")))
740 return ::mlir::failure();
742 unsigned index = 0; (void)index;
745 for (
auto v : valueGroup0) {
746 if (::mlir::failed(__mlir_ods_local_type_constraint_Ops1(*
this, v.getType(),
"result", index++)))
747 return ::mlir::failure();
750 return ::mlir::success();
758 ::mlir::SymbolRefAttr name_refAttr;
759 ::mlir::Type valRawType{};
760 ::llvm::ArrayRef<::mlir::Type> valTypes(&valRawType, 1);
762 if (parser.parseCustomAttributeWithFallback(name_refAttr, parser.getBuilder().getType<::mlir::NoneType>())) {
763 return ::mlir::failure();
766 if (parser.parseColon())
767 return ::mlir::failure();
771 if (parser.parseCustomTypeWithFallback(type))
772 return ::mlir::failure();
776 auto loc = parser.getCurrentLocation();(void)loc;
777 if (parser.parseOptionalAttrDict(result.attributes))
778 return ::mlir::failure();
780 return parser.emitError(loc) <<
"'" << result.name.getStringRef() <<
"' op ";
782 return ::mlir::failure();
784 result.addTypes(valTypes);
785 return ::mlir::success();
791 _odsPrinter <<
' ' <<
":";
794 auto type =
getVal().getType();
795 if (
auto validType = ::llvm::dyn_cast<::mlir::Type>(type))
796 _odsPrinter.printStrippedAttrOrType(validType);
800 ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
801 elidedAttrs.push_back(
"name_ref");
802 _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
829 if (!tblgen_name_ref)
return emitError(loc,
"'global.write' op ""requires attribute 'name_ref'");
831 if (tblgen_name_ref && !((::llvm::isa<::mlir::SymbolRefAttr>(tblgen_name_ref))))
832 return emitError(loc,
"'global.write' op ""attribute 'name_ref' failed to satisfy constraint: symbol reference attribute");
833 return ::mlir::success();
837 ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr);
839 emitError() <<
"expected DictionaryAttr to set properties";
840 return ::mlir::failure();
845 auto attr = dict.get(
"name_ref");
847 auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<
decltype(propStorage)>>(attr);
849 propStorage = convertedAttr;
851 emitError() <<
"Invalid attribute `name_ref` in property conversion: " << attr;
852 return ::mlir::failure();
856 return ::mlir::success();
860 ::mlir::SmallVector<::mlir::NamedAttribute> attrs;
861 ::mlir::Builder odsBuilder{ctx};
864 const auto &propStorage = prop.
name_ref;
866 attrs.push_back(odsBuilder.getNamedAttr(
"name_ref",
871 return odsBuilder.getDictionaryAttr(attrs);
876 return llvm::hash_combine(
877 llvm::hash_value(prop.
name_ref.getAsOpaquePointer()));
881 if (
name ==
"name_ref")
887 if (
name ==
"name_ref") {
888 prop.
name_ref = ::llvm::dyn_cast_or_null<std::remove_reference_t<
decltype(prop.
name_ref)>>(value);
900 if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_Ops5(attr,
"name_ref", emitError)))
901 return ::mlir::failure();
903 return ::mlir::success();
907 auto &prop = state.getOrAddProperties<
Properties>(); (void)prop;
908 if (::mlir::failed(reader.readAttribute(prop.
name_ref)))
909 return ::mlir::failure();
910 return ::mlir::success();
914 auto &prop = getProperties(); (void)prop;
915 writer.writeAttribute(prop.
name_ref);
923void GlobalWriteOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::SymbolRefAttr name_ref, ::mlir::Value val) {
924 odsState.addOperands(val);
925 odsState.getOrAddProperties<
Properties>().name_ref = name_ref;
928void GlobalWriteOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::SymbolRefAttr name_ref, ::mlir::Value val) {
929 odsState.addOperands(val);
930 odsState.getOrAddProperties<
Properties>().name_ref = name_ref;
931 assert(resultTypes.size() == 0u &&
"mismatched number of results");
932 odsState.addTypes(resultTypes);
935void GlobalWriteOp::build(::mlir::OpBuilder &, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::mlir::ValueRange operands, ::llvm::ArrayRef<::mlir::NamedAttribute> attributes) {
936 assert(operands.size() == 1u &&
"mismatched number of parameters");
937 odsState.addOperands(operands);
938 odsState.addAttributes(attributes);
939 assert(resultTypes.size() == 0u &&
"mismatched number of return types");
940 odsState.addTypes(resultTypes);
942 if (!attributes.empty()) {
943 ::mlir::OpaqueProperties properties =
945 std::optional<::mlir::RegisteredOperationName> info =
946 odsState.name.getRegisteredInfo();
947 if (failed(info->setOpPropertiesFromAttribute(odsState.name, properties,
948 odsState.attributes.getDictionary(odsState.getContext()),
nullptr)))
949 ::llvm::report_fatal_error(
"Property conversion failed.");
954 auto tblgen_name_ref = getProperties().name_ref; (void)tblgen_name_ref;
955 if (!tblgen_name_ref)
return emitOpError(
"requires attribute 'name_ref'");
957 if (::mlir::failed(__mlir_ods_local_attr_constraint_Ops5(*
this, tblgen_name_ref,
"name_ref")))
958 return ::mlir::failure();
960 unsigned index = 0; (void)index;
963 for (
auto v : valueGroup0) {
964 if (::mlir::failed(__mlir_ods_local_type_constraint_Ops1(*
this, v.getType(),
"operand", index++)))
965 return ::mlir::failure();
968 return ::mlir::success();
976 ::mlir::SymbolRefAttr name_refAttr;
977 ::mlir::OpAsmParser::UnresolvedOperand valRawOperand{};
978 ::llvm::ArrayRef<::mlir::OpAsmParser::UnresolvedOperand> valOperands(&valRawOperand, 1); ::llvm::SMLoc valOperandsLoc;
979 (void)valOperandsLoc;
980 ::mlir::Type valRawType{};
981 ::llvm::ArrayRef<::mlir::Type> valTypes(&valRawType, 1);
983 if (parser.parseCustomAttributeWithFallback(name_refAttr, parser.getBuilder().getType<::mlir::NoneType>())) {
984 return ::mlir::failure();
987 if (parser.parseEqual())
988 return ::mlir::failure();
990 valOperandsLoc = parser.getCurrentLocation();
991 if (parser.parseOperand(valRawOperand))
992 return ::mlir::failure();
993 if (parser.parseColon())
994 return ::mlir::failure();
998 if (parser.parseCustomTypeWithFallback(type))
999 return ::mlir::failure();
1003 auto loc = parser.getCurrentLocation();(void)loc;
1004 if (parser.parseOptionalAttrDict(result.attributes))
1005 return ::mlir::failure();
1007 return parser.emitError(loc) <<
"'" << result.name.getStringRef() <<
"' op ";
1009 return ::mlir::failure();
1011 if (parser.resolveOperands(valOperands, valTypes, valOperandsLoc, result.operands))
1012 return ::mlir::failure();
1013 return ::mlir::success();
1019 _odsPrinter <<
' ' <<
"=";
1022 _odsPrinter <<
' ' <<
":";
1025 auto type =
getVal().getType();
1026 if (
auto validType = ::llvm::dyn_cast<::mlir::Type>(type))
1027 _odsPrinter.printStrippedAttrOrType(validType);
1029 _odsPrinter << type;
1031 ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
1032 elidedAttrs.push_back(
"name_ref");
1033 _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
::llvm::LogicalResult verify(::mlir::Location loc)
GlobalDefOpAdaptor(GlobalDefOp op)
GlobalDefOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions={})
::mlir::ValueRange getOperands()
::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError)
static void populateDefaultProperties(::mlir::OperationName opName, Properties &properties)
FoldAdaptor::Properties Properties
::mlir::Attribute getInitialValue()
void setType(::mlir::Type attrValue)
::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state)
::mlir::ParseResult parseGlobalInitialValue(::mlir::OpAsmParser &parser, ::mlir::Attribute &initialValue, ::mlir::TypeAttr typeAttr)
static std::optional< mlir::Attribute > getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name)
static void printGlobalInitialValue(::mlir::OpAsmPrinter &printer, GlobalDefOp op, ::mlir::Attribute initialValue, ::mlir::TypeAttr typeAttr)
::llvm::LogicalResult verifyInvariants()
::mlir::TypeAttr getTypeAttr()
::llvm::StringRef getSymName()
::mlir::StringAttr getSymNameAttrName()
::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop)
::mlir::Attribute getInitialValueAttr()
::mlir::StringAttr getSymNameAttr()
::mlir::UnitAttr getConstantAttr()
void setSymName(::llvm::StringRef attrValue)
void writeProperties(::mlir::DialectBytecodeWriter &writer)
void print(::mlir::OpAsmPrinter &_odsPrinter)
::llvm::LogicalResult verifyInvariantsImpl()
::mlir::StringAttr getTypeAttrName()
void setConstant(bool attrValue)
::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError)
static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs)
static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::StringAttr sym_name, ::mlir::UnitAttr constant, ::mlir::TypeAttr type, ::mlir::Attribute initial_value=nullptr)
::mlir::StringAttr getInitialValueAttrName()
::llvm::LogicalResult verify()
static llvm::hash_code computePropertiesHash(const Properties &prop)
::mlir::StringAttr getConstantAttrName()
static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value)
::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result)
GlobalReadOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions={})
::llvm::LogicalResult verify(::mlir::Location loc)
GlobalReadOpAdaptor(GlobalReadOp op)
::mlir::ValueRange getOperands()
static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::Type val, ::mlir::SymbolRefAttr name_ref)
::mlir::StringAttr getNameRefAttrName()
void writeProperties(::mlir::DialectBytecodeWriter &writer)
FoldAdaptor::Properties Properties
::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop)
::mlir::Operation::result_range getODSResults(unsigned index)
::llvm::LogicalResult verifyInvariants()
void print(::mlir::OpAsmPrinter &_odsPrinter)
static llvm::hash_code computePropertiesHash(const Properties &prop)
::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result)
static std::optional< mlir::Attribute > getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name)
::mlir::SymbolRefAttr getNameRefAttr()
static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value)
::mlir::TypedValue<::mlir::Type > getVal()
::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError)
::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError)
::mlir::SymbolRefAttr getNameRef()
::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state)
static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs)
::llvm::LogicalResult verifyInvariantsImpl()
GlobalWriteOpAdaptor(GlobalWriteOp op)
GlobalWriteOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions={})
::llvm::LogicalResult verify(::mlir::Location loc)
::mlir::ValueRange getOperands()
::mlir::TypedValue<::mlir::Type > getVal()
static llvm::hash_code computePropertiesHash(const Properties &prop)
::mlir::StringAttr getNameRefAttrName()
::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result)
::mlir::SymbolRefAttr getNameRefAttr()
::mlir::Operation::operand_range getODSOperands(unsigned index)
static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs)
void print(::mlir::OpAsmPrinter &_odsPrinter)
FoldAdaptor::Properties Properties
::llvm::LogicalResult verifyInvariants()
::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop)
::llvm::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError)
static void build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::SymbolRefAttr name_ref, ::mlir::Value val)
static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value)
void writeProperties(::mlir::DialectBytecodeWriter &writer)
static std::optional< mlir::Attribute > getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name)
::llvm::LogicalResult verifyInvariantsImpl()
::llvm::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError)
::mlir::SymbolRefAttr getNameRef()
::llvm::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state)
::mlir::DictionaryAttr odsAttrs
::mlir::Attribute getInitialValueAttr()
GlobalDefOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions={})
::mlir::RegionRange odsRegions
::llvm::StringRef getSymName()
::std::optional<::mlir::OperationName > odsOpName
::mlir::UnitAttr getConstantAttr()
const Properties & getProperties()
::mlir::Attribute getInitialValue()
::mlir::TypeAttr getTypeAttr()
::mlir::StringAttr getSymNameAttr()
const Properties & getProperties()
::mlir::SymbolRefAttr getNameRef()
::mlir::RegionRange odsRegions
GlobalReadOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions={})
::mlir::DictionaryAttr odsAttrs
::std::optional<::mlir::OperationName > odsOpName
::mlir::SymbolRefAttr getNameRefAttr()
::mlir::SymbolRefAttr getNameRefAttr()
::mlir::RegionRange odsRegions
const Properties & getProperties()
::mlir::SymbolRefAttr getNameRef()
::std::optional<::mlir::OperationName > odsOpName
GlobalWriteOpGenericAdaptorBase(::mlir::DictionaryAttr attrs, const Properties &properties, ::mlir::RegionRange regions={})
::mlir::DictionaryAttr odsAttrs
bool isValidGlobalType(Type type)
initial_valueTy initial_value