#include "../besched_t.h"
#include "../be.h"
#include "../beabi.h"
+#include "../bemodule.h"
#include "bearch_TEMPLATE_t.h"
return &p;
}
-#ifdef WITH_LIBCORE
-static void TEMPLATE_register_options(lc_opt_entry_t *ent)
+void be_init_arch_TEMPLATE()
{
}
-#endif /* WITH_LIBCORE */
+BE_REGISTER_MODULE_CONSTRUCTOR(be_init_arch_TEMPLATE);
const arch_isa_if_t TEMPLATE_isa_if = {
TEMPLATE_init,
TEMPLATE_get_list_sched_selector,
TEMPLATE_get_reg_class_alignment,
TEMPLATE_get_libfirm_params,
-#ifdef WITH_LIBCORE
- TEMPLATE_register_options
-#endif
};
#include "irargs_t.h"
#include "../besched.h"
+#include "../beblocksched.h"
#include "arm_emitter.h"
#include "gen_arm_emitter.h"
arm_register_emitters();
/* create the block schedule. For now, we don't need it earlier. */
- blk_sched = sched_create_block_schedule(cg->irg, cg->birg->exec_freq);
+ blk_sched = be_create_block_schedule(cg->irg, cg->birg->exec_freq);
arm_emit_start(F, irg);
irg_block_walk_graph(irg, arm_gen_labels, NULL, &emit_env);
#include "../beabi.h"
#include "../bemachine.h"
#include "../beilpsched.h"
+#include "../bemodule.h"
#include "bearch_arm_t.h"
* arm-fpuunit=unit select the floating point unit
* arm-gen_reg_names use generic register names instead of SP, LR, PC
*/
-static void arm_register_options(lc_opt_entry_t *ent)
+void be_init_arch_arm(void)
{
- lc_opt_entry_t *be_grp_arm = lc_opt_get_grp(ent, "arm");
- lc_opt_add_table(be_grp_arm, arm_options);
+ lc_opt_entry_t *be_grp = lc_opt_get_grp(firm_opt_get_root(), "be");
+ lc_opt_entry_t *arm_grp = lc_opt_get_grp(be_grp, "arm");
+
+ lc_opt_add_table(arm_grp, arm_options);
}
+BE_REGISTER_MODULE_CONSTRUCTOR(be_init_arch_arm);
#endif /* WITH_LIBCORE */
const arch_isa_if_t arm_isa_if = {
arm_get_libfirm_params,
arm_get_allowed_execution_units,
arm_get_machine,
-#ifdef WITH_LIBCORE
- arm_register_options
-#endif
};
arm_code_gen_t *cg; /**< current code generator */
FILE *out; /**< output file */
- unsigned fpu_arch; /**< FPU architecture */
+ int fpu_arch; /**< FPU architecture */
};
#include "dbginfo.h"
#include "ifconv.h"
+#ifdef WITH_LIBCORE
+#include <libcore/lc_opts.h>
+#include <libcore/lc_opts_enum.h>
+#include <libcore/lc_timing.h>
+#endif /* WITH_LIBCORE */
+
#define LC_STOP_AND_RESET_TIMER(timer) do { lc_timer_stop(timer); lc_timer_reset(timer); } while(0)
/**
* @param self The isa object.
*/
const be_machine_t *(*get_machine)(const void *self);
-
-#ifdef WITH_LIBCORE
- /**
- * Register command line options for this backend.
- * @param grp The root group.
- */
- void (*register_options)(lc_opt_entry_t *grp);
-#endif
};
#define arch_isa_get_n_reg_class(isa) ((isa)->impl->get_n_reg_class(isa))
#include "irtools.h"
#include "debug.h"
#include "beirgmod.h"
+#include "bemodule.h"
+#include "be.h"
#ifdef WITH_LIBCORE
#include <libcore/lc_opts.h>
* |_| |_|\__,_|_|_| |_|
*
*/
-
-#ifdef WITH_LIBCORE
-void be_block_schedule_register_options(lc_opt_entry_t *grp)
+void be_init_blocksched(void)
{
- static int run_once = 0;
- lc_opt_entry_t *blocksched_grp;
-
- if (run_once)
- return;
-
- run_once = 1;
- blocksched_grp = lc_opt_get_grp(grp, "blocksched");
+ lc_opt_entry_t *be_grp = lc_opt_get_grp(firm_opt_get_root(), "be");
+ lc_opt_entry_t *blocksched_grp = lc_opt_get_grp(be_grp, "blocksched");
lc_opt_add_table(blocksched_grp, be_blocksched_options);
}
-#endif /* WITH_LIBCORE */
+
+BE_REGISTER_MODULE_CONSTRUCTOR(be_init_blocksched);
ir_node **be_create_block_schedule(ir_graph *irg, ir_exec_freq *execfreqs)
{
ir_node **be_create_block_schedule(ir_graph *irg, ir_exec_freq *execfreqs);
-#ifdef WITH_LIBCORE
-#include <libcore/lc_opts.h>
-void be_block_schedule_register_options(lc_opt_entry_t *grp);
-#endif /* WITH_LIBCORE */
-
#endif /* _BEBLOCKSCHED_H */
#include "bearch.h"
#include "bera.h"
-/**
- * The register allocator structure.
- */
-extern const be_ra_t be_ra_chordal_allocator;
-
typedef struct _be_chordal_env_t be_chordal_env_t;
#endif
#include "benode_t.h"
#include "bestatevent.h"
#include "bestat.h"
+#include "bemodule.h"
#include "bespillbelady.h"
#include "bespillmorgan.h"
double pre_spill_cost;
} post_spill_env_t;
-#ifdef WITH_LIBCORE
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 }
};
-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
- }
-}
-#endif /* WITH_LIBCORE */
-
static void dump(unsigned mask, ir_graph *irg,
const arch_register_class_t *cls,
const char *suffix,
* @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);
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);
#include "irprintf.h"
#include "irtools.h"
+#include "bemodule.h"
#include "beabi.h"
#include "benode_t.h"
#include "becopyopt.h"
{ NULL }
};
-void be_co2_register_options(lc_opt_entry_t *grp)
+void be_init_copyheur2(void)
{
- lc_opt_entry_t *co2_grp = lc_opt_get_grp(grp, "co2");
+ 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_entry_t *co2_grp = lc_opt_get_grp(chordal_grp, "co2");
+
lc_opt_add_table(co2_grp, options);
}
+
+BE_REGISTER_MODULE_CONSTRUCTOR(be_init_copyheur2);
#endif
/*
#include "irprintf.h"
#include "irtools.h"
+#include "bemodule.h"
#include "beabi.h"
#include "benode_t.h"
#include "becopyopt.h"
{ NULL }
};
-void be_co3_register_options(lc_opt_entry_t *grp)
+void be_init_copyheur3(void)
{
- lc_opt_entry_t *co3_grp = lc_opt_get_grp(grp, "co3");
+ 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_entry_t *co3_grp = lc_opt_get_grp(chordal_grp, "co3");
+
lc_opt_add_table(co3_grp, options);
}
-#endif
+BE_REGISTER_MODULE_CONSTRUCTOR(be_init_copyheur3);
+#endif
static void set_admissible_regs(be_java_coal_t *coal, copy_opt_t *co, ir_node *irn, int t_idx, int *col_map)
{
{ NULL }
};
-void be_co_ilp_register_options(lc_opt_entry_t *grp)
+void be_init_copyilp(void)
{
- lc_opt_entry_t *ilp_grp = lc_opt_get_grp(grp, "ilp");
+ 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_entry_t *co_grp = lc_opt_get_grp(chordal_grp, "co");
+ lc_opt_entry_t *ilp_grp = lc_opt_get_grp(co_grp, "ilp");
+
lc_opt_add_table(ilp_grp, options);
}
+
+BE_REGISTER_MODULE_CONSTRUCTOR(be_init_copyilp);
#endif /* WITH_LIBCORE */
#include "irphase_t.h"
#include "irprintf_t.h"
-
+#include "bemodule.h"
#include "bearch.h"
#include "benode_t.h"
#include "beutil.h"
extern void be_co2_register_options(lc_opt_entry_t *grp);
extern void be_co3_register_options(lc_opt_entry_t *grp);
-void co_register_options(lc_opt_entry_t *grp)
+void be_init_copycoal(void)
{
- lc_opt_entry_t *co_grp = lc_opt_get_grp(grp, "co");
- lc_opt_add_table(co_grp, options);
+ 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_entry_t *co_grp = lc_opt_get_grp(chordal_grp, "co");
- be_co2_register_options(co_grp);
- be_co3_register_options(co_grp);
-#ifdef WITH_ILP
- be_co_ilp_register_options(co_grp);
-#endif
+ lc_opt_add_table(co_grp, options);
}
+
+BE_REGISTER_MODULE_CONSTRUCTOR(be_init_copycoal);
#endif
DEBUG_ONLY(static firm_dbg_module_t *dbg = NULL;)
-void be_copy_opt_init(void) {
-}
-
copy_opt_t *new_copy_opt(be_chordal_env_t *chordal_env, cost_fct_t get_costs)
{
const char *s1, *s2, *s3;
/** The driver for copy minimization. */
void co_driver(be_chordal_env_t *cenv);
-/**
- * Has to be called during the firm init phase
- */
-void be_copy_opt_init(void);
-
typedef struct _copy_opt_t copy_opt_t;
typedef int(*cost_fct_t)(const copy_opt_t *, ir_node*, ir_node*, int);
#include "becopyopt_t.h"
#include "becopystat.h"
#include "beirg_t.h"
+#include "bemodule.h"
#define DEBUG_LVL SET_LEVEL_1
DEBUG_ONLY(static firm_dbg_module_t *dbg = NULL;)
static pset *all_copy_nodes;
static ir_graph *last_irg;
-void copystat_init(void) {
+void be_init_copystat(void) {
FIRM_DBG_REGISTER(dbg, "firm.be.copystat");
all_phi_nodes = pset_new_ptr_default();
all_phi_classes = pset_new_ptr_default();
all_copy_nodes = pset_new_ptr_default();
+ memset(curr_vals, 0, sizeof(curr_vals));
}
+BE_REGISTER_MODULE_CONSTRUCTOR(be_init_copystat);
-void copystat_reset(void) {
- int i;
- for (i = 0; i < ASIZE; ++i)
- curr_vals[i] = 0;
+void be_quit_copystat(void) {
del_pset(all_phi_nodes);
del_pset(all_phi_classes);
del_pset(all_copy_nodes);
- all_phi_nodes = pset_new_ptr_default();
- all_phi_classes = pset_new_ptr_default();
- all_copy_nodes = pset_new_ptr_default();
+}
+BE_REGISTER_MODULE_DESTRUCTOR(be_quit_copystat);
+
+void copystat_reset(void) {
+ be_quit_copystat();
+ be_init_copystat();
}
/**
#include "bearch.h"
#include "bechordal_t.h"
-void copystat_init(void);
-void copystat_reset(void);
void copystat_collect_cls(be_chordal_env_t *chordal_env);
void copystat_add_max_costs(int costs);
void copystat_add_inevit_costs(int costs);
/**
* Register ILP scheduler options.
*/
-void ilpsched_register_options(lc_opt_entry_t *grp) {
- static int run_once = 0;
- lc_opt_entry_t *sched_grp;
-
- if (! run_once) {
- run_once = 1;
- sched_grp = lc_opt_get_grp(grp, "ilpsched");
+void be_init_ilpsched(void)
+{
+ lc_opt_entry_t *be_grp = lc_opt_get_grp(firm_opt_get_root(), "be");
+ lc_opt_entry_t *sched_grp = lc_opt_get_grp(be_grp, "ilpsched");
- lc_opt_add_table(sched_grp, ilpsched_option_table);
- }
+ lc_opt_add_table(sched_grp, ilpsched_option_table);
}
#endif /* WITH_LIBCORE */
{ NULL }
};
-void be_java_coal_register_options(lc_opt_entry_t *grp)
+void be_init_javacoal(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_entry_t *jc_grp = lc_opt_get_grp(grp, "jc");
lc_opt_add_table(jc_grp, options);
}
+
+BE_REGISTER_MODULE_CONSTRUCTOR(be_init_javacoal);
#endif /* WITH_LIBCORE */
#include <jni.h>
{
}
-
#endif /* WITH_JVM */
#include "debug.h"
#include "irtools.h"
+#include "bemodule.h"
#include "besched_t.h"
#include "beutil.h"
#include "belive_t.h"
/**
* Register list scheduler options.
*/
-void list_sched_register_options(lc_opt_entry_t *grp) {
- static int run_once = 0;
- lc_opt_entry_t *sched_grp;
+void be_init_listsched(void) {
+ lc_opt_entry_t *be_grp = lc_opt_get_grp(firm_opt_get_root(), "be");
+ lc_opt_entry_t *sched_grp = lc_opt_get_grp(be_grp, "listsched");
- if (! run_once) {
- run_once = 1;
- sched_grp = lc_opt_get_grp(grp, "listsched");
-
- lc_opt_add_table(sched_grp, list_sched_option_table);
- rss_register_options(sched_grp);
- }
+ lc_opt_add_table(sched_grp, list_sched_option_table);
}
+
+BE_REGISTER_MODULE_CONSTRUCTOR(be_init_listsched);
#endif /* WITH_LIBCORE */
#include "arm/bearch_arm.h"
#include "ppc32/bearch_ppc32.h"
#include "mips/bearch_mips.h"
-// #include "sta/bearch_sta.h"
#include "be_t.h"
+#include "bemodule.h"
#include "beutil.h"
#include "benode_t.h"
#include "beirgmod.h"
static char config_file[256] = { 0 };
/* register allocator to use. */
-static const be_ra_t *ra = &be_ra_chordal_allocator;
+//static const be_ra_t *ra = &be_ra_chordal_allocator;
/* back end instruction set architecture to use */
static const arch_isa_if_t *isa_if = &ia32_isa_if;
#ifdef WITH_LIBCORE
-static lc_opt_entry_t *be_grp_root = NULL;
-
/* possible dumping options */
static const lc_opt_enum_mask_items_t dump_items[] = {
{ "none", DUMP_NONE },
{ NULL, 0 }
};
-/* register allocators */
-static const lc_opt_enum_const_ptr_items_t ra_items[] = {
- { "chordal", &be_ra_chordal_allocator },
- { "external", &be_ra_external_allocator },
- { NULL, NULL }
-};
-
/* instruction set architectures. */
static const lc_opt_enum_const_ptr_items_t isa_items[] = {
{ "ia32", &ia32_isa_if },
&be_options.dump_flags, dump_items
};
-static lc_opt_enum_const_ptr_var_t ra_var = {
- (const void **) &ra, ra_items
-};
-
static lc_opt_enum_const_ptr_var_t isa_var = {
(const void **) &isa_if, isa_items
};
static const lc_opt_table_entry_t be_main_options[] = {
LC_OPT_ENT_STR ("config", "read another config file containing backend options", config_file, sizeof(config_file)),
LC_OPT_ENT_ENUM_MASK("dump", "dump irg on several occasions", &dump_var),
- LC_OPT_ENT_ENUM_PTR ("ra", "register allocator", &ra_var),
LC_OPT_ENT_ENUM_PTR ("isa", "the instruction set architecture", &isa_var),
LC_OPT_ENT_NEGBOOL ("noomitfp", "do not omit frame pointer", &be_options.omit_fp),
LC_OPT_ENT_BOOL ("stabs", "enable stabs debug support", &be_options.stabs_debug_support),
void be_opt_register(void)
{
#ifdef WITH_LIBCORE
- int i;
- lc_opt_entry_t *be_grp_ra;
+ lc_opt_entry_t *be_grp;
static int run_once = 0;
- if (! run_once) {
- run_once = 1;
- be_grp_root = lc_opt_get_grp(firm_opt_get_root(), "be");
- be_grp_ra = lc_opt_get_grp(be_grp_root, "ra");
-
- lc_opt_add_table(be_grp_root, be_main_options);
-
- /* register allocator options */
- for(i = 0; ra_items[i].name != NULL; ++i) {
- const be_ra_t *ra = ra_items[i].value;
- ra->register_options(be_grp_ra);
- }
-
- /* register isa options */
- for(i = 0; isa_items[i].name != NULL; ++i) {
- const arch_isa_if_t *isa = isa_items[i].value;
- isa->register_options(be_grp_root);
- }
+ if (run_once) {
+ return;
+ }
+ run_once = 1;
- /* list scheduler register options */
- list_sched_register_options(be_grp_root);
+ be_init_modules();
-#ifdef WITH_ILP
- /* ilp scheduler register options */
- ilpsched_register_options(be_grp_root);
-#endif /* WITH_ILP */
-
- be_block_schedule_register_options(be_grp_root);
- }
+ be_grp = lc_opt_get_grp(firm_opt_get_root(), "be");
+ lc_opt_add_table(be_grp, be_main_options);
#endif /* WITH_LIBCORE */
}
/* Parse one argument. */
int be_parse_arg(const char *arg) {
#ifdef WITH_LIBCORE
+ lc_opt_entry_t *be_grp = lc_opt_get_grp(firm_opt_get_root(), "be");
if (strcmp(arg, "help") == 0 || (arg[0] == '?' && arg[1] == '\0')) {
- lc_opt_print_help(be_grp_root, stdout);
+ lc_opt_print_help(be_grp, stdout);
return -1;
}
- return lc_opt_from_single_arg(be_grp_root, NULL, arg, NULL);
+ return lc_opt_from_single_arg(be_grp, NULL, arg, NULL);
#else
return 0;
#endif /* WITH_LIBCORE */
const backend_params *be_init(void)
{
be_opt_register();
-
- be_sched_init();
- be_copy_opt_init();
- copystat_init();
+ be_init_modules();
phi_class_init();
if (isa_if->get_params)
/* Do register allocation */
BE_TIMER_PUSH(t_regalloc);
- ra_timer = ra->allocate(birg);
+ //ra_timer = ra->allocate(birg);
BE_TIMER_POP(t_regalloc);
#ifdef FIRM_STATISTICS
//---------------------------------------------------------------------------
+#ifdef WITH_LIBCORE
typedef struct module_opt_data_t {
void **var;
- const be_module_list_entry_t * const *list_head;
+ be_module_list_entry_t * const *list_head;
} module_opt_data_t;
-static int set_opt_module(const char *name, lc_opt_type_t type, void *data, size_t length, ...)
+static int set_opt_module(const char *name, lc_opt_type_t type, void *data,
+ size_t length, ...)
{
module_opt_data_t *moddata = data;
va_list args;
void be_add_module_list_opt(lc_opt_entry_t *grp, const char *name,
const char *description,
- const be_module_list_entry_t * const * list_head,
+ be_module_list_entry_t * const * list_head,
void **var)
{
module_opt_data_t *moddata = xmalloc(sizeof(moddata[0]));
set_opt_module, dump_opt_module, dump_opt_module_vals,
NULL);
}
+
+#endif
void be_add_module_list_opt(lc_opt_entry_t *grp, const char *name,
const char *description,
- const be_module_list_entry_t * const * first, void **var);
+ be_module_list_entry_t * const * first,
+ void **var);
#endif
#include "config.h"
#endif
+#include <stdlib.h>
+
#include "pset.h"
#include "impl.h"
#include "irmode.h"
#include "irdom.h"
+#include "bera.h"
#include "beutil.h"
#include "besched_t.h"
#include "belive_t.h"
+#include "bemodule.h"
static sched_timestep_t get_time_step(const ir_node *irn)
{
if(get_nodes_block(user) == bb && !is_Phi(user) && b != user && value_dominates(b, user))
return 1;
}
- }
- return 0;
+ }
+
+ return 0;
+}
+
+/** The list of register allocators */
+static be_module_list_entry_t *register_allocators = NULL;
+static be_ra_t *selected_allocator = NULL;
+
+void be_register_allocator(const char *name, be_ra_t *allocator)
+{
+ if(selected_allocator == NULL)
+ selected_allocator = allocator;
+ be_add_module_to_list(®ister_allocators, name, allocator);
+}
+
+void be_init_ra(void)
+{
+ lc_opt_entry_t *be_grp = lc_opt_get_grp(firm_opt_get_root(), "be");
+
+ be_add_module_list_opt(be_grp, "regalloc", "register allocator",
+ ®ister_allocators, (void**) &selected_allocator);
}
+BE_REGISTER_MODULE_CONSTRUCTOR(init_be_ra);
#include "firm_config.h"
#ifdef WITH_LIBCORE
-#include <libcore/lc_opts.h>
#include <libcore/lc_timing.h>
#endif
#include "be.h"
#include "belive.h"
#include "beirg.h"
+#include "bemodule.h"
#ifdef WITH_LIBCORE
typedef void *lc_opt_entry_t;
#endif /* WITH_LIBCORE */
-typedef struct {
- void (*register_options)(lc_opt_entry_t *grp);
- be_ra_timer_t *(*allocate)(be_irg_t *bi);
+typedef struct be_ra_t {
+ void (*allocate)(be_irg_t *bi); /**< allocate registers on a graph */
} be_ra_t;
+void be_register_allocator(const char *name, be_ra_t *allocator);
+
+/**
+ * Do register allocation with currently selected register allocator
+ */
+void be_allocate_registers(be_irg_t *birg);
/**
* Check, if two values interfere.
#include "irdom_t.h"
#include "phiclass.h"
+#include "bemodule.h"
#include "beraextern.h"
#include "beabi.h"
#include "bearch.h"
* Read in results and apply them
*
*/
-static be_ra_timer_t *be_ra_extern_main(be_irg_t *birg) {
+static void be_ra_extern_main(be_irg_t *birg) {
be_main_env_t *env = birg->main_env;
ir_graph *irg = birg->irg;
free_ssa_destr_simple(raenv.vars);
be_invalidate_liveness(birg);
-
- return NULL;
}
/******************************************************************************
{ NULL }
};
-static void be_ra_extern_register_options(lc_opt_entry_t *root) {
- lc_opt_entry_t *grp = lc_opt_get_grp(root, "ext");
+static be_ra_t be_ra_external_allocator = {
+ be_ra_extern_main
+};
+
+void be_init_raextern(void) {
+ lc_opt_entry_t *be_grp = lc_opt_get_grp(firm_opt_get_root(), "be");
+ lc_opt_entry_t *blocksched_grp = lc_opt_get_grp(be_grp, "ra");
+ lc_opt_entry_t *ext_grp = lc_opt_get_grp(blocksched_grp, "ext");
+
+ lc_opt_add_table(ext_grp, be_ra_extern_options);
- lc_opt_add_table(grp, be_ra_extern_options);
+ be_register_allocator("ext", &be_ra_external_allocator);
}
+BE_REGISTER_MODULE_CONSTRUCTOR(be_init_raextern);
#endif /* WITH_LIBCORE */
-
-const be_ra_t be_ra_external_allocator = {
-#ifdef WITH_LIBCORE
- be_ra_extern_register_options,
-#endif
- be_ra_extern_main
-};
#include "bera.h"
-extern const be_ra_t be_ra_external_allocator;
-
#endif
#include "irextbb.h"
#include "debug.h"
+#include "bemodule.h"
#include "bearch.h"
#include "besched_t.h"
#include "beutil.h"
}
/* Init the scheduling stuff. */
-void be_sched_init(void)
+void be_init_sched(void)
{
sched_irn_data_offset = register_additional_node_data(sizeof(sched_info_t));
}
+BE_REGISTER_MODULE_CONSTRUCTOR(be_init_sched);
+
void sched_renumber(const ir_node *block)
{
ir_node *irn;
#define get_irn_sched_info(irn) get_irn_data(irn, sched_info_t, sched_irn_data_offset)
#define get_sched_info_irn(sched_info) get_irn_data_base(sched_info, sched_irn_data_offset)
-/**
- * Init the scheduling stuff.
- * To be called from the central backend initialization routine.
- */
-void be_sched_init(void);
-
/**
* Check, if the node is scheduled.
* @param irn The node.
#include "height.h"
#include "beabi.h"
+#include "bemodule.h"
#include "benode_t.h"
#include "besched_t.h"
/**
* Register the options.
*/
-void rss_register_options(lc_opt_entry_t *grp) {
- static int run_once = 0;
- lc_opt_entry_t *rss_grp;
+void be_init_schedrss(void) {
+ lc_opt_entry_t *be_grp = lc_opt_get_grp(firm_opt_get_root(), "be");
+ lc_opt_entry_t *sched_grp = lc_opt_get_grp(be_grp, "sched");
+ lc_opt_entry_t *rss_grp = lc_opt_get_grp(sched_grp, "rss");
- if (! run_once) {
- run_once = 1;
- rss_grp = lc_opt_get_grp(grp, "rss");
-
- lc_opt_add_table(rss_grp, rss_option_table);
- }
+ lc_opt_add_table(rss_grp, rss_option_table);
}
+
+BE_REGISTER_MODULE_CONSTRUCTOR(be_init_schedrss);
#endif /* WITH_LIBCORE */
/**
FIRM_DBG_REGISTER(dbg, "firm.be.spill.belady");
//firm_dbg_set_mask(dbg, DBG_SPILL);
+ be_assure_liveness(chordal_env->birg);
+
/* init belady env */
obstack_init(&env.ob);
env.cenv = chordal_env;
#include "config.h"
#endif
+#include "irtools.h"
+
#include "bespilloptions.h"
+#include "bemodule.h"
+#include "be.h"
-#ifdef WITH_LIBCORE
#include <libcore/lc_opts.h>
#include <libcore/lc_opts_enum.h>
#include <libcore/lc_timing.h>
-#endif /* WITH_LIBCORE */
int be_coalesce_spill_slots = 1;
int be_do_remats = 1;
-#ifdef WITH_LIBCORE
static const lc_opt_table_entry_t be_spill_options[] = {
LC_OPT_ENT_BOOL ("coalesce_slots", "coalesce the spill slots", &be_coalesce_spill_slots),
LC_OPT_ENT_BOOL ("remat", "try to rematerialize values instead of reloading", &be_do_remats),
{ NULL }
};
-void be_spill_register_options(lc_opt_entry_t *grp)
+void be_init_spill(void)
{
- static int run_once = 0;
- lc_opt_entry_t *spill_grp;
-
- if (run_once)
- return;
-
- run_once = 1;
- spill_grp = lc_opt_get_grp(grp, "spill");
+ lc_opt_entry_t *be_grp = lc_opt_get_grp(firm_opt_get_root(), "be");
+ lc_opt_entry_t *spill_grp = lc_opt_get_grp(be_grp, "spill");
lc_opt_add_table(spill_grp, be_spill_options);
}
-#endif /* WITH_LIBCORE */
+
+BE_REGISTER_MODULE_CONSTRUCTOR(be_init_spill);
extern int be_coalesce_spill_slots;
extern int be_do_remats;
-#ifdef WITH_LIBCORE
-#include <libcore/lc_opts.h>
-void be_spill_register_options(lc_opt_entry_t *grp);
-#endif
-
#endif
{ NULL }
};
-void be_spill_remat_register_options(lc_opt_entry_t *grp)
+void be_init_spillremat(void)
{
- lc_opt_entry_t *my_grp = lc_opt_get_grp(grp, "remat");
- lc_opt_add_table(my_grp, options);
+ 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_entry_t *remat_grp = lc_opt_get_grp(chordal_grp, "remat");
+
+ lc_opt_add_table(remat_grp, options);
}
+
+BE_REGISTER_MODULE_CONSTRUCTOR(be_init_spillremat);
#endif
#include "../bemachine.h"
#include "../beilpsched.h"
#include "../bespillslots.h"
+#include "../bemodule.h"
#include "bearch_ia32_t.h"
* ia32-nopushargs do not create pushs for function argument passing
* ia32-gasmode set the GAS compatibility mode
*/
-static void ia32_register_options(lc_opt_entry_t *ent)
+void be_init_arch_ia32(void)
{
- lc_opt_entry_t *be_grp_ia32 = lc_opt_get_grp(ent, "ia32");
- lc_opt_add_table(be_grp_ia32, ia32_options);
+ lc_opt_entry_t *be_grp = lc_opt_get_grp(firm_opt_get_root(), "be");
+ lc_opt_entry_t *ia32_grp = lc_opt_get_grp(be_grp, "ia32");
+
+ lc_opt_add_table(ia32_grp, ia32_options);
}
+BE_REGISTER_MODULE_CONSTRUCTOR(be_init_arch_ia32);
#endif /* WITH_LIBCORE */
const arch_isa_if_t ia32_isa_if = {
ia32_get_libfirm_params,
ia32_get_allowed_execution_units,
ia32_get_machine,
-#ifdef WITH_LIBCORE
- ia32_register_options
-#endif
};
* Purpose: Implements several optimizations for IA32
* Author: Christian Wuerdig
* CVS-ID: $Id$
- * Copyright: (c) 2006 Universitรคt Karlsruhe
+ * Copyright: (c) 2006 Universitaet Karlsruhe
* Licence: This file protected by GPL - GNU GENERAL PUBLIC LICENSE.
*/
#include "../be.h"
#include "../beabi.h"
#include "../bemachine.h"
+#include "../bemodule.h"
#include "bearch_mips_t.h"
}
#ifdef WITH_LIBCORE
-static void mips_register_options(lc_opt_entry_t *ent)
+void be_init_arch_mips(void)
{
}
+BE_REGISTER_MODULE_CONSTRUCTOR(be_init_arch_mips);
#endif /* WITH_LIBCORE */
const arch_isa_if_t mips_isa_if = {
mips_get_libfirm_params,
mips_get_allowed_execution_units,
mips_get_machine,
-#ifdef WITH_LIBCORE
- mips_register_options
-#endif
};
#include "../be.h"
#include "../beabi.h"
#include "../bemachine.h"
+#include "../bemodule.h"
+#include "../beblocksched.h"
#include "pset.h"
*/
static void ppc32_before_ra(void *self) {
ppc32_code_gen_t *cg = self;
- cg->blk_sched = sched_create_block_schedule(cg->irg, cg->birg->exec_freq);
+ cg->blk_sched = be_create_block_schedule(cg->irg, cg->birg->exec_freq);
}
static void ppc32_transform_spill(ir_node *node, void *env)
return &p;
}
-#ifdef WITH_LIBCORE
-static void ppc32_register_options(lc_opt_entry_t *ent)
+void be_init_arch_ppc32(void)
{
}
-#endif /* WITH_LIBCORE */
+BE_REGISTER_MODULE_CONSTRUCTOR(be_init_arch_ppc32);
const arch_isa_if_t ppc32_isa_if = {
ppc32_init,
ppc32_get_libfirm_params,
ppc32_get_allowed_execution_units,
ppc32_get_machine,
-#ifdef WITH_LIBCORE
- ppc32_register_options
-#endif
};