Clean up the list of optimisations.
authorChristoph Mallon <christoph.mallon@gmx.de>
Sat, 10 Apr 2010 22:41:01 +0000 (22:41 +0000)
committerChristoph Mallon <christoph.mallon@gmx.de>
Sat, 10 Apr 2010 22:41:01 +0000 (22:41 +0000)
[r27375]

driver/firm_opt.c

index 922dd76..1b50ef1 100644 (file)
@@ -302,53 +302,59 @@ typedef enum opt_flags {
 
 typedef void (*transform_irg_func)(ir_graph *irg);
 typedef void (*transform_irp_func)(void);
-typedef void (*func_ptr_t)(void);
 
 typedef struct {
        opt_target_t  target;
        const char   *name;
-       func_ptr_t    func;
+       union {
+               transform_irg_func transform_irg;
+               transform_irp_func transform_irp;
+       } u;
        const char   *description;
        opt_flags_t   flags;
 } opt_config_t;
 
 static opt_config_t opts[] = {
-       { OPT_TARGET_IRP, "rts",             (func_ptr_t) rts_map,                 "optimization of known library functions", OPT_FLAG_HIDE_OPTIONS },
-       { OPT_TARGET_IRG, "combo",           (func_ptr_t) combo,                   "combined CCE, UCE and GVN",               OPT_FLAG_NONE},
-       { OPT_TARGET_IRG, "control-flow",    (func_ptr_t) optimize_cf,             "optimization of control-flow",            OPT_FLAG_HIDE_OPTIONS },
-       { OPT_TARGET_IRG, "local",           (func_ptr_t) optimize_graph_df,       "local graph optimizations",               OPT_FLAG_HIDE_OPTIONS },
-       { OPT_TARGET_IRP, "remove-unused",   (func_ptr_t) garbage_collect_entities,"removal of unused functions/variables",   OPT_FLAG_NO_DUMP | OPT_FLAG_NO_VERIFY },
-       { OPT_TARGET_IRG, "opt-tail-rec",    (func_ptr_t) opt_tail_rec_irg,        "tail-recursion eliminiation",             OPT_FLAG_NONE },
-       { OPT_TARGET_IRP, "opt-func-call",   (func_ptr_t) do_optimize_funccalls,   "function call optimization",              OPT_FLAG_NONE },
-       { OPT_TARGET_IRG, "lower",           (func_ptr_t) do_lower_highlevel,      "lowering",                                OPT_FLAG_HIDE_OPTIONS | OPT_FLAG_ESSENTIAL },
-       { OPT_TARGET_IRP, "lower-const",     (func_ptr_t) lower_const_code,        "lowering of constant code",               OPT_FLAG_HIDE_OPTIONS | OPT_FLAG_NO_DUMP | OPT_FLAG_NO_VERIFY | OPT_FLAG_ESSENTIAL },
-       { OPT_TARGET_IRP, "lower-dw",        (func_ptr_t) do_lower_dw_ops,         "lowering of doubleword operations",       OPT_FLAG_HIDE_OPTIONS | OPT_FLAG_ESSENTIAL },
-       { OPT_TARGET_IRG, "lower-switch",    (func_ptr_t) do_lower_switch,         "switch lowering",                         OPT_FLAG_HIDE_OPTIONS | OPT_FLAG_ESSENTIAL },
-       { OPT_TARGET_IRG, "one-return",      (func_ptr_t) normalize_one_return,    "normalisation to 1 return",               OPT_FLAG_HIDE_OPTIONS | OPT_FLAG_NO_DUMP | OPT_FLAG_NO_VERIFY },
-       { OPT_TARGET_IRG, "scalar-replace",  (func_ptr_t) scalar_replacement_opt,  "scalar replacement",                      OPT_FLAG_NONE },
-       { OPT_TARGET_IRG, "reassociation",   (func_ptr_t) optimize_reassociation,  "reassociation",                           OPT_FLAG_NONE },
-       { OPT_TARGET_IRG, "gcse",            (func_ptr_t) do_gcse,                 "global common subexpression elimination", OPT_FLAG_NONE },
-       { OPT_TARGET_IRG, "place",           (func_ptr_t) place_code,              "code placement",                          OPT_FLAG_NONE },
-       { OPT_TARGET_IRG, "confirm",         (func_ptr_t) construct_confirms,      "confirm optimisation",                    OPT_FLAG_HIDE_OPTIONS },
-       { OPT_TARGET_IRG, "opt-load-store",  (func_ptr_t) optimize_load_store,     "load store optimization",                 OPT_FLAG_NONE },
-       { OPT_TARGET_IRG, "parallelize-mem", (func_ptr_t) opt_parallelize_mem,     "parallelize memory",                      OPT_FLAG_NONE },
-       { OPT_TARGET_IRG, "deconv",          (func_ptr_t) conv_opt,                "conv node elimination",                   OPT_FLAG_NONE },
-       { OPT_TARGET_IRG, "thread-jumps",    (func_ptr_t) opt_jumpthreading,       "path-sensitive jumpthreading",            OPT_FLAG_NONE },
-       { OPT_TARGET_IRG, "remove-confirms", (func_ptr_t) remove_confirms,         "confirm removal",                         OPT_FLAG_HIDE_OPTIONS | OPT_FLAG_NO_DUMP | OPT_FLAG_NO_VERIFY },
-       { OPT_TARGET_IRG, "gvn-pre",         (func_ptr_t) do_gvn_pre,              "global value numbering partial redundancy elimination", OPT_FLAG_NONE },
-       { OPT_TARGET_IRG, "if-conversion",   (func_ptr_t) do_if_conv,              "if-conversion",                           OPT_FLAG_NONE },
-       { OPT_TARGET_IRG, "bool",            (func_ptr_t) opt_bool,                "bool simplification",                     OPT_FLAG_NONE },
-       { OPT_TARGET_IRG, "shape-blocks",    (func_ptr_t) shape_blocks,            "block shaping",                           OPT_FLAG_NONE },
-       { OPT_TARGET_IRG, "ivopts",          (func_ptr_t) do_stred,                "induction variable strength reduction",   OPT_FLAG_NONE },
-       { OPT_TARGET_IRG, "remove-phi-cycles", (func_ptr_t) remove_phi_cycles,     "removal of phi cycles",                   OPT_FLAG_HIDE_OPTIONS },
-       { OPT_TARGET_IRG, "dead",            (func_ptr_t) dead_node_elimination,   "dead node elimination",                   OPT_FLAG_HIDE_OPTIONS | OPT_FLAG_NO_DUMP | OPT_FLAG_NO_VERIFY },
-       { OPT_TARGET_IRP, "inline",          (func_ptr_t) do_inline,               "inlining",                                OPT_FLAG_NONE },
-       { OPT_TARGET_IRP, "opt-proc-clone",  (func_ptr_t) do_cloning,              "procedure cloning",                       OPT_FLAG_NONE },
-       { OPT_TARGET_IRG, "invert-loops",    (func_ptr_t) do_loop_inversion,       "loop inversion",                          OPT_FLAG_NONE },
-       { OPT_TARGET_IRG, "unroll-loops",    (func_ptr_t) do_loop_unrolling,       "loop unrolling",                          OPT_FLAG_NONE },
-       { OPT_TARGET_IRG, "lower-mux",       (func_ptr_t) do_lower_mux,            "mux lowering",                            OPT_FLAG_NONE },
-       { OPT_TARGET_IRG, "vrp",                         (func_ptr_t) do_vrp,                              "value range propagation",                             OPT_FLAG_NONE },
-       { OPT_TARGET_IRG, "frame",           (func_ptr_t) opt_frame_irg,           "remove unused frame entities",            OPT_FLAG_NONE },
+#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 }
+       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("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),
+       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("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),
+       IRG("place",             place_code,               "code placement",                                        OPT_FLAG_NONE),
+       IRG("reassociation",     optimize_reassociation,   "reassociation",                                         OPT_FLAG_NONE),
+       IRG("remove-confirms",   remove_confirms,          "confirm removal",                                       OPT_FLAG_HIDE_OPTIONS | OPT_FLAG_NO_DUMP | OPT_FLAG_NO_VERIFY),
+       IRG("remove-phi-cycles", remove_phi_cycles,        "removal of phi cycles",                                 OPT_FLAG_HIDE_OPTIONS),
+       IRG("scalar-replace",    scalar_replacement_opt,   "scalar replacement",                                    OPT_FLAG_NONE),
+       IRG("shape-blocks",      shape_blocks,             "block shaping",                                         OPT_FLAG_NONE),
+       IRG("thread-jumps",      opt_jumpthreading,        "path-sensitive jumpthreading",                          OPT_FLAG_NONE),
+       IRG("unroll-loops",      do_loop_unrolling,        "loop unrolling",                                        OPT_FLAG_NONE),
+       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("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),
+       IRP("rts",               rts_map,                  "optimization of known library functions",               OPT_FLAG_HIDE_OPTIONS),
+#undef IRP
+#undef IRG
 };
 static const int n_opts = sizeof(opts) / sizeof(opts[0]);
 ir_timer_t *timers[sizeof(opts)/sizeof(opts[0])];
@@ -385,10 +391,9 @@ static bool get_opt_enabled(const char *name)
  */
 static bool do_irg_opt(ir_graph *irg, const char *name)
 {
-       transform_irg_func  func;
-       ir_graph           *old_irg;
-       opt_config_t       *config = get_opt(name);
-       size_t              n      = config - opts;
+       ir_graph     *old_irg;
+       opt_config_t *config = get_opt(name);
+       size_t        n      = config - opts;
        assert(config != NULL);
        assert(config->target == OPT_TARGET_IRG);
        if (! (config->flags & OPT_FLAG_ENABLED))
@@ -397,10 +402,8 @@ static bool do_irg_opt(ir_graph *irg, const char *name)
        old_irg          = current_ir_graph;
        current_ir_graph = irg;
 
-       func = (transform_irg_func) config->func;
-
        timer_push(timers[n]);
-       func(irg);
+       config->u.transform_irg(irg);
        timer_pop(timers[n]);
 
        if (firm_dump.all_phases && firm_dump.ir_graph) {
@@ -419,17 +422,14 @@ static bool do_irg_opt(ir_graph *irg, const char *name)
 
 static void do_irp_opt(const char *name)
 {
-       transform_irp_func  func;
-       opt_config_t       *config = get_opt(name);
-       size_t              n      = config - opts;
+       opt_config_t *config = get_opt(name);
+       size_t        n      = config - opts;
        assert(config->target == OPT_TARGET_IRP);
        if (! (config->flags & OPT_FLAG_ENABLED))
                return;
 
-       func = (transform_irp_func) config->func;
-
        timer_push(timers[n]);
-       func();
+       config->u.transform_irp();
        timer_pop(timers[n]);
 
        if (firm_dump.ir_graph && firm_dump.all_phases) {