LLZK 0.1.0
Veridise's ZK Language IR
Loading...
Searching...
No Matches
Types.cpp.inc
Go to the documentation of this file.
1/*===- TableGen'erated file -------------------------------------*- C++ -*-===*\
2|* *|
3|* TypeDef Definitions *|
4|* *|
5|* Automatically generated file, do not edit! *|
6|* *|
7\*===----------------------------------------------------------------------===*/
8
9#ifdef GET_TYPEDEF_LIST
10#undef GET_TYPEDEF_LIST
11
13
14#endif // GET_TYPEDEF_LIST
15
16#ifdef GET_TYPEDEF_CLASSES
17#undef GET_TYPEDEF_CLASSES
18
19static ::mlir::OptionalParseResult generatedTypeParser(::mlir::AsmParser &parser, ::llvm::StringRef *mnemonic, ::mlir::Type &value) {
20 return ::mlir::AsmParser::KeywordSwitch<::mlir::OptionalParseResult>(parser)
21 .Case(::llzk::component::StructType::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) {
23 return ::mlir::success(!!value);
24 })
25 .Default([&](llvm::StringRef keyword, llvm::SMLoc) {
26 *mnemonic = keyword;
27 return std::nullopt;
28 });
29}
30
31static ::mlir::LogicalResult generatedTypePrinter(::mlir::Type def, ::mlir::AsmPrinter &printer) {
32 return ::llvm::TypeSwitch<::mlir::Type, ::mlir::LogicalResult>(def) .Case<::llzk::component::StructType>([&](auto t) {
34t.print(printer);
35 return ::mlir::success();
36 })
37 .Default([](auto) { return ::mlir::failure(); });
38}
39
40namespace llzk {
41namespace component {
42namespace detail {
43struct StructTypeStorage : public ::mlir::TypeStorage {
44 using KeyTy = std::tuple<::mlir::SymbolRefAttr, ::mlir::ArrayAttr>;
45 StructTypeStorage(::mlir::SymbolRefAttr nameRef, ::mlir::ArrayAttr params) : nameRef(std::move(nameRef)), params(std::move(params)) {}
46
47 KeyTy getAsKey() const {
48 return KeyTy(nameRef, params);
49 }
50
51 bool operator==(const KeyTy &tblgenKey) const {
52 return (nameRef == std::get<0>(tblgenKey)) && (params == std::get<1>(tblgenKey));
53 }
54
55 static ::llvm::hash_code hashKey(const KeyTy &tblgenKey) {
56 return ::llvm::hash_combine(std::get<0>(tblgenKey), std::get<1>(tblgenKey));
57 }
58
59 static StructTypeStorage *construct(::mlir::TypeStorageAllocator &allocator, KeyTy &&tblgenKey) {
60 auto nameRef = std::move(std::get<0>(tblgenKey));
61 auto params = std::move(std::get<1>(tblgenKey));
62 return new (allocator.allocate<StructTypeStorage>()) StructTypeStorage(std::move(nameRef), std::move(params));
63 }
64
65 ::mlir::SymbolRefAttr nameRef;
66 ::mlir::ArrayAttr params;
67};
68} // namespace detail
69StructType StructType::get(::mlir::SymbolRefAttr structName) {
70 return Base::get(structName.getContext(), structName, ::mlir::ArrayAttr());
71}
72
73StructType StructType::getChecked(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, ::mlir::SymbolRefAttr structName) {
74 return Base::getChecked(emitError, structName.getContext(), structName, ::mlir::ArrayAttr());
75}
76
77StructType StructType::get(::mlir::SymbolRefAttr structName, ::mlir::ArrayAttr params) {
78 ::mlir::MLIRContext *ctx = structName.getContext();
79 if (params) {
80 params = ::mlir::ArrayAttr::get(ctx, forceIntAttrTypes(params.getValue()));
81 }
82 return Base::get(ctx, structName, params);
83}
84
85StructType StructType::getChecked(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, ::mlir::SymbolRefAttr structName, ::mlir::ArrayAttr params) {
86 ::mlir::MLIRContext *ctx = structName.getContext();
87 if (params) {
88 params = ::mlir::ArrayAttr::get(ctx, forceIntAttrTypes(params.getValue()));
89 }
90 return Base::getChecked(emitError, ctx, structName, params);
91}
92
93StructType StructType::get(::mlir::SymbolRefAttr structName, ::llvm::ArrayRef<::mlir::Attribute> paramsRef) {
94 ::mlir::MLIRContext *ctx = structName.getContext();
95 ::llvm::SmallVector<::mlir::Attribute> p = forceIntAttrTypes(paramsRef);
96 return Base::get(ctx, structName, ::mlir::ArrayAttr::get(ctx, p));
97}
98
99StructType StructType::getChecked(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, ::mlir::SymbolRefAttr structName, ::llvm::ArrayRef<::mlir::Attribute> paramsRef) {
100 ::mlir::MLIRContext *ctx = structName.getContext();
101 ::llvm::SmallVector<::mlir::Attribute> p = forceIntAttrTypes(paramsRef);
102 return Base::getChecked(emitError, ctx, structName, ::mlir::ArrayAttr::get(ctx, p));
103}
104
105::mlir::Type StructType::parse(::mlir::AsmParser &odsParser) {
106 ::mlir::Builder odsBuilder(odsParser.getContext());
107 ::llvm::SMLoc odsLoc = odsParser.getCurrentLocation();
108 (void) odsLoc;
109 ::mlir::FailureOr<::mlir::SymbolRefAttr> _result_nameRef;
110 ::mlir::FailureOr<::mlir::ArrayAttr> _result_params;
111 // Parse literal '<'
112 if (odsParser.parseLess()) return {};
113
114 // Parse variable 'nameRef'
115 _result_nameRef = ::mlir::FieldParser<::mlir::SymbolRefAttr>::parse(odsParser);
116 if (::mlir::failed(_result_nameRef)) {
117 odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse LLZK_StructType parameter 'nameRef' which is to be a `::mlir::SymbolRefAttr`");
118 return {};
119 }
120 // Parse literal '<'
121 if (odsParser.parseOptionalLess()) {
122 } else {
123 {
124 auto odsCustomLoc = odsParser.getCurrentLocation();
125 (void)odsCustomLoc;
126 auto odsCustomResult = parseStructParams(odsParser,
127 ::mlir::detail::unwrapForCustomParse(_result_params));
128 if (::mlir::failed(odsCustomResult)) return {};
129 }
130 // Parse literal '>'
131 if (odsParser.parseGreater()) return {};
132 }
133 // Parse literal '>'
134 if (odsParser.parseGreater()) return {};
135 assert(::mlir::succeeded(_result_nameRef));
136 return odsParser.getChecked<StructType>(odsLoc, odsParser.getContext(),
137 ::mlir::SymbolRefAttr((*_result_nameRef)),
138 ::mlir::ArrayAttr((_result_params.value_or(::mlir::ArrayAttr()))));
139}
140
141void StructType::print(::mlir::AsmPrinter &odsPrinter) const {
142 ::mlir::Builder odsBuilder(getContext());
143 odsPrinter << "<";
144 odsPrinter.printStrippedAttrOrType(getNameRef());
145 if (!(getParams() == ::mlir::ArrayAttr())) {
146 odsPrinter << "<";
147 printStructParams(odsPrinter,
148 getParams());
149 odsPrinter << ">";
150 } else {
151 }
152 odsPrinter << ">";
153}
154
155::mlir::SymbolRefAttr StructType::getNameRef() const {
156 return getImpl()->nameRef;
157}
158
159::mlir::ArrayAttr StructType::getParams() const {
160 return getImpl()->params;
161}
162
163} // namespace component
164} // namespace llzk
165MLIR_DEFINE_EXPLICIT_TYPE_ID(::llzk::component::StructType)
166namespace llzk {
167namespace component {
168
170::mlir::Type StructDialect::parseType(::mlir::DialectAsmParser &parser) const {
171 ::llvm::SMLoc typeLoc = parser.getCurrentLocation();
172 ::llvm::StringRef mnemonic;
173 ::mlir::Type genType;
174 auto parseResult = generatedTypeParser(parser, &mnemonic, genType);
175 if (parseResult.has_value())
176 return genType;
177
178 parser.emitError(typeLoc) << "unknown type `"
179 << mnemonic << "` in dialect `" << getNamespace() << "`";
180 return {};
181}
182
183void StructDialect::printType(::mlir::Type type,
184 ::mlir::DialectAsmPrinter &printer) const {
185 if (::mlir::succeeded(generatedTypePrinter(type, printer)))
186 return;
187
188}
189} // namespace component
190} // namespace llzk
191
192#endif // GET_TYPEDEF_CLASSES
193
void printType(::mlir::Type type, ::mlir::DialectAsmPrinter &os) const override
Print a type registered to this dialect.
::mlir::Type parseType(::mlir::DialectAsmParser &parser) const override
Parse a type registered to this dialect.
::mlir::SymbolRefAttr getNameRef() const
static StructType getChecked(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, ::mlir::SymbolRefAttr structName)
Definition Types.cpp.inc:73
void print(::mlir::AsmPrinter &odsPrinter) const
static StructType get(::mlir::SymbolRefAttr structName)
Definition Types.cpp.inc:69
::mlir::Type parse(::mlir::AsmParser &odsParser)
static constexpr ::llvm::StringLiteral getMnemonic()
Definition Types.h.inc:47
::mlir::ArrayAttr getParams() const
void printStructParams(AsmPrinter &printer, ArrayAttr value)
Definition Types.cpp:28
ParseResult parseStructParams(AsmParser &parser, ArrayAttr &value)
Definition Types.cpp:18
SmallVector< Attribute > forceIntAttrTypes(ArrayRef< Attribute > attrList)
::llvm::hash_code hashKey(const KeyTy &tblgenKey)
Definition Types.cpp.inc:55
StructTypeStorage(::mlir::SymbolRefAttr nameRef, ::mlir::ArrayAttr params)
Definition Types.cpp.inc:45
static StructTypeStorage * construct(::mlir::TypeStorageAllocator &allocator, KeyTy &&tblgenKey)
Definition Types.cpp.inc:59
std::tuple<::mlir::SymbolRefAttr, ::mlir::ArrayAttr > KeyTy
Definition Types.cpp.inc:44
bool operator==(const KeyTy &tblgenKey) const
Definition Types.cpp.inc:51