out edges for entities and types
[libfirm] / ir / ana / irdom.h
1 /*
2  * Project:     libFIRM
3  * File name:   ir/ana/irdom.h
4  * Purpose:     Construct and access dominator tree.
5  * Author:      Goetz Lindenmaier
6  * Modified by:
7  * Created:     2.2002
8  * CVS-ID:      $Id$
9  * Copyright:   (c) 2002-2003 Universität Karlsruhe
10  * Licence:     This file protected by GPL -  GNU GENERAL PUBLIC LICENSE.
11  */
12
13 /**
14 * @file irdom.h
15 *
16 *   This file contains routines to construct and access dominator information.
17 *
18 *   The dominator information is stored in three fields of block nodes:
19 *     - idom: a reference to the block that is the immediate dominator of
20 *       this block.
21 *     - dom_depth: a number giving the depth of the block in the dominator
22 *       tree.
23 *     - pre_num:  Number in preorder traversal.
24 *
25 * @author Goetz Lindenmaier
26 */
27
28
29 # ifndef _IRDOM_H_
30 # define _IRDOM_H_
31
32 # include "irgraph.h"
33 # include "irnode.h"
34
35
36 /** Accessing the dominator datastructure.
37  *
38  * These routines only work properly if the ir_graph is in state
39  * dom_consistent or dom_inconsistent.
40  *
41  * If the block is not reachable from Start, returns a Bad node.
42  */
43 ir_node *get_Block_idom(ir_node *bl);
44 void set_Block_idom(ir_node *bl, ir_node *n);
45
46 int get_Block_dom_depth(ir_node *bl);
47 void set_Block_dom_depth(ir_node *bl, int depth);
48
49 int get_Block_pre_num(ir_node *bl);
50 void set_Block_pre_num(ir_node *bl, int num);
51
52
53 /* ------------ Building and Removing the dominator datasturcture ----------- */
54
55 /** Computes the dominator trees.
56  *
57  * Sets a flag in irg to "dom_consistent".
58  * If the control flow of the graph is changed this flag must be set to
59  * "dom_inconsistent".
60  * Does not compute dominator information for control dead code.  Blocks
61  * not reachable from Start contain the following information:
62  *   idom = NULL;
63  *   dom_depth = -1;
64  *   pre_num = -1;
65  * Also constructs outs information.  As this information is correct after
66  * the run does not free the outs information.
67  */
68 void compute_doms(ir_graph *irg);
69
70 /** Frees the dominator datastructures.  Sets the flag in irg to "dom_none". */
71 void free_dom_and_peace(ir_graph *irg);
72
73 #endif /* _IRDOM_H_ */