Merge timers[] into opts[].
[cparser] / driver / firm_opt.c
index 5d78a86..a8069e5 100644 (file)
@@ -292,11 +292,6 @@ static void rts_map(void)
 
 static int *irg_dump_no;
 
-static void do_lower_highlevel(ir_graph *irg)
-{
-       lower_highlevel_graph(irg, false);
-}
-
 static void do_stred(ir_graph *irg)
 {
        opt_osr(irg, osr_flag_default | osr_flag_keep_reg_pressure | osr_flag_ignore_x86_shift);
@@ -366,6 +361,7 @@ typedef struct {
        } u;
        const char   *description;
        opt_flags_t   flags;
+       ir_timer_t   *timer;
 } opt_config_t;
 
 static opt_config_t opts[] = {
@@ -384,7 +380,7 @@ static opt_config_t opts[] = {
        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",             lower_highlevel_graph,    "lowering",                                              OPT_FLAG_HIDE_OPTIONS | OPT_FLAG_ESSENTIAL),
        IRG("lower-mux",         do_lower_mux,             "mux lowering",                                          OPT_FLAG_NONE),
        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),
@@ -412,7 +408,6 @@ static opt_config_t opts[] = {
 #undef IRG
 };
 static const int n_opts = sizeof(opts) / sizeof(opts[0]);
-static ir_timer_t *timers[sizeof(opts)/sizeof(opts[0])];
 
 static opt_config_t *get_opt(const char *name)
 {
@@ -446,20 +441,18 @@ static bool get_opt_enabled(const char *name)
  */
 static bool do_irg_opt(ir_graph *irg, const char *name)
 {
-       ir_graph     *old_irg;
-       opt_config_t *config = get_opt(name);
-       size_t        n      = config - opts;
+       opt_config_t *const config = get_opt(name);
        assert(config != NULL);
        assert(config->target == OPT_TARGET_IRG);
        if (! (config->flags & OPT_FLAG_ENABLED))
                return false;
 
-       old_irg          = current_ir_graph;
+       ir_graph *const old_irg = current_ir_graph;
        current_ir_graph = irg;
 
-       timer_push(timers[n]);
+       timer_push(config->timer);
        config->u.transform_irg(irg);
-       timer_pop(timers[n]);
+       timer_pop(config->timer);
 
        if (firm_dump.all_phases && firm_dump.ir_graph) {
                dump_ir_graph(irg, name);
@@ -477,15 +470,14 @@ static bool do_irg_opt(ir_graph *irg, const char *name)
 
 static void do_irp_opt(const char *name)
 {
-       opt_config_t *config = get_opt(name);
-       size_t        n      = config - opts;
+       opt_config_t *const config = get_opt(name);
        assert(config->target == OPT_TARGET_IRP);
        if (! (config->flags & OPT_FLAG_ENABLED))
                return;
 
-       timer_push(timers[n]);
+       timer_push(config->timer);
        config->u.transform_irp();
-       timer_pop(timers[n]);
+       timer_pop(config->timer);
 
        if (firm_dump.ir_graph && firm_dump.all_phases) {
                int i;
@@ -698,6 +690,7 @@ static void do_firm_lowering(const char *input_filename)
        for (i = get_irp_n_irgs() - 1; i >= 0; --i) {
                ir_graph *irg = get_irp_irg(i);
 
+               do_irg_opt(irg, "lower-blockcopy");
                do_irg_opt(irg, "local");
                do_irg_opt(irg, "deconv");
                do_irg_opt(irg, "control-flow");
@@ -744,8 +737,8 @@ void gen_firm_init(void)
        int      i;
 
        for (i = 0; i < n_opts; ++i) {
-               timers[i] = ir_timer_new();
-               timer_register(timers[i], opts[i].description);
+               opts[i].timer = ir_timer_new();
+               timer_register(opts[i].timer, opts[i].description);
        }
        t_verify = ir_timer_new();
        timer_register(t_verify, "Firm: verify pass");