X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;ds=sidebyside;f=driver%2Ffirm_opt.c;h=f535c1ce9e116ae64497f8f08b135c31dd2baf88;hb=211aaabd26e2f4eab27d054b1984c66904fb45c2;hp=d5a05bd3707e1e856741bd00601c06934088b26e;hpb=17c17e5c66fbe270d3d71a6e994dff4c820e2e62;p=cparser diff --git a/driver/firm_opt.c b/driver/firm_opt.c index d5a05bd..f535c1c 100644 --- a/driver/firm_opt.c +++ b/driver/firm_opt.c @@ -130,8 +130,6 @@ static const struct params { { X("verify-off"), &firm_opt.verify, FIRM_VERIFICATION_OFF, "disable node verification" }, { X("verify-on"), &firm_opt.verify, FIRM_VERIFICATION_ON, "enable node verification" }, { X("verify-report"), &firm_opt.verify, FIRM_VERIFICATION_REPORT, "node verification, report only" }, - { X("check-all"), &firm_opt.check_all, 1, "enable checking all Firm phases" }, - { X("no-check-all"), &firm_opt.check_all, 0, "disable checking all Firm phases" }, /* dumping */ { X("dump-ir"), &firm_dump.ir_graph, 1, "dump IR graph" }, @@ -281,6 +279,39 @@ static void rts_map(void) static int *irg_dump_no; +typedef enum opt_target { + OPT_TARGET_IRG, /**< optimization function works on a single graph */ + OPT_TARGET_IRP /**< optimization function works on the complete program */ +} opt_target_t; + +typedef enum opt_flags { + OPT_FLAG_NONE = 0, + OPT_FLAG_ENABLED = 1 << 0, /**< enable the optimization */ + OPT_FLAG_NO_DUMP = 1 << 1, /**< don't dump after transformation */ + OPT_FLAG_NO_VERIFY = 1 << 2, /**< don't verify after transformation */ + OPT_FLAG_HIDE_OPTIONS = 1 << 3, /**< do not automatically process + -foptions for this transformation */ + OPT_FLAG_ESSENTIAL = 1 << 4, /**< output won't work without this pass + so we need it even with -O0 */ +} opt_flags_t; + +typedef void (*transform_irg_func)(ir_graph *irg); +typedef void (*transform_irp_func)(void); + +typedef struct { + opt_target_t target; + const char *name; + union { + transform_irg_func transform_irg; + transform_irp_func transform_irp; + } u; + const char *description; + opt_flags_t flags; + ir_timer_t *timer; +} opt_config_t; + +static opt_config_t *get_opt(const char *name); + static void do_stred(ir_graph *irg) { opt_osr(irg, osr_flag_default | osr_flag_keep_reg_pressure | osr_flag_ignore_x86_shift); @@ -288,10 +319,15 @@ static void do_stred(ir_graph *irg) static void after_inline_opt(ir_graph *irg) { + opt_config_t *const config = get_opt("inline"); + timer_stop(config->timer); + do_irg_opt(irg, "scalar-replace"); do_irg_opt(irg, "local"); do_irg_opt(irg, "control-flow"); do_irg_opt(irg, "combo"); + + timer_start(config->timer); } static void do_inline(void) @@ -317,37 +353,6 @@ static void do_gcse(ir_graph *irg) set_opt_global_cse(0); } -typedef enum opt_target { - OPT_TARGET_IRG, /**< optimization function works on a single graph */ - OPT_TARGET_IRP /**< optimization function works on the complete program */ -} opt_target_t; - -typedef enum opt_flags { - OPT_FLAG_NONE = 0, - OPT_FLAG_ENABLED = 1 << 0, /**< enable the optimization */ - OPT_FLAG_NO_DUMP = 1 << 1, /**< don't dump after transformation */ - OPT_FLAG_NO_VERIFY = 1 << 2, /**< don't verify after transformation */ - OPT_FLAG_HIDE_OPTIONS = 1 << 3, /**< do not automatically process - -foptions for this transformation */ - OPT_FLAG_ESSENTIAL = 1 << 4, /**< output won't work without this pass - so we need it even with -O0 */ -} opt_flags_t; - -typedef void (*transform_irg_func)(ir_graph *irg); -typedef void (*transform_irp_func)(void); - -typedef struct { - opt_target_t target; - const char *name; - union { - transform_irg_func transform_irg; - transform_irp_func transform_irp; - } u; - const char *description; - opt_flags_t flags; - ir_timer_t *timer; -} opt_config_t; - static opt_config_t opts[] = { #define IRG(a, b, c, d) { OPT_TARGET_IRG, a, .u.transform_irg = (transform_irg_func)b, c, d } #define IRP(a, b, c, d) { OPT_TARGET_IRP, a, .u.transform_irp = b, c, d } @@ -381,6 +386,8 @@ static opt_config_t opts[] = { IRG("vrp", set_vrp_data, "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("local-const", local_opts_const_code, "local optimisation of constant initializers", + OPT_FLAG_HIDE_OPTIONS | OPT_FLAG_NO_DUMP | OPT_FLAG_NO_VERIFY | 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", optimize_funccalls, "function call optimization", OPT_FLAG_NONE), IRP("opt-proc-clone", do_cloning, "procedure cloning", OPT_FLAG_NONE), @@ -432,15 +439,15 @@ static bool do_irg_opt(ir_graph *irg, const char *name) ir_graph *const old_irg = current_ir_graph; current_ir_graph = irg; - timer_push(config->timer); + timer_start(config->timer); config->u.transform_irg(irg); - timer_pop(config->timer); + timer_stop(config->timer); if (firm_dump.all_phases && firm_dump.ir_graph) { dump_ir_graph(irg, name); } - if (firm_opt.check_all) { + if (firm_opt.verify) { timer_push(t_verify); irg_verify(irg, VERIFY_ENFORCE_SSA); timer_pop(t_verify); @@ -457,9 +464,9 @@ static void do_irp_opt(const char *name) if (! (config->flags & OPT_FLAG_ENABLED)) return; - timer_push(config->timer); + timer_start(config->timer); config->u.transform_irp(); - timer_pop(config->timer); + timer_stop(config->timer); if (firm_dump.ir_graph && firm_dump.all_phases) { int i; @@ -469,7 +476,7 @@ static void do_irp_opt(const char *name) } } - if (firm_opt.check_all) { + if (firm_opt.verify) { int i; timer_push(t_verify); for (i = get_irp_n_irgs() - 1; i >= 0; --i) { @@ -491,6 +498,7 @@ static void enable_safe_defaults(void) set_opt_enabled("control-flow", true); set_opt_enabled("local", true); set_opt_enabled("lower-const", true); + set_opt_enabled("local-const", true); set_opt_enabled("scalar-replace", true); set_opt_enabled("place", true); set_opt_enabled("gcse", true); @@ -539,8 +547,6 @@ static void do_firm_optimizations(const char *input_filename) if (get_opt_enabled("ivopts")) set_opt_enabled("remove-phi-cycles", false); - timer_start(t_all_opt); - do_irp_opt("rts"); /* first step: kill dead code */ @@ -637,8 +643,6 @@ static void do_firm_optimizations(const char *input_filename) if (firm_dump.statistic & STAT_AFTER_OPT) stat_dump_snapshot(input_filename, "opt"); - - timer_stop(t_all_opt); } /** @@ -666,8 +670,6 @@ static void do_firm_lowering(const char *input_filename) if (firm_dump.statistic & STAT_AFTER_LOWER) stat_dump_snapshot(input_filename, "low"); - timer_start(t_all_opt); - for (i = get_irp_n_irgs() - 1; i >= 0; --i) { ir_graph *irg = get_irp_irg(i); @@ -698,9 +700,9 @@ static void do_firm_lowering(const char *input_filename) do_irg_opt(irg, "parallelize-mem"); do_irg_opt(irg, "frame"); } + do_irp_opt("local-const"); do_irp_opt("remove-unused"); do_irp_opt("opt-cc"); - timer_stop(t_all_opt); dump_all("low-opt"); if (firm_dump.statistic & STAT_FINAL) { @@ -773,18 +775,21 @@ void generate_code(FILE *out, const char *input_filename) /* FIXME: cloning might ADD new graphs. */ irg_dump_no = calloc(get_irp_last_idx(), sizeof(*irg_dump_no)); + ir_timer_init_parent(t_verify); + ir_timer_init_parent(t_vcg_dump); + timer_start(t_all_opt); + if (firm_dump.all_types) { dump_ir_prog_ext(dump_typegraph, "types.vcg"); } dump_all(""); - timer_push(t_verify); - tr_verify(); - timer_pop(t_verify); - - /* all graphs are finalized, set the irp phase to high */ - set_irp_phase_state(phase_high); + if (firm_opt.verify) { + timer_push(t_verify); + tr_verify(); + timer_pop(t_verify); + } /* BEWARE: kill unreachable code before doing compound lowering */ for (i = get_irp_n_irgs() - 1; i >= 0; --i) { @@ -799,9 +804,7 @@ void generate_code(FILE *out, const char *input_filename) do_firm_optimizations(input_filename); do_firm_lowering(input_filename); - /* set the phase to low */ - for (i = get_irp_n_irgs() - 1; i >= 0; --i) - set_irg_phase_state(get_irp_irg(i), phase_low); + timer_stop(t_all_opt); if (firm_dump.statistic & STAT_FINAL_IR) stat_dump_snapshot(input_filename, "final-ir");