move backend into libfirm
[libfirm] / ir / be / beirgmod.h
1 /**
2  * @file
3  * @brief
4  * This file contains the following IRG modifications for be routines:
5  * - SSA construction for a set of nodes
6  * - insertion of Perm nodes
7  * - empty block elimination
8  * - a simple dead node elimination (set inputs of unreachable nodes to BAD)
9  *
10  * @author      Sebastian Hack, Daniel Grund, Matthias Braun, Christian Wuerdig
11  * @date        04.05.2005
12  * @version     $Id$
13  * Copyright:   (c) Universitaet Karlsruhe
14  * Licence:     This file protected by GPL -  GNU GENERAL PUBLIC LICENSE.
15  */
16 #ifndef _FIRM_BE_IRGMOD_H_
17 #define _FIRM_BE_IRGMOD_H_
18
19 #include "firm_types.h"
20 #include "pset.h"
21 #include "irnodeset.h"
22
23 #include "bedomfront.h"
24 #include "belive.h"
25
26 /**
27  * Introduce several copies for one node.
28  *
29  * A copy in this context means, that you want to introduce several new
30  * abstract values (in Firm: nodes) for which you know, that they
31  * represent the same concrete value. This is the case if you
32  * - copy
33  * - spill and reload
34  * - re-materialize
35  * a value.
36  *
37  * This function reroutes all uses of the original value to the copies in the
38  * corresponding dominance subtrees and creates Phi functions where necessary.
39  *
40  * @note The visited flag and link fields are used.
41  *
42  * @param info            Dominance frontier information.
43  * @param lv          Liveness information to be updated. If NULL, no liveness
44  *                    updating is performed.
45  * @param value       The value that has been duplicated.
46  * @param copies_len  the length of the copies array
47  * @param copie       an array holding all copies of the value
48  * @param phis        An ARR_F where all newly created phis will be inserted,
49  *                    may be NULL
50  * @param ignore_uses A set of nodes probably using one of the nodes in
51  *                    @p nodes. Their usage will not adjusted. They remain
52  *                    untouched by this function. May be NULL.
53  */
54 ir_node **be_ssa_construction(const be_dom_front_info_t *info, be_lv_t *lv,
55                             ir_node *value, int copies_len, ir_node **copies,
56                             const ir_nodeset_t *ignore_uses, int need_new_phis);
57
58 /** @deprecated */
59 void be_ssa_constr_set_ignore(const be_dom_front_info_t *info, be_lv_t *lv,
60                               pset *nodes, pset *ignores);
61
62 /**
63  * Insert a Perm which permutes all (non-ignore) live values of a given register class
64  * after a certain instruction.
65  * @param arch_env  The architecture environment.
66  * @param lv        Liveness Information.
67  * @param cls       The register class.
68  * @param dom_front Dominance frontier information.
69  * @param irn       The node to insert the Perm after.
70  * @return          The Perm or NULL if nothing was live before @p irn.
71  */
72 ir_node *insert_Perm_after(const arch_env_t *arch_env,
73                                                    be_lv_t *lv,
74                                                    const arch_register_class_t *cls,
75                                                    be_dom_front_info_t *dom_front,
76                                                    ir_node *irn);
77
78 /**
79  * Removes basic blocks that only contain a jump instruction
80  * (this will potentially create critical edges).
81  *
82  * @param irg  the graph that will be changed
83  *
84  * @return non-zero if the graph was changed, zero else
85  */
86 int be_remove_empty_blocks(ir_graph *irg);
87
88 #endif /* _BEIRGMOD_H */