-#endif /* DEBUG_libfirm */
-
-#define TEST_COLORS 2048
-
-static firm_dbg_module_t *dbg;
-
-/**
- * Environment for each of the chordal register allocator phases
- */
-typedef struct _env_t {
- struct obstack obst; /**< An obstack for temporary storage. */
-#ifdef BUILD_GRAPH
- set *graph; /**< The interference graph. */
-#endif
-
- bitset_t *live; /**< A liveness bitset. */
- bitset_t *colors; /**< The color mask. */
- bitset_t *in_colors; /**< Colors used by live in values. */
- int colors_n; /**< The number of colors. */
-} env_t;
-
-
-typedef struct _be_chordal_dump_params_t {
- int x_dist;
- int y_dist;
- double font_scale;
-} be_chordal_dump_params_t;
-
-static const be_chordal_dump_params_t dump_params = {
- 30,
- 10,
- 4
-};
-
-static void draw_interval_graphs(ir_node *block,
- struct list_head *border_head,
- const be_chordal_dump_params_t *params)
-{
- int i;
- int x_dist = params->x_dist;
- int y_dist = params->y_dist;
- ir_graph *irg = get_irn_irg(block);
-
- FILE *f;
- char buf[1024];
-
- ir_snprintf(buf, sizeof(buf), "intv_%s_bl%N.eps",
- get_entity_name(get_irg_entity(irg)), block);
-
- if((f = fopen(buf, "wt")) != NULL) {
- border_t *b;
- int *seen = xcalloc(get_graph_node_count(irg), sizeof(seen[0]));
- int last_pos = list_empty(border_head) ? 0 : list_entry(border_head->prev, border_t, list)->step;
- int max_col = 0;
-
- list_for_each_entry_reverse(border_t, b, border_head, list) {
- const ir_node *irn = b->irn;
- int col = get_irn_color(irn);
- max_col = max_col > col ? max_col : col;
- }
-
- fprintf(f, "%%!PS-Adobe-2.0\n");
- fprintf(f, "%%%%BoundingBox: -10 -10 %d %d\n",
- x_dist * last_pos + x_dist, y_dist * max_col + y_dist);
- fprintf(f, "/mainfont /Courier findfont %f scalefont def\n", params->font_scale);
- fprintf(f, "mainfont setfont\n");
- fprintf(f, "0.2 setlinewidth\n");
-
- for(i = 0; i <= last_pos; ++i) {
- fprintf(f, "0 0 0 setrgbcolor\n");
- fprintf(f, "%d %d moveto\n", i * x_dist, -2);
- fprintf(f, "%d %d lineto\n", i * x_dist, max_col * y_dist + 2);
- fprintf(f, "stroke\n");
- }
- fprintf(f, "0.5 setlinewidth\n");
-
- list_for_each_entry_reverse(border_t, b, border_head, list) {
- const ir_node *irn = b->irn;
- int nr = get_irn_graph_nr(irn);
-
- if(b->is_def)
- seen[nr] = b->step;
- else {
- int col = get_irn_color(irn);
-
- int pos = last_pos - seen[nr];
- int end_pos = last_pos - b->step;
- int live_in = is_live_in(block, irn);
- int live_end = is_live_end(block, irn);
- int y_val = y_dist * col;
-
- int red = 0;
- int green = live_end;
- int blue = live_in;
-
- fprintf(f, "0 0 0 setrgbcolor\n");
- fprintf(f, "%d %d moveto\n", x_dist * pos + 2, y_val + 2);
- ir_fprintf(f, "(%n/%d%s) show\n", irn, nr, is_phi_operand(irn) ? "*" : "");
- fprintf(f, "%d %d %d setrgbcolor\n", red, green, blue);
- fprintf(f, "%d %d moveto\n", x_dist * pos, y_val);
- fprintf(f, "%d %d lineto\n", (x_dist * end_pos) - 5, y_val);
- fprintf(f, "stroke\n");
- }
- }
-
- free(seen);
- fclose(f);
- }
-}
-
-#ifdef BUILD_GRAPH
-
-typedef struct _if_edge_t {
- int src, tgt;
-} if_edge_t;
-
-#define IF_EDGE_HASH(e) ((e)->src)
-
-static int if_edge_cmp(const void *p1, const void *p2, size_t size)
-{
- const if_edge_t *e1 = p1;
- const if_edge_t *e2 = p2;
-
- return !(e1->src == e2->src && e1->tgt == e2->tgt);
-}
-
-static INLINE if_edge_t *edge_init(if_edge_t *edge, int src, int tgt)
-{
- /* Bring the smaller entry to src. */
- if(src > tgt) {
- edge->src = tgt;
- edge->tgt = src;
- } else {
- edge->src = src;
- edge->tgt = tgt;
- }
-
- return edge;
-}
-
-static INLINE void add_if(const env_t *env, int src, int tgt)
-{
- if_edge_t edge;
- edge_init(&edge, src, tgt);
- set_insert(env->graph, &edge, sizeof(edge), IF_EDGE_HASH(&edge));
-}
-
-static INLINE int are_connected(const env_t *env, int src, int tgt)