return get_dom_info(bl)->next;
}
-void dom_tree_walk(ir_node *n, irg_walk_func *pre,
+void dom_tree_walk(ir_node *bl, irg_walk_func *pre,
irg_walk_func *post, void *env)
{
ir_node *p;
- assert(get_irn_irg(n)->dom_state == dom_consistent
- && "The dominators of the irg must be consistent");
-
- for(p = get_dom_info(p)->first; p; p = get_dom_info(p)->next) {
- if(pre)
- pre(p, env);
+ if(pre)
+ pre(bl, env);
+ dominates_for_each(bl, p) {
dom_tree_walk(p, pre, post, env);
-
- if(post)
- post(p, env);
}
+
+ if(post)
+ post(bl, env);
}
void dom_tree_walk_irg(ir_graph *irg, irg_walk_func *pre,
{
unsigned *num = data;
dom_info *bi = get_dom_info(bl);
+
bi->tree_pre_num = (*num)++;
}
dom_info *bi = get_dom_info(bl);
ir_node *p;
unsigned max = 0;
+ unsigned children = 0;
for(p = bi->first; p; p = get_dom_info(p)->next) {
unsigned max_p = get_dom_info(p)->max_subtree_pre_num;
max = max > max_p ? max : max_p;
+ children++;
}
- bi->max_subtree_pre_num = max;
+ bi->max_subtree_pre_num = children > 0 ? max : bi->tree_pre_num;
+ assert(bi->max_subtree_pre_num >= bi->tree_pre_num);
}
/*--------------------------------------------------------------------*/
int *n_blocks = (int *) env;
(*n_blocks) ++;
+ memset(get_dom_info(bl), 0, sizeof(dom_info));
set_Block_idom(bl, NULL);
set_Block_pre_num(bl, -1);
set_Block_dom_depth(bl, -1);
}
/* Step 4 */
tdi_list[0].dom = NULL;
- memset(get_dom_info(tdi_list[0].block), 0, sizeof(dom_info));
set_Block_idom(tdi_list[0].block, NULL);
set_Block_dom_depth(tdi_list[0].block, 1);
for (i = 1; i < n_blocks; i++) {
tmp_dom_info *w = &tdi_list[i];
if (w->dom != w->semi) w->dom = w->dom->dom;
- memset(get_dom_info(tdi_list[i].block), 0, sizeof(dom_info));
set_Block_idom(w->block, w->dom->block);
set_Block_dom_depth(w->block, get_Block_dom_depth(w->dom->block) + 1);
}