11#include "mlir/IR/Builders.h"
12#include "mlir/IR/DialectImplementation.h"
13#include "llvm/ADT/StringSet.h"
14#include "llvm/ADT/TypeSwitch.h"
19#define GET_TYPEDEF_CLASSES
20#include "circt/Dialect/RTG/IR/RTGTypes.cpp.inc"
26LogicalResult DictType::verify(function_ref<InFlightDiagnostic()> emitError,
27 ArrayRef<DictEntry> entries) {
29 for (
auto entry : entries) {
30 if (entry.name.empty())
31 return emitError() <<
"empty strings not allowed as entry names";
33 if (last && entry.name.getValue() <= last.getValue())
34 return emitError() <<
"dictionary must be sorted by names and contain no "
35 "duplicates, first violation at entry '"
36 << entry.name.getValue() <<
"'";
44Type DictType::parse(AsmParser &p) {
45 SmallVector<DictEntry> entries;
46 auto loc = p.getCurrentLocation();
48 auto parseResult = p.parseCommaSeparatedList(
49 mlir::AsmParser::Delimiter::LessGreater, [&]() -> ParseResult {
52 loc = p.getCurrentLocation();
54 if (p.parseKeywordOrString(&name) || p.parseColon() ||
59 entry.name = StringAttr::get(p.getContext(), name);
61 entries.emplace_back(entry);
65 if (failed(parseResult))
68 auto emitError = [&]() {
return p.emitError(loc); };
73 return getChecked(emitError, p.getContext(), entries);
76void DictType::print(AsmPrinter &p)
const {
78 llvm::interleaveComma(getEntries(), p, [&](
auto entry) {
79 p.printKeywordOrString(entry.name.getValue());
80 p <<
": " << entry.type;
85bool DictType::entryTypesMatch(TypeRange types)
const {
86 return llvm::equal(getEntries(), types,
87 [](
const DictEntry &entry,
const Type &type) {
88 return entry.type == type;
92void circt::rtg::RTGDialect::registerTypes() {
94#define GET_TYPEDEF_LIST
95#include "circt/Dialect/RTG/IR/RTGTypes.cpp.inc"
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.