29static ::mlir::LogicalResult __mlir_ods_local_type_constraint_Ops0(
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 ::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();
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();
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();
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();
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();
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();
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();
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();
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();
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();
133 auto attr = ::llvm::cast<::mlir::StringAttr>(
getProperties().sym_name);
139 return attr.getValue();
143 auto attr = ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(
getProperties().constant);
145 attr = ((
false) ? ::mlir::Builder(
odsAttrs.getContext()).getUnitAttr() :
nullptr);
152 return ((
false) ? ::mlir::Builder(
odsAttrs.getContext()).getUnitAttr() :
nullptr) !=
nullptr;
153 return attr !=
nullptr;
157 auto attr = ::llvm::cast<::mlir::TypeAttr>(
getProperties().type);
163 return ::llvm::cast<::mlir::Type>(attr.getValue());
167 auto attr = ::llvm::dyn_cast_or_null<::mlir::Attribute>(
getProperties().initial_value);
183 if (!tblgen_sym_name)
return emitError(loc,
"'global.def' op ""requires attribute 'sym_name'");
185 if (!tblgen_type)
return emitError(loc,
"'global.def' op ""requires attribute 'type'");
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");
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");
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");
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();
207 return {std::next(getOperation()->operand_begin(), valueRange.first),
208 std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)};
217 return {std::next(getOperation()->result_begin(), valueRange.first),
218 std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)};
222 ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr);
224 emitError() <<
"expected DictionaryAttr to set properties";
225 return ::mlir::failure();
230 auto attr = dict.get(
"constant");
233 emitError() <<
"expected key entry for constant in DictionaryAttr to set "
235 return ::mlir::failure();
237 auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<
decltype(propStorage)>>(attr);
239 propStorage = convertedAttr;
241 emitError() <<
"Invalid attribute `constant` in property conversion: " << attr;
242 return ::mlir::failure();
249 auto attr = dict.get(
"initial_value");
252 emitError() <<
"expected key entry for initial_value in DictionaryAttr to set "
254 return ::mlir::failure();
256 auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<
decltype(propStorage)>>(attr);
258 propStorage = convertedAttr;
260 emitError() <<
"Invalid attribute `initial_value` in property conversion: " << attr;
261 return ::mlir::failure();
268 auto attr = dict.get(
"sym_name");
271 emitError() <<
"expected key entry for sym_name in DictionaryAttr to set "
273 return ::mlir::failure();
275 auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<
decltype(propStorage)>>(attr);
277 propStorage = convertedAttr;
279 emitError() <<
"Invalid attribute `sym_name` in property conversion: " << attr;
280 return ::mlir::failure();
286 auto &propStorage = prop.
type;
287 auto attr = dict.get(
"type");
290 emitError() <<
"expected key entry for type in DictionaryAttr to set "
292 return ::mlir::failure();
294 auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<
decltype(propStorage)>>(attr);
296 propStorage = convertedAttr;
298 emitError() <<
"Invalid attribute `type` in property conversion: " << attr;
299 return ::mlir::failure();
303 return ::mlir::success();
307 ::mlir::SmallVector<::mlir::NamedAttribute> attrs;
308 ::mlir::Builder odsBuilder{ctx};
311 const auto &propStorage = prop.
constant;
313 attrs.push_back(odsBuilder.getNamedAttr(
"constant",
320 attrs.push_back(odsBuilder.getNamedAttr(
"initial_value",
325 const auto &propStorage = prop.
sym_name;
327 attrs.push_back(odsBuilder.getNamedAttr(
"sym_name",
332 const auto &propStorage = prop.
type;
334 attrs.push_back(odsBuilder.getNamedAttr(
"type",
339 return odsBuilder.getDictionaryAttr(attrs);
344 return llvm::hash_combine(
345 llvm::hash_value(prop.
constant.getAsOpaquePointer()),
347 llvm::hash_value(prop.
sym_name.getAsOpaquePointer()),
348 llvm::hash_value(prop.
type.getAsOpaquePointer()));
352 if (name ==
"constant")
355 if (name ==
"initial_value")
358 if (name ==
"sym_name")
367 if (name ==
"constant") {
368 prop.
constant = ::llvm::dyn_cast_or_null<std::remove_reference_t<
decltype(prop.
constant)>>(value);
372 if (name ==
"initial_value") {
377 if (name ==
"sym_name") {
378 prop.
sym_name = ::llvm::dyn_cast_or_null<std::remove_reference_t<
decltype(prop.
sym_name)>>(value);
382 if (name ==
"type") {
383 prop.
type = ::llvm::dyn_cast_or_null<std::remove_reference_t<
decltype(prop.
type)>>(value);
395 if (prop.
type) attrs.append(
"type", prop.
type);
398::mlir::LogicalResult
GlobalDefOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
401 if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_Ops1(attr,
"constant", emitError)))
402 return ::mlir::failure();
407 if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_Ops3(attr,
"initial_value", emitError)))
408 return ::mlir::failure();
413 if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_Ops0(attr,
"sym_name", emitError)))
414 return ::mlir::failure();
419 if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_Ops2(attr,
"type", emitError)))
420 return ::mlir::failure();
422 return ::mlir::success();
426 auto &prop = state.getOrAddProperties<
Properties>(); (void)prop;
427 if (::mlir::failed(reader.readOptionalAttribute(prop.
constant)))
428 return ::mlir::failure();
430 if (::mlir::failed(reader.readOptionalAttribute(prop.
initial_value)))
431 return ::mlir::failure();
433 if (::mlir::failed(reader.readAttribute(prop.
sym_name)))
434 return ::mlir::failure();
436 if (::mlir::failed(reader.readAttribute(prop.
type)))
437 return ::mlir::failure();
438 return ::mlir::success();
442 auto &prop = getProperties(); (void)prop;
444 writer.writeOptionalAttribute(prop.
constant);
447 writer.writeAttribute(prop.
sym_name);
448 writer.writeAttribute(prop.
type);
452 return ::llvm::cast<::mlir::StringAttr>(getProperties().sym_name);
457 return attr.getValue();
461 return ::llvm::dyn_cast_or_null<::mlir::UnitAttr>(getProperties().constant);
467 return ((
false) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() :
nullptr) !=
nullptr;
468 return attr !=
nullptr;
472 return ::llvm::cast<::mlir::TypeAttr>(getProperties().type);
477 return ::llvm::cast<::mlir::Type>(attr.getValue());
481 return ::llvm::dyn_cast_or_null<::mlir::Attribute>(getProperties().initial_value);
494 (*this)->setAttr(
getSymNameAttrName(), ::mlir::Builder((*this)->getContext()).getStringAttr(attrValue));
503 return (*this)->setAttr(
getConstantAttrName(), ((attrValue) ? ::mlir::Builder((*this)->getContext()).getUnitAttr() :
nullptr));
520 auto &attr = getProperties().constant;
525void GlobalDefOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::StringAttr sym_name, ::mlir::UnitAttr constant, ::mlir::TypeAttr type, ::mlir::Attribute initial_value) {
526 odsState.getOrAddProperties<
Properties>().sym_name = sym_name;
528 odsState.getOrAddProperties<
Properties>().constant = constant;
530 odsState.getOrAddProperties<
Properties>().type = type;
532 odsState.getOrAddProperties<
Properties>().initial_value = initial_value;
536void 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) {
537 odsState.getOrAddProperties<
Properties>().sym_name = sym_name;
539 odsState.getOrAddProperties<
Properties>().constant = constant;
541 odsState.getOrAddProperties<
Properties>().type = type;
543 odsState.getOrAddProperties<
Properties>().initial_value = initial_value;
545 assert(resultTypes.size() == 0u &&
"mismatched number of results");
546 odsState.addTypes(resultTypes);
549void GlobalDefOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::llvm::StringRef sym_name,
bool constant, ::mlir::Type type, ::mlir::Attribute initial_value) {
550 odsState.getOrAddProperties<
Properties>().sym_name = odsBuilder.getStringAttr(sym_name);
552 odsState.getOrAddProperties<
Properties>().constant = ((constant) ? odsBuilder.getUnitAttr() :
nullptr);
554 odsState.getOrAddProperties<
Properties>().type = ::mlir::TypeAttr::get(type);
555 odsState.getOrAddProperties<
Properties>().initial_value = initial_value;
558void GlobalDefOp::build(::mlir::OpBuilder &odsBuilder, ::mlir::OperationState &odsState, ::mlir::TypeRange resultTypes, ::llvm::StringRef sym_name,
bool constant, ::mlir::Type type, ::mlir::Attribute initial_value) {
559 odsState.getOrAddProperties<
Properties>().sym_name = odsBuilder.getStringAttr(sym_name);
561 odsState.getOrAddProperties<
Properties>().constant = ((constant) ? odsBuilder.getUnitAttr() :
nullptr);
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);
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);
578 ::mlir::Builder odsBuilder(opName.getContext());
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'");
591 if (::mlir::failed(__mlir_ods_local_attr_constraint_Ops0(*
this, tblgen_sym_name,
"sym_name")))
592 return ::mlir::failure();
594 if (::mlir::failed(__mlir_ods_local_attr_constraint_Ops1(*
this, tblgen_constant,
"constant")))
595 return ::mlir::failure();
597 if (::mlir::failed(__mlir_ods_local_attr_constraint_Ops2(*
this, tblgen_type,
"type")))
598 return ::mlir::failure();
600 if (::mlir::failed(__mlir_ods_local_attr_constraint_Ops3(*
this, tblgen_initial_value,
"initial_value")))
601 return ::mlir::failure();
602 return ::mlir::success();
607 return ::mlir::success();
608 return ::mlir::failure();
612 ::mlir::StringAttr sym_nameAttr;
613 ::mlir::TypeAttr typeAttr;
614 ::mlir::Attribute initial_valueAttr;
615 if (::mlir::succeeded(parser.parseOptionalKeyword(
"const"))) {
618 if (parser.parseSymbolName(sym_nameAttr))
619 return ::mlir::failure();
621 if (parser.parseColon())
622 return ::mlir::failure();
624 if (parser.parseCustomAttributeWithFallback(typeAttr, parser.getBuilder().getType<::mlir::NoneType>())) {
625 return ::mlir::failure();
630 if (odsResult) return ::mlir::failure();
631 if (initial_valueAttr)
635 auto loc = parser.getCurrentLocation();(void)loc;
636 if (parser.parseOptionalAttrDict(result.attributes))
637 return ::mlir::failure();
639 return parser.emitError(loc) <<
"'" << result.name.getStringRef() <<
"' op ";
641 return ::mlir::failure();
643 return ::mlir::success();
648 _odsPrinter <<
' ' <<
"const";
652 _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");
662 ::mlir::Builder odsBuilder(getContext());
664 if(attr && (attr == ((
false) ? odsBuilder.getUnitAttr() :
nullptr)))
665 elidedAttrs.push_back(
"constant");
668 ::mlir::Builder odsBuilder(getContext());
670 if(attr && (attr ==
nullptr))
671 elidedAttrs.push_back(
"initial_value");
673 _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
703 auto attr = ::llvm::cast<::mlir::SymbolRefAttr>(
getProperties().name_ref);
717 if (!tblgen_name_ref)
return emitError(loc,
"'global.read' op ""requires attribute 'name_ref'");
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();
730 return {std::next(getOperation()->operand_begin(), valueRange.first),
731 std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)};
740 return {std::next(getOperation()->result_begin(), valueRange.first),
741 std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)};
745 return ::llvm::cast<::mlir::Value>(*
getODSResults(0).begin());
749 ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr);
751 emitError() <<
"expected DictionaryAttr to set properties";
752 return ::mlir::failure();
757 auto attr = dict.get(
"name_ref");
760 emitError() <<
"expected key entry for name_ref in DictionaryAttr to set "
762 return ::mlir::failure();
764 auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<
decltype(propStorage)>>(attr);
766 propStorage = convertedAttr;
768 emitError() <<
"Invalid attribute `name_ref` in property conversion: " << attr;
769 return ::mlir::failure();
773 return ::mlir::success();
777 ::mlir::SmallVector<::mlir::NamedAttribute> attrs;
778 ::mlir::Builder odsBuilder{ctx};
781 const auto &propStorage = prop.
name_ref;
783 attrs.push_back(odsBuilder.getNamedAttr(
"name_ref",
788 return odsBuilder.getDictionaryAttr(attrs);
793 return llvm::hash_combine(
794 llvm::hash_value(prop.
name_ref.getAsOpaquePointer()));
798 if (name ==
"name_ref")
804 if (name ==
"name_ref") {
805 prop.
name_ref = ::llvm::dyn_cast_or_null<std::remove_reference_t<
decltype(prop.
name_ref)>>(value);
814::mlir::LogicalResult
GlobalReadOp::verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError) {
817 if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_Ops4(attr,
"name_ref", emitError)))
818 return ::mlir::failure();
820 return ::mlir::success();
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();
831 auto &prop = getProperties(); (void)prop;
832 writer.writeAttribute(prop.
name_ref);
836 return ::llvm::cast<::mlir::SymbolRefAttr>(getProperties().name_ref);
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);
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);
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);
868 auto tblgen_name_ref = getProperties().name_ref; (void)tblgen_name_ref;
869 if (!tblgen_name_ref)
return emitOpError(
"requires attribute 'name_ref'");
871 if (::mlir::failed(__mlir_ods_local_attr_constraint_Ops4(*
this, tblgen_name_ref,
"name_ref")))
872 return ::mlir::failure();
874 unsigned index = 0; (void)index;
877 for (
auto v : valueGroup0) {
878 if (::mlir::failed(__mlir_ods_local_type_constraint_Ops0(*
this, v.getType(),
"result", index++)))
879 return ::mlir::failure();
882 return ::mlir::success();
890 ::mlir::SymbolRefAttr name_refAttr;
891 ::mlir::Type valRawTypes[1];
892 ::llvm::ArrayRef<::mlir::Type> valTypes(valRawTypes);
894 if (parser.parseCustomAttributeWithFallback(name_refAttr, parser.getBuilder().getType<::mlir::NoneType>())) {
895 return ::mlir::failure();
898 if (parser.parseColon())
899 return ::mlir::failure();
903 if (parser.parseCustomTypeWithFallback(type))
904 return ::mlir::failure();
905 valRawTypes[0] = type;
908 auto loc = parser.getCurrentLocation();(void)loc;
909 if (parser.parseOptionalAttrDict(result.attributes))
910 return ::mlir::failure();
912 return parser.emitError(loc) <<
"'" << result.name.getStringRef() <<
"' op ";
914 return ::mlir::failure();
916 result.addTypes(valTypes);
917 return ::mlir::success();
923 _odsPrinter <<
' ' <<
":";
926 auto type =
getVal().getType();
927 if (
auto validType = ::llvm::dyn_cast<::mlir::Type>(type))
928 _odsPrinter.printStrippedAttrOrType(validType);
932 ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
933 elidedAttrs.push_back(
"name_ref");
934 _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
964 auto attr = ::llvm::cast<::mlir::SymbolRefAttr>(
getProperties().name_ref);
978 if (!tblgen_name_ref)
return emitError(loc,
"'global.write' op ""requires attribute 'name_ref'");
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();
991 return {std::next(getOperation()->operand_begin(), valueRange.first),
992 std::next(getOperation()->operand_begin(), valueRange.first + valueRange.second)};
1001 return getOperation()->getOpOperand(range.first);
1010 return {std::next(getOperation()->result_begin(), valueRange.first),
1011 std::next(getOperation()->result_begin(), valueRange.first + valueRange.second)};
1015 ::mlir::DictionaryAttr dict = ::llvm::dyn_cast<::mlir::DictionaryAttr>(attr);
1017 emitError() <<
"expected DictionaryAttr to set properties";
1018 return ::mlir::failure();
1023 auto attr = dict.get(
"name_ref");
1026 emitError() <<
"expected key entry for name_ref in DictionaryAttr to set "
1028 return ::mlir::failure();
1030 auto convertedAttr = ::llvm::dyn_cast<std::remove_reference_t<
decltype(propStorage)>>(attr);
1031 if (convertedAttr) {
1032 propStorage = convertedAttr;
1034 emitError() <<
"Invalid attribute `name_ref` in property conversion: " << attr;
1035 return ::mlir::failure();
1039 return ::mlir::success();
1043 ::mlir::SmallVector<::mlir::NamedAttribute> attrs;
1044 ::mlir::Builder odsBuilder{ctx};
1047 const auto &propStorage = prop.
name_ref;
1049 attrs.push_back(odsBuilder.getNamedAttr(
"name_ref",
1054 return odsBuilder.getDictionaryAttr(attrs);
1059 return llvm::hash_combine(
1060 llvm::hash_value(prop.
name_ref.getAsOpaquePointer()));
1064 if (name ==
"name_ref")
1066 return std::nullopt;
1070 if (name ==
"name_ref") {
1071 prop.
name_ref = ::llvm::dyn_cast_or_null<std::remove_reference_t<
decltype(prop.
name_ref)>>(value);
1083 if (attr && ::mlir::failed(__mlir_ods_local_attr_constraint_Ops4(attr,
"name_ref", emitError)))
1084 return ::mlir::failure();
1086 return ::mlir::success();
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();
1097 auto &prop = getProperties(); (void)prop;
1098 writer.writeAttribute(prop.
name_ref);
1102 return ::llvm::cast<::mlir::SymbolRefAttr>(getProperties().name_ref);
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;
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);
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);
1135 auto tblgen_name_ref = getProperties().name_ref; (void)tblgen_name_ref;
1136 if (!tblgen_name_ref)
return emitOpError(
"requires attribute 'name_ref'");
1138 if (::mlir::failed(__mlir_ods_local_attr_constraint_Ops4(*
this, tblgen_name_ref,
"name_ref")))
1139 return ::mlir::failure();
1141 unsigned index = 0; (void)index;
1144 for (
auto v : valueGroup0) {
1145 if (::mlir::failed(__mlir_ods_local_type_constraint_Ops0(*
this, v.getType(),
"operand", index++)))
1146 return ::mlir::failure();
1149 return ::mlir::success();
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);
1164 if (parser.parseCustomAttributeWithFallback(name_refAttr, parser.getBuilder().getType<::mlir::NoneType>())) {
1165 return ::mlir::failure();
1168 if (parser.parseEqual())
1169 return ::mlir::failure();
1171 valOperandsLoc = parser.getCurrentLocation();
1172 if (parser.parseOperand(valRawOperands[0]))
1173 return ::mlir::failure();
1174 if (parser.parseColon())
1175 return ::mlir::failure();
1179 if (parser.parseCustomTypeWithFallback(type))
1180 return ::mlir::failure();
1181 valRawTypes[0] = type;
1184 auto loc = parser.getCurrentLocation();(void)loc;
1185 if (parser.parseOptionalAttrDict(result.attributes))
1186 return ::mlir::failure();
1188 return parser.emitError(loc) <<
"'" << result.name.getStringRef() <<
"' op ";
1190 return ::mlir::failure();
1192 if (parser.resolveOperands(valOperands, valTypes, valOperandsLoc, result.operands))
1193 return ::mlir::failure();
1194 return ::mlir::success();
1200 _odsPrinter <<
' ' <<
"=";
1203 _odsPrinter <<
' ' <<
":";
1206 auto type =
getVal().getType();
1207 if (
auto validType = ::llvm::dyn_cast<::mlir::Type>(type))
1208 _odsPrinter.printStrippedAttrOrType(validType);
1210 _odsPrinter << type;
1212 ::llvm::SmallVector<::llvm::StringRef, 2> elidedAttrs;
1213 elidedAttrs.push_back(
"name_ref");
1214 _odsPrinter.printOptionalAttrDict((*this)->getAttrs(), elidedAttrs);
GlobalDefOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs=nullptr, const Properties &properties={}, ::mlir::RegionRange regions={})
GlobalDefOpAdaptor(GlobalDefOp op)
::mlir::LogicalResult verify(::mlir::Location loc)
::mlir::ValueRange getOperands()
void setInitialValueAttr(::mlir::Attribute attr)
static void populateDefaultProperties(::mlir::OperationName opName, Properties &properties)
::mlir::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError)
FoldAdaptor::Properties Properties
::mlir::Attribute getInitialValue()
void setType(::mlir::Type attrValue)
::mlir::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state)
::mlir::LogicalResult verifyInvariantsImpl()
::mlir::Attribute removeConstantAttr()
std::pair< unsigned, unsigned > getODSResultIndexAndLength(unsigned index)
void setTypeAttr(::mlir::TypeAttr attr)
::mlir::ParseResult parseGlobalInitialValue(::mlir::OpAsmParser &parser, ::mlir::Attribute &initialValue, ::mlir::TypeAttr typeAttr)
::mlir::UnitAttr getConstantAttr()
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::StringRef getSymName()
std::pair< unsigned, unsigned > getODSOperandIndexAndLength(unsigned index)
::mlir::StringAttr getSymNameAttrName()
::mlir::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError)
::mlir::Attribute getInitialValueAttr()
::mlir::Operation::result_range getODSResults(unsigned index)
::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop)
void setSymName(::llvm::StringRef attrValue)
void writeProperties(::mlir::DialectBytecodeWriter &writer)
void print(::mlir::OpAsmPrinter &_odsPrinter)
::mlir::StringAttr getTypeAttrName()
void setConstant(bool attrValue)
void setConstantAttr(::mlir::UnitAttr attr)
::mlir::TypeAttr getTypeAttr()
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()
::mlir::LogicalResult verify()
::mlir::LogicalResult verifyInvariants()
static llvm::hash_code computePropertiesHash(const Properties &prop)
::mlir::StringAttr getConstantAttrName()
::mlir::StringAttr getSymNameAttr()
static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value)
::mlir::Operation::operand_range getODSOperands(unsigned index)
::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result)
void setSymNameAttr(::mlir::StringAttr attr)
::mlir::LogicalResult verify(::mlir::Location loc)
GlobalReadOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs=nullptr, const Properties &properties={}, ::mlir::RegionRange regions={})
GlobalReadOpAdaptor(GlobalReadOp op)
::mlir::ValueRange getOperands()
::mlir::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError)
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::SymbolRefAttr getNameRefAttr()
std::pair< unsigned, unsigned > getODSOperandIndexAndLength(unsigned index)
::mlir::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError)
void print(::mlir::OpAsmPrinter &_odsPrinter)
::mlir::Operation::operand_range getODSOperands(unsigned index)
::mlir::Operation::result_range getODSResults(unsigned index)
static llvm::hash_code computePropertiesHash(const Properties &prop)
::mlir::LogicalResult verifyInvariantsImpl()
::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result)
::mlir::LogicalResult verifyInvariants()
void setNameRefAttr(::mlir::SymbolRefAttr attr)
static std::optional< mlir::Attribute > getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name)
static void setInherentAttr(Properties &prop, llvm::StringRef name, mlir::Attribute value)
std::pair< unsigned, unsigned > getODSResultIndexAndLength(unsigned index)
::mlir::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state)
::mlir::SymbolRefAttr getNameRef()
static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs)
GlobalWriteOpAdaptor(GlobalWriteOp op)
GlobalWriteOpGenericAdaptor(RangeT values, ::mlir::DictionaryAttr attrs=nullptr, const Properties &properties={}, ::mlir::RegionRange regions={})
::mlir::LogicalResult verify(::mlir::Location loc)
::mlir::ValueRange getOperands()
static llvm::hash_code computePropertiesHash(const Properties &prop)
::mlir::LogicalResult verifyInvariantsImpl()
::mlir::StringAttr getNameRefAttrName()
::mlir::Operation::operand_range getODSOperands(unsigned index)
::mlir::ParseResult parse(::mlir::OpAsmParser &parser, ::mlir::OperationState &result)
::mlir::SymbolRefAttr getNameRefAttr()
static void populateInherentAttrs(::mlir::MLIRContext *ctx, const Properties &prop, ::mlir::NamedAttrList &attrs)
void print(::mlir::OpAsmPrinter &_odsPrinter)
::mlir::LogicalResult readProperties(::mlir::DialectBytecodeReader &reader, ::mlir::OperationState &state)
std::pair< unsigned, unsigned > getODSOperandIndexAndLength(unsigned index)
FoldAdaptor::Properties Properties
void setNameRefAttr(::mlir::SymbolRefAttr attr)
::mlir::OpOperand & getValMutable()
::mlir::Attribute getPropertiesAsAttr(::mlir::MLIRContext *ctx, const Properties &prop)
::mlir::LogicalResult setPropertiesFromAttr(Properties &prop, ::mlir::Attribute attr, ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError)
::mlir::LogicalResult verifyInvariants()
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)
std::pair< unsigned, unsigned > getODSResultIndexAndLength(unsigned index)
void writeProperties(::mlir::DialectBytecodeWriter &writer)
::mlir::Operation::result_range getODSResults(unsigned index)
static std::optional< mlir::Attribute > getInherentAttr(::mlir::MLIRContext *ctx, const Properties &prop, llvm::StringRef name)
::mlir::LogicalResult verifyInherentAttrs(::mlir::OperationName opName, ::mlir::NamedAttrList &attrs, llvm::function_ref<::mlir::InFlightDiagnostic()> emitError)
::mlir::SymbolRefAttr getNameRef()
std::pair< unsigned, unsigned > getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize)
::mlir::DictionaryAttr getAttributes()
::mlir::DictionaryAttr odsAttrs
::mlir::Attribute getInitialValueAttr()
::mlir::StringAttr getSymNameAttr()
::mlir::RegionRange odsRegions
::llvm::StringRef getSymName()
::std::optional<::mlir::OperationName > odsOpName
::mlir::UnitAttr getConstantAttr()
const Properties & getProperties()
::mlir::Attribute getInitialValue()
GlobalDefOpGenericAdaptorBase(::mlir::DictionaryAttr attrs=nullptr, const Properties &properties={}, ::mlir::RegionRange regions={})
::mlir::TypeAttr getTypeAttr()
const Properties & getProperties()
::mlir::SymbolRefAttr getNameRef()
::mlir::RegionRange odsRegions
::mlir::DictionaryAttr odsAttrs
GlobalReadOpGenericAdaptorBase(::mlir::DictionaryAttr attrs=nullptr, const Properties &properties={}, ::mlir::RegionRange regions={})
::std::optional<::mlir::OperationName > odsOpName
::mlir::SymbolRefAttr getNameRefAttr()
::mlir::DictionaryAttr getAttributes()
std::pair< unsigned, unsigned > getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize)
std::pair< unsigned, unsigned > getODSOperandIndexAndLength(unsigned index, unsigned odsOperandsSize)
::mlir::DictionaryAttr getAttributes()
::mlir::SymbolRefAttr getNameRefAttr()
::mlir::RegionRange odsRegions
const Properties & getProperties()
::mlir::SymbolRefAttr getNameRef()
::std::optional<::mlir::OperationName > odsOpName
GlobalWriteOpGenericAdaptorBase(::mlir::DictionaryAttr attrs=nullptr, const Properties &properties={}, ::mlir::RegionRange regions={})
::mlir::DictionaryAttr odsAttrs
bool isValidGlobalType(Type type)
initial_valueTy initial_value