LLZK 2.0.0
An open-source IR for Zero Knowledge (ZK) circuits
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::felt::FeltType::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) {
22 value = ::llzk::felt::FeltType::parse(parser);
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::felt::FeltType>([&](auto t) {
34t.print(printer);
35 return ::mlir::success();
36 })
37 .Default([](auto) { return ::mlir::failure(); });
38}
39
40namespace llzk {
41namespace felt {
42namespace detail {
43struct FeltTypeStorage : public ::mlir::TypeStorage {
44 using KeyTy = std::tuple<::mlir::StringAttr>;
45 FeltTypeStorage(::mlir::StringAttr fieldName) : fieldName(std::move(fieldName)) {}
46
47 KeyTy getAsKey() const {
48 return KeyTy(fieldName);
49 }
50
51 bool operator==(const KeyTy &tblgenKey) const {
52 return (fieldName == std::get<0>(tblgenKey));
53 }
54
55 static ::llvm::hash_code hashKey(const KeyTy &tblgenKey) {
56 return ::llvm::hash_combine(std::get<0>(tblgenKey));
57 }
58
59 static FeltTypeStorage *construct(::mlir::TypeStorageAllocator &allocator, KeyTy &&tblgenKey) {
60 auto fieldName = std::move(std::get<0>(tblgenKey));
61 return new (allocator.allocate<FeltTypeStorage>()) FeltTypeStorage(std::move(fieldName));
62 }
63
64 ::mlir::StringAttr fieldName;
65};
66} // namespace detail
67FeltType FeltType::get(::mlir::MLIRContext *context, ::mlir::StringAttr fieldName) {
68 return Base::get(context, std::move(fieldName));
69}
70
71FeltType FeltType::getChecked(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, ::mlir::MLIRContext *context, ::mlir::StringAttr fieldName) {
72 return Base::getChecked(emitError, context, fieldName);
73}
74
75FeltType FeltType::get(::mlir::MLIRContext *context) {
76 return Base::get(context, ::mlir::StringAttr());
77}
78
79FeltType FeltType::getChecked(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, ::mlir::MLIRContext *context) {
80 return Base::getChecked(emitError, context, ::mlir::StringAttr());
81}
82
83FeltType FeltType::get(::mlir::MLIRContext *context, ::llvm::StringRef fieldName) {
84 return Base::get(context, ::mlir::StringAttr::get(context, fieldName));
85}
86
87FeltType FeltType::getChecked(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, ::mlir::MLIRContext *context, ::llvm::StringRef fieldName) {
88 return Base::getChecked(emitError, context, ::mlir::StringAttr::get(context, fieldName));
89}
90
91::llvm::LogicalResult FeltType::verifyInvariants(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, ::mlir::StringAttr fieldName) {
92 if (::mlir::failed(verify(emitError, fieldName)))
93 return ::mlir::failure();
94 return ::mlir::success();
95}
96
97::mlir::Type FeltType::parse(::mlir::AsmParser &odsParser) {
98 ::mlir::Builder odsBuilder(odsParser.getContext());
99 ::llvm::SMLoc odsLoc = odsParser.getCurrentLocation();
100 (void) odsLoc;
101 ::mlir::FailureOr<::mlir::StringAttr> _result_fieldName;
102 // Parse literal '<'
103 if (odsParser.parseOptionalLess()) {
104 } else {
105
106 // Parse variable 'fieldName'
107 _result_fieldName = ::mlir::FieldParser<::mlir::StringAttr>::parse(odsParser);
108 if (::mlir::failed(_result_fieldName)) {
109 odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse LLZK_FeltType parameter 'fieldName' which is to be a `::mlir::StringAttr`");
110 return {};
111 }
112 // Parse literal '>'
113 if (odsParser.parseGreater()) return {};
114 }
115 return odsParser.getChecked<FeltType>(odsLoc, odsParser.getContext(),
116 ::mlir::StringAttr((_result_fieldName.value_or(::mlir::StringAttr()))));
117}
118
119void FeltType::print(::mlir::AsmPrinter &odsPrinter) const {
120 ::mlir::Builder odsBuilder(getContext());
121 if (!(getFieldName() == ::mlir::StringAttr())) {
122 odsPrinter << "<";
123 if (!(getFieldName() == ::mlir::StringAttr())) {
124 odsPrinter.printStrippedAttrOrType(getFieldName());
125 }
126 odsPrinter << ">";
127 } else {
128 }
129}
130
131::mlir::StringAttr FeltType::getFieldName() const {
132 return getImpl()->fieldName;
133}
134
135} // namespace felt
136} // namespace llzk
137MLIR_DEFINE_EXPLICIT_TYPE_ID(::llzk::felt::FeltType)
138namespace llzk {
139namespace felt {
140
142::mlir::Type FeltDialect::parseType(::mlir::DialectAsmParser &parser) const {
143 ::llvm::SMLoc typeLoc = parser.getCurrentLocation();
144 ::llvm::StringRef mnemonic;
145 ::mlir::Type genType;
146 auto parseResult = generatedTypeParser(parser, &mnemonic, genType);
147 if (parseResult.has_value())
148 return genType;
149
150 parser.emitError(typeLoc) << "unknown type `"
151 << mnemonic << "` in dialect `" << getNamespace() << "`";
152 return {};
153}
154
155void FeltDialect::printType(::mlir::Type type,
156 ::mlir::DialectAsmPrinter &printer) const {
157 if (::mlir::succeeded(generatedTypePrinter(type, printer)))
158 return;
159
160}
161} // namespace felt
162} // namespace llzk
163
164#endif // GET_TYPEDEF_CLASSES
165
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.
static constexpr ::llvm::StringLiteral getMnemonic()
Definition Types.h.inc:43
::llvm::LogicalResult verify(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, ::mlir::StringAttr fieldName)
Definition Dialect.cpp:171
static FeltType getChecked(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, ::mlir::MLIRContext *context, ::mlir::StringAttr fieldName)
Definition Types.cpp.inc:71
::llvm::LogicalResult verifyInvariants(::llvm::function_ref<::mlir::InFlightDiagnostic()> emitError, ::mlir::StringAttr fieldName)
Definition Types.cpp.inc:91
::mlir::StringAttr getFieldName() const
::mlir::Type parse(::mlir::AsmParser &odsParser)
Definition Types.cpp.inc:97
void print(::mlir::AsmPrinter &odsPrinter) const
static FeltType get(::mlir::MLIRContext *context, ::mlir::StringAttr fieldName)
Definition Types.cpp.inc:67
FeltTypeStorage(::mlir::StringAttr fieldName)
Definition Types.cpp.inc:45
::llvm::hash_code hashKey(const KeyTy &tblgenKey)
Definition Types.cpp.inc:55
std::tuple<::mlir::StringAttr > KeyTy
Definition Types.cpp.inc:44
static FeltTypeStorage * construct(::mlir::TypeStorageAllocator &allocator, KeyTy &&tblgenKey)
Definition Types.cpp.inc:59
bool operator==(const KeyTy &tblgenKey) const
Definition Types.cpp.inc:51