3 * Internal datastructures for the chordal register allocator.
4 * @author Sebastian Hack
11 #include "firm_types.h"
12 #include "firm_config.h"
29 #include "bechordal.h"
32 typedef struct _be_ra_chordal_opts_t be_ra_chordal_opts_t;
34 /** Defines an invalid register index. */
38 * A liveness interval border.
40 typedef struct _border_t {
41 unsigned magic; /**< A magic number for checking. */
42 struct list_head list; /**< list head for queuing. */
43 struct _border_t *other_end; /**< The other end of the border. */
44 ir_node *irn; /**< The node. */
45 unsigned step; /**< The number equal to the interval border. */
46 unsigned pressure; /**< The pressure at this interval border. (The border itself is counting). */
47 unsigned is_def : 1; /**< Does this border denote a use or a def. */
48 unsigned is_real : 1; /**< Is the def/use real? Or is it just inserted
49 at block beginnings or ends to ensure that inside
50 a block, each value has one begin and one end. */
54 * Environment for each of the chordal register allocator phases
56 struct _be_chordal_env_t {
57 struct obstack obst; /**< An obstack for temporary storage. */
58 be_ra_chordal_opts_t *opts; /**< A pointer to the chordal ra options. */
59 const be_irg_t *birg; /**< Back-end IRG session. */
60 dom_front_info_t *dom_front; /**< Dominance frontiers. */
61 ir_graph *irg; /**< The graph under examination. */
62 const arch_register_class_t *cls; /**< The current register class. */
63 exec_freq_t *exec_freq; /**< Adam's execution frequencies. */
64 pmap *border_heads; /**< Maps blocks to border heads. */
65 be_ifg_t *ifg; /**< The interference graph. */
66 void *data; /**< Some pointer, to which different phases can attach data to. */
67 bitset_t *ignore_colors; /**< A set of colors which shall be ignored in register allocation. */
68 DEBUG_ONLY(firm_dbg_module_t *dbg;) /**< Debug module for the chordal register allocator. */
71 static INLINE struct list_head *_get_block_border_head(const be_chordal_env_t *inf, ir_node *bl) {
72 return pmap_get(inf->border_heads, bl);
75 #define get_block_border_head(info, bl) _get_block_border_head(info, bl)
77 #define foreach_border_head(head, pos) list_for_each_entry_reverse(border_t, pos, head, list)
78 #define border_next(b) (list_entry((b)->list.next, border_t, list))
79 #define border_prev(b) (list_entry((b)->list.prev, border_t, list))
81 #define chordal_has_class(chordal_env, irn) \
82 arch_irn_consider_in_reg_alloc(chordal_env->birg->main_env->arch_env, chordal_env->cls, irn)
84 int nodes_interfere(const be_chordal_env_t *env, const ir_node *a, const ir_node *b);
86 void be_ra_chordal_color(be_chordal_env_t *chordal_env);
89 * Check a register allocation obtained with the chordal register allocator.
90 * @param chordal_env The chordal environment.
92 void be_ra_chordal_check(be_chordal_env_t *chordal_env);
96 BE_CH_SPILL_BELADY = 1,
97 BE_CH_SPILL_MORGAN = 2,
98 BE_CH_SPILL_REMAT = 3,
101 BE_CH_DUMP_NONE = (1 << 0),
102 BE_CH_DUMP_SPILL = (1 << 1),
103 BE_CH_DUMP_LIVE = (1 << 2),
104 BE_CH_DUMP_COLOR = (1 << 3),
105 BE_CH_DUMP_COPYMIN = (1 << 4),
106 BE_CH_DUMP_SSADESTR = (1 << 5),
107 BE_CH_DUMP_TREE_INTV = (1 << 6),
108 BE_CH_DUMP_CONSTR = (1 << 7),
109 BE_CH_DUMP_LOWER = (1 << 8),
110 BE_CH_DUMP_ALL = 2 * BE_CH_DUMP_LOWER - 1,
113 BE_CH_COPYMIN_NONE = 0,
114 BE_CH_COPYMIN_HEUR1 = 1,
115 BE_CH_COPYMIN_HEUR2 = 2,
116 BE_CH_COPYMIN_STAT = 3,
117 BE_CH_COPYMIN_ILP1 = 4,
118 BE_CH_COPYMIN_ILP2 = 5,
119 BE_CH_COPYMIN_PARK_MOON = 6,
124 BE_CH_IFG_CLIQUE = 3,
125 BE_CH_IFG_POINTER = 4,
129 /* lower perm options */
130 BE_CH_LOWER_PERM_SWAP = 1,
131 BE_CH_LOWER_PERM_COPY = 2,
136 BE_CH_VRFY_ASSERT = 3,
139 struct _be_ra_chordal_opts_t {
147 char ilp_server[128];
148 char ilp_solver[128];
152 * Open a file whose name is composed from the graph's name and the current register class.
153 * @note The name of the file will be prefix(ifg_name)_(reg_class_name).suffix
154 * @param prefix The file name's prefix.
155 * @param suffix The file name's ending (the . is inserted automatically).
156 * @return A text file opened for writing.
158 FILE *be_chordal_open(const be_chordal_env_t *env, const char *prefix, const char *suffix);
160 #endif /* _BECHORDAL_T_H */