11 #include "mlir/IR/Builders.h"
12 #include "mlir/IR/DialectImplementation.h"
13 #include "llvm/ADT/StringSet.h"
14 #include "llvm/ADT/TypeSwitch.h"
16 using namespace circt;
19 #define GET_TYPEDEF_CLASSES
20 #include "circt/Dialect/RTG/IR/RTGTypes.cpp.inc"
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() <<
"'";
44 Type 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() ||
61 entries.emplace_back(entry);
65 if (failed(parseResult))
68 auto emitError = [&]() {
return p.emitError(loc); };
73 return getChecked(emitError, p.getContext(), entries);
76 void DictType::print(AsmPrinter &p)
const {
78 llvm::interleaveComma(getEntries(), p, [&](
auto entry) {
79 p.printKeywordOrString(entry.name.getValue());
80 p <<
": " << entry.type;
85 bool DictType::entryTypesMatch(TypeRange types)
const {
86 return llvm::equal(getEntries(), types,
87 [](
const DictEntry &entry,
const Type &type) {
88 return entry.type == type;
92 void circt::rtg::RTGDialect::registerTypes() {
94 #define GET_TYPEDEF_LIST
95 #include "circt/Dialect/RTG/IR/RTGTypes.cpp.inc"
static LogicalResult verify(Value clock, bool eventExists, mlir::Location loc)
Direction get(bool isOutput)
Returns an output direction if isOutput is true, otherwise returns an input direction.
The InstanceGraph op interface, see InstanceGraphInterface.td for more details.