be_abi_put_ignore_regs returns now number of ignore registers as unsigned
[libfirm] / ir / be / belive.h
1 /*
2  * Copyright (C) 1995-2007 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       Interblock liveness analysis.
23  * @author      Sebastian Hack
24  * @date        06.12.2004
25  * @version     $Id$
26  */
27 #ifndef FIRM_BE_BELIVE_H
28 #define FIRM_BE_BELIVE_H
29
30 #include <stdio.h>
31
32 #include "firm_types.h"
33 #include "pset.h"
34
35 #include "irlivechk.h"
36 #include "bearch.h"
37
38 typedef enum {
39         be_lv_state_in  = 1,
40         be_lv_state_end = 2,
41         be_lv_state_out = 4,
42 } be_lv_state_t;
43
44 typedef struct _be_lv_t be_lv_t;
45
46 typedef struct _be_lv_info_t be_lv_info_t;
47
48 /**
49  * Compute the inter block liveness for a graph.
50  * @param irg The graph.
51  */
52 be_lv_t *be_liveness(ir_graph *irg);
53
54 /**
55  * Check the given liveness information against a freshly computed one.
56  */
57 void be_liveness_check(be_lv_t *lv);
58
59 /**
60  * Free the liveness information.
61  */
62 void be_liveness_free(be_lv_t *lv);
63
64 /**
65  * Recompute the complete liveness information.
66  */
67 void be_liveness_recompute(be_lv_t *lv);
68
69 /**
70  * Update the liveness information for a single node.
71  * It is irrelevant if there is liveness information present for the node.
72  * The liveness information for the node is firstly deleted and then recomputed.
73  * If the node is fresh and never recorded inf the liveness information before,
74  * it is more efficient to call be_liveness_introduce().
75  */
76 void be_liveness_update(be_lv_t *lv, ir_node *irn);
77
78 /**
79  * Remove a node from the liveness information.
80  */
81 void be_liveness_remove(be_lv_t *lv, ir_node *irn);
82
83 /**
84  * Introduce a new node to the liveness information.
85  * The new irn is not deleted from any block's liveness information, so it must be fresh!
86  * @param lv The liveness info.
87  * @param irn The node.
88  */
89 void be_liveness_introduce(be_lv_t *lv, ir_node *irn);
90
91 /**
92  * Add all nodes which are missing in the current liveness data.
93  * The liveness data of the already existing nodes (in the liveness data) is not touched.
94  * @param The liveness info.
95  */
96 void be_liveness_add_missing(be_lv_t *lv);
97
98 /**
99  * Dump the liveness information for a graph.
100  * @param f The output.
101  * @param irg The graph.
102  */
103 void be_liveness_dump(const be_lv_t *lv, FILE *f);
104
105 /**
106  * Dump the liveness information for a graph.
107  * @param irg The graph.
108  * @param cls_name A string used as substring in the filename.
109  */
110 void be_liveness_dumpto(const be_lv_t *lv, const char *cls_name);
111
112 /**
113  * Check, if a node is live in at a block.
114  * @param block The block.
115  * @param irn The node to check for.
116  * @return 1, if @p irn is live at the entrance of @p block, 0 if not.
117  */
118 int (be_is_live_in)(const be_lv_t *lv, const ir_node *block, const ir_node *irn);
119
120 /**
121  * Check, if a node is live out at a block.
122  * @param block The block.
123  * @param irn The node to check for.
124  * @return 1, if @p irn is live at the exit of @p block, 0 if not.
125  */
126 int (be_is_live_out)(const be_lv_t *lv, const ir_node *block, const ir_node *irn);
127
128 /**
129  * Check, if a node is live at the end of a block.
130  * @param block The block.
131  * @param irn The node to check for.
132  * @return 1, if @p irn is live at the end of the block, 0 if not.
133  */
134 int (be_is_live_end)(const be_lv_t *lv, const ir_node *block, const ir_node *irn);
135
136 /**
137  * Check, if the SSA dominance property is fulfilled.
138  * @param irg The graph.
139  * @return   1 if dominance property is fulfilled, 0 otherwise
140  */
141 int be_check_dominance(ir_graph *irg);
142
143 /**
144  * The liveness transfer function.
145  * Updates a live set over a single step from a given node to its predecessor.
146  * Everything defined at the node is removed from the set, the uses of the node get inserted.
147  * @param arch_env The architecture environment.
148  * @param cls      The register class to consider.
149  * @param irn      The node at which liveness should be computed.
150  * @param live     The set of nodes live before @p irn. This set gets modified by updating it to
151  *                 the nodes live after irn.
152  * @return live.
153  */
154 pset *be_liveness_transfer(const arch_env_t *arch_env, const arch_register_class_t *cls, ir_node *irn, pset *live);
155
156 /**
157  * Put all node live at the end of a block into a set.
158  * @param arch_env The architecture environment.
159  * @param cls      The register class to consider.
160  * @param bl       The block.
161  * @param live     The set to put them into.
162  * @return live.
163  */
164 pset *be_liveness_end_of_block(const be_lv_t *lv, const arch_env_t *arch_env, const arch_register_class_t *cls, const ir_node *bl, pset *live);
165
166 /**
167  * Compute a set of nodes which are live at another node.
168  * BEWARE: This is the liveness immediately after the node,
169  *         so the node itself is alive but it's operands maybe not.
170  * @param arch_env The architecture environment.
171  * @param cls      The register class to consider.
172  * @param pos      The node.
173  * @param live     The set to put them into.
174  * @return live.
175  */
176 pset *be_liveness_nodes_live_at(const be_lv_t *lv, const arch_env_t *arch_env, const arch_register_class_t *cls, const ir_node *pos, pset *live);
177
178 /**
179  * Compute a set of nodes which are live at another node.
180  * BEWARE: This is the liveness immediately before the node,
181  *         so the node itself is not alive but it's operands are.
182  * @param arch_env The architecture environment.
183  * @param cls      The register class to consider.
184  * @param pos      The node.
185  * @param live     The set to put them into.
186  * @return live.
187  */
188 pset *be_liveness_nodes_live_at_input(const be_lv_t *lv, const arch_env_t *arch_env, const arch_register_class_t *cls, const ir_node *pos, pset *live);
189
190
191 #endif /* FIRM_BE_BELIVE_H */