bescripts: Copy all common node attributes into the constructor variants.
[libfirm] / ir / be / belive.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       Interblock liveness analysis.
23  * @author      Sebastian Hack
24  * @date        06.12.2004
25  */
26 #ifndef FIRM_BE_BELIVE_H
27 #define FIRM_BE_BELIVE_H
28
29 #include "be_types.h"
30 #include "irnodeset.h"
31
32 typedef enum {
33         be_lv_state_in  = 1,
34         be_lv_state_end = 2,
35         be_lv_state_out = 4,
36 } be_lv_state_t;
37
38 /**
39  * Compute the inter block liveness for a graph.
40  * @param irg The graph.
41  */
42 be_lv_t *be_liveness_new(ir_graph *irg);
43
44 /**
45  * Free the liveness information.
46  */
47 void be_liveness_free(be_lv_t *lv);
48
49 /**
50  * (Re)compute the liveness information if necessary.
51  */
52 void be_liveness_compute_sets(be_lv_t *lv);
53 void be_liveness_compute_chk(be_lv_t *lv);
54
55 /**
56  * Invalidate the liveness information.
57  * You must call this if you modify the program and do not
58  * update the liveness with the be_liveness_{update,remove,introduce}
59  * functions.
60  * @note If changed the control flow then you must also call
61  *       be_liveness_invalidate_chk()
62  */
63 void be_liveness_invalidate_sets(be_lv_t *lv);
64 void be_liveness_invalidate_chk(be_lv_t *lv);
65
66 /**
67  * Update the liveness information for a single node.
68  * It is irrelevant if there is liveness information present for the node.
69  * The liveness information for the node is firstly deleted and then recomputed.
70  * If the node is fresh and never recorded inf the liveness information before,
71  * it is more efficient to call be_liveness_introduce().
72  */
73 void be_liveness_update(be_lv_t *lv, ir_node *irn);
74
75 /**
76  * Remove a node from the liveness information.
77  */
78 void be_liveness_remove(be_lv_t *lv, const ir_node *irn);
79
80 /**
81  * Introduce a new node to the liveness information.
82  * The new irn is not deleted from any block's liveness information, so it must be fresh!
83  * @param lv The liveness info.
84  * @param irn The node.
85  */
86 void be_liveness_introduce(be_lv_t *lv, ir_node *irn);
87
88 /**
89  * Check, if a node is live in at a block.
90  * @param block The block.
91  * @param irn The node to check for.
92  * @return 1, if @p irn is live at the entrance of @p block, 0 if not.
93  */
94 int (be_is_live_in)(const be_lv_t *lv, const ir_node *block, const ir_node *irn);
95
96 /**
97  * Check, if a node is live out at a block.
98  * @param block The block.
99  * @param irn The node to check for.
100  * @return 1, if @p irn is live at the exit of @p block, 0 if not.
101  */
102 int (be_is_live_out)(const be_lv_t *lv, const ir_node *block, const ir_node *irn);
103
104 /**
105  * Check, if a node is live at the end of a block.
106  * @param block The block.
107  * @param irn The node to check for.
108  * @return 1, if @p irn is live at the end of the block, 0 if not.
109  */
110 int (be_is_live_end)(const be_lv_t *lv, const ir_node *block, const ir_node *irn);
111
112 /**
113  * The liveness transfer function.
114  * Updates a live set over a single step from a given node to its predecessor.
115  * Everything defined at the node is removed from the set, the uses of the node get inserted.
116  * @param cls      The register class to consider.
117  * @param irn      The node at which liveness should be computed.
118  * @param live     The set of nodes live before @p irn. This set gets modified by updating it to
119  *                 the nodes live after irn.
120  * @return live.
121  */
122 void be_liveness_transfer(const arch_register_class_t *cls, ir_node *node,
123                           ir_nodeset_t *nodeset);
124
125 /**
126  * Put all node live at the end of a block into a set.
127  * @param cls      The register class to consider.
128  * @param bl       The block.
129  * @param live     The set to put them into.
130  * @return live.
131  */
132 void be_liveness_end_of_block(const be_lv_t *lv,
133                               const arch_register_class_t *cls,
134                               const ir_node *bl, ir_nodeset_t *nodeset);
135
136 /**
137  * Compute a set of nodes which are live just before the given node.
138  * @param cls      The register class to consider.
139  * @param pos      The node.
140  * @param live     The set to put them into.
141  */
142 void be_liveness_nodes_live_before(be_lv_t const *lv, arch_register_class_t const *cls, ir_node const *pos, ir_nodeset_t *live);
143
144 #endif