1/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\
2|* *|
3|* AttrDef Definitions *|
4|* *|
5|* Automatically generated file, do not edit! *|
6|* *|
7\*===----------------------------------------------------------------------===*/
8
9#ifdef GET_ATTRDEF_LIST
10#undef GET_ATTRDEF_LIST
11
12::mlir::transform::ParamOperandAttr
13
14#endif // GET_ATTRDEF_LIST
15
16#ifdef GET_ATTRDEF_CLASSES
17#undef GET_ATTRDEF_CLASSES
18
19#include "llvm/ADT/TypeSwitch.h"
20#include "mlir/IR/Builders.h"
21#include "mlir/IR/DialectImplementation.h"
22#include "mlir/IR/OpImplementation.h"
23
24static ::mlir::OptionalParseResult generatedAttributeParser(::mlir::AsmParser &parser, ::llvm::StringRef *mnemonic, ::mlir::Type type, ::mlir::Attribute &value) {
25 return ::mlir::AsmParser::KeywordSwitch<::mlir::OptionalParseResult>(parser, mnemonic)
26 .Case(str: ::mlir::transform::ParamOperandAttr::getMnemonic(), fn: [&](llvm::StringRef, llvm::SMLoc) {
27 value = ::mlir::transform::ParamOperandAttr::parse(odsParser&: parser, odsType: type);
28 return ::mlir::success(IsSuccess: !!value);
29 })
30 .Default(fn: [&](llvm::StringRef keyword, llvm::SMLoc) {
31 *mnemonic = keyword;
32 return std::nullopt;
33 });
34}
35
36static ::llvm::LogicalResult generatedAttributePrinter(::mlir::Attribute def, ::mlir::AsmPrinter &printer) {
37 return ::llvm::TypeSwitch<::mlir::Attribute, ::llvm::LogicalResult>(def) .Case<::mlir::transform::ParamOperandAttr>(caseFn: [&](auto t) {
38 printer << ::mlir::transform::ParamOperandAttr::getMnemonic();
39t.print(printer);
40 return ::mlir::success();
41 })
42 .Default(defaultFn: [](auto) { return ::mlir::failure(); });
43}
44
45namespace mlir::transform {
46
47namespace detail {
48
49struct ParamOperandAttrStorage : public ::mlir::AttributeStorage {
50 using KeyTy = std::tuple<IntegerAttr>;
51 ParamOperandAttrStorage(IntegerAttr index) : index(std::move(index)) {}
52
53 KeyTy getAsKey() const {
54 return KeyTy(index);
55 }
56
57 bool operator==(const KeyTy &tblgenKey) const {
58 return (index == std::get<0>(t: tblgenKey));
59 }
60
61 static ::llvm::hash_code hashKey(const KeyTy &tblgenKey) {
62 return ::llvm::hash_combine(args: std::get<0>(t: tblgenKey));
63 }
64
65 static ParamOperandAttrStorage *construct(::mlir::AttributeStorageAllocator &allocator, KeyTy &&tblgenKey) {
66 auto index = std::move(std::get<0>(t&: tblgenKey));
67 return new (allocator.allocate<ParamOperandAttrStorage>()) ParamOperandAttrStorage(std::move(index));
68 }
69
70 IntegerAttr index;
71};
72
73} // namespace detail
74ParamOperandAttr ParamOperandAttr::get(::mlir::MLIRContext *context, IntegerAttr index) {
75 return Base::get(ctx: context, args: std::move(index));
76}
77
78::mlir::Attribute ParamOperandAttr::parse(::mlir::AsmParser &odsParser, ::mlir::Type odsType) {
79 ::mlir::Builder odsBuilder(odsParser.getContext());
80 ::llvm::SMLoc odsLoc = odsParser.getCurrentLocation();
81 (void) odsLoc;
82 ::mlir::FailureOr<IntegerAttr> _result_index;
83 // Parse literal '<'
84 if (odsParser.parseLess()) return {};
85 // Parse literal 'index'
86 if (odsParser.parseKeyword(keyword: "index")) return {};
87 // Parse literal '='
88 if (odsParser.parseEqual()) return {};
89
90 // Parse variable 'index'
91 _result_index = ::mlir::FieldParser<IntegerAttr>::parse(parser&: odsParser);
92 if (::mlir::failed(Result: _result_index)) {
93 odsParser.emitError(loc: odsParser.getCurrentLocation(), message: "failed to parse ParamOperandAttr parameter 'index' which is to be a `IntegerAttr`");
94 return {};
95 }
96 // Parse literal '>'
97 if (odsParser.parseGreater()) return {};
98 assert(::mlir::succeeded(_result_index));
99 return ParamOperandAttr::get(context: odsParser.getContext(),
100 index: IntegerAttr((*_result_index)));
101}
102
103void ParamOperandAttr::print(::mlir::AsmPrinter &odsPrinter) const {
104 ::mlir::Builder odsBuilder(getContext());
105 odsPrinter << "<";
106 odsPrinter << "index";
107 odsPrinter << ' ' << "=";
108 odsPrinter << ' ';
109 odsPrinter.printStrippedAttrOrType(attrOrType: getIndex());
110 odsPrinter << ">";
111}
112
113IntegerAttr ParamOperandAttr::getIndex() const {
114 return getImpl()->index;
115}
116
117
118} // namespace mlir::transform
119MLIR_DEFINE_EXPLICIT_TYPE_ID(::mlir::transform::ParamOperandAttr)
120
121#endif // GET_ATTRDEF_CLASSES
122
123