From e96155a7245cb7eee1de5980f8a158582a8dcff0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Christian=20W=C3=BCrdig?= Date: Tue, 24 Jan 2006 14:58:41 +0000 Subject: [PATCH] added codegenerator to main environment changed interface names for getting codegen interface added callbacks to codegen interface for spill/reload lowering --- ir/be/be_t.h | 1 + ir/be/bearch.h | 12 +++++++++++- ir/be/bemain.c | 13 ++++++------- ir/be/firm/bearch_firm.c | 12 +++++++----- 4 files changed, 25 insertions(+), 13 deletions(-) diff --git a/ir/be/be_t.h b/ir/be/be_t.h index 8d7f90ccb..6da99d4da 100644 --- a/ir/be/be_t.h +++ b/ir/be/be_t.h @@ -25,6 +25,7 @@ struct _be_main_env_t { struct _be_node_factory_t *node_factory; struct _arch_env_t *arch_env; struct _be_options_t *options; + struct _arch_code_generator_t *cg; firm_dbg_module_t *dbg; }; diff --git a/ir/be/bearch.h b/ir/be/bearch.h index 2c90be827..c287d33ca 100644 --- a/ir/be/bearch.h +++ b/ir/be/bearch.h @@ -404,6 +404,16 @@ struct _arch_code_generator_if_t { */ void (*before_ra)(void *self); + /** + * Called after register allocation to lower Spills to Stores + */ + ir_node *(*lower_spill)(void *self, ir_node *spill); + + /** + * Called after register allocation to lower Reloads to Loads + */ + ir_node *(*lower_reload)(void *self, ir_node *reload); + /** * Called after everything happened. * The code generator must also be de-allocated here. @@ -482,7 +492,7 @@ struct _arch_isa_if_t { * @param self The this pointer. * @return Some code generator interface. */ - const arch_code_generator_if_t *(*get_code_generator)(void *self); + const arch_code_generator_if_t *(*get_code_generator_if)(void *self); /** * Get the list scheduler to use. diff --git a/ir/be/bemain.c b/ir/be/bemain.c index 96b421b56..a0e0e584d 100644 --- a/ir/be/bemain.c +++ b/ir/be/bemain.c @@ -238,7 +238,6 @@ static void be_main_loop(FILE *file_handle) for(i = 0, n = get_irp_n_irgs(); i < n; ++i) { ir_graph *irg = get_irp_irg(i); - arch_code_generator_t *cg; const arch_code_generator_if_t *cg_if; DBG((env.dbg, LEVEL_2, "====> IRG: %F\n", irg)); @@ -248,14 +247,14 @@ static void be_main_loop(FILE *file_handle) current_ir_graph = irg; /* Get the code generator interface. */ - cg_if = isa->impl->get_code_generator(isa); + cg_if = isa->impl->get_code_generator_if(isa); /* get a code generator for this graph. */ - cg = cg_if->init(file_handle, irg, env.arch_env); + env.cg = cg_if->init(file_handle, irg, env.arch_env); /* create the code generator and generate code. */ prepare_graph(&env, irg); - arch_code_generator_prepare_graph(cg); + arch_code_generator_prepare_graph(env.cg); edges_deactivate(irg); dead_node_elimination(irg); @@ -264,7 +263,7 @@ static void be_main_loop(FILE *file_handle) dump(DUMP_PREPARED, irg, "-prepared", dump_ir_block_graph); /* Schedule the graphs. */ - arch_code_generator_before_sched(cg); + arch_code_generator_before_sched(env.cg); list_sched(isa, irg); dump(DUMP_SCHED, irg, "-sched", dump_ir_block_graph_sched); @@ -273,12 +272,12 @@ static void be_main_loop(FILE *file_handle) sched_verify_irg(irg); /* Do register allocation */ - arch_code_generator_before_ra(cg); + arch_code_generator_before_ra(env.cg); ra->allocate(&env, irg); dump(DUMP_RA, irg, "-ra", dump_ir_block_graph_sched); - arch_code_generator_done(cg); + arch_code_generator_done(env.cg); dump(DUMP_FINAL, irg, "-end", dump_ir_block_graph_sched); } diff --git a/ir/be/firm/bearch_firm.c b/ir/be/firm/bearch_firm.c index ad3ab0d75..4e01c33da 100644 --- a/ir/be/firm/bearch_firm.c +++ b/ir/be/firm/bearch_firm.c @@ -500,26 +500,28 @@ static void firm_codegen_done(void *self) static void *firm_cg_init(FILE *file_handle, ir_graph *irg, const arch_env_t *env); -static const arch_code_generator_if_t firm_code_gen = { +static const arch_code_generator_if_t firm_code_gen_if = { firm_cg_init, firm_prepare_graph, firm_before_sched, firm_before_ra, + NULL, /* lower spill */ + NULL, /* lower reload */ firm_codegen_done }; static void *firm_cg_init(FILE *file_handle, ir_graph *irg, const arch_env_t *env) { firm_code_gen_t *cg = xmalloc(sizeof(*cg)); - cg->impl = &firm_code_gen; + cg->impl = &firm_code_gen_if; cg->irg = irg; return cg; } -static const arch_code_generator_if_t *firm_get_code_generator(void *self) +static const arch_code_generator_if_t *firm_get_code_generator_if(void *self) { - return &firm_code_gen; + return &firm_code_gen_if; } static const list_sched_selector_t *firm_get_list_sched_selector(const void *self) { @@ -541,6 +543,6 @@ const arch_isa_if_t firm_isa = { firm_get_n_reg_class, firm_get_reg_class, firm_get_irn_handler, - firm_get_code_generator, + firm_get_code_generator_if, firm_get_list_sched_selector }; -- 2.20.1