+unsigned get_Block_dom_tree_pre_num(const ir_node *bl)
+{
+ assert(is_Block(bl));
+ return get_dom_info(bl)->tree_pre_num;
+}
+
+unsigned get_Block_dom_max_subtree_pre_num(const ir_node *bl)
+{
+ assert(is_Block(bl));
+ return get_dom_info(bl)->max_subtree_pre_num;
+}
+
+int block_dominates(const ir_node *a, const ir_node *b)
+{
+ const dom_info *ai, *bi;
+
+ assert(is_Block(a) && is_Block(b));
+ ai = get_dom_info(a);
+ bi = get_dom_info(b);
+ return bi->tree_pre_num - ai->tree_pre_num
+ <= ai->max_subtree_pre_num - ai->tree_pre_num;
+}
+
+ir_node *get_Block_dominated_first(const ir_node *bl)
+{
+ assert(is_Block(bl));
+ return get_dom_info(bl)->first;
+}
+
+ir_node *get_Block_dominated_next(const ir_node *bl)
+{
+ assert(is_Block(bl));
+ return get_dom_info(bl)->next;
+}
+
+void dom_tree_walk(ir_node *bl, irg_walk_func *pre,
+ irg_walk_func *post, void *env)
+{
+ ir_node *p;
+
+ if(pre)
+ pre(bl, env);
+
+ dominates_for_each(bl, p) {
+ dom_tree_walk(p, pre, post, env);
+ }
+
+ if(post)
+ post(bl, env);
+}
+
+void dom_tree_walk_irg(ir_graph *irg, irg_walk_func *pre,
+ irg_walk_func *post, void *env)
+{
+ /* The root of the dominator tree should be the start node. */
+ ir_node *root = get_irg_start_block(irg);
+
+ assert(irg->dom_state == dom_consistent
+ && "The dominators of the irg must be consistent");
+ assert(root && "The start block of the graph is NULL?");
+ assert(get_dom_info(root)->idom == NULL
+ && "The start node in the graph must be the root of the dominator tree");
+ dom_tree_walk(root, pre, post, env);
+}
+
+static void assign_tree_pre_order(ir_node *bl, void *data)
+{
+ unsigned *num = data;
+ dom_info *bi = get_dom_info(bl);
+
+ bi->tree_pre_num = (*num)++;
+}