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(); });
44struct RecordAttrStorage :
public ::mlir::AttributeStorage {
45 using KeyTy = std::tuple<::mlir::StringAttr, ::mlir::Type>;
46 RecordAttrStorage(::mlir::StringAttr name, ::mlir::Type type) : name(std::move(name)), type(std::move(type)) {}
48 KeyTy getAsKey()
const {
49 return KeyTy(name, type);
52 bool operator==(
const KeyTy &tblgenKey)
const {
53 return (name == std::get<0>(tblgenKey)) && (type == std::get<1>(tblgenKey));
56 static ::llvm::hash_code hashKey(
const KeyTy &tblgenKey) {
57 return ::llvm::hash_combine(std::get<0>(tblgenKey), std::get<1>(tblgenKey));
60 static RecordAttrStorage *construct(::mlir::AttributeStorageAllocator &allocator, KeyTy &&tblgenKey) {
61 auto name = std::move(std::get<0>(tblgenKey));
62 auto type = std::move(std::get<1>(tblgenKey));
63 return new (allocator.allocate<RecordAttrStorage>()) RecordAttrStorage(std::move(name), std::move(type));
66 ::mlir::StringAttr name;
71RecordAttr RecordAttr::get(::mlir::MLIRContext *context, ::mlir::StringAttr name, ::mlir::Type type) {
72 return Base::get(context, std::move(name), std::move(type));
75::mlir::Attribute RecordAttr::parse(::mlir::AsmParser &odsParser, ::mlir::Type odsType) {
76 ::mlir::Builder odsBuilder(odsParser.getContext());
77 ::llvm::SMLoc odsLoc = odsParser.getCurrentLocation();
79 ::mlir::FailureOr<::mlir::StringAttr> _result_name;
80 ::mlir::FailureOr<::mlir::Type> _result_type;
82 auto odsCustomLoc = odsParser.getCurrentLocation();
85 ::mlir::detail::unwrapForCustomParse(_result_name),
86 ::mlir::detail::unwrapForCustomParse(_result_type));
87 if (::mlir::failed(odsCustomResult))
return {};
88 if (::mlir::failed(_result_name)) {
89 odsParser.emitError(odsCustomLoc,
"custom parser failed to parse parameter 'name'");
92 if (::mlir::failed(_result_type)) {
93 odsParser.emitError(odsCustomLoc,
"custom parser failed to parse parameter 'type'");
97 assert(::mlir::succeeded(_result_name));
98 assert(::mlir::succeeded(_result_type));
99 return RecordAttr::get(odsParser.getContext(),
100 ::mlir::StringAttr((*_result_name)),
101 ::mlir::Type((*_result_type)));
104void RecordAttr::print(::mlir::AsmPrinter &odsPrinter)
const {
105 ::mlir::Builder odsBuilder(getContext());
111::mlir::StringAttr RecordAttr::getName()
const {
112 return getImpl()->name;
115::mlir::Type RecordAttr::getType()
const {
116 return getImpl()->type;
121MLIR_DEFINE_EXPLICIT_TYPE_ID(::llzk::pod::RecordAttr)
127 ::mlir::Type type)
const {
128 ::llvm::SMLoc typeLoc = parser.getCurrentLocation();
129 ::llvm::StringRef attrTag;
131 ::mlir::Attribute attr;
132 auto parseResult = generatedAttributeParser(parser, &attrTag, type, attr);
133 if (parseResult.has_value())
137 parser.emitError(typeLoc) <<
"unknown attribute `"
138 << attrTag <<
"` in dialect `" << getNamespace() <<
"`";
143 ::mlir::DialectAsmPrinter &printer)
const {
144 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.
Common interface for operations that reference a plain-old-data struct value.
void printRecord(AsmPrinter &printer, StringAttr name, Type type)
ParseResult parseRecord(AsmParser &parser, StringAttr &name, Type &type)