adapt to new timer API
authorMatthias Braun <matze@braunis.de>
Mon, 15 Oct 2012 17:09:35 +0000 (19:09 +0200)
committerChristoph Mallon <christoph.mallon@gmx.de>
Tue, 30 Oct 2012 09:24:38 +0000 (10:24 +0100)
driver/firm_opt.c
driver/firm_timing.c
main.c

index 04a9a88..f535c1c 100644 (file)
@@ -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 }
@@ -434,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);
@@ -459,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;
@@ -471,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) {
@@ -542,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 */
@@ -640,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);
 }
 
 /**
@@ -669,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);
 
@@ -704,7 +703,6 @@ static void do_firm_lowering(const char *input_filename)
        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) {
@@ -777,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) {
@@ -803,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");
index 8503bc9..d41574a 100644 (file)
@@ -45,9 +45,11 @@ void timer_term(FILE *f)
 
        for (info = infos; info != NULL; info = next) {
                ir_timer_t *timer = info->timer;
-               double      val         = (double)ir_timer_elapsed_usec(timer) / 1000.0;
-               const char *description = info->description;
-               fprintf(f, "%-45s %8.3f msec\n", description, val);
+               if (f != NULL) {
+                       double      val         = (double)ir_timer_elapsed_usec(timer) / 1000.0;
+                       const char *description = info->description;
+                       fprintf(f, "%-45s %8.3f msec\n", description, val);
+               }
 
                ir_timer_free(timer);
                xfree(info->description);
@@ -68,9 +70,8 @@ void timer_push(ir_timer_t *timer)
 
 void timer_pop(ir_timer_t *timer)
 {
-       (void) timer;
        if (timers_inited)
-               ir_timer_pop();
+               ir_timer_pop(timer);
 }
 
 void timer_start(ir_timer_t *timer)
diff --git a/main.c b/main.c
index 7590a9b..6e596b2 100644 (file)
--- a/main.c
+++ b/main.c
@@ -224,7 +224,7 @@ static void do_parsing(compilation_unit_t *unit)
 {
        ir_timer_t *t_parsing = ir_timer_new();
        timer_register(t_parsing, "Frontend: Parsing");
-       timer_push(t_parsing);
+       timer_start(t_parsing);
 
        start_parsing();
 
@@ -239,7 +239,7 @@ static void do_parsing(compilation_unit_t *unit)
 
        unit->type         = COMPILATION_UNIT_AST;
        unit->parse_errors = error_count > 0 || !res;
-       timer_pop(t_parsing);
+       timer_stop(t_parsing);
 }
 
 static void add_flag(struct obstack *obst, const char *format, ...)
@@ -1304,14 +1304,14 @@ again:
                        /* build the firm graph */
                        ir_timer_t *t_construct = ir_timer_new();
                        timer_register(t_construct, "Frontend: Graph construction");
-                       timer_push(t_construct);
+                       timer_start(t_construct);
                        if (already_constructed_firm) {
                                panic("compiling multiple files/translation units not possible");
                        }
                        init_implicit_optimizations();
                        translation_unit_to_firm(unit->ast);
                        already_constructed_firm = true;
-                       timer_pop(t_construct);
+                       timer_stop(t_construct);
                        unit->type = COMPILATION_UNIT_INTERMEDIATE_REPRESENTATION;
                        goto again;
 
@@ -1359,7 +1359,11 @@ again:
                        } else {
                                asm_out = make_temp_file("ccs", &unit->name);
                        }
+                       ir_timer_t *t_opt_codegen = ir_timer_new();
+                       timer_register(t_opt_codegen, "Optimization and Codegeneration");
+                       timer_start(t_opt_codegen);
                        generate_code(asm_out, inputname);
+                       timer_stop(t_opt_codegen);
                        if (asm_out != out) {
                                fclose(asm_out);
                        }