X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fbe%2Fbemain.c;h=005223936792fd513bfb0e7879f12443981501ab;hb=5cc462a3b818894990ff363e93a0cd4ab38fa503;hp=b33b277765c65e1768a08c26c7084c89021f31a8;hpb=cd24451220d027f8f2620d01019de23091895374;p=libfirm diff --git a/ir/be/bemain.c b/ir/be/bemain.c index b33b27776..005223936 100644 --- a/ir/be/bemain.c +++ b/ir/be/bemain.c @@ -60,7 +60,6 @@ #include "bestat.h" #include "beverify.h" #include "beprofile.h" -#include "beblocksched.h" #include "be_dbgout.h" #ifdef WITH_ILP @@ -219,7 +218,6 @@ const backend_params *be_init(void) { be_opt_register(); be_init_modules(); - phi_class_init(); if (isa_if->get_params) return isa_if->get_params(); @@ -318,6 +316,8 @@ static void initialize_birg(be_irg_t *birg, ir_graph *irg, be_main_env_t *env) /* reset the phi handler. */ be_phi_handler_reset(env->phi_handler); + + set_irg_phase_state(irg, phase_backend); } #ifdef WITH_LIBCORE @@ -373,6 +373,7 @@ static void be_main_loop(FILE *file_handle, const char *cup_name) static const char suffix[] = ".prof"; be_irg_t *birgs; unsigned num_birgs; + ir_graph **irg_list, **backend_irg_list; be_ra_timer_t *ra_timer; @@ -407,16 +408,20 @@ static void be_main_loop(FILE *file_handle, const char *cup_name) be_dbg_so(env.db_handle, cup_name); be_dbg_types(env.db_handle); + /* backend may provide an ordered list of irgs where code should be generated for */ + irg_list = NEW_ARR_F(ir_graph *, 0); + backend_irg_list = arch_isa_get_backend_irg_list(isa, &irg_list); + /* we might need 1 birg more for instrumentation constructor */ - num_birgs = get_irp_n_irgs(); + num_birgs = backend_irg_list ? ARR_LEN(backend_irg_list) : get_irp_n_irgs(); birgs = alloca(sizeof(birgs[0]) * (num_birgs + 1)); /* First: initialize all birgs */ - for(i = 0; i < get_irp_n_irgs(); ++i) { - ir_graph *irg = get_irp_irg(i); - + for(i = 0; i < num_birgs; ++i) { + ir_graph *irg = backend_irg_list ? backend_irg_list[i] : get_irp_irg(i); initialize_birg(&birgs[i], irg, &env); } + DEL_ARR_F(irg_list); /* Get the filename for the profiling data. @@ -435,14 +440,13 @@ static void be_main_loop(FILE *file_handle, const char *cup_name) initialize_birg(&birgs[num_birgs], prof_init_irg, &env); num_birgs++; set_method_img_section(get_irg_entity(prof_init_irg), section_constructors); - } - else { + } else { be_profile_read(prof_filename); } /* For all graphs */ for (i = 0; i < num_birgs; ++i) { - be_irg_t *birg = & birgs[i]; + be_irg_t *birg = &birgs[i]; ir_graph *irg = birg->irg; optimization_state_t state; const arch_code_generator_if_t *cg_if; @@ -485,15 +489,6 @@ static void be_main_loop(FILE *file_handle, const char *cup_name) } BE_TIMER_POP(t_verify); - /** - * Create execution frequencies from profile data or estimate some - */ - if (be_profile_has_data()) { - birg->exec_freq = be_create_execfreqs_from_profile(irg); - } else { - birg->exec_freq = compute_execfreq(irg, 10); - } - BE_TIMER_ONLY(num_nodes_b = get_num_reachable_nodes(irg)); /* Get the code generator interface. */ @@ -516,6 +511,14 @@ static void be_main_loop(FILE *file_handle, const char *cup_name) dump(DUMP_ABI, irg, "-abi", dump_ir_block_graph); be_do_stat_nodes(irg, "02 Abi"); + if (be_options.vrfy_option == BE_VRFY_WARN) { + be_check_dominance(irg); + be_verify_out_edges(irg); + } else if (be_options.vrfy_option == BE_VRFY_ASSERT) { + assert(be_verify_out_edges(irg)); + assert(be_check_dominance(irg) && "Dominance verification failed"); + } + /* generate code */ BE_TIMER_PUSH(t_codegen); arch_code_generator_prepare_graph(birg->cg); @@ -523,19 +526,31 @@ static void be_main_loop(FILE *file_handle, const char *cup_name) be_do_stat_nodes(irg, "03 Prepare"); - /* - Since the code generator made a lot of new nodes and skipped - a lot of old ones, we should do dead node elimination here. - Note that this requires disabling the edges here. - */ + /* Transformation may produce nodes only reachable via out edges, kill them. */ +#if 1 edges_deactivate(irg); - //dead_node_elimination(irg); edges_activate(irg); - - /* Compute loop nesting information (for weighting copies) */ +#endif dump(DUMP_PREPARED, irg, "-prepared", dump_ir_block_graph); BE_TIMER_ONLY(num_nodes_r = get_num_reachable_nodes(irg)); + if (be_options.vrfy_option == BE_VRFY_WARN) { + be_check_dominance(irg); + be_verify_out_edges(irg); + } else if (be_options.vrfy_option == BE_VRFY_ASSERT) { + assert(be_verify_out_edges(irg)); + assert(be_check_dominance(irg) && "Dominance verification failed"); + } + + /** + * Create execution frequencies from profile data or estimate some + */ + if (be_profile_has_data()) { + birg->exec_freq = be_create_execfreqs_from_profile(irg); + } else { + birg->exec_freq = compute_execfreq(irg, 10); + } + /* let backend prepare scheduling */ BE_TIMER_PUSH(t_codegen); arch_code_generator_before_sched(birg->cg); @@ -637,6 +652,8 @@ static void be_main_loop(FILE *file_handle, const char *cup_name) be_abi_fix_stack_bias(birg->abi); BE_TIMER_POP(t_abi); + dump(DUMP_SCHED, irg, "-fix_stack_after_ra", dump_ir_block_graph_sched); + BE_TIMER_PUSH(t_finish); arch_code_generator_finish(birg->cg); BE_TIMER_POP(t_finish); @@ -667,7 +684,7 @@ static void be_main_loop(FILE *file_handle, const char *cup_name) arch_code_generator_done(birg->cg); BE_TIMER_POP(t_emit); - dump(DUMP_FINAL, irg, "-end", dump_ir_extblock_graph_sched); + dump(DUMP_FINAL, irg, "-end", dump_ir_block_graph_sched); BE_TIMER_PUSH(t_abi); be_abi_free(birg->abi);