48 using Graph = ReversibleParserGraph::Graph;
49 using Vertex = boost::graph_traits<Graph>::vertex_descriptor;
50 using IndexMap = boost::property_map<Graph, boost::vertex_index_t>::type;
51 using PredMap = boost::iterator_property_map<std::vector<Vertex>::iterator, IndexMap>;
57 std::set<const IR::BFN::ParserState *> states;
63 bool preorder(
const IR::BFN::Parser *parser)
override;
68 bool preorder(
const IR::BFN::ParserState *parser_state)
override;
83 bool get_post_dominators) {
84 std::vector<Vertex> dom_tree_pred_vector;
85 IndexMap index_map(boost::get(boost::vertex_index, graph));
86 dom_tree_pred_vector =
87 std::vector<Vertex>(boost::num_vertices(graph), boost::graph_traits<G>::null_vertex());
88 PredMap dom_tree_pred_map =
89 boost::make_iterator_property_map(dom_tree_pred_vector.begin(), index_map);
90 boost::lengauer_tarjan_dominator_tree(graph, entry, dom_tree_pred_map);
92 typename boost::graph_traits<G>::vertex_iterator it, end;
94 std::string out = get_post_dominators ?
"post-dominator" :
"dominator";
95 LOG7(
"Building " << out <<
" int map");
96 for (std::tie(it, end) = boost::vertices(graph); it != end; ++it) {
97 if (boost::get(dom_tree_pred_map, *it) != boost::graph_traits<G>::null_vertex()) {
98 idom[boost::get(index_map, *it)] =
99 boost::get(index_map, boost::get(dom_tree_pred_map, *it));
100 LOG7(TAB1 <<
"Setting " << out <<
" for " << boost::get(index_map, *it) <<
" to "
101 << boost::get(index_map, boost::get(dom_tree_pred_map, *it)));
103 idom[boost::get(index_map, *it)] = -1;
104 LOG7(TAB1 <<
"Setting " << out <<
" for " << boost::get(index_map, *it)
157 std::set<const IR::BFN::ParserState *> get_all_dominatees(
const IR::BFN::ParserState *state,
159 bool get_post_dominatees);
170 std::set<const IR::BFN::ParserState *> get_all_dominators(
const IR::BFN::ParserState *state,
172 bool get_post_dominators);
177 void build_dominator_maps();
188 std::set<const IR::BFN::ParserState *> get_all_dominatees(
const IR::BFN::ParserState *state,
189 gress_t gress = INGRESS);
200 const IR::BFN::ParserState *state, gress_t gress = INGRESS);
210 std::set<const IR::BFN::ParserState *> get_all_dominators(
const IR::BFN::ParserState *state,
211 gress_t gress = INGRESS);
222 const IR::BFN::ParserState *state, gress_t gress = INGRESS);
225 void end_apply()
override;
std::set< const IR::BFN::ParserState * > get_all_post_dominatees(const IR::BFN::ParserState *state, gress_t gress=INGRESS)
Get all parser states that are post-dominated by state.
Definition parser_dominator_builder.cpp:126
std::set< const IR::BFN::ParserState * > get_all_post_dominators(const IR::BFN::ParserState *state, gress_t gress=INGRESS)
Get all post-dominators of a given parser state.
Definition parser_dominator_builder.cpp:136