LLZK 3.0.0
An open-source IR for Zero Knowledge (ZK) circuits
Loading...
Searching...
No Matches
Attrs.cpp.inc
Go to the documentation of this file.
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::llzk::pod::RecordAttr
13
14#endif // GET_ATTRDEF_LIST
15
16#ifdef GET_ATTRDEF_CLASSES
17#undef GET_ATTRDEF_CLASSES
18
19static ::mlir::OptionalParseResult generatedAttributeParser(::mlir::AsmParser &parser, ::llvm::StringRef *mnemonic, ::mlir::Type type, ::mlir::Attribute &value) {
20 return ::mlir::AsmParser::KeywordSwitch<::mlir::OptionalParseResult>(parser)
21 .Case(::llzk::pod::RecordAttr::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) {
22 value = ::llzk::pod::RecordAttr::parse(parser, type);
23 return ::mlir::success(!!value);
24 })
25 .Default([&](llvm::StringRef keyword, llvm::SMLoc) {
26 *mnemonic = keyword;
27 return std::nullopt;
28 });
29}
30
31static ::llvm::LogicalResult generatedAttributePrinter(::mlir::Attribute def, ::mlir::AsmPrinter &printer) {
32 return ::llvm::TypeSwitch<::mlir::Attribute, ::llvm::LogicalResult>(def) .Case<::llzk::pod::RecordAttr>([&](auto t) {
33 printer << ::llzk::pod::RecordAttr::getMnemonic();
34t.print(printer);
35 return ::mlir::success();
36 })
37 .Default([](auto) { return ::mlir::failure(); });
38}
39
40namespace llzk::pod {
41
42namespace detail {
43
44struct RecordAttrStorage : public ::mlir::AttributeStorage {
45 using KeyTy = std::tuple<::mlir::StringAttr, ::mlir::Type>;
46 RecordAttrStorage(::mlir::StringAttr name, ::mlir::Type type) : name(std::move(name)), type(std::move(type)) {}
47
48 KeyTy getAsKey() const {
49 return KeyTy(name, type);
50 }
51
52 bool operator==(const KeyTy &tblgenKey) const {
53 return (name == std::get<0>(tblgenKey)) && (type == std::get<1>(tblgenKey));
54 }
55
56 static ::llvm::hash_code hashKey(const KeyTy &tblgenKey) {
57 return ::llvm::hash_combine(std::get<0>(tblgenKey), std::get<1>(tblgenKey));
58 }
59
60 static RecordAttrStorage *construct(::mlir::AttributeStorageAllocator &allocator, KeyTy &&tblgenKey) {
61 auto name = std::move(std::get<0>(tblgenKey));
62 auto type = std::move(std::get<1>(tblgenKey));
63 return new (allocator.allocate<RecordAttrStorage>()) RecordAttrStorage(std::move(name), std::move(type));
64 }
65
66 ::mlir::StringAttr name;
67 ::mlir::Type type;
68};
69
70} // namespace detail
71RecordAttr RecordAttr::get(::mlir::MLIRContext *context, ::mlir::StringAttr name, ::mlir::Type type) {
72 return Base::get(context, std::move(name), std::move(type));
73}
74
75::mlir::Attribute RecordAttr::parse(::mlir::AsmParser &odsParser, ::mlir::Type odsType) {
76 ::mlir::Builder odsBuilder(odsParser.getContext());
77 ::llvm::SMLoc odsLoc = odsParser.getCurrentLocation();
78 (void) odsLoc;
79 ::mlir::FailureOr<::mlir::StringAttr> _result_name;
80 ::mlir::FailureOr<::mlir::Type> _result_type;
81 {
82 auto odsCustomLoc = odsParser.getCurrentLocation();
83 (void)odsCustomLoc;
84 auto odsCustomResult = parseRecord(odsParser,
85 ::mlir::detail::unwrapForCustomParse(_result_name),
86 ::mlir::detail::unwrapForCustomParse(_result_type));
87 if (::mlir::failed(odsCustomResult)) return {};
88 if (::mlir::failed(_result_name)) {
89 odsParser.emitError(odsCustomLoc, "custom parser failed to parse parameter 'name'");
90 return {};
91 }
92 if (::mlir::failed(_result_type)) {
93 odsParser.emitError(odsCustomLoc, "custom parser failed to parse parameter 'type'");
94 return {};
95 }
96 }
97 assert(::mlir::succeeded(_result_name));
98 assert(::mlir::succeeded(_result_type));
99 return RecordAttr::get(odsParser.getContext(),
100 ::mlir::StringAttr((*_result_name)),
101 ::mlir::Type((*_result_type)));
102}
103
104void RecordAttr::print(::mlir::AsmPrinter &odsPrinter) const {
105 ::mlir::Builder odsBuilder(getContext());
106 printRecord(odsPrinter,
107 getName(),
108 getType());
109}
110
111::mlir::StringAttr RecordAttr::getName() const {
112 return getImpl()->name;
113}
114
115::mlir::Type RecordAttr::getType() const {
116 return getImpl()->type;
117}
118
119
120} // namespace llzk::pod
121MLIR_DEFINE_EXPLICIT_TYPE_ID(::llzk::pod::RecordAttr)
122namespace llzk::pod {
123
124
126::mlir::Attribute PODDialect::parseAttribute(::mlir::DialectAsmParser &parser,
127 ::mlir::Type type) const {
128 ::llvm::SMLoc typeLoc = parser.getCurrentLocation();
129 ::llvm::StringRef attrTag;
130 {
131 ::mlir::Attribute attr;
132 auto parseResult = generatedAttributeParser(parser, &attrTag, type, attr);
133 if (parseResult.has_value())
134 return attr;
135 }
136
137 parser.emitError(typeLoc) << "unknown attribute `"
138 << attrTag << "` in dialect `" << getNamespace() << "`";
139 return {};
140}
142void PODDialect::printAttribute(::mlir::Attribute attr,
143 ::mlir::DialectAsmPrinter &printer) const {
144 if (::mlir::succeeded(generatedAttributePrinter(attr, printer)))
145 return;
146
147}
148
149} // namespace llzk::pod
150
151#endif // GET_ATTRDEF_CLASSES
152
::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.
Common interface for operations that reference a plain-old-data struct value.
void printRecord(AsmPrinter &printer, StringAttr name, Type type)
Definition Attrs.cpp:35
ParseResult parseRecord(AsmParser &parser, StringAttr &name, Type &type)
Definition Attrs.cpp:27