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 ::llvm::LogicalResult generatedTypePrinter(::mlir::Type def, ::mlir::AsmPrinter &printer) {
32 return ::llvm::TypeSwitch<::mlir::Type, ::llvm::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
69namespace {
77 const ::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError = nullptr;
78}
79StructType StructType::get(::mlir::SymbolRefAttr structName) {
80 return Base::get(structName.getContext(), structName, ::mlir::ArrayAttr());
81}
82
83StructType StructType::getChecked(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, ::mlir::SymbolRefAttr structName) {
84 return Base::getChecked(emitError, structName.getContext(), structName, ::mlir::ArrayAttr());
85}
86
87StructType StructType::get(::mlir::SymbolRefAttr structName, ::mlir::ArrayAttr params) {
88 ::mlir::MLIRContext *ctx = structName.getContext();
89 if (params) {
91 auto paramsRes = forceIntAttrTypes(params.getValue(), emitErrorFn);
92 if(::mlir::failed(paramsRes)) { return StructType(); }
93 params = ::mlir::ArrayAttr::get(ctx, *paramsRes);
94 }
95 return Base::get(ctx, structName, params);
96}
97
98StructType StructType::getChecked(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, ::mlir::SymbolRefAttr structName, ::mlir::ArrayAttr params) {
99 ::mlir::MLIRContext *ctx = structName.getContext();
100 if (params) {
101 OwningEmitErrorFn emitErrorFn = ::llzk::wrapNullableInFlightDiagnostic(emitError, ctx);
102 auto paramsRes = forceIntAttrTypes(params.getValue(), emitErrorFn);
103 if(::mlir::failed(paramsRes)) { return StructType(); }
104 params = ::mlir::ArrayAttr::get(ctx, *paramsRes);
105 }
106 return Base::getChecked(emitError, ctx, structName, params);
107}
108
109StructType StructType::get(::mlir::SymbolRefAttr structName, ::llvm::ArrayRef<::mlir::Attribute> paramsRef) {
110 ::mlir::MLIRContext *ctx = structName.getContext();
111 OwningEmitErrorFn emitErrorFn = ::llzk::wrapNullableInFlightDiagnostic(emitError, ctx);
112 auto paramsRes = forceIntAttrTypes(paramsRef, emitErrorFn);
113 if(::mlir::failed(paramsRes)) { return StructType(); }
114 return Base::get(ctx, structName, ::mlir::ArrayAttr::get(ctx, *paramsRes));
115}
116
117StructType StructType::getChecked(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, ::mlir::SymbolRefAttr structName, ::llvm::ArrayRef<::mlir::Attribute> paramsRef) {
118 ::mlir::MLIRContext *ctx = structName.getContext();
119 OwningEmitErrorFn emitErrorFn = ::llzk::wrapNullableInFlightDiagnostic(emitError, ctx);
120 auto paramsRes = forceIntAttrTypes(paramsRef, emitErrorFn);
121 if(::mlir::failed(paramsRes)) { return StructType(); }
122 return Base::getChecked(emitError, ctx, structName, ::mlir::ArrayAttr::get(ctx, *paramsRes));
123}
124
125::llvm::LogicalResult StructType::verifyInvariants(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, ::mlir::SymbolRefAttr nameRef, ::mlir::ArrayAttr params) {
126 if (::mlir::failed(verify(emitError, nameRef, params)))
127 return ::mlir::failure();
128 return ::mlir::success();
129}
130
131::mlir::Type StructType::parse(::mlir::AsmParser &odsParser) {
132 ::mlir::Builder odsBuilder(odsParser.getContext());
133 ::llvm::SMLoc odsLoc = odsParser.getCurrentLocation();
134 (void) odsLoc;
135 ::mlir::FailureOr<::mlir::SymbolRefAttr> _result_nameRef;
136 ::mlir::FailureOr<::mlir::ArrayAttr> _result_params;
137 // Parse literal '<'
138 if (odsParser.parseLess()) return {};
139
140 // Parse variable 'nameRef'
141 _result_nameRef = ::mlir::FieldParser<::mlir::SymbolRefAttr>::parse(odsParser);
142 if (::mlir::failed(_result_nameRef)) {
143 odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse LLZK_StructType parameter 'nameRef' which is to be a `::mlir::SymbolRefAttr`");
144 return {};
145 }
146 // Parse literal '<'
147 if (odsParser.parseOptionalLess()) {
148 } else {
149 {
150 auto odsCustomLoc = odsParser.getCurrentLocation();
151 (void)odsCustomLoc;
152 auto odsCustomResult = parseStructParams(odsParser,
153 ::mlir::detail::unwrapForCustomParse(_result_params));
154 if (::mlir::failed(odsCustomResult)) return {};
155 }
156 // Parse literal '>'
157 if (odsParser.parseGreater()) return {};
158 }
159 // Parse literal '>'
160 if (odsParser.parseGreater()) return {};
161 assert(::mlir::succeeded(_result_nameRef));
162 return odsParser.getChecked<StructType>(odsLoc, odsParser.getContext(),
163 ::mlir::SymbolRefAttr((*_result_nameRef)),
164 ::mlir::ArrayAttr((_result_params.value_or(::mlir::ArrayAttr()))));
165}
166
167void StructType::print(::mlir::AsmPrinter &odsPrinter) const {
168 ::mlir::Builder odsBuilder(getContext());
169 odsPrinter << "<";
170 odsPrinter.printStrippedAttrOrType(getNameRef());
171 if (!(getParams() == ::mlir::ArrayAttr())) {
172 odsPrinter << "<";
173 printStructParams(odsPrinter,
174 getParams());
175 odsPrinter << ">";
176 } else {
177 }
178 odsPrinter << ">";
179}
180
181::mlir::SymbolRefAttr StructType::getNameRef() const {
182 return getImpl()->nameRef;
183}
184
185::mlir::ArrayAttr StructType::getParams() const {
186 return getImpl()->params;
187}
188
189} // namespace component
190} // namespace llzk
191MLIR_DEFINE_EXPLICIT_TYPE_ID(::llzk::component::StructType)
192namespace llzk {
193namespace component {
194
196::mlir::Type StructDialect::parseType(::mlir::DialectAsmParser &parser) const {
197 ::llvm::SMLoc typeLoc = parser.getCurrentLocation();
198 ::llvm::StringRef mnemonic;
199 ::mlir::Type genType;
200 auto parseResult = generatedTypeParser(parser, &mnemonic, genType);
201 if (parseResult.has_value())
202 return genType;
203
204 parser.emitError(typeLoc) << "unknown type `"
205 << mnemonic << "` in dialect `" << getNamespace() << "`";
206 return {};
207}
208
209void StructDialect::printType(::mlir::Type type,
210 ::mlir::DialectAsmPrinter &printer) const {
211 if (::mlir::succeeded(generatedTypePrinter(type, printer)))
212 return;
213
214}
215} // namespace component
216} // namespace llzk
217
218#endif // GET_TYPEDEF_CLASSES
219
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:83
void print(::mlir::AsmPrinter &odsPrinter) const
static StructType get(::mlir::SymbolRefAttr structName)
Definition Types.cpp.inc:79
::mlir::Type parse(::mlir::AsmParser &odsParser)
::llvm::LogicalResult verify(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, ::mlir::SymbolRefAttr nameRef, ::mlir::ArrayAttr params)
Definition Types.cpp:40
static constexpr ::llvm::StringLiteral getMnemonic()
Definition Types.h.inc:49
::mlir::ArrayAttr getParams() const
::llvm::LogicalResult verifyInvariants(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, ::mlir::SymbolRefAttr nameRef, ::mlir::ArrayAttr params)
void printStructParams(AsmPrinter &printer, ArrayAttr value)
Definition Types.cpp:34
ParseResult parseStructParams(AsmParser &parser, ArrayAttr &value)
Definition Types.cpp:18
FailureOr< SmallVector< Attribute > > forceIntAttrTypes(ArrayRef< Attribute > attrList, EmitErrorFn emitError)
std::function< InFlightDiagnosticWrapper()> OwningEmitErrorFn
This type is required in cases like the functions below to take ownership of the lambda so it is not ...
OwningEmitErrorFn wrapNullableInFlightDiagnostic(llvm::function_ref< mlir::InFlightDiagnostic()> emitError, mlir::MLIRContext *ctx)
If the given emitError is non-null, return it.
::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