#include "beabi.h"
#include "beutil.h"
#include "besched.h"
-#include "besched_t.h"
+#include "besched.h"
#include "belive_t.h"
-#include "bearch_t.h"
+#include "bearch.h"
#include "beifg_t.h"
#include "beifg_impl.h"
-#include "benode_t.h"
+#include "benode.h"
#include "bestatevent.h"
#include "bestat.h"
#include "bemodule.h"
#include "be_t.h"
#include "bera.h"
-#include "beirg_t.h"
+#include "beirg.h"
#include "bespillslots.h"
-#include "bespilloptions.h"
+#include "bespill.h"
#include "belower.h"
#include "becopystat.h"
#include "becopyopt.h"
#include "bessadestr.h"
#include "beverify.h"
-#include "benode_t.h"
+#include "benode.h"
+
+#include "bepbqpcoloring.h"
static be_ra_chordal_opts_t options = {
BE_CH_DUMP_NONE,
LC_OPT_LAST
};
+static be_module_list_entry_t *colorings = NULL;
+static const be_ra_chordal_coloring_t *selected_coloring = NULL;
+
+void be_register_chordal_coloring(const char *name, be_ra_chordal_coloring_t *coloring)
+{
+ if (selected_coloring == NULL)
+ selected_coloring = coloring;
+
+ be_add_module_to_list(&colorings, name, coloring);
+}
+
+void be_ra_chordal_coloring(be_chordal_env_t *env)
+{
+ assert(selected_coloring != NULL);
+ if(selected_coloring != NULL) {
+ selected_coloring->allocate(env);
+ }
+}
+
+
static void dump(unsigned mask, ir_graph *irg,
const arch_register_class_t *cls,
const char *suffix,
/**
* Starts a walk for memory operands if supported by the backend.
*/
-static INLINE void check_for_memory_operands(ir_graph *irg)
+void check_for_memory_operands(ir_graph *irg)
{
irg_walk_graph(irg, NULL, memory_operand_walker, NULL);
}
be_put_ignore_regs(birg, pse->cls, chordal_env->ignore_colors);
BE_TIMER_PUSH(t_ra_constr);
- be_pre_spill_prepare_constr(chordal_env);
+ be_pre_spill_prepare_constr(chordal_env->birg, chordal_env->cls);
BE_TIMER_POP(t_ra_constr);
dump(BE_CH_DUMP_CONSTR, birg->irg, pse->cls, "-constr-pre", dump_ir_block_graph_sched);
/* Color the graph. */
BE_TIMER_PUSH(t_ra_color);
- be_ra_chordal_color(chordal_env);
+ be_ra_chordal_coloring(chordal_env);
BE_TIMER_POP(t_ra_color);
dump(BE_CH_DUMP_CONSTR, irg, pse->cls, "-color", dump_ir_block_graph_sched);
node_stats[BE_STAT_COPIES]);
}
- /* copy minimization */
BE_TIMER_PUSH(t_ra_copymin);
co_driver(chordal_env);
BE_TIMER_POP(t_ra_copymin);
dump(BE_CH_DUMP_COPYMIN, irg, pse->cls, "-copymin", dump_ir_block_graph_sched);
-
/* ssa destruction */
BE_TIMER_PUSH(t_ra_ssa);
be_ssa_destruction(chordal_env);
/* the backend has its own spiller */
m = arch_env_get_n_reg_class(arch_env);
- pse = alloca(m * sizeof(pse[0]));
+ pse = ALLOCAN(post_spill_env_t, m);
for (j = 0; j < m; ++j) {
memcpy(&pse[j].cenv, &chordal_env, sizeof(chordal_env));
BE_TIMER_POP(t_ra_other);
}
-static be_ra_t be_ra_chordal_allocator = {
- be_ra_chordal_main,
-};
-
void be_init_chordal_main(void)
{
+ static be_ra_t be_ra_chordal_allocator = {
+ be_ra_chordal_main,
+ };
+
+ be_register_allocator("chordal", &be_ra_chordal_allocator);
+
lc_opt_entry_t *be_grp = lc_opt_get_grp(firm_opt_get_root(), "be");
lc_opt_entry_t *ra_grp = lc_opt_get_grp(be_grp, "ra");
lc_opt_entry_t *chordal_grp = lc_opt_get_grp(ra_grp, "chordal");
lc_opt_add_table(chordal_grp, be_chordal_options);
-
- be_register_allocator("chordal", &be_ra_chordal_allocator);
+ be_add_module_list_opt(chordal_grp, "coloring", "select coloring methode", &colorings, (void**) &selected_coloring);
}
BE_REGISTER_MODULE_CONSTRUCTOR(be_init_chordal_main);