#include "benode_t.h"
#include "bestatevent.h"
#include "bestat.h"
+#include "bemodule.h"
#include "bespillbelady.h"
#include "bespillmorgan.h"
/** Assumed loop iteration count for execution frequency estimation. */
static int be_loop_weight = 9;
-#ifdef WITH_LIBCORE
+typedef struct _post_spill_env_t {
+ be_chordal_env_t cenv;
+ double pre_spill_cost;
+} post_spill_env_t;
+
static be_ra_timer_t ra_timer = {
NULL,
NULL,
};
static const lc_opt_enum_int_items_t spill_items[] = {
- { "morgan", BE_CH_SPILL_MORGAN },
{ "belady", BE_CH_SPILL_BELADY },
+ { "morgan", BE_CH_SPILL_MORGAN },
#ifdef WITH_ILP
{ "remat", BE_CH_SPILL_REMAT },
#endif /* WITH_ILP */
{ NULL }
};
-typedef struct _post_spill_env_t {
- be_chordal_env_t cenv;
- double pre_spill_cost;
-} post_spill_env_t;
-
-extern void be_spill_remat_register_options(lc_opt_entry_t *ent);
-
void be_ra_chordal_check(be_chordal_env_t *chordal_env) {
const arch_env_t *arch_env = chordal_env->birg->main_env->arch_env;
struct obstack ob;
return values_interfere(env->birg->lv, a, b);
}
-static void be_ra_chordal_register_options(lc_opt_entry_t *grp)
-{
- static int run_once = 0;
- lc_opt_entry_t *chordal_grp;
-
- if (! run_once) {
- run_once = 1;
- chordal_grp = lc_opt_get_grp(grp, "chordal");
-
- lc_opt_add_table(chordal_grp, be_chordal_options);
-
- co_register_options(chordal_grp);
-#ifdef WITH_JVM
- be_java_coal_register_options(chordal_grp);
-#endif
-#ifdef WITH_ILP
- be_spill_remat_register_options(chordal_grp);
-#endif
- be_spill_register_options(chordal_grp);
- }
-}
-#endif /* WITH_LIBCORE */
-
static void dump(unsigned mask, ir_graph *irg,
const arch_register_class_t *cls,
const char *suffix,
if (! be_is_Reload(irn))
return;
- /* always use addressmode, it's good for x86 */
-#if 0
/* only use memory operands, if the reload is only used by 1 node */
if(get_irn_n_edges(irn) > 1)
return;
-#endif
spill = be_get_Reload_mem(irn);
block = get_nodes_block(irn);
if (get_nodes_block(src) == block && arch_possible_memory_operand(aenv, src, pos)) {
DBG((cenv->dbg, LEVEL_3, "performing memory operand %+F at %+F\n", irn, src));
- //arch_perform_memory_operand(aenv, src, spill, pos);
+ arch_perform_memory_operand(aenv, src, spill, pos);
}
}
/* kill the Reload */
if (get_irn_n_edges(irn) == 0) {
sched_remove(irn);
- set_irn_n(irn, 0, new_Bad());
- set_irn_n(irn, 1, new_Bad());
+ set_irn_n(irn, be_pos_Reload_mem, new_Bad());
}
}
* @param birg Backend irg object
* @return Structure containing timer for the single phases or NULL if no timing requested.
*/
-static be_ra_timer_t *be_ra_chordal_main(be_irg_t *birg)
+static void be_ra_chordal_main(be_irg_t *birg)
{
const be_main_env_t *main_env = birg->main_env;
const arch_isa_t *isa = arch_env_get_isa(main_env->arch_env);
/* spilling */
switch(options.spill_method) {
case BE_CH_SPILL_MORGAN:
- be_spill_morgan(&chordal_env);
+ be_spill_morgan(&pse.cenv);
break;
case BE_CH_SPILL_BELADY:
- be_spill_belady(&chordal_env);
+ be_spill_belady(&pse.cenv);
break;
#ifdef WITH_ILP
case BE_CH_SPILL_REMAT:
- be_spill_remat(&chordal_env);
+ be_spill_remat(&pse.cenv);
break;
#endif /* WITH_ILP */
default:
fprintf(stderr, "no valid spiller selected. falling back to belady\n");
- be_spill_belady(&chordal_env);
+ be_spill_belady(&pse.cenv);
}
BE_TIMER_POP(ra_timer.t_spill);
- dump(BE_CH_DUMP_SPILL, irg, chordal_env.cls, "-spill", dump_ir_block_graph_sched);
+ dump(BE_CH_DUMP_SPILL, irg, pse.cenv.cls, "-spill", dump_ir_block_graph_sched);
post_spill(&pse);
}
be_stat_ev("insns_after", count_insns(irg));
-#ifdef WITH_LIBCORE
- return main_opts->timing == BE_TIME_ON ? &ra_timer : NULL;
-#endif /* WITH_LIBCORE */
- return NULL;
+ return;
}
-const be_ra_t be_ra_chordal_allocator = {
-#ifdef WITH_LIBCORE
- be_ra_chordal_register_options,
-#else
- NULL,
-#endif
+static be_ra_t be_ra_chordal_allocator = {
be_ra_chordal_main,
};
+
+void be_init_chordal(void)
+{
+ 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_REGISTER_MODULE_CONSTRUCTOR(be_init_chordal);