rename ir_phase to ir_nodemap and simplify interface
[libfirm] / include / libfirm / heights.h
1 /*
2  * Copyright (C) 1995-2008 University of Karlsruhe.  All right reserved.
3  *
4  * This file is part of libFirm.
5  *
6  * This file may be distributed and/or modified under the terms of the
7  * GNU General Public License version 2 as published by the Free Software
8  * Foundation and appearing in the file LICENSE.GPL included in the
9  * packaging of this file.
10  *
11  * Licensees holding valid libFirm Professional Edition licenses may use
12  * this file in accordance with the libFirm Commercial License.
13  * Agreement provided with the Software.
14  *
15  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
16  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17  * PURPOSE.
18  */
19
20 /**
21  * @file
22  * @brief   Compute heights of nodes inside basic blocks
23  * @author  Sebastian Hack
24  * @date    19.04.2006
25  * @version $Id$
26  *
27  * The height is a measure for the longest datadependencies path from a node to
28  * the end of a basic block. This is usefull for scheduling heuristics and can
29  * also be used to speedup reachability queries.
30  */
31 #ifndef FIRM_ANA_HEIGHTS_H
32 #define FIRM_ANA_HEIGHTS_H
33
34 #include "firm_types.h"
35 #include "begin.h"
36
37 /**
38  * Get the height of a node inside a basic block.
39  * The height of the node is the maximal number of edges between a sink node in
40  * that block and the node itself (plus 1).
41  * @param h    The heights object.
42  * @param irn  The node.
43  * @return     The height of the node.
44  */
45 FIRM_API unsigned get_irn_height(const ir_heights_t *h, const ir_node *irn);
46
47 /**
48  * Check, if a certain node is reachable according to data dependence edges
49  * from another node. Both nodes must be in the same block.
50  * @param h The heights object.
51  * @param n The first node.
52  * @param m The other node.
53  * @return  1, if n is data dependent on m, 0 if not.
54  */
55 FIRM_API int heights_reachable_in_block(ir_heights_t *h, const ir_node *n,
56                                         const ir_node *m);
57
58 /**
59  * Recompute the height information for a certain block.
60  * This can be used to recompute the height information of a block.
61  * @param h     The heights object.
62  * @param block The block
63  * @return The maximum over all heights in the block.
64  */
65 FIRM_API unsigned heights_recompute_block(ir_heights_t *h, ir_node *block);
66
67 /**
68  * Make a new heights object.
69  * This also computes the heights for each block in the graph.
70  * @param irg The graph.
71  */
72 FIRM_API ir_heights_t *heights_new(ir_graph *irg);
73
74 /**
75  * Free a heights object.
76  * @param h The heights object.
77  */
78 FIRM_API void heights_free(ir_heights_t *h);
79
80 #include "end.h"
81
82 #endif