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