16 #include "mlir/IR/Builders.h"
17 #include "mlir/IR/DialectImplementation.h"
19 #include "llvm/ADT/STLExtras.h"
20 #include "llvm/ADT/TypeSwitch.h"
22 using namespace circt;
25 #define GET_ATTRDEF_CLASSES
26 #include "circt/Dialect/SSP/SSPAttributes.cpp.inc"
28 void SSPDialect::registerAttributes() {
30 #define GET_ATTRDEF_LIST
31 #include "circt/Dialect/SSP/SSPAttributes.cpp.inc"
35 mlir::OptionalParseResult
37 ArrayRef<Attribute> alreadyParsed) {
38 auto &builder = parser.getBuilder();
40 if (parser.parseOptionalLSquare()) {
41 if (!alreadyParsed.empty()) {
42 attr = builder.getArrayAttr(alreadyParsed);
48 SmallVector<Attribute> elements;
49 elements.append(alreadyParsed.begin(), alreadyParsed.end());
51 auto parseListResult = parser.parseCommaSeparatedList([&]() -> ParseResult {
55 auto parseGenericAttrResult = parser.parseOptionalAttribute(elem);
56 if (parseGenericAttrResult.has_value()) {
57 if (failed(*parseGenericAttrResult))
60 elements.push_back(elem);
66 auto parseShortformAttrResult =
67 generatedAttributeParser(parser, &mnemonic, Type(), elem);
69 if (!parseShortformAttrResult.has_value()) {
70 return parser.emitError(parser.getCurrentLocation(),
71 "carries unknown shortform property: ")
75 if (failed(*parseShortformAttrResult))
78 elements.push_back(elem);
82 if (parseListResult || parser.parseRSquare())
85 attr = builder.getArrayAttr(elements);
90 ArrayRef<Attribute> alreadyPrinted) {
91 auto elementsToPrint =
92 llvm::make_filter_range(attr.getAsRange<Attribute>(), [&](Attribute a) {
93 return !llvm::is_contained(alreadyPrinted, a);
95 if (elementsToPrint.empty())
99 llvm::interleaveComma(elementsToPrint, p, [&](Attribute elem) {
102 if (failed(generatedAttributePrinter(elem, p)))
103 p.printAttribute(attr);
void printPropertyArray(ArrayAttr attr, AsmPrinter &p, ArrayRef< Attribute > alreadyPrinted={})
Print an array attribute, suppressing the #ssp.
mlir::OptionalParseResult parseOptionalPropertyArray(ArrayAttr &attr, AsmParser &parser, ArrayRef< Attribute > alreadyParsed={})
Parse an array of attributes while recognizing the properties of the SSP dialect even without a #ssp.
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.