10#undef GET_ATTRDEF_LIST
12::llzk::pod::RecordAttr
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::pod::RecordAttr::getMnemonic(), [&](llvm::StringRef, llvm::SMLoc) {
22 value = ::llzk::pod::RecordAttr::parse(parser, type);
23 return ::mlir::success(!!value);
25 .Default([&](llvm::StringRef keyword, llvm::SMLoc) {
31static ::llvm::LogicalResult generatedAttributePrinter(::mlir::Attribute def, ::mlir::AsmPrinter &printer) {
32 return ::llvm::TypeSwitch<::mlir::Attribute, ::llvm::LogicalResult>(def) .Case<::llzk::pod::RecordAttr>([&](
auto t) {
33 printer << ::llzk::pod::RecordAttr::getMnemonic();
35 return ::mlir::success();
37 .Default([](
auto) { return ::mlir::failure(); });
43struct RecordAttrStorage :
public ::mlir::AttributeStorage {
44 using KeyTy = std::tuple<::mlir::StringAttr, ::mlir::Type>;
45 RecordAttrStorage(::mlir::StringAttr name, ::mlir::Type type) : name(std::move(name)), type(std::move(type)) {}
47 KeyTy getAsKey()
const {
48 return KeyTy(name, type);
51 bool operator==(
const KeyTy &tblgenKey)
const {
52 return (name == std::get<0>(tblgenKey)) && (type == std::get<1>(tblgenKey));
55 static ::llvm::hash_code hashKey(
const KeyTy &tblgenKey) {
56 return ::llvm::hash_combine(std::get<0>(tblgenKey), std::get<1>(tblgenKey));
59 static RecordAttrStorage *construct(::mlir::AttributeStorageAllocator &allocator, KeyTy &&tblgenKey) {
60 auto name = std::move(std::get<0>(tblgenKey));
61 auto type = std::move(std::get<1>(tblgenKey));
62 return new (allocator.allocate<RecordAttrStorage>()) RecordAttrStorage(std::move(name), std::move(type));
65 ::mlir::StringAttr name;
69RecordAttr RecordAttr::get(::mlir::MLIRContext *context, ::mlir::StringAttr name, ::mlir::Type type) {
70 return Base::get(context, std::move(name), std::move(type));
73::mlir::Attribute RecordAttr::parse(::mlir::AsmParser &odsParser, ::mlir::Type odsType) {
74 ::mlir::Builder odsBuilder(odsParser.getContext());
75 ::llvm::SMLoc odsLoc = odsParser.getCurrentLocation();
77 ::mlir::FailureOr<::mlir::StringAttr> _result_name;
78 ::mlir::FailureOr<::mlir::Type> _result_type;
80 auto odsCustomLoc = odsParser.getCurrentLocation();
83 ::mlir::detail::unwrapForCustomParse(_result_name),
84 ::mlir::detail::unwrapForCustomParse(_result_type));
85 if (::mlir::failed(odsCustomResult))
return {};
86 if (::mlir::failed(_result_name)) {
87 odsParser.emitError(odsCustomLoc,
"custom parser failed to parse parameter 'name'");
90 if (::mlir::failed(_result_type)) {
91 odsParser.emitError(odsCustomLoc,
"custom parser failed to parse parameter 'type'");
95 assert(::mlir::succeeded(_result_name));
96 assert(::mlir::succeeded(_result_type));
97 return RecordAttr::get(odsParser.getContext(),
98 ::mlir::StringAttr((*_result_name)),
99 ::mlir::Type((*_result_type)));
102void RecordAttr::print(::mlir::AsmPrinter &odsPrinter)
const {
103 ::mlir::Builder odsBuilder(getContext());
109::mlir::StringAttr RecordAttr::getName()
const {
110 return getImpl()->name;
113::mlir::Type RecordAttr::getType()
const {
114 return getImpl()->type;
119MLIR_DEFINE_EXPLICIT_TYPE_ID(::llzk::pod::RecordAttr)
125 ::mlir::Type type)
const {
126 ::llvm::SMLoc typeLoc = parser.getCurrentLocation();
127 ::llvm::StringRef attrTag;
129 ::mlir::Attribute attr;
130 auto parseResult = generatedAttributeParser(parser, &attrTag, type, attr);
131 if (parseResult.has_value())
135 parser.emitError(typeLoc) <<
"unknown attribute `"
136 << attrTag <<
"` in dialect `" << getNamespace() <<
"`";
141 ::mlir::DialectAsmPrinter &printer)
const {
142 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.
void printRecord(AsmPrinter &printer, StringAttr name, Type type)
ParseResult parseRecord(AsmParser &parser, StringAttr &name, Type &type)