Commit da48a7f7 authored by Matthias Braun's avatar Matthias Braun
Browse files

- All backend modules use module constructors for registering their options now

- New register allocator modules can register themselfes in a list now,
	the same will be done for spillers, copy coalescers, architectures soon
parent 6d2368b0
......@@ -21,6 +21,7 @@
#include "../besched_t.h"
#include "../be.h"
#include "../beabi.h"
#include "../bemodule.h"
#include "bearch_TEMPLATE_t.h"
......@@ -585,11 +586,10 @@ static const backend_params *TEMPLATE_get_libfirm_params(void) {
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,
......@@ -603,7 +603,4 @@ const arch_isa_if_t TEMPLATE_isa_if = {
TEMPLATE_get_list_sched_selector,
TEMPLATE_get_reg_class_alignment,
TEMPLATE_get_libfirm_params,
#ifdef WITH_LIBCORE
TEMPLATE_register_options
#endif
};
......@@ -19,6 +19,7 @@
#include "irargs_t.h"
#include "../besched.h"
#include "../beblocksched.h"
#include "arm_emitter.h"
#include "gen_arm_emitter.h"
......@@ -951,7 +952,7 @@ void arm_gen_routine(FILE *F, ir_graph *irg, const arm_code_gen_t *cg) {
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);
......
......@@ -29,6 +29,7 @@
#include "../beabi.h"
#include "../bemachine.h"
#include "../beilpsched.h"
#include "../bemodule.h"
#include "bearch_arm_t.h"
......@@ -1148,11 +1149,14 @@ static const lc_opt_table_entry_t arm_options[] = {
* 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 = {
......@@ -1170,7 +1174,4 @@ 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
};
......@@ -132,7 +132,7 @@ struct _arm_isa_t {
arm_code_gen_t *cg; /**< current code generator */
FILE *out; /**< output file */
unsigned fpu_arch; /**< FPU architecture */
int fpu_arch; /**< FPU architecture */
};
......
......@@ -8,6 +8,12 @@
#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)
/**
......
......@@ -736,14 +736,6 @@ struct _arch_isa_if_t {
* @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))
......
......@@ -25,6 +25,8 @@
#include "irtools.h"
#include "debug.h"
#include "beirgmod.h"
#include "bemodule.h"
#include "be.h"
#ifdef WITH_LIBCORE
#include <libcore/lc_opts.h>
......@@ -696,22 +698,15 @@ static ir_node **create_extbb_block_schedule(ir_graph *irg, ir_exec_freq *execfr
* |_| |_|\__,_|_|_| |_|
*
*/
#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)
{
......
......@@ -15,9 +15,4 @@
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 */
......@@ -11,11 +11,6 @@
#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
......@@ -57,6 +57,7 @@
#include "benode_t.h"
#include "bestatevent.h"
#include "bestat.h"
#include "bemodule.h"
#include "bespillbelady.h"
#include "bespillmorgan.h"
......@@ -94,7 +95,6 @@ typedef struct _post_spill_env_t {
double pre_spill_cost;
} post_spill_env_t;
#ifdef WITH_LIBCORE
static be_ra_timer_t ra_timer = {
NULL,
NULL,
......@@ -110,8 +110,8 @@ static be_ra_timer_t ra_timer = {
};
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 */
......@@ -191,8 +191,6 @@ static const lc_opt_table_entry_t be_chordal_options[] = {
{ 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;
......@@ -243,28 +241,6 @@ int nodes_interfere(const be_chordal_env_t *env, const ir_node *a, const ir_node
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,
......@@ -706,7 +682,7 @@ static void post_spill(post_spill_env_t *pse) {
* @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);
......@@ -821,17 +797,22 @@ static be_ra_timer_t *be_ra_chordal_main(be_irg_t *birg)
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);
......@@ -30,6 +30,7 @@
#include "irprintf.h"
#include "irtools.h"
#include "bemodule.h"
#include "beabi.h"
#include "benode_t.h"
#include "becopyopt.h"
......@@ -69,11 +70,17 @@ static const lc_opt_table_entry_t options[] = {
{ 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
/*
......
......@@ -31,6 +31,7 @@
#include "irprintf.h"
#include "irtools.h"
#include "bemodule.h"
#include "beabi.h"
#include "benode_t.h"
#include "becopyopt.h"
......@@ -66,13 +67,18 @@ static const lc_opt_table_entry_t options[] = {
{ 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)
{
......
......@@ -45,11 +45,18 @@ static const lc_opt_table_entry_t options[] = {
{ 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 */
......
......@@ -29,7 +29,7 @@
#include "irphase_t.h"
#include "irprintf_t.h"
#include "bemodule.h"
#include "bearch.h"
#include "benode_t.h"
#include "beutil.h"
......@@ -136,17 +136,17 @@ extern void be_co_ilp_register_options(lc_opt_entry_t *grp);
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
......@@ -165,9 +165,6 @@ void co_register_options(lc_opt_entry_t *grp)
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;
......
......@@ -48,11 +48,6 @@ enum {
/** 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);
......
......@@ -22,6 +22,7 @@
#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;)
......@@ -94,24 +95,26 @@ static pset *all_phi_classes;
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();
}
/**
......
......@@ -13,8 +13,6 @@
#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);
......
......@@ -1891,16 +1891,12 @@ void be_ilp_sched(const be_irg_t *birg) {
/**
* 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 */
......
......@@ -43,11 +43,16 @@ static const lc_opt_table_entry_t options[] = {
{ 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>
......@@ -463,5 +468,4 @@ void be_java_coal_start_jvm(void)
{
}
#endif /* WITH_JVM */
......@@ -32,6 +32,7 @@
#include "debug.h"
#include "irtools.h"
#include "bemodule.h"
#include "besched_t.h"
#include "beutil.h"
#include "belive_t.h"
......@@ -622,16 +623,12 @@ void list_sched(const be_irg_t *birg, be_options_t *be_opts)
/**
* 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 */
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment