3 * Internal data structures for the chordal register allocator.
4 * @author Sebastian Hack
11 #include "firm_types.h"
12 #include "firm_config.h"
29 #include "bechordal.h"
33 typedef struct _be_ra_chordal_opts_t be_ra_chordal_opts_t;
35 /** Defines an invalid register index. */
39 * A liveness interval border.
41 typedef struct _border_t {
42 DEBUG_ONLY(unsigned magic;) /**< A magic number for checking. */
43 struct list_head list; /**< list head for queuing. */
44 struct _border_t *other_end; /**< The other end of the border. */
45 ir_node *irn; /**< The node. */
46 unsigned step; /**< The number equal to the interval border. */
47 unsigned pressure; /**< The pressure at this interval border. (The border itself is counting). */
48 unsigned is_def : 1; /**< Does this border denote a use or a def. */
49 unsigned is_real : 1; /**< Is the def/use real? Or is it just inserted
50 at block beginnings or ends to ensure that inside
51 a block, each value has one begin and one end. */
55 * Environment for each of the chordal register allocator phases
57 struct _be_chordal_env_t {
58 struct obstack obst; /**< An obstack for temporary storage. */
59 be_ra_chordal_opts_t *opts; /**< A pointer to the chordal ra options. */
60 be_irg_t *birg; /**< Back-end IRG session. */
61 ir_graph *irg; /**< The graph under examination. */
62 const arch_register_class_t *cls; /**< The current register class. */
63 pmap *border_heads; /**< Maps blocks to border heads. */
64 be_ifg_t *ifg; /**< The interference graph. */
65 bitset_t *ignore_colors; /**< A set of colors which shall be ignored in register allocation. */
66 DEBUG_ONLY(firm_dbg_module_t *dbg;) /**< Debug module for the chordal register allocator. */
69 static INLINE struct list_head *_get_block_border_head(const be_chordal_env_t *inf, ir_node *bl) {
70 return pmap_get(inf->border_heads, bl);
73 #define get_block_border_head(info, bl) _get_block_border_head(info, bl)
75 #define foreach_border_head(head, pos) list_for_each_entry_reverse(border_t, pos, head, list)
76 #define border_next(b) (list_entry((b)->list.next, border_t, list))
77 #define border_prev(b) (list_entry((b)->list.prev, border_t, list))
79 #define chordal_has_class(chordal_env, irn) \
80 arch_irn_consider_in_reg_alloc(chordal_env->birg->main_env->arch_env, chordal_env->cls, irn)
82 void be_ra_chordal_color(be_chordal_env_t *chordal_env);
86 BE_CH_DUMP_NONE = (1 << 0),
87 BE_CH_DUMP_SPILL = (1 << 1),
88 BE_CH_DUMP_LIVE = (1 << 2),
89 BE_CH_DUMP_COLOR = (1 << 3),
90 BE_CH_DUMP_COPYMIN = (1 << 4),
91 BE_CH_DUMP_SSADESTR = (1 << 5),
92 BE_CH_DUMP_TREE_INTV = (1 << 6),
93 BE_CH_DUMP_CONSTR = (1 << 7),
94 BE_CH_DUMP_SPILLSLOTS = (1 << 8),
95 BE_CH_DUMP_LOWER = (1 << 9),
96 BE_CH_DUMP_APPEL = (1 << 10),
97 BE_CH_DUMP_ALL = 2 * BE_CH_DUMP_APPEL - 1,
99 /* lower perm options */
100 BE_CH_LOWER_PERM_SWAP = 1,
101 BE_CH_LOWER_PERM_COPY = 2,
106 BE_CH_VRFY_ASSERT = 3,
109 struct _be_ra_chordal_opts_t {
114 char ilp_server[128];
115 char ilp_solver[128];
118 void be_pre_spill_prepare_constr(be_chordal_env_t *cenv);
120 #endif /* _BECHORDAL_T_H */