30 mutable indent_t indent;
31 mutable std::set<const IR::MAU::TableSeq *> done;
32 safe_vector<cstring> name;
33 const IR::MAU::TableSeq *seq;
34 const IR::BFN::Pipe *pipe;
36 void print(std::ostream &out,
const safe_vector<cstring> &tag,
37 const IR::MAU::TableSeq *s)
const {
44 out <<
": [" << s->seq_uid <<
"]";
46 out <<
"..." << std::endl;
49 bool big = (s->tables.size() > 5);
50 if (big) out << std::endl << indent <<
" +--" << s->tables[0]->name;
51 for (
unsigned i = 1; i < s->tables.size(); ++i) {
52 if (big) out << std::endl << indent <<
" ";
54 for (
unsigned j = 0; j < i; ++j) out << (s->deps(i, j) ?
'1' :
'0');
55 if (big) out <<
"+--" << s->tables[i]->name;
59 for (
auto tbl : s->tables) print(out, tbl);
63 void print(std::ostream &out,
const IR::MAU::Table *tbl)
const {
64 ordered_map<const IR::MAU::TableSeq *, safe_vector<cstring>> next;
67 out << hex(*tbl->global_id()) <<
": ";
68 else if (tbl->stage() != -1)
69 out << hex(tbl->stage() * 16) <<
": ";
71 const char *sep =
"(";
72 for (
auto &row : tbl->gateway_rows) {
78 if (row.second) out <<
" => " << row.second;
81 out << (*sep ==
',' ?
")" :
"");
82 if (tbl->layout.match_width_bits || tbl->layout.overhead_bits) {
83 out <<
"{ " << (tbl->layout.gateway ?
"G" :
"") << (tbl->layout.ternary ?
"T" :
"E")
84 <<
" " << tbl->layout.match_width_bits <<
"+" << tbl->layout.overhead_bits <<
", "
85 << tbl->layout.action_data_bytes;
86 if (!tbl->ways.empty()) {
87 out <<
" [" << tbl->ways[0].width <<
'x' << tbl->ways[0].match_groups;
88 for (
auto &way : tbl->ways) out <<
" " << (way.entries / 1024U) <<
"K";
91 out <<
" " << (tbl->layout.entries / 1024U) <<
"K";
95 auto stage = tbl->get_provided_stage();
96 if (stage >= 0) out <<
" @stage(" << stage <<
")";
98 for (
auto &at : tbl->attached) {
99 if (at->attached->direct)
continue;
100 out << indent << at->attached->kind() <<
" " << at->attached->name <<
" "
101 << n4(at->attached->size) << std::endl;
103 for (
auto &n : tbl->next) next[n.second].push_back(n.first);
104 for (
auto &n : next) print(out, n.second, n.first);
109 TableTree(cstring name,
const IR::MAU::TableSeq *seq) : name{name}, seq(seq), pipe(
nullptr) {}
110 explicit TableTree(
const IR::BFN::Pipe *pipe) : name{}, seq(
nullptr), pipe(pipe) {}
111 friend std::ostream &operator<<(std::ostream &out,
const TableTree &tt) {
112 tt.indent = indent_t();
115 if (tt.pipe->thread[INGRESS].mau)
116 tt.print(out, {
"ingress"_cs}, tt.pipe->thread[INGRESS].mau);
117 if (tt.pipe->thread[EGRESS].mau)
118 tt.print(out, {
"egress"_cs}, tt.pipe->thread[EGRESS].mau);
119 if (tt.pipe->ghost_thread.ghost_mau)
120 tt.print(out, {
"ghost mau"_cs}, tt.pipe->ghost_thread.ghost_mau);
122 tt.print(out, tt.name, tt.seq);