no need for kill_dead_nodes, use edges_deactivate; edges_activate if you need this...
[libfirm] / ir / be / beirgmod.h
1 /**
2  * This file contains the following IRG modifications for be routines:
3  * - backend dominance information
4  * - SSA construction for a set of nodes
5  * - insertion of Perm nodes
6  * - empty block elimination
7  * - a simple dead node elimination (set inputs of unreachable nodes to BAD)
8  *
9  * Author:      Sebastian Hack, Daniel Grund, Matthias Braun, Christian Wuerdig
10  * Date:        04.05.2005
11  * Copyright:   (c) Universitaet Karlsruhe
12  * Licence:     This file protected by GPL -  GNU GENERAL PUBLIC LICENSE.
13  * CVS-Id:      $Id$
14  */
15
16 #ifndef _BEIRGMOD_H
17 #define _BEIRGMOD_H
18
19 #include "firm_types.h"
20 #include "pset.h"
21
22 #include "belive.h"
23
24 /*
25  * Forward type declaration.
26  */
27 typedef struct _be_dom_front_info_t be_dom_front_info_t;
28
29 /**
30  * Compute the dominance frontiers for a given graph.
31  * @param  irg The graphs.
32  * @return A pointer to the dominance frontier information.
33  */
34 be_dom_front_info_t *be_compute_dominance_frontiers(ir_graph *irg);
35
36 /**
37  * Get the dominance frontier of a block.
38  * @param info  A pointer to the dominance frontier information.
39  * @param block The block whose dominance frontier you want.
40  * @return A list containing the all blocks in the dominance frontier of @p block.
41  */
42 ir_node **be_get_dominance_frontier(be_dom_front_info_t *info, ir_node *block);
43
44 /**
45  * Free some dominance frontier information.
46  * @param info Some dominance frontier information.
47  */
48 void be_free_dominance_frontiers(be_dom_front_info_t *info);
49
50 /**
51  * Introduce several copies for one node.
52  *
53  * A copy in this context means, that you want to introduce several new
54  * abstract values (in Firm: nodes) for which you know, that they
55  * represent the same concrete value. This is the case if you
56  * - copy
57  * - spill and reload
58  * - re-materialize
59  * a value.
60  *
61  * This function reroutes all uses of the original value to the copies in the
62  * corresponding dominance subtrees and creates Phi functions if necessary.
63  *
64  * @param info            Dominance frontier information.
65  * @param lv          Liveness information to be updated. If NULL, liveness updating is simply ignored.
66  * @param n           Length of nodes array.
67  * @param nodes       The nodes which shall represent the same SSA value.
68  * @param phis        A set to which all inserted Phis are added.
69  * @param ignore_uses A set of nodes probably using one of the nodes in @p nodes.
70  *                    Their usage will not adjusted. They remain untouched by this function.
71  */
72 void be_ssa_constr_phis_ignore(be_dom_front_info_t *info, be_lv_t *lv, int n, ir_node *nodes[], pset *phis, pset *ignore_uses);
73
74 /**
75  * Same as be_ssa_constr_phis_ignore() but without the ignore set.
76  */
77 void be_ssa_constr_phis(be_dom_front_info_t *info, be_lv_t *lv, int n, ir_node *nodes[], pset *phis);
78
79 /**
80  * Same as be_ssa_constr_phis_ignore() but without the Phi set.
81  */
82 void be_ssa_constr_ignore(be_dom_front_info_t *info, be_lv_t *lv, int n, ir_node *nodes[], pset *ignore_uses);
83
84 /**
85  * Same as be_ssa_constr_ignore() but with empty ignore set.
86  */
87 void be_ssa_constr(be_dom_front_info_t *info, be_lv_t *lv, int n, ir_node *nodes[]);
88
89 /**
90  * Same as be_ssa_constr_ignore() but with pset instead of array.
91  */
92 void be_ssa_constr_set_ignore(be_dom_front_info_t *df, be_lv_t *lv, pset *nodes, pset *ignore_uses);
93
94 /**
95  * Same as be_ssa_constr() but with pset instead of array.
96  */
97 void be_ssa_constr_set(be_dom_front_info_t *info, be_lv_t *lv, pset *nodes);
98
99 /**
100  * Same as be_ssa_constr_phis_ignore() but with set instead of array.
101  */
102 void be_ssa_constr_set_phis_ignore(be_dom_front_info_t *info, be_lv_t *lv, pset *nodes, pset *phis, pset *ignore);
103
104 /**
105  * Same as be_ssa_constr_phis_ignore() but without ignore set.
106  */
107 void be_ssa_constr_set_phis(be_dom_front_info_t *info, be_lv_t *lv, pset *nodes, pset *phis);
108
109 /**
110  * Insert a Perm which permutes all (non-ignore) live values of a given register class
111  * after a certain instruction.
112  * @param arch_env  The architecture environment.
113  * @param lv        Liveness Information.
114  * @param cls       The register class.
115  * @param dom_front Dominance frontier information.
116  * @param irn       The node to insert the Perm after.
117  * @return          The Perm or NULL if nothing was live before @p irn.
118  */
119 ir_node *insert_Perm_after(const arch_env_t *arch_env,
120                                                    be_lv_t *lv,
121                                                    const arch_register_class_t *cls,
122                                                    be_dom_front_info_t *dom_front,
123                                                    ir_node *irn);
124
125 struct _be_chordal_env_t;
126
127 void extreme_liverange_splitting(struct _be_chordal_env_t *cenv);
128
129 /**
130  * Removes basic blocks that only contain a jump instruction
131  * (this will potentially create critical edges).
132  *
133  * @param irg  the graph that will be changed
134  *
135  * @return non-zero if the graph was changed, zero else
136  */
137 int be_remove_empty_blocks(ir_graph *irg);
138
139 #endif /* _BEIRGMOD_H */