Added copyright headers
[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 ir_node *get_Block_idom(ir_node *bl);
42 void set_Block_idom(ir_node *bl, ir_node *n);
43
44 int get_Block_dom_depth(ir_node *bl);
45 void set_Block_dom_depth(ir_node *bl, int depth);
46
47 int get_Block_pre_num(ir_node *bl);
48 void set_Block_pre_num(ir_node *bl, int num);
49
50
51 /* ------------ Building and Removing the dominator datasturcture ----------- */
52
53 /** Computes the dominator trees.
54  *
55  * Sets a flag in irg to "dom_consistent".
56  * If the control flow of the graph is changed this flag must be set to
57  * "dom_inconsistent".
58  * Does not compute dominator information for control dead code.  Blocks
59  * not reachable from Start contain the following information:
60  *   idom = NULL;
61  *   dom_depth = -1;
62  *   pre_num = -1;
63  */
64 void compute_doms(ir_graph *irg);
65
66 /** Frees the dominator datastructures.  Sets the flag in irg to "no_dom". */
67 void free_dom_and_peace(ir_graph *irg);
68
69 #endif /* _IRDOM_H_ */