X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=driver%2Ffirm_opt.c;h=50139c02ba9023ed0e87aa0d312ed521fc0e877f;hb=27f4ce3da8d78ff0e70afde834793e0ebd81a42a;hp=653cb1d9b7b0e3936606ac0c0ee1193d011fcfa7;hpb=91bf133d80ee1e2376ef94b1563408d79d28368d;p=cparser diff --git a/driver/firm_opt.c b/driver/firm_opt.c index 653cb1d..50139c0 100644 --- a/driver/firm_opt.c +++ b/driver/firm_opt.c @@ -6,8 +6,10 @@ * * $Id$ */ +#include #include #include +#include #include #include #include @@ -307,6 +309,7 @@ static void do_optimize_funccalls(void) static void do_gcse(ir_graph *irg) { set_opt_global_cse(1); + optimize_graph_df(irg); place_code(irg); set_opt_global_cse(0); } @@ -328,7 +331,7 @@ static void do_stred(ir_graph *irg) static void do_inline(void) { - inline_functions(500, 50); + inline_functions(firm_opt.inline_maxsize, firm_opt.inline_threshold); } static void do_cloning(void) @@ -338,7 +341,7 @@ static void do_cloning(void) static void do_lower_switch(ir_graph *irg) { - lower_switch(irg, 128); + lower_switch(irg, firm_opt.spare_size); } typedef enum opt_target { @@ -376,7 +379,7 @@ static opt_config_t opts[] = { { OPT_TARGET_IRG, "place", (func_ptr_t) place_code, true, true, true, TV_CODE_PLACE }, { OPT_TARGET_IRG, "confirm", (func_ptr_t) construct_confirms, true, true, true, TV_CONFIRM_CREATE }, { OPT_TARGET_IRG, "ldst", (func_ptr_t) optimize_load_store, true, true, true, TV_LOAD_STORE }, - { OPT_TARGET_IRG, "ldst2", (func_ptr_t) opt_ldst2, true, true, true, -1 }, + { OPT_TARGET_IRG, "sync", (func_ptr_t) opt_sync, true, true, true, -1 }, { OPT_TARGET_IRG, "lower", (func_ptr_t) do_lower_highlevel, true, true, true, -1 }, { OPT_TARGET_IRG, "deconv", (func_ptr_t) conv_opt, true, true, true, TV_DECONV }, { OPT_TARGET_IRG, "condeval", (func_ptr_t) opt_cond_eval, true, true, true, TV_COND_EVAL }, @@ -476,6 +479,7 @@ static void do_firm_optimizations(const char *input_filename) set_opt_scalar_replacement(firm_opt.scalar_replace); set_opt_auto_create_sync(firm_opt.auto_sync); set_opt_alias_analysis(firm_opt.alias_analysis); + set_opt_combo(firm_opt.combo); aa_opt = aa_opt_no_opt; if (firm_opt.strict_alias) @@ -494,7 +498,7 @@ static void do_firm_optimizations(const char *input_filename) set_opt_enabled("place", !firm_opt.gcse); set_opt_enabled("confirm", firm_opt.confirm); set_opt_enabled("remove_confirms", firm_opt.confirm); - set_opt_enabled("ldst2", firm_opt.luffig); + set_opt_enabled("sync", firm_opt.sync); set_opt_enabled("ldst", firm_opt.load_store); set_opt_enabled("deconv", firm_opt.deconv); set_opt_enabled("condeval", firm_opt.cond_eval); @@ -509,15 +513,18 @@ static void do_firm_optimizations(const char *input_filename) do_irp_opt("rts"); - for (i = 0; i < get_irp_n_irgs(); i++) { - ir_graph *irg = get_irp_irg(i); - do_irg_opt(irg, "combo"); - do_irg_opt(irg, "local"); - - /* Confirm construction currently can only handle blocks with only one control - flow predecessor. Calling optimize_cf here removes Bad predecessors and help - the optimization of switch constructs. */ - do_irg_opt(irg, "controlflow"); + /* first step: kill dead code */ + if (firm_opt.combo) { + for (i = 0; i < get_irp_n_irgs(); i++) { + ir_graph *irg = get_irp_irg(i); + do_irg_opt(irg, "combo"); + } + } else { + for (i = 0; i < get_irp_n_irgs(); i++) { + ir_graph *irg = get_irp_irg(i); + do_irg_opt(irg, "local"); + do_irg_opt(irg, "controlflow"); + } } do_irp_opt("gc_irgs"); @@ -529,16 +536,16 @@ static void do_firm_optimizations(const char *input_filename) ir_graph *irg = get_irp_irg(i); #ifdef FIRM_EXT_GRS - /* If SIMD optimization is on, make sure we have only 1 return */ - if (firm_ext_grs.create_pattern || firm_ext_grs.simd_opt) - do_irg_opt("onereturn"); + /* If SIMD optimization is on, make sure we have only 1 return */ + if (firm_ext_grs.create_pattern || firm_ext_grs.simd_opt) + do_irg_opt("onereturn"); #endif - do_irg_opt(irg, "scalar"); - do_irg_opt(irg, "local"); - do_irg_opt(irg, "reassoc"); - do_irg_opt(irg, "local"); - do_irg_opt(irg, "gcse"); + do_irg_opt(irg, "scalar"); + do_irg_opt(irg, "local"); + do_irg_opt(irg, "reassoc"); + do_irg_opt(irg, "local"); + do_irg_opt(irg, "gcse"); if (firm_opt.confirm) { /* Confirm construction currently can only handle blocks with only one control @@ -549,7 +556,6 @@ static void do_firm_optimizations(const char *input_filename) do_irg_opt(irg, "local"); } - do_irg_opt(irg, "ldst2"); do_irg_opt(irg, "controlflow"); do_irg_opt(irg, "ldst"); do_irg_opt(irg, "lower"); @@ -559,7 +565,7 @@ static void do_firm_optimizations(const char *input_filename) do_irg_opt(irg, "remove_confirms"); do_irg_opt(irg, "gvnpre"); do_irg_opt(irg, "place"); - do_irg_opt(irg, "controlflow"); + do_irg_opt(irg, "controlflow"); if (firm_opt.if_conversion) { do_irg_opt(irg, "ifconv"); @@ -838,14 +844,9 @@ static void do_firm_lowering(const char *input_filename) /* run reassociation first on all graphs BEFORE the architecture dependent optimizations are enabled */ for (i = get_irp_n_irgs() - 1; i >= 0; --i) { - current_ir_graph = get_irp_irg(i); - - timer_push(TV_REASSOCIATION); - optimize_reassociation(current_ir_graph); - timer_pop(); - DUMP_ONE_C(firm_dump.ir_graph && firm_dump.all_phases, current_ir_graph, "reassoc"); - CHECK_ONE(firm_opt.check_all, current_ir_graph); - } + ir_graph *irg = get_irp_irg(i); + do_irg_opt(irg, "reassoc"); + } /* enable architecture dependent optimizations */ arch_dep_set_opts((arch_dep_opts_t) @@ -854,61 +855,23 @@ static void do_firm_lowering(const char *input_filename) (firm_opt.mods ? arch_dep_mod_by_const : arch_dep_none) )); for (i = get_irp_n_irgs() - 1; i >= 0; --i) { - current_ir_graph = get_irp_irg(i); - - if (firm_opt.gcse) - set_opt_global_cse(1); - - timer_push(TV_LOCAL_OPT); - optimize_graph_df(current_ir_graph); - timer_pop(); - DUMP_ONE_C(firm_dump.ir_graph && firm_dump.all_phases, current_ir_graph, "lopt"); - if (! firm_opt.gcse) - CHECK_ONE(firm_opt.check_all, current_ir_graph); - - if (firm_opt.gcse) { - timer_push(TV_CODE_PLACE); - place_code(current_ir_graph); - set_opt_global_cse(0); - timer_pop(); - DUMP_ONE_C(firm_dump.ir_graph && firm_dump.all_phases, current_ir_graph, "place"); - CHECK_ONE(firm_opt.check_all, current_ir_graph); - } - - timer_push(TV_LOAD_STORE); - optimize_load_store(current_ir_graph); - timer_pop(); - DUMP_ONE_C(firm_dump.ir_graph && firm_dump.all_phases, current_ir_graph, "ldst"); - CHECK_ONE(firm_opt.check_all, current_ir_graph); - + ir_graph *irg = get_irp_irg(i); - timer_push(TV_LOCAL_OPT); - optimize_graph_df(current_ir_graph); - timer_pop(); - DUMP_ONE_C(firm_dump.ir_graph && firm_dump.all_phases, current_ir_graph, "lopt"); + current_ir_graph = irg; - timer_push(TV_CF_OPT); - optimize_cf(current_ir_graph); - timer_pop(); - DUMP_ONE_C(firm_dump.ir_graph && firm_dump.all_phases, current_ir_graph, "cf"); - CHECK_ONE(firm_opt.check_all, current_ir_graph); + do_irg_opt(irg, "local"); + do_irg_opt(irg, "gcse"); + do_irg_opt(irg, "ldst"); + do_irg_opt(irg, "local"); + do_irg_opt(irg, "controlflow"); if (firm_opt.if_conversion) { - timer_push(TV_IF_CONV); - opt_if_conv(current_ir_graph, if_conv_info); - timer_pop(); - DUMP_ONE_C(firm_dump.ir_graph && firm_dump.all_phases, current_ir_graph, "if"); - CHECK_ONE(firm_opt.check_all, current_ir_graph); - - timer_push(TV_LOCAL_OPT); - optimize_graph_df(current_ir_graph); - timer_pop(); - timer_push(TV_CF_OPT); - optimize_cf(current_ir_graph); - timer_pop(); - DUMP_ONE_C(firm_dump.ir_graph && firm_dump.all_phases, current_ir_graph, "after_if"); - CHECK_ONE(firm_opt.check_all, current_ir_graph); - } + do_irg_opt(irg, "ifconv"); + do_irg_opt(irg, "local"); + do_irg_opt(irg, "controlflow"); + } + + do_irg_opt(current_ir_graph, "sync"); } timer_stop(TV_ALL_OPT);