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