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