P4C
The P4 Compiler
Loading...
Searching...
No Matches
dominator_tree.h
1
19#ifndef BACKENDS_TOFINO_BF_P4C_PHV_ANALYSIS_DOMINATOR_TREE_H_
20#define BACKENDS_TOFINO_BF_P4C_PHV_ANALYSIS_DOMINATOR_TREE_H_
21
22#include "bf-p4c/mau/mau_visitor.h"
23#include "bf-p4c/mau/table_flow_graph.h"
24#include "ir/ir.h"
25
33 public:
36 using G = FlowGraph::Graph;
37 using Vertex = boost::graph_traits<G>::vertex_descriptor;
38 using IndexMap = boost::property_map<G, boost::vertex_index_t>::type;
39 using PredMap = boost::iterator_property_map<std::vector<Vertex>::iterator, IndexMap>;
40
41 private:
46
47 profile_t init_apply(const IR::Node *root) override;
48 bool preorder(const IR::BFN::Pipe *pipe) override;
49 bool preorder(const IR::MAU::Table *tbl) override;
50
54 void generateIndexToTableMap(const FlowGraph &fg,
56
61 void generateDominatorTree(const FlowGraph &fg,
62 const ordered_map<int, const IR::MAU::Table *> &indexToTableMap,
64
67 void printDominatorTree(const ImmediateDominatorMap &idom) const;
68
69 public:
72 const ordered_map<gress_t, FlowGraph> &getFlowGraph() const { return flowGraph; }
73
74 /* setup dominator tree using flowGraph
75 */
76 void setupDomTree();
77
82 std::optional<const IR::MAU::Table *> getImmediateDominator(const IR::MAU::Table *t,
83 gress_t gress) const;
84
89 std::optional<const IR::MAU::Table *> getNonGatewayImmediateDominator(const IR::MAU::Table *t,
90 gress_t gress) const;
91
94 bool strictlyDominates(const IR::BFN::Unit *u1, const IR::BFN::Unit *u2) const;
95
98 bool strictlyDominates(const IR::MAU::Table *t1, const IR::MAU::Table *t2) const;
99
102 const IR::MAU::Table *getNonGatewayGroupDominator(
104
107 const std::vector<const IR::MAU::Table *> getAllDominators(const IR::MAU::Table *t,
108 gress_t gress) const;
109
110 explicit BuildDominatorTree(ordered_map<gress_t, FlowGraph> &fg) : flowGraph(fg) {}
111
113
117 cstring hasImmediateDominator(gress_t g, cstring t) const;
118
122 bool strictlyDominates(cstring t1, cstring t2, gress_t gress) const;
123
127 bool isDominator(cstring t1, gress_t gress, cstring t2) const;
128};
129#endif /* BACKENDS_TOFINO_BF_P4C_PHV_ANALYSIS_DOMINATOR_TREE_H_ */
Definition dominator_tree.h:32
const ordered_map< gress_t, FlowGraph > & getFlowGraph() const
Definition dominator_tree.h:72
bool strictlyDominates(const IR::BFN::Unit *u1, const IR::BFN::Unit *u2) const
Definition phv/analysis/dominator_tree.cpp:185
std::optional< const IR::MAU::Table * > getNonGatewayImmediateDominator(const IR::MAU::Table *t, gress_t gress) const
Definition phv/analysis/dominator_tree.cpp:171
std::optional< const IR::MAU::Table * > getImmediateDominator(const IR::MAU::Table *t, gress_t gress) const
Definition phv/analysis/dominator_tree.cpp:162
cstring hasImmediateDominator(gress_t g, cstring t) const
GTest methods.
Definition phv/analysis/dominator_tree.cpp:324
bool isDominator(cstring t1, gress_t gress, cstring t2) const
Definition phv/analysis/dominator_tree.cpp:349
const std::vector< const IR::MAU::Table * > getAllDominators(const IR::MAU::Table *t, gress_t gress) const
Definition phv/analysis/dominator_tree.cpp:226
const IR::MAU::Table * getNonGatewayGroupDominator(ordered_set< const IR::MAU::Table * > &tables) const
Definition phv/analysis/dominator_tree.cpp:238
Definition mau_visitor.h:29
Definition node.h:95
Definition visitor.h:78
Definition cstring.h:85
Definition ordered_map.h:32
Definition ordered_set.h:32
Definition table_flow_graph.h:45