75 circt::hw::HWModuleOp) {
76 return llvm::TypeSwitch<mlir::Operation *, std::string>(node)
77 .Case<circt::comb::AddOp>([&](
auto) {
return "+"; })
78 .Case<circt::comb::SubOp>([&](
auto) {
return "-"; })
79 .Case<circt::comb::AndOp>([&](
auto) {
return "&"; })
80 .Case<circt::comb::OrOp>([&](
auto) {
return "|"; })
81 .Case<circt::comb::XorOp>([&](
auto) {
return "^"; })
82 .Case<circt::comb::MulOp>([&](
auto) {
return "*"; })
83 .Case<circt::comb::MuxOp>([&](
auto) {
return "mux"; })
84 .Case<circt::comb::ShrSOp, circt::comb::ShrUOp>(
85 [&](
auto) {
return ">>"; })
86 .Case<circt::comb::ShlOp>([&](
auto) {
return "<<"; })
87 .Case<circt::comb::ICmpOp>([&](
auto op) {
88 switch (op.getPredicate()) {
89 case circt::comb::ICmpPredicate::eq:
90 case circt::comb::ICmpPredicate::ceq:
91 case circt::comb::ICmpPredicate::weq:
93 case circt::comb::ICmpPredicate::wne:
94 case circt::comb::ICmpPredicate::cne:
95 case circt::comb::ICmpPredicate::ne:
97 case circt::comb::ICmpPredicate::uge:
98 case circt::comb::ICmpPredicate::sge:
100 case circt::comb::ICmpPredicate::ugt:
101 case circt::comb::ICmpPredicate::sgt:
103 case circt::comb::ICmpPredicate::ule:
104 case circt::comb::ICmpPredicate::sle:
106 case circt::comb::ICmpPredicate::ult:
107 case circt::comb::ICmpPredicate::slt:
110 llvm_unreachable(
"unhandled ICmp predicate");
112 .Case<circt::seq::FirRegOp>([&](
auto op) {
return op.getName().str(); })
113 .Case<circt::seq::CompRegOp>([&](
auto op) -> std::string {
114 if (
auto name = op.getName())
118 .Case<circt::hw::ConstantOp>([&](
auto op) {
119 llvm::SmallString<64> valueString;
120 op.getValue().toString(valueString, 10,
false);
121 return valueString.str().str();
123 .Default([&](
auto op) {
return op->getName().getStringRef().str(); });
127 circt::hw::HWModuleOp) {
128 return llvm::TypeSwitch<mlir::Operation *, std::string>(node)
129 .Case<circt::hw::ConstantOp>(
130 [&](
auto) {
return "fillcolor=darkgoldenrod1,style=filled"; })
131 .Case<circt::comb::MuxOp>([&](
auto) {
132 return "shape=invtrapezium,fillcolor=bisque,style=filled";
134 .Case<circt::hw::OutputOp>(
135 [&](
auto) {
return "fillcolor=lightblue,style=filled"; })
136 .Default([&](
auto op) {
137 return llvm::TypeSwitch<mlir::Dialect *, std::string>(
139 .Case<circt::comb::CombDialect>([&](
auto) {
140 return "shape=oval,fillcolor=bisque,style=filled";
142 .
template Case<circt::seq::SeqDialect>([&](
auto) {
143 return "shape=folder,fillcolor=gainsboro,style=filled";
145 .Default([&](
auto) {
return ""; });
151 llvm::GraphWriter<circt::hw::HWModuleOp> &g) {
154 auto &os = g.getOStream();
155 os <<
"subgraph cluster_entry_args {\n";
156 os <<
"label=\"Input arguments\";\n";
158 for (
auto [info, arg] :
159 llvm::zip(iports.
getInputs(), mod.getBodyBlock()->getArguments())) {
160 g.emitSimpleNode(
reinterpret_cast<void *
>(&arg),
"",
161 info.getName().str());
164 for (
auto [info, arg] :
165 llvm::zip(iports.
getInputs(), mod.getBodyBlock()->getArguments())) {
166 for (
auto *user : arg.getUsers()) {
167 g.emitEdge(
reinterpret_cast<void *
>(&arg), 0, user, -1,
"");
174 Iterator it, circt::hw::HWModuleOp mod) {
176 mlir::OpOperand &operand = *it.getCurrent();
177 mlir::Value v = operand.get();
179 llvm::raw_string_ostream os(str);
180 auto verboseEdges = mod->getAttrOfType<mlir::BoolAttr>(
"dot_verboseEdges");
181 if (verboseEdges.getValue()) {
182 os <<
"label=\"" << operand.getOperandNumber() <<
" (" << v.getType()