10#undef GET_ATTRDEF_LIST
12::llzk::felt::FeltConstAttr
16#ifdef GET_ATTRDEF_CLASSES
17#undef GET_ATTRDEF_CLASSES
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::felt::FeltConstAttr::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) {
22 value = ::llzk::felt::FeltConstAttr::parse(parser, type);
23 return ::mlir::success(!!value);
25 .Default([&](llvm::StringRef keyword, llvm::SMLoc) {
31static ::mlir::LogicalResult generatedAttributePrinter(::mlir::Attribute def, ::mlir::AsmPrinter &printer) {
32 return ::llvm::TypeSwitch<::mlir::Attribute, ::mlir::LogicalResult>(def) .Case<::llzk::felt::FeltConstAttr>([&](
auto t) {
33 printer << ::llzk::felt::FeltConstAttr::getMnemonic();
35 return ::mlir::success();
37 .Default([](
auto) { return ::mlir::failure(); });
43struct FeltConstAttrStorage :
public ::mlir::AttributeStorage {
44 using KeyTy = std::tuple<::llvm::APInt>;
45 FeltConstAttrStorage(::llvm::APInt value) : value(std::move(value)) {}
47 KeyTy getAsKey()
const {
51 bool operator==(
const KeyTy &tblgenKey)
const {
52 return (::llvm::APInt::isSameValue(value, std::get<0>(tblgenKey)));
55 static ::llvm::hash_code hashKey(
const KeyTy &tblgenKey) {
56 return ::llvm::hash_combine(std::get<0>(tblgenKey));
59 static FeltConstAttrStorage *construct(::mlir::AttributeStorageAllocator &allocator, KeyTy &&tblgenKey) {
60 auto value = std::move(std::get<0>(tblgenKey));
61 return new (allocator.allocate<FeltConstAttrStorage>()) FeltConstAttrStorage(std::move(value));
67FeltConstAttr FeltConstAttr::get(::mlir::MLIRContext *context, ::llvm::APInt value) {
68 return Base::get(context, std::move(value));
71::mlir::Attribute FeltConstAttr::parse(::mlir::AsmParser &odsParser, ::mlir::Type odsType) {
72 ::mlir::Builder odsBuilder(odsParser.getContext());
73 ::llvm::SMLoc odsLoc = odsParser.getCurrentLocation();
75 ::mlir::FailureOr<::llvm::APInt> _result_value;
78 _result_value = ::mlir::FieldParser<::llvm::APInt>::parse(odsParser);
79 if (::mlir::failed(_result_value)) {
80 odsParser.emitError(odsParser.getCurrentLocation(),
"failed to parse LLZK_FeltConstAttr parameter 'value' which is to be a `::llvm::APInt`");
83 assert(::mlir::succeeded(_result_value));
84 return FeltConstAttr::get(odsParser.getContext(),
85 ::llvm::APInt((*_result_value)));
88void FeltConstAttr::print(::mlir::AsmPrinter &odsPrinter)
const {
89 ::mlir::Builder odsBuilder(getContext());
91 odsPrinter.printStrippedAttrOrType(getValue());
94::llvm::APInt FeltConstAttr::getValue()
const {
95 return getImpl()->value;
100MLIR_DEFINE_EXPLICIT_TYPE_ID(::llzk::felt::FeltConstAttr)
106 ::mlir::Type type)
const {
107 ::llvm::SMLoc typeLoc = parser.getCurrentLocation();
108 ::llvm::StringRef attrTag;
110 ::mlir::Attribute attr;
111 auto parseResult = generatedAttributeParser(parser, &attrTag, type, attr);
112 if (parseResult.has_value())
116 parser.emitError(typeLoc) <<
"unknown attribute `"
117 << attrTag <<
"` in dialect `" << getNamespace() <<
"`";
122 ::mlir::DialectAsmPrinter &printer)
const {
123 if (::mlir::succeeded(generatedAttributePrinter(attr, printer)))
::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.