- Split bearch.h correctly into bearch.h and bearch_t.h
[libfirm] / ir / be / bechordal_t.h
1
2 /**
3  * Internal data structures 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 "firm_types.h"
12 #include "firm_config.h"
13
14 #include <stdlib.h>
15
16 #include "bitset.h"
17 #include "list.h"
18 #include "obst.h"
19 #include "pset.h"
20 #include "pmap.h"
21 #include "set.h"
22
23 #include "execfreq.h"
24
25 #include "be_t.h"
26 #include "beifg.h"
27 #include "bera.h"
28 #include "bearch_t.h"
29 #include "bechordal.h"
30 #include "belive.h"
31 #include "beirg_t.h"
32
33 typedef struct be_ra_chordal_opts_t  be_ra_chordal_opts_t;
34 typedef struct border_t              border_t;
35
36 /** Defines an invalid register index. */
37 #define NO_COLOR (-1)
38
39 /**
40  * A liveness interval border.
41  */
42 struct border_t {
43         DEBUG_ONLY(unsigned magic;)     /**< A magic number for checking. */
44         struct list_head  list;         /**< list head for queuing. */
45         border_t         *other_end;    /**< The other end of the border. */
46         ir_node          *irn;          /**< The node. */
47         unsigned         step;          /**< The number equal to the interval border. */
48         unsigned         pressure;      /**< The pressure at this interval border. (The border itself is counting). */
49         unsigned         is_def : 1;    /**< Does this border denote a use or a def. */
50         unsigned         is_real : 1;   /**< Is the def/use real? Or is it just
51                                              inserted at block beginnings or ends
52                                              to ensure that inside a block, each
53                                              value has one begin and one end. */
54 };
55
56 /**
57  * Environment for each of the chordal register allocator phases
58  */
59 struct be_chordal_env_t {
60         struct obstack        obst;         /**< An obstack for temporary storage. */
61         be_ra_chordal_opts_t *opts;         /**< A pointer to the chordal ra options. */
62         be_irg_t             *birg;         /**< Back-end IRG session. */
63         ir_graph             *irg;          /**< The graph under examination. */
64         const arch_register_class_t *cls;   /**< The current register class. */
65         pmap                 *border_heads; /**< Maps blocks to border heads. */
66         be_ifg_t             *ifg;          /**< The interference graph. */
67         bitset_t             *ignore_colors;/**< A set of colors which shall be ignored in register allocation. */
68 };
69
70 static INLINE struct list_head *_get_block_border_head(const be_chordal_env_t *inf, ir_node *bl) {
71   return pmap_get(inf->border_heads, bl);
72 }
73
74 #define get_block_border_head(info, bl)     _get_block_border_head(info, bl)
75
76 #define foreach_border_head(head, pos)          list_for_each_entry_reverse(border_t, pos, head, list)
77 #define border_next(b)                      (list_entry((b)->list.next, border_t, list))
78 #define border_prev(b)                      (list_entry((b)->list.prev, border_t, list))
79
80 #define chordal_has_class(chordal_env, irn) \
81         arch_irn_consider_in_reg_alloc(chordal_env->birg->main_env->arch_env, chordal_env->cls, irn)
82
83 void be_ra_chordal_color(be_chordal_env_t *chordal_env);
84
85 enum {
86         /* Dump flags */
87         BE_CH_DUMP_NONE       = (1 << 0),
88         BE_CH_DUMP_SPILL      = (1 << 1),
89         BE_CH_DUMP_LIVE       = (1 << 2),
90         BE_CH_DUMP_COLOR      = (1 << 3),
91         BE_CH_DUMP_COPYMIN    = (1 << 4),
92         BE_CH_DUMP_SSADESTR   = (1 << 5),
93         BE_CH_DUMP_TREE_INTV  = (1 << 6),
94         BE_CH_DUMP_CONSTR     = (1 << 7),
95         BE_CH_DUMP_SPILLSLOTS = (1 << 8),
96         BE_CH_DUMP_LOWER      = (1 << 9),
97         BE_CH_DUMP_APPEL      = (1 << 10),
98         BE_CH_DUMP_ALL        = 2 * BE_CH_DUMP_APPEL - 1,
99
100         /* lower perm options */
101         BE_CH_LOWER_PERM_SWAP   = 1,
102         BE_CH_LOWER_PERM_COPY   = 2,
103
104         /* verify options */
105         BE_CH_VRFY_OFF    = 1,
106         BE_CH_VRFY_WARN   = 2,
107         BE_CH_VRFY_ASSERT = 3,
108 };
109
110 struct be_ra_chordal_opts_t {
111         int dump_flags;
112         int lower_perm_opt;
113         int vrfy_option;
114
115         char ilp_server[128];
116         char ilp_solver[128];
117 };
118
119 void be_pre_spill_prepare_constr(be_chordal_env_t *cenv);
120
121 #endif /* _BECHORDAL_T_H */