Keep flag added
[libfirm] / ir / be / bechordal_t.h
1
2 /**
3  * Internal datastructures for the chordal register allocator.
4  * @author Sebastian Hack
5  * @date 25.1.2005
6  */
7
8 #ifndef _BECHORDAL_T_H
9 #define _BECHORDAL_T_H
10
11 #include <stdlib.h>
12
13 #include "bitset.h"
14 #include "list.h"
15 #include "obst.h"
16 #include "pset.h"
17 #include "pmap.h"
18 #include "set.h"
19
20 #include "irnode.h"
21 #include "irgraph.h"
22
23 #include "be_t.h"
24 #include "beifg.h"
25 #include "bera.h"
26 #include "bearch.h"
27 #include "bechordal.h"
28 #include "beirgmod.h"
29
30 /** Defines an invalid register index. */
31 #define NO_COLOR (-1)
32
33 /**
34  * A liveness interval border.
35  */
36 typedef struct _border_t {
37         unsigned magic;                 /**< A magic number for checking. */
38         struct list_head list;          /**< list head for queuing. */
39         struct _border_t *other_end;    /**< The other end of the border. */
40         ir_node *irn;                   /**< The node. */
41         unsigned step;                  /**< The number equal to the interval border. */
42         unsigned pressure;              /**< The pressure at this interval border. (The border itself is counting). */
43         unsigned is_def : 1;            /**< Does this border denote a use or a def. */
44         unsigned is_real : 1;           /**< Is the def/use real? Or is it just inserted
45                                         at block beginnings or ends to ensure that inside
46                                         a block, each value has one begin and one end. */
47 } border_t;
48
49 /**
50  * Environment for each of the chordal register allocator phases
51  */
52 struct _be_chordal_env_t {
53         struct obstack obst;       /**< An obstack for temporary storage. */
54         firm_dbg_module_t *dbg;    /**< Debug module for the chordal register allocator. */
55         const be_main_env_t *main_env;   /**< Environment with back-end data. */
56         dom_front_info_t *dom_front; /**< Dominance frontiers. */
57         ir_graph *irg;             /**< The graph under examination. */
58         const arch_register_class_t *cls;   /**< The current register class. */
59         pmap *border_heads;        /**< Maps blocks to border heads. */
60         pset *constr_irn;          /**< Nodes which deserve special constraint handling. */
61         be_ifg_t *ifg;             /**< The interference graph. */
62         void *data;                /**< Some pointer, to which different
63                                     phases can attach data to. */
64 };
65
66 static INLINE struct list_head *_get_block_border_head(const be_chordal_env_t *inf, ir_node *bl) {
67   return pmap_get(inf->border_heads, bl);
68 }
69
70 #define get_block_border_head(info, bl)     _get_block_border_head(info, bl)
71
72 #define foreach_border_head(head, pos)          list_for_each_entry_reverse(border_t, pos, head, list)
73 #define border_next(b)                      (list_entry((b)->list.next, border_t, list))
74 #define border_prev(b)                      (list_entry((b)->list.prev, border_t, list))
75
76 #define chordal_has_class(chordal_env, irn) \
77         arch_irn_has_reg_class(chordal_env->main_env->arch_env, irn, -1, chordal_env->cls)
78
79 int nodes_interfere(const be_chordal_env_t *env, const ir_node *a, const ir_node *b);
80
81 void be_ra_chordal_color(be_chordal_env_t *chordal_env);
82
83 enum {
84         /* spill method */
85         BE_CH_SPILL_BELADY    = 1,
86         BE_CH_SPILL_ILP       = 2,
87
88         /* Dump flags */
89         BE_CH_DUMP_NONE       = (1 << 0),
90         BE_CH_DUMP_SPILL      = (1 << 1),
91         BE_CH_DUMP_LIVE       = (1 << 2),
92         BE_CH_DUMP_COLOR      = (1 << 3),
93         BE_CH_DUMP_COPYMIN    = (1 << 4),
94         BE_CH_DUMP_SSADESTR   = (1 << 5),
95         BE_CH_DUMP_TREE_INTV  = (1 << 6),
96         BE_CH_DUMP_CONSTR     = (1 << 7),
97         BE_CH_DUMP_LOWER      = (1 << 8),
98         BE_CH_DUMP_ALL        = 2 * BE_CH_DUMP_LOWER - 1,
99
100         /* copymin method */
101         BE_CH_COPYMIN_HEUR    = 1,
102         BE_CH_COPYMIN_ILP     = 2,
103
104         /* ifg flavor */
105         BE_CH_IFG_STD         = 1,
106         BE_CH_IFG_FAST        = 2,
107
108         /* lower perm method */
109         BE_CH_LOWER_PERM_SWAP = 1,
110         BE_CH_LOWER_PERM_COPY = 2
111 };
112
113 typedef struct {
114         unsigned dump_flags;
115         int spill_method;
116         int copymin_method;
117         int ifg_flavor;
118         int lower_perm_method;
119
120         char ilp_server[128];
121         char ilp_solver[128];
122 } be_ra_chordal_opts_t;
123
124
125 #endif /* _BECHORDAL_T_H */