2 * Interblock liveness analysis.
3 * @author Sebastian Hack
11 #include "firm_types.h"
23 typedef struct _be_lv_t be_lv_t;
25 typedef struct _be_lv_info_t be_lv_info_t;
29 * Compute the inter block liveness for a graph.
30 * @param irg The graph.
32 be_lv_t *be_liveness(ir_graph *irg);
35 * Check the given liveness information against a freshly computed one.
37 void be_liveness_check(be_lv_t *lv);
40 * Free the liveness information.
42 void be_liveness_free(be_lv_t *lv);
45 * Recompute the complete liveness information.
47 void be_liveness_recompute(be_lv_t *lv);
50 * Update the liveness information for a single node.
51 * It is irrelevant if there is liveness information present for the node.
52 * The liveness information for the node is firstly deleted and then recomputed.
53 * If the node is fresh and never recorded inf the liveness information before,
54 * it is more efficient to call be_liveness_introduce().
56 void be_liveness_update(be_lv_t *lv, ir_node *irn);
59 * Remove a node from the liveness information.
61 void be_liveness_remove(be_lv_t *lv, ir_node *irn);
64 * Introduce a new node to the liveness information.
65 * The new irn is not deleted from any block's liveness information, so it must be fresh!
66 * @param lv The liveness info.
67 * @param irn The node.
69 void be_liveness_introduce(be_lv_t *lv, ir_node *irn);
72 * Add all nodes which are missing in the current liveness data.
73 * The liveness data of the already existing nodes (in the liveness data) is not touched.
74 * @param The liveness info.
76 void be_liveness_add_missing(be_lv_t *lv);
79 * Dump the liveness information for a graph.
80 * @param f The output.
81 * @param irg The graph.
83 void be_liveness_dump(const be_lv_t *lv, FILE *f);
86 * Dump the liveness information for a graph.
87 * @param irg The graph.
88 * @param cls_name A string used as substring in the filename.
90 void be_liveness_dumpto(const be_lv_t *lv, const char *cls_name);
93 * Check, if a node is live in at 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 entrance of @p block, 0 if not.
98 int (be_is_live_in)(const be_lv_t *lv, const ir_node *block, const ir_node *irn);
101 * Check, if a node is live out at a block.
102 * @param block The block.
103 * @param irn The node to check for.
104 * @return 1, if @p irn is live at the exit of @p block, 0 if not.
106 int (be_is_live_out)(const be_lv_t *lv, const ir_node *block, const ir_node *irn);
109 * Check, if a node is live at the end of a block.
110 * @param block The block.
111 * @param irn The node to check for.
112 * @return 1, if @p irn is live at the end of the block, 0 if not.
114 int (be_is_live_end)(const be_lv_t *lv, const ir_node *block, const ir_node *irn);
117 * Check, if the SSA dominance property is fulfilled.
118 * @param irg The graph.
119 * @return 1 if dominance property is fulfilled, 0 otherwise
121 int be_check_dominance(ir_graph *irg);
124 * The liveness transfer function.
125 * Updates a live set over a single step from a given node to its predecessor.
126 * Everything defined at the node is removed from the set, the uses of the node get inserted.
127 * @param arch_env The architecture environment.
128 * @param cls The register class to consider.
129 * @param irn The node at which liveness should be computed.
130 * @param live The set of nodes live before @p irn. This set gets modified by updating it to
131 * the nodes live after irn.
134 pset *be_liveness_transfer(const arch_env_t *arch_env, const arch_register_class_t *cls, ir_node *irn, pset *live);
137 * Put all node live at the end of a block into a set.
138 * @param arch_env The architecture environment.
139 * @param cls The register class to consider.
140 * @param bl The block.
141 * @param live The set to put them into.
144 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);
147 * Compute a set of nodes which are live at another node.
148 * BEWARE: This is the liveness immediately after the node,
149 * so the node itself is alive but it's operands maybe not.
150 * @param arch_env The architecture environment.
151 * @param cls The register class to consider.
152 * @param pos The node.
153 * @param live The set to put them into.
156 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);
159 * Compute a set of nodes which are live at another node.
160 * BEWARE: This is the liveness immediately before the node,
161 * so the node itself is not alive but it's operands are.
162 * @param arch_env The architecture environment.
163 * @param cls The register class to consider.
164 * @param pos The node.
165 * @param live The set to put them into.
168 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);
172 * FIXME: Need comment
174 void be_liveness_add_missing(be_lv_t *lv);
176 #endif /* _BELIVE_H */