Merge timers[] into opts[].
[cparser] / driver / firm_opt.c
index 966139e..a8069e5 100644 (file)
@@ -69,7 +69,7 @@ struct a_firm_be_opt {
 };
 
 /* optimization settings */
-struct a_firm_opt firm_opt = {
+static struct a_firm_opt firm_opt = {
        .const_folding    =  true,
        .cse              =  true,
        .confirm          =  true,
@@ -88,7 +88,7 @@ struct a_firm_opt firm_opt = {
 };
 
 /* dumping options */
-struct a_firm_dump firm_dump = {
+static struct a_firm_dump firm_dump = {
        .debug_print  = false,
        .all_types    = false,
        .no_blocks    = false,
@@ -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[] = {
@@ -373,7 +369,7 @@ static opt_config_t opts[] = {
 #define IRP(a, b, c, d) { OPT_TARGET_IRP, a, .u.transform_irp = b,                     c, d }
        IRG("bool",              opt_bool,                 "bool simplification",                                   OPT_FLAG_NONE),
        IRG("combo",             combo,                    "combined CCE, UCE and GVN",                             OPT_FLAG_NONE),
-       IRG("confirm",           construct_confirms,       "confirm optimisation",                                  OPT_FLAG_HIDE_OPTIONS),
+       IRG("confirm",           construct_confirms,       "confirm optimization",                                  OPT_FLAG_HIDE_OPTIONS),
        IRG("control-flow",      optimize_cf,              "optimization of control-flow",                          OPT_FLAG_HIDE_OPTIONS),
        IRG("dead",              dead_node_elimination,    "dead node elimination",                                 OPT_FLAG_HIDE_OPTIONS | OPT_FLAG_NO_DUMP | OPT_FLAG_NO_VERIFY),
        IRG("deconv",            conv_opt,                 "conv node elimination",                                 OPT_FLAG_NONE),
@@ -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]);
-ir_timer_t *timers[sizeof(opts)/sizeof(opts[0])];
 
 static opt_config_t *get_opt(const char *name)
 {
@@ -440,26 +435,24 @@ static bool get_opt_enabled(const char *name)
 }
 
 /**
- * perform an optimisation on a single graph
+ * perform an optimization on a single graph
  *
  * @return  true if something changed, false otherwise
  */
 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");
@@ -966,7 +959,7 @@ int firm_option(const char *const opt)
                }
        }
 
-       /* maybe this enables/disables optimisations */
+       /* maybe this enables/disables optimizations */
        if (firm_opt_option(opt))
                return 1;
 
@@ -989,7 +982,7 @@ static void set_option(const char *arg)
 
 void choose_optimization_pack(int level)
 {
-       /* apply optimisation level */
+       /* apply optimization level */
        switch(level) {
        case 0:
                set_option("no-opt");