LLZK 0.1.0
Veridise's ZK Language IR
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::boolean::FeltCmpPredicateAttr
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::boolean::FeltCmpPredicateAttr::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) {
22 value = ::llzk::boolean::FeltCmpPredicateAttr::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 ::mlir::LogicalResult generatedAttributePrinter(::mlir::Attribute def, ::mlir::AsmPrinter &printer) {
32 return ::llvm::TypeSwitch<::mlir::Attribute, ::mlir::LogicalResult>(def) .Case<::llzk::boolean::FeltCmpPredicateAttr>([&](auto t) {
33 printer << ::llzk::boolean::FeltCmpPredicateAttr::getMnemonic();
34t.print(printer);
35 return ::mlir::success();
36 })
37 .Default([](auto) { return ::mlir::failure(); });
38}
39
40namespace llzk {
41namespace boolean {
42namespace detail {
43struct FeltCmpPredicateAttrStorage : public ::mlir::AttributeStorage {
44 using KeyTy = std::tuple<::llzk::boolean::FeltCmpPredicate>;
45 FeltCmpPredicateAttrStorage(::llzk::boolean::FeltCmpPredicate value) : value(std::move(value)) {}
46
47 KeyTy getAsKey() const {
48 return KeyTy(value);
49 }
50
51 bool operator==(const KeyTy &tblgenKey) const {
52 return (value == 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 FeltCmpPredicateAttrStorage *construct(::mlir::AttributeStorageAllocator &allocator, KeyTy &&tblgenKey) {
60 auto value = std::move(std::get<0>(tblgenKey));
61 return new (allocator.allocate<FeltCmpPredicateAttrStorage>()) FeltCmpPredicateAttrStorage(std::move(value));
62 }
63
65};
66} // namespace detail
67FeltCmpPredicateAttr FeltCmpPredicateAttr::get(::mlir::MLIRContext *context, ::llzk::boolean::FeltCmpPredicate value) {
68 return Base::get(context, std::move(value));
69}
70
71::mlir::Attribute FeltCmpPredicateAttr::parse(::mlir::AsmParser &odsParser, ::mlir::Type odsType) {
72 ::mlir::Builder odsBuilder(odsParser.getContext());
73 ::llvm::SMLoc odsLoc = odsParser.getCurrentLocation();
74 (void) odsLoc;
75 ::mlir::FailureOr<::llzk::boolean::FeltCmpPredicate> _result_value;
76
77 // Parse variable 'value'
78 _result_value = [&]() -> ::mlir::FailureOr<::llzk::boolean::FeltCmpPredicate> {
79 auto loc = odsParser.getCurrentLocation();
80 ::llvm::StringRef enumKeyword;
81 if (::mlir::failed(odsParser.parseKeyword(&enumKeyword)))
82 return ::mlir::failure();
83 auto maybeEnum = ::llzk::boolean::symbolizeFeltCmpPredicate(enumKeyword);
84 if (maybeEnum)
85 return *maybeEnum;
86 return {(::mlir::LogicalResult)(odsParser.emitError(loc) << "expected " << "::llzk::boolean::FeltCmpPredicate" << " to be one of: " << "eq" << ", " << "ne" << ", " << "lt" << ", " << "le" << ", " << "gt" << ", " << "ge")};
87 }();
88 if (::mlir::failed(_result_value)) {
89 odsParser.emitError(odsParser.getCurrentLocation(), "failed to parse LLZK_CmpPredicateAttr parameter 'value' which is to be a `::llzk::boolean::FeltCmpPredicate`");
90 return {};
91 }
92 assert(::mlir::succeeded(_result_value));
93 return FeltCmpPredicateAttr::get(odsParser.getContext(),
94 ::llzk::boolean::FeltCmpPredicate((*_result_value)));
95}
96
97void FeltCmpPredicateAttr::print(::mlir::AsmPrinter &odsPrinter) const {
98 ::mlir::Builder odsBuilder(getContext());
99 odsPrinter << ' ';
100 odsPrinter << stringifyFeltCmpPredicate(getValue());
101}
102
103::llzk::boolean::FeltCmpPredicate FeltCmpPredicateAttr::getValue() const {
104 return getImpl()->value;
105}
106
107} // namespace boolean
108} // namespace llzk
109MLIR_DEFINE_EXPLICIT_TYPE_ID(::llzk::boolean::FeltCmpPredicateAttr)
110namespace llzk {
111namespace boolean {
112
114::mlir::Attribute BoolDialect::parseAttribute(::mlir::DialectAsmParser &parser,
115 ::mlir::Type type) const {
116 ::llvm::SMLoc typeLoc = parser.getCurrentLocation();
117 ::llvm::StringRef attrTag;
118 {
119 ::mlir::Attribute attr;
120 auto parseResult = generatedAttributeParser(parser, &attrTag, type, attr);
121 if (parseResult.has_value())
122 return attr;
123 }
124
125 parser.emitError(typeLoc) << "unknown attribute `"
126 << attrTag << "` in dialect `" << getNamespace() << "`";
127 return {};
128}
130void BoolDialect::printAttribute(::mlir::Attribute attr,
131 ::mlir::DialectAsmPrinter &printer) const {
132 if (::mlir::succeeded(generatedAttributePrinter(attr, printer)))
133 return;
134
135}
136} // namespace boolean
137} // namespace llzk
138
139#endif // GET_ATTRDEF_CLASSES
140
::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.
::llvm::StringRef stringifyFeltCmpPredicate(FeltCmpPredicate val)
Definition Enums.cpp.inc:12
::std::optional< FeltCmpPredicate > symbolizeFeltCmpPredicate(::llvm::StringRef str)
Definition Enums.cpp.inc:24