10#undef GET_ATTRDEF_LIST
17#ifdef GET_ATTRDEF_CLASSES
18#undef GET_ATTRDEF_CLASSES
20static ::mlir::OptionalParseResult generatedAttributeParser(::mlir::AsmParser &parser, ::llvm::StringRef *mnemonic, ::mlir::Type type, ::mlir::Attribute &value) {
21 return ::mlir::AsmParser::KeywordSwitch<::mlir::OptionalParseResult>(parser)
22 .Case(::llzk::PublicAttr::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) {
23 value = ::llzk::PublicAttr::get(parser.getContext());
24 return ::mlir::success(!!value);
26 .Case(::llzk::LoopBoundsAttr::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) {
27 value = ::llzk::LoopBoundsAttr::parse(parser, type);
28 return ::mlir::success(!!value);
30 .Default([&](llvm::StringRef keyword, llvm::SMLoc) {
36static ::llvm::LogicalResult generatedAttributePrinter(::mlir::Attribute def, ::mlir::AsmPrinter &printer) {
37 return ::llvm::TypeSwitch<::mlir::Attribute, ::llvm::LogicalResult>(def) .Case<::llzk::PublicAttr>([&](
auto t) {
38 printer << ::llzk::PublicAttr::getMnemonic();
39 return ::mlir::success();
41 .Case<::llzk::LoopBoundsAttr>([&](
auto t) {
42 printer << ::llzk::LoopBoundsAttr::getMnemonic();
44 return ::mlir::success();
46 .Default([](
auto) { return ::mlir::failure(); });
51MLIR_DEFINE_EXPLICIT_TYPE_ID(::llzk::PublicAttr)
54struct LoopBoundsAttrStorage :
public ::mlir::AttributeStorage {
55 using KeyTy = std::tuple<::llzk::APIntValue, ::llzk::APIntValue, ::llzk::APIntValue>;
56 LoopBoundsAttrStorage(::llzk::APIntValue lower, ::llzk::APIntValue upper, ::llzk::APIntValue step) : lower(std::move(lower)), upper(std::move(upper)), step(std::move(step)) {}
58 KeyTy getAsKey()
const {
59 return KeyTy(lower, upper, step);
62 bool operator==(
const KeyTy &tblgenKey)
const {
63 return (lower == std::get<0>(tblgenKey)) && (upper == std::get<1>(tblgenKey)) && (step == std::get<2>(tblgenKey));
66 static ::llvm::hash_code hashKey(
const KeyTy &tblgenKey) {
67 return ::llvm::hash_combine(std::get<0>(tblgenKey), std::get<1>(tblgenKey), std::get<2>(tblgenKey));
70 static LoopBoundsAttrStorage *construct(::mlir::AttributeStorageAllocator &allocator, KeyTy &&tblgenKey) {
71 auto lower = std::move(std::get<0>(tblgenKey));
72 auto upper = std::move(std::get<1>(tblgenKey));
73 auto step = std::move(std::get<2>(tblgenKey));
74 return new (allocator.allocate<LoopBoundsAttrStorage>()) LoopBoundsAttrStorage(std::move(lower), std::move(upper), std::move(step));
77 ::llzk::APIntValue lower;
78 ::llzk::APIntValue upper;
79 ::llzk::APIntValue step;
82LoopBoundsAttr LoopBoundsAttr::get(::mlir::MLIRContext *context, ::llzk::APIntValue lower, ::llzk::APIntValue upper, ::llzk::APIntValue step) {
83 return Base::get(context, std::move(lower), std::move(upper), std::move(step));
86LoopBoundsAttr LoopBoundsAttr::get(::mlir::MLIRContext *context, ::llvm::APInt lower, ::llvm::APInt upper, ::llvm::APInt step) {
87 return Base::get(context, ::llzk::APIntValue(std::move(lower)),
88 ::llzk::APIntValue(std::move(upper)),
89 ::llzk::APIntValue(std::move(step)));
92::mlir::Attribute LoopBoundsAttr::parse(::mlir::AsmParser &odsParser, ::mlir::Type odsType) {
93 ::mlir::Builder odsBuilder(odsParser.getContext());
94 ::llvm::SMLoc odsLoc = odsParser.getCurrentLocation();
96 ::mlir::FailureOr<::llzk::APIntValue> _result_lower;
97 ::mlir::FailureOr<::llzk::APIntValue> _result_upper;
98 ::mlir::FailureOr<::llzk::APIntValue> _result_step;
100 if (odsParser.parseLess())
return {};
104 if (::mlir::failed(_result_lower)) {
105 odsParser.emitError(odsParser.getCurrentLocation(),
"failed to parse LLZK_LoopBoundsAttr parameter 'lower' which is to be a `::llzk::APIntValue`");
109 if (odsParser.parseKeyword(
"to"))
return {};
113 if (::mlir::failed(_result_upper)) {
114 odsParser.emitError(odsParser.getCurrentLocation(),
"failed to parse LLZK_LoopBoundsAttr parameter 'upper' which is to be a `::llzk::APIntValue`");
118 if (odsParser.parseKeyword(
"step"))
return {};
122 if (::mlir::failed(_result_step)) {
123 odsParser.emitError(odsParser.getCurrentLocation(),
"failed to parse LLZK_LoopBoundsAttr parameter 'step' which is to be a `::llzk::APIntValue`");
127 if (odsParser.parseGreater())
return {};
128 assert(::mlir::succeeded(_result_lower));
129 assert(::mlir::succeeded(_result_upper));
130 assert(::mlir::succeeded(_result_step));
131 return LoopBoundsAttr::get(odsParser.getContext(),
132 ::llzk::APIntValue((*_result_lower)),
133 ::llzk::APIntValue((*_result_upper)),
134 ::llzk::APIntValue((*_result_step)));
137void LoopBoundsAttr::print(::mlir::AsmPrinter &odsPrinter)
const {
138 ::mlir::Builder odsBuilder(getContext());
140 odsPrinter << getLower();
141 odsPrinter <<
' ' <<
"to";
143 odsPrinter << getUpper();
144 odsPrinter <<
' ' <<
"step";
146 odsPrinter << getStep();
150const ::llvm::APInt &LoopBoundsAttr::getLower()
const {
151 return getImpl()->lower;
154const ::llvm::APInt &LoopBoundsAttr::getUpper()
const {
155 return getImpl()->upper;
158const ::llvm::APInt &LoopBoundsAttr::getStep()
const {
159 return getImpl()->step;
163MLIR_DEFINE_EXPLICIT_TYPE_ID(::llzk::LoopBoundsAttr)
168 ::mlir::Type type)
const {
169 ::llvm::SMLoc typeLoc = parser.getCurrentLocation();
170 ::llvm::StringRef attrTag;
172 ::mlir::Attribute attr;
173 auto parseResult = generatedAttributeParser(parser, &attrTag, type, attr);
174 if (parseResult.has_value())
178 parser.emitError(typeLoc) <<
"unknown attribute `"
179 << attrTag <<
"` in dialect `" << getNamespace() <<
"`";
184 ::mlir::DialectAsmPrinter &printer)
const {
185 if (::mlir::succeeded(generatedAttributePrinter(attr, printer)))
::mlir::Attribute parseAttribute(::mlir::DialectAsmParser &parser, ::mlir::Type type) const override
Parse an attribute registered to this dialect.
void printAttribute(::mlir::Attribute attr, ::mlir::DialectAsmPrinter &os) const override
Print an attribute registered to this dialect.
mlir::FailureOr< APIntValue > parseAPIntValue(mlir::AsmParser &parser)