P4C
The P4 Compiler
Loading...
Searching...
No Matches
mau_backtracker.h
1
19#ifndef BF_P4C_PHV_MAU_BACKTRACKER_H_
20#define BF_P4C_PHV_MAU_BACKTRACKER_H_
21
22#include "backends/tofino/bf-p4c/mau/table_summary.h"
23#include "ir/ir.h"
24#include "lib/ordered_map.h"
25
29class MauBacktracker : public Backtrack {
30 private:
31 State::state_t &state;
32 static constexpr unsigned NUM_LOGICAL_TABLES_PER_STAGE = 16;
34 int numInvoked = 0;
35
41
44
50
55
56 // true if a valid table placement is stored in tables. NOTE: we need this variable instead
57 // of just using !tables.empty() because for program with no table, an empty alloc is valid.
58 bool has_table_placement = false;
59
61 int maxStage = -1;
62
64 bool metaInitDisable = false;
65
67 bool ignorePackConflicts = false;
68
70 bool firstRoundFit = false;
71
77 TableSummary *table_summary;
78
79 const IR::Node *apply_visitor(const IR::Node *root, const char *) override;
80
83 bool backtrack(trigger &) override;
84
85 ordered_set<int> inSameStage(const IR::MAU::Table *t1, const IR::MAU::Table *t2,
86 const ordered_map<cstring, ordered_set<int>> &tableMap) const;
87
88 public:
91 ordered_set<int> inSameStage(const IR::MAU::Table *t1, const IR::MAU::Table *t2) const;
92
94 std::string printTableAlloc() const;
95
98 bool hasTablePlacement() const;
99
102 ordered_set<int> stage(const IR::MAU::Table *t, bool internal = false) const;
103
105 bool disableMetadataInitialization() const { return metaInitDisable; }
106
108 bool didFirstRoundFit() const { return firstRoundFit; }
109
110 bool happensBefore(const IR::MAU::Table *t1, const IR::MAU::Table *t2) const;
111
113 int numStages() const;
114
116 const TableSummary *get_table_summary() const { return table_summary; };
117
120 return internalTables;
121 }
122
125 return mergedGateways;
126 }
127
131 void clear();
132
135 explicit MauBacktracker(State::state_t &state = *(new State::state_t),
136 TableSummary *table_summary = nullptr)
137 : state(state), table_summary(table_summary) {}
138};
139
140#endif /* BF_P4C_PHV_MAU_BACKTRACKER_H_ */
Definition mau_backtracker.h:29
int numStages() const
Definition mau_backtracker.cpp:176
MauBacktracker(State::state_t &state= *(new State::state_t), TableSummary *table_summary=nullptr)
Definition mau_backtracker.h:135
bool hasTablePlacement() const
Definition mau_backtracker.cpp:139
const ordered_map< cstring, ordered_set< int > > & getInternalTablesInfo() const
Definition mau_backtracker.h:119
bool disableMetadataInitialization() const
Definition mau_backtracker.h:105
const ordered_map< cstring, std::pair< cstring, cstring > > & getMergedGatewaysInfo() const
Definition mau_backtracker.h:124
const TableSummary * get_table_summary() const
Definition mau_backtracker.h:116
bool didFirstRoundFit() const
Definition mau_backtracker.h:108
std::string printTableAlloc() const
Prints the table allocation received by MauBacktracker by means of the backtrack trigger.
Definition mau_backtracker.cpp:123
void clear()
Definition mau_backtracker.cpp:178
ordered_set< int > stage(const IR::MAU::Table *t, bool internal=false) const
Definition mau_backtracker.cpp:141
Definition visitor.h:766
Definition node.h:94
Definition cstring.h:85
Definition ordered_map.h:32
Definition ordered_set.h:32
Definition table_summary.h:158
Definition visitor.h:768