37 bool preorder(
const IR::MAU::TableSeq *)
override {
return false; }
38 bool preorder(
const IR::MAU::Table *tbl)
override {
39 return !tbl->is_a_gateway_table_only();
42 bool preorder(
const IR::MAU::Instruction *inst)
override {
43 for (
unsigned i = 0; i < inst->operands.size(); i++) {
44 auto f = phv.field(inst->operands[i]);
61 void dump(std::ostream &out,
const IR::MAU::Table *tbl)
const override {
62 out << FlowGraph::viz_node_name(tbl) <<
" [ shape=record, style=\"filled\","
63 <<
" fillcolor=cornsilk, label=\""
64 << (tbl->is_a_gateway_table_only() ? tbl->gateway_cond : tbl->name) <<
"\\l\\l"
67 if (!tbl->match_key.empty()) {
68 out <<
"M:\\l" << std::endl;
69 for (
auto m : tbl->match_key) {
70 auto f = phv.field(m->expr);
74 "PHV details for %s not found. Possibly trying to match on an error type?",
76 out <<
" " << stripThreadPrefix(f->name) <<
"\\l" << std::endl;
84 if (!fields.reads.empty()) {
85 out <<
"R:\\l" << std::endl;
86 for (
auto r : fields.reads)
87 out <<
" " << stripThreadPrefix(r->name) <<
"\\l" << std::endl;
91 if (!fields.writes.empty()) {
92 out <<
"W:\\l" << std::endl;
93 for (
auto w : fields.writes)
94 out <<
" " << stripThreadPrefix(w->name) <<
"\\l" << std::endl;
97 out <<
" \"];" << std::endl;
101 std::ofstream *open_file(gress_t gress,
int pipe_id,
cstring directory =
"graphs"_cs) {
103 if (!outdir)
return nullptr;
106 auto filepath = outdir +
"/" + std::to_string(fid++) +
"_" +
"table_flow_graph" +
"_" +
107 ::toString(gress) +
".dot";
109 return new std::ofstream(filepath);
112 const IR::Node *apply_visitor(
const IR::Node *n,
const char *)
override {
return n; }
114 Visitor::profile_t init_apply(
const IR::Node *root)
override {
115 auto rv = Visitor::init_apply(root);
121 for (
auto &kv : graphs) {
122 if (kv.second.emptyFlowGraph)
continue;
124 auto fs = open_file(kv.first, root->to<IR::BFN::Pipe>()->canon_id());
125 kv.second.dump_viz(*fs,
new PhvDetails(phv));
static BFNContext & get()
Definition bf-p4c-options.cpp:777
cstring getOutputDirectory(const cstring &suffix=cstring(), int pipe_id=-1)
Definition bf-p4c-options.cpp:795