X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fbe%2Fbemain.c;h=82ed7e44a2c2ffe6172b2b176715e3c20e90579f;hb=ad8368234bf59eb46fbc0cfff5b7322a7efac964;hp=ab22f64b1d78222b0afcf95bf6a1a5c0c26de47e;hpb=742bc895a0407b132971382c5c12f60342d15dae;p=libfirm diff --git a/ir/be/bemain.c b/ir/be/bemain.c index ab22f64b1..82ed7e44a 100644 --- a/ir/be/bemain.c +++ b/ir/be/bemain.c @@ -38,20 +38,25 @@ #include "benode_t.h" #include "beirgmod.h" #include "bespillilp.h" +#include "bespillbelady.h" #include "beasm_dump_globals.h" #include "beasm_asm_gnu.h" -#undef DUMP_ALLOCATED -#define DUMP_PREPARED -#define DUMP_SPILL -#define DUMP_SCHED -#undef DUMP_POST +#include "firm2arch.h" +#undef DUMP_BEGIN +#undef DUMP_PREPARED +#define DUMP_TRANSFORM +#define DUMP_SCHED +#define DUMP_SPILL +#undef DUMP_ALLOCATED +#undef DUMP_COPYMIN +#undef DUMP_SSADESTR +#undef DUMP_END #define N_PHASES 256 - void be_init(void) { be_sched_init(); @@ -123,11 +128,7 @@ static void prepare_graph(be_main_session_env_t *s) if (get_irg_loopinfo_state(s->irg) != (loopinfo_valid & loopinfo_cf_consistent)) construct_cf_backedges(s->irg); -#ifdef DUMP_PREPARED - dump_dominator_information(true); - dump_ir_block_graph(s->irg, "-prepared"); - dump_dominator_information(false); -#endif + be_check_dominance(s->irg); } static void be_main_loop(void) @@ -139,15 +140,19 @@ static void be_main_loop(void) be_init_env(&env); isa = arch_env_get_isa(env.arch_env); + /* create required irop's */ + create_bearch_asm_opcodes(); + /* For all graphs */ for(i = 0, n = get_irp_n_irgs(); i < n; ++i) { int j, m; ir_graph *irg = get_irp_irg(i); be_main_session_env_t session; - dump_ir_block_graph(irg, "-be-begin"); - - DBG((env.dbg, LEVEL_1, "====> IRG: %F\n", irg)); + DBG((env.dbg, LEVEL_2, "====> IRG: %F\n", irg)); +#ifdef DUMP_BEGIN + dump_ir_block_graph(irg, "-begin"); +#endif /* Init the session. */ be_init_session_env(&session, &env, irg); @@ -155,8 +160,24 @@ static void be_main_loop(void) /* Compute some analyses and prepare the graph for backend use. */ prepare_graph(&session); + transform_firm(irg); + +#ifdef DUMP_TRANSFORM + dump_ir_block_graph(irg, "-transformed"); +#endif + + +#if 0 +#ifdef DUMP_PREPARED + dump_dominator_information(true); + dump_ir_block_graph(irg, "-prepared"); + dump_dominator_information(false); +#endif + /* Schedule the graphs. */ list_sched(irg, trivial_selector); + be_sched_imm(irg); + #ifdef DUMP_SCHED dump_ir_block_graph_sched(irg, "-sched"); #endif @@ -171,10 +192,11 @@ static void be_main_loop(void) for(j = 0, m = isa->get_n_reg_class(); j < m; ++j) { be_chordal_env_t *chordal_env; const arch_register_class_t *cls = isa->get_reg_class(j); - DBG((env.dbg, LEVEL_1, "----> Reg class: %s\n", cls->name)); - be_spill_ilp(&session, cls); + /* spilling */ + //be_spill_ilp(&session, cls); + be_spill_belady(&session, cls); #ifdef DUMP_SPILL dump_ir_block_graph_sched(session.irg, "-spill"); #endif @@ -194,45 +216,45 @@ static void be_main_loop(void) } #endif + /* allocation */ chordal_env = be_ra_chordal(&session, cls); - #ifdef DUMP_ALLOCATED dump_allocated_irg(env.arch_env, irg, ""); #endif - copystat_collect_cls(chordal_env); - dump_allocated_irg(env.arch_env, irg, "pre"); + /* copy minimization */ + copystat_collect_cls(chordal_env); be_copy_opt(chordal_env); - dump_allocated_irg(env.arch_env, irg, "post"); +#ifdef DUMP_COPYMIN + dump_allocated_irg(env.arch_env, irg, "-copymin"); +#endif + /* ssa destruction */ be_ssa_destruction(chordal_env); be_ssa_destruction_check(chordal_env); be_ra_chordal_check(chordal_env); +#ifdef DUMP_SSADESTR + dump_allocated_irg(env.arch_env, irg, "-ssadestr"); +#endif be_ra_chordal_done(chordal_env); be_numbering_done(irg); } -#ifdef DUMP_POST - dump_ir_block_graph_sched(session.irg, "-post"); +#ifdef DUMP_END + dump_ir_block_graph_sched(session.irg, "-end"); #endif copystat_dump(irg); +#endif /* if 0 */ } } void be_main(int argc, const char *argv[]) { - assembler_t *gnu_assembler; - FILE *asm_output_file; + FILE *asm_output_file; - be_main_loop(); + be_main_loop(); -#if 0 - gnu_assembler = gnuasm_create_assembler(); - asm_output_file = fopen("asm_output.asm", "w"); - - asm_dump_globals(gnu_assembler); - gnuasm_dump(gnu_assembler, asm_output_file); - gnuasm_delete_assembler(gnu_assembler); - fclose(asm_output_file); -#endif + asm_output_file = fopen(argv[0], "w"); + firmbe_gen_code(asm_output_file); + fclose(asm_output_file); }