#include <ctype.h>
#include "obst.h"
+#include "pset.h"
#include "list.h"
#include "bitset.h"
#include "iterator.h"
#define NO_COLOR (-1)
-#define DUMP_INTERVALS
+#undef DUMP_INTERVALS
#undef DUMP_PRESSURE
#undef DUMP_IFG
static void dump_ifg(const be_chordal_env_t *env)
{
- static const char *colors[] = {
- "coral",
- "azure",
- "bisque",
- "aliceblue",
- "blanchedalmond",
- "deeppink",
- "cornsilk",
- "blueviolet",
- "floralwhite",
- "hotpink",
- "gainsboro",
- "indianred",
- "cornflowerblue",
- "ghostwhite",
- "lightpink",
- "palegoldenrod",
- "darkslateblue",
- "honeydew",
- "ivory",
- "lavender",
- "mediumvioletred",
- "indigo",
- "lavenderblush",
- "lemonchiffon",
- "linen",
- "pink",
- "mintcream",
- "red",
- "mediumblue",
- "mistyrose",
- "mediumslateblue",
- "moccasin",
- "tomato",
- "forestgreen",
- "midnightblue",
- "navajowhite",
- "navy",
- "oldlace",
- "greenyellow",
- "navyblue",
- "papayawhip",
- "lawngreen",
- "powderblue",
- "peachpuff",
- "seashell",
- "snow",
- "thistle",
- "wheat",
- "darkkhaki",
- "mintcream",
- "khaki",
- "Magentas",
- "whitesmoke",
- "peru",
- "palegreen",
- "blueviolet",
- "rosybrown",
- "saddlebrown",
- "springgreen",
- "darkviolet",
- "darkslategray",
- "dimgray",
- "sienna",
- "gray",
- "tan",
- "gray",
- "mediumvioletred",
- "lightgray",
- "Oranges",
- "cyan",
- "lightslategray",
- "darkorange",
- "slategray",
- "orangered",
- "mediumturquoise",
- "violet",
- "paleturquoise"
- };
-
- static const int n_colors = sizeof(colors) / sizeof(colors[0]);
-
FILE *f;
- set *edges = env->edges;
- ir_graph *irg = env->irg;
- char filename[128];
+ set *edges = env->edges;
+ ir_graph *irg = env->irg;
+ char filename[128];
- ir_snprintf(filename, sizeof(filename), "ifg_%s_%F.dot", env->cls->name, irg);
+ ir_snprintf(filename, sizeof(filename), "ifg_%s_%F.dot", env->cls->name, irg);
if((f = fopen(filename, "wt")) != NULL) {
bitset_pos_t pos;
bitset_foreach(bs, pos) {
int nr = (int) pos;
ir_node *irn = get_irn_for_graph_nr(irg, nr);
- int color = get_irn_color(irn);
- ir_fprintf(f, "\tn%d [label=\"%n\",color=\"%s\"]\n", nr, irn,
- color >= 0 && color < n_colors ? colors[color] : "black");
+ ir_fprintf(f, "\tn%d [label=\"%+F\"]\n", nr, irn);
}
for(edge = set_first(edges); edge; edge = set_next(edges)) {
b->irn = irn;
b->step = step;
list_add_tail(&b->list, head);
- DBG((dbg, LEVEL_5, "\t\t%s adding %n, step: %d\n",
+ DBG((dbg, LEVEL_5, "\t\t%s adding %+F, step: %d\n",
is_def ? "def" : "use", irn, step));
return b;
unsigned step = 0;
unsigned pressure = 0;
struct list_head *head;
- pset *live_in = get_live_in(block);
- pset *live_end = get_live_end(block);
- const arch_register_class_t *cls = env->cls;
+ pset *live_in = put_live_in(block, pset_new_ptr_default());
+ pset *live_end = put_live_end(block, pset_new_ptr_default());
+ const arch_register_class_t *cls = env->cls;
- DBG((dbg, LEVEL_1, "Computing pressure in block %n\n", block));
+ DBG((dbg, LEVEL_1, "Computing pressure in block %+F\n", block));
bitset_clear_all(live);
/* Set up the border list in the block info */
- head = obstack_alloc(&env->obst, sizeof(*head));
+ head = obstack_alloc(&env->obst, sizeof(*head));
INIT_LIST_HEAD(head);
- pmap_insert(env->border_heads, block, head);
+ pmap_insert(env->border_heads, block, head);
/*
* Make final uses of all values live out of the block.
- * They are neccessary to build up real intervals.
+ * They are necessary to build up real intervals.
*/
for(irn = pset_first(live_end); irn; irn = pset_next(live_end)) {
- DBG((dbg, LEVEL_3, "\tMaking live: %n/%d\n", irn, get_irn_graph_nr(irn)));
+ DBG((dbg, LEVEL_3, "\tMaking live: %+F/%d\n", irn, get_irn_graph_nr(irn)));
bitset_set(live, get_irn_graph_nr(irn));
- if(arch_irn_has_reg_class(env->arch_env, irn, 0, cls))
- border_use(irn, step, 0);
+ if(arch_irn_has_reg_class(env->arch_env, irn, 0, cls))
+ border_use(irn, step, 0);
}
-
++step;
/*
* relevant for the interval borders.
*/
sched_foreach_reverse(block, irn) {
- DBG((dbg, LEVEL_1, "\tinsn: %n, pressure: %d\n", irn, pressure));
+ DBG((dbg, LEVEL_1, "\tinsn: %+F, pressure: %d\n", irn, pressure));
DBG((dbg, LEVEL_2, "\tlive: %b\n", live));
- /*
- * If the node defines some value, which can put into a
- * register of the current class, make a border for it.
- */
+ /*
+ * If the node defines some value, which can put into a
+ * register of the current class, make a border for it.
+ */
if(arch_irn_has_reg_class(env->arch_env, irn, 0, cls)) {
- bitset_pos_t elm;
+ bitset_pos_t elm;
int nr = get_irn_graph_nr(irn);
bitset_clear(live, nr);
border_def(irn, step, 1);
#ifdef BUILD_GRAPH
- bitset_foreach(live, elm)
- add_if(env, nr, (int) elm);
+ bitset_foreach(live, elm)
+ add_if(env, nr, (int) elm);
#endif
}
if(arch_irn_has_reg_class(env->arch_env, op, 0, cls)) {
int nr = get_irn_graph_nr(op);
- DBG((dbg, LEVEL_4, "\t\tpos: %d, use: %n\n", i, op));
+ DBG((dbg, LEVEL_4, "\t\tpos: %d, use: %+F\n", i, op));
if(!bitset_is_set(live, nr)) {
border_use(op, step, 1);
}
}
}
-
++step;
}
border_def(irn, step, 0);
}
}
+
+ del_pset(live_in);
+ del_pset(live_end);
}
static void assign(ir_node *block, void *env_ptr)
bitset_t *live = env->live;
bitset_t *colors = env->colors;
bitset_t *in_colors = env->in_colors;
- const arch_register_class_t *cls = env->cls;
+ const arch_register_class_t *cls = env->cls;
/* Mark the obstack level and allocate the temporary tmp_colors */
void *obstack_level = obstack_base(obst);
const ir_node *irn;
border_t *b;
struct list_head *head = get_block_border_head(env, block);
- pset *live_in = get_live_in(block);
+ pset *live_in = put_live_in(block, pset_new_ptr_default());
bitset_clear_all(live);
bitset_clear_all(colors);
bitset_clear_all(in_colors);
- DBG((dbg, LEVEL_4, "Assigning colors for block %n\n", block));
+ DBG((dbg, LEVEL_4, "Assigning colors for block %+F\n", block));
DBG((dbg, LEVEL_4, "\tusedef chain for block\n"));
list_for_each_entry(border_t, b, head, list) {
- DBG((dbg, LEVEL_4, "\t%s %n/%d\n", b->is_def ? "def" : "use",
+ DBG((dbg, LEVEL_4, "\t%s %+F/%d\n", b->is_def ? "def" : "use",
b->irn, get_irn_graph_nr(b->irn)));
}
const arch_register_t *reg = arch_get_irn_register(env->arch_env, irn, 0);
int col;
- assert(reg && "Nodfe must have been assigned a register");
+ assert(reg && "Node must have been assigned a register");
col = arch_register_get_index(reg);
/* Mark the color of the live in value as used. */
bitset_set(live, nr);
arch_set_irn_register(env->arch_env, irn, 0, reg);
- DBG((dbg, LEVEL_1, "\tassigning register %s(%d) to %n\n",
+ DBG((dbg, LEVEL_1, "\tassigning register %s(%d) to %+F\n",
arch_register_get_name(reg), col, irn));
}
/* Free the auxillary data on the obstack. */
obstack_free(obst, obstack_level);
+
+ del_pset(live_in);
}
void be_ra_chordal_init(void)
const arch_register_class_t *cls)
{
int node_count = get_graph_node_count(irg);
- int colors_n = arch_register_class_n_regs(cls);
+ int colors_n = arch_register_class_n_regs(cls);
be_chordal_env_t *env = malloc(sizeof(*env));
if(get_irg_dom_state(irg) != dom_consistent)
env->colors = bitset_obstack_alloc(&env->obst, colors_n);
env->in_colors = bitset_obstack_alloc(&env->obst, colors_n);
env->colors_n = colors_n;
- env->cls = cls;
- env->arch_env = arch_env;
- env->irg = irg;
- env->border_heads = pmap_create();
+ env->cls = cls;
+ env->arch_env = arch_env;
+ env->irg = irg;
+ env->border_heads = pmap_create();
/* First, determine the pressure */
dom_tree_walk_irg(irg, pressure, NULL, env);
dom_tree_walk_irg(irg, assign, NULL, env);
#ifdef DUMP_IFG
- dump_ifg(env);
+ dump_ifg(env);
#endif
#ifdef DUMP_INTERVALS
{
char buf[128];
- plotter_t *plotter;
+ plotter_t *plotter;
ir_snprintf(buf, sizeof(buf), "ifg_%s_%F.eps", cls->name, irg);
- plotter = new_plotter_ps(buf);
+ plotter = new_plotter_ps(buf);
- draw_interval_tree(&draw_chordal_def_opts, env, plotter, arch_env, cls);
- plotter_free(plotter);
+ draw_interval_tree(&draw_chordal_def_opts, env, plotter, arch_env, cls);
+ plotter_free(plotter);
}
#endif
-
- return env;
+ return env;
}
void be_ra_chordal_done(be_chordal_env_t *env)