X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fbe%2Fbemain.c;h=3fd710d98a89a7a3f8763c143e60a03f93794d45;hb=3959bcf756b76ddefe1e6c0ae6c1d0d3cb2280eb;hp=08a4576ca6bb7f73bf489e961f358bd871e66272;hpb=e5ab50e3025460b25b6287e7bb3659d6256e38fb;p=libfirm diff --git a/ir/be/bemain.c b/ir/be/bemain.c index 08a4576ca..3fd710d98 100644 --- a/ir/be/bemain.c +++ b/ir/be/bemain.c @@ -15,6 +15,7 @@ #include "irprog.h" #include "irgraph.h" #include "irdump.h" +#include "phiclass.h" #include "be_t.h" #include "bera_t.h" @@ -26,6 +27,8 @@ #include "bechordal.h" #include "bearch.h" #include "becopyoptmain.h" +#include "becopystat.h" +#include "bearch_firm.h" #include "beasm_dump_globals.h" #include "beasm_asm_gnu.h" @@ -35,87 +38,40 @@ #define N_PHASES 256 -typedef struct _be_graph_info_t { - bitset_t *applied_phases; -} be_graph_info_t; - -static size_t be_info_offset = 0; - -#define get_irg_be_info(irg) get_irg_data(irg, be_graph_info_t, be_info_offset) - -static int phase_ids = 1; -static struct obstack obst; - -int phase_register(phase_t *phase) -{ - phase->id = phase_ids; - return phase_ids++; -} - -void phase_applied(const ir_graph *irg, const phase_t *phase) -{ - be_graph_info_t *info = get_irg_be_info(irg); - - if(!info->applied_phases) - info->applied_phases = bitset_obstack_alloc(&obst, N_PHASES); - - bitset_set(info->applied_phases, phase->id); -} - -int phase_depends_on(const ir_graph *irg, const phase_t *phase, int n, ...) -{ - int errors = 0; - int i; - va_list args; - - if(n > 0) { - const be_graph_info_t *info = get_irg_be_info(irg); - const bitset_t *applied_phases = info->applied_phases; - - va_start(args, n); - - for(i = 0; i < n; ++i) { - const phase_t *dep_phase = va_arg(args, const phase_t *); - - if(!applied_phases || !bitset_is_set(applied_phases, dep_phase->id)) { - errors++; - fprintf(stderr, "phase dependency unfulfilled: \"%s\" depends on \"%s\"\n", - phase->name, dep_phase->name); - } - } - - va_end(args); - - assert(errors > 0 && "There were phase dependency errors"); - } - - return errors; -} void be_init(void) { - obstack_init(&obst); - be_info_offset = register_additional_graph_data(sizeof(be_graph_info_t)); - be_sched_init(); be_liveness_init(); be_numbering_init(); be_ra_init(); be_ra_chordal_init(); be_copy_opt_init(); +#ifdef DO_STAT + stat_init(); +#endif } -/* The preliminary Firm backend isa. */ -extern arch_isa_if_t arch_isa_if_firm; +static void be_init_arch_env(arch_env_t *env) +{ + arch_env_init(env, &firm_isa); + arch_env_add_irn_handler(env, &firm_irn_handler); + + env->isa->init(); +} static void be_main_loop(void) { int i, n; - const arch_isa_if_t *isa = &arch_isa_if_firm; + arch_env_t env; + const arch_isa_if_t *isa; - for(i = 0, n = get_irp_n_irgs(); i < n; ++i) { - int j, m; + be_init_arch_env(&env); + + isa = arch_env_get_isa(&env); + for(i = 0, n = get_irp_n_irgs(); i < n; ++i) { + int j, m; ir_graph *irg = get_irp_irg(i); localize_consts(irg); @@ -125,36 +81,41 @@ static void be_main_loop(void) #endif be_numbering(irg); - /* Schedule the graphs. */ + /* Schedule the graphs. */ list_sched(irg, trivial_selector); - /* Liveness analysis */ - be_liveness(irg); + /* Liveness analysis */ + be_liveness(irg); - /* - * Perform the following for each register - * class. - */ - for(j = 0, m = isa->get_n_reg_class(); j < m; ++j) { - const arch_register_class_t *cls = isa->get_reg_class(j); +#ifdef DO_STAT + stat_reset(); +#endif + /* Perform the following for each register class. */ + for(j = 0, m = isa->get_n_reg_class(); j < m; ++j) { + const arch_register_class_t *cls = isa->get_reg_class(j); - be_ra_chordal(irg, isa, cls); + be_ra_chordal(irg, &env, cls); #ifdef DUMP_ALLOCATED - dump_allocated_irg(irg, ""); + dump_allocated_irg(&env, irg, ""); #endif - // be_copy_opt(irg); - be_ra_chordal_done(irg); - } - - be_numbering_done(irg); +#ifdef DO_STAT + stat_collect_irg(irg); +#endif + be_copy_opt(irg, isa, cls); + be_ra_chordal_done(irg); + } +#ifdef DO_STAT + stat_dump(irg); +#endif + be_numbering_done(irg); } } void be_main(int argc, const char *argv[]) { - assembler_t *gnu_assembler; - FILE *asm_output_file; + assembler_t *gnu_assembler; + FILE *asm_output_file; be_main_loop(); gnu_assembler = gnuasm_create_assembler();