X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=driver%2Ffirm_opt.c;h=174a34a99757f3b5620252201efd3e3adec475ab;hb=2c26c7a7885635fc12bda81d06b334f9726a70df;hp=2d25c4c29913c5cac428f8140a7e46f1db26d217;hpb=5de879168ae94a7bca2e3d7a0bec4de4345e4737;p=cparser diff --git a/driver/firm_opt.c b/driver/firm_opt.c index 2d25c4c..174a34a 100644 --- a/driver/firm_opt.c +++ b/driver/firm_opt.c @@ -39,34 +39,9 @@ static void dump_all(const char *suffix) timer_pop(t_vcg_dump); } -/* set by the backend parameters */ -static const ir_settings_arch_dep_t *ad_param = NULL; -static create_intrinsic_fkt *arch_create_intrinsic = NULL; -static void *create_intrinsic_ctx = NULL; -static const ir_settings_if_conv_t *if_conv_info = NULL; - /* entities of runtime functions */ ir_entity_ptr rts_entities[rts_max]; -/** - * factory for setting architecture dependent parameters - */ -static const ir_settings_arch_dep_t *arch_factory(void) -{ - static const ir_settings_arch_dep_t param = { - 1, /* also use subs */ - 4, /* maximum shifts */ - 31, /* maximum shift amount */ - NULL, /* use default evaluator */ - - 1, /* allow Mulhs */ - 1, /* allow Mulus */ - 32 /* Mulh allowed up to 32 bit */ - }; - - return ad_param ? ad_param : ¶m; -} - /** * Map runtime functions. */ @@ -195,11 +170,6 @@ static void do_lower_highlevel(ir_graph *irg) lower_highlevel_graph(irg, firm_opt.lower_bitfields); } -static void do_if_conv(ir_graph *irg) -{ - opt_if_conv(irg, if_conv_info); -} - static void do_stred(ir_graph *irg) { opt_osr(irg, osr_flag_default | osr_flag_keep_reg_pressure | osr_flag_ignore_x86_shift); @@ -224,36 +194,11 @@ static void do_cloning(void) proc_cloning((float) firm_opt.clone_threshold); } -static void do_lower_switch(ir_graph *irg) -{ - lower_switch(irg, firm_opt.spare_size); -} - static void do_lower_mux(ir_graph *irg) { lower_mux(irg, NULL); } -static void do_lower_dw_ops(void) -{ - lwrdw_param_t init = { - 1, - 1, - get_atomic_mode(ATOMIC_TYPE_LONGLONG), - get_atomic_mode(ATOMIC_TYPE_ULONGLONG), - get_atomic_mode(ATOMIC_TYPE_INT), - get_atomic_mode(ATOMIC_TYPE_UINT), - def_create_intrinsic_fkt, - NULL - }; - - if (arch_create_intrinsic) { - init.create_intrinsic = arch_create_intrinsic; - init.ctx = create_intrinsic_ctx; - } - lower_dw_ops(&init); -} - static void do_vrp(ir_graph *irg) { set_vrp_data(irg); @@ -302,14 +247,12 @@ static opt_config_t opts[] = { IRG("frame", opt_frame_irg, "remove unused frame entities", OPT_FLAG_NONE), IRG("gcse", do_gcse, "global common subexpression elimination", OPT_FLAG_NONE), IRG("gvn-pre", do_gvn_pre, "global value numbering partial redundancy elimination", OPT_FLAG_NONE), - IRG("if-conversion", do_if_conv, "if-conversion", OPT_FLAG_NONE), + IRG("if-conversion", opt_if_conv, "if-conversion", OPT_FLAG_NONE), IRG("invert-loops", do_loop_inversion, "loop inversion", OPT_FLAG_NONE), IRG("ivopts", do_stred, "induction variable strength reduction", OPT_FLAG_NONE), IRG("local", optimize_graph_df, "local graph optimizations", OPT_FLAG_HIDE_OPTIONS), IRG("lower", do_lower_highlevel, "lowering", OPT_FLAG_HIDE_OPTIONS | OPT_FLAG_ESSENTIAL), IRG("lower-mux", do_lower_mux, "mux lowering", OPT_FLAG_NONE), - IRG("lower-switch", do_lower_switch, "switch lowering", OPT_FLAG_HIDE_OPTIONS | OPT_FLAG_ESSENTIAL), - IRG("one-return", normalize_one_return, "normalisation to 1 return", OPT_FLAG_HIDE_OPTIONS | OPT_FLAG_NO_DUMP | OPT_FLAG_NO_VERIFY), IRG("opt-load-store", optimize_load_store, "load store optimization", OPT_FLAG_NONE), IRG("opt-tail-rec", opt_tail_rec_irg, "tail-recursion eliminiation", OPT_FLAG_NONE), IRG("parallelize-mem", opt_parallelize_mem, "parallelize memory", OPT_FLAG_NONE), @@ -324,7 +267,7 @@ static opt_config_t opts[] = { IRG("vrp", do_vrp, "value range propagation", OPT_FLAG_NONE), IRP("inline", do_inline, "inlining", OPT_FLAG_NONE), IRP("lower-const", lower_const_code, "lowering of constant code", OPT_FLAG_HIDE_OPTIONS | OPT_FLAG_NO_DUMP | OPT_FLAG_NO_VERIFY | OPT_FLAG_ESSENTIAL), - IRP("lower-dw", do_lower_dw_ops, "lowering of doubleword operations", OPT_FLAG_HIDE_OPTIONS | OPT_FLAG_ESSENTIAL), + IRP("target-lowering", be_lower_for_target, "lowering necessary for target architecture", OPT_FLAG_HIDE_OPTIONS | OPT_FLAG_ESSENTIAL), IRP("opt-func-call", do_optimize_funccalls, "function call optimization", OPT_FLAG_NONE), IRP("opt-proc-clone", do_cloning, "procedure cloning", OPT_FLAG_NONE), IRP("remove-unused", garbage_collect_entities, "removal of unused functions/variables", OPT_FLAG_NO_DUMP | OPT_FLAG_NO_VERIFY), @@ -447,11 +390,12 @@ static void enable_safe_defaults(void) set_opt_enabled("remove-confirms", true); set_opt_enabled("ivopts", true); set_opt_enabled("dead", true); - set_opt_enabled("lower-switch", true); set_opt_enabled("remove-phi-cycles", true); set_opt_enabled("frame", true); set_opt_enabled("combo", true); set_opt_enabled("invert-loops", true); + set_opt_enabled("target-lowering", true); + set_opt_enabled("rts", true); } /** @@ -461,7 +405,7 @@ static void enable_safe_defaults(void) */ static void do_firm_optimizations(const char *input_filename) { - int i; + size_t i; unsigned aa_opt; set_opt_alias_analysis(firm_opt.alias_analysis); @@ -475,7 +419,6 @@ static void do_firm_optimizations(const char *input_filename) set_irp_memory_disambiguator_options(aa_opt); /* parameter passing code should set them directly sometime... */ - set_opt_enabled("rts", !firm_opt.freestanding); set_opt_enabled("gcse", firm_opt.gcse); set_opt_enabled("place", !firm_opt.gcse); set_opt_enabled("confirm", firm_opt.confirm); @@ -547,7 +490,6 @@ static void do_firm_optimizations(const char *input_filename) do_irg_opt(irg, "bool"); do_irg_opt(irg, "shape-blocks"); - do_irg_opt(irg, "lower-switch"); do_irg_opt(irg, "ivopts"); do_irg_opt(irg, "local"); do_irg_opt(irg, "dead"); @@ -596,34 +538,31 @@ static void do_firm_lowering(const char *input_filename) { int i; - do_irp_opt("lower-dw"); + /* enable architecture dependent optimizations */ + arch_dep_set_opts((arch_dep_opts_t) + ((firm_opt.muls ? arch_dep_mul_to_shift : arch_dep_none) | + (firm_opt.divs ? arch_dep_div_by_const : arch_dep_none) | + (firm_opt.mods ? arch_dep_mod_by_const : arch_dep_none) )); + for (i = get_irp_n_irgs() - 1; i >= 0; --i) { + ir_graph *irg = get_irp_irg(i); + do_irg_opt(irg, "reassociation"); + do_irg_opt(irg, "local"); + } + + do_irp_opt("target-lowering"); if (firm_dump.statistic & STAT_AFTER_LOWER) stat_dump_snapshot(input_filename, "low"); - dump_all("low"); - if (firm_opt.enabled) { timer_start(t_all_opt); - /* run reassociation first on all graphs BEFORE the architecture - dependent optimizations are enabled */ - for (i = get_irp_n_irgs() - 1; i >= 0; --i) { - ir_graph *irg = get_irp_irg(i); - do_irg_opt(irg, "reassociation"); - } - - /* enable architecture dependent optimizations */ - arch_dep_set_opts((arch_dep_opts_t) - ((firm_opt.muls ? arch_dep_mul_to_shift : arch_dep_none) | - (firm_opt.divs ? arch_dep_div_by_const : arch_dep_none) | - (firm_opt.mods ? arch_dep_mod_by_const : arch_dep_none) )); - for (i = get_irp_n_irgs() - 1; i >= 0; --i) { ir_graph *irg = get_irp_irg(i); do_irg_opt(irg, "local"); do_irg_opt(irg, "gcse"); + do_irg_opt(irg, "control-flow"); do_irg_opt(irg, "opt-load-store"); do_irg_opt(irg, "local"); do_irg_opt(irg, "control-flow"); @@ -653,13 +592,6 @@ static void do_firm_lowering(const char *input_filename) if (firm_opt.cc_opt) mark_private_methods(); - /* set the phase to low */ - for (i = get_irp_n_irgs() - 1; i >= 0; --i) { - ir_graph *irg = get_irp_irg(i); - set_irg_phase_state(irg, phase_low); - } - set_irp_phase_state(phase_low); - if (firm_dump.statistic & STAT_FINAL) { stat_dump_snapshot(input_filename, "final"); } @@ -695,19 +627,6 @@ void gen_firm_init(void) 0 : FIRMSTAT_ENABLED | FIRMSTAT_COUNT_STRONG_OP | FIRMSTAT_COUNT_CONSTS | pattern); - if (firm_be_opt.selection == BE_FIRM_BE) { - const backend_params *be_params = be_get_backend_param(); - - if (be_params->do_dw_lowering) - set_opt_enabled("lower-dw", true); - - arch_create_intrinsic = be_params->arch_create_intrinsic_fkt; - create_intrinsic_ctx = be_params->create_intrinsic_ctx; - - ad_param = be_params->dep_param; - if_conv_info = be_params->if_conv_info; - } - edges_init_dbg(firm_opt.verify_edges); /* Sel node cannot produce NULL pointers */ @@ -716,8 +635,6 @@ void gen_firm_init(void) /* dynamic dispatch works currently only if whole world scenarios */ set_opt_dyn_meth_dispatch(0); - arch_dep_init(arch_factory); - /* do not run architecture dependent optimizations in building phase */ arch_dep_set_opts(arch_dep_none); @@ -736,9 +653,6 @@ void gen_firm_init(void) set_opt_cse(firm_opt.cse); set_opt_global_cse(0); set_opt_unreachable_code(1); - set_opt_control_flow(firm_opt.control_flow); - set_opt_control_flow_weak_simplification(1); - set_opt_control_flow_strong_simplification(1); } else { set_optimize(0); }