extend/fix timing stuff
authorMatthias Braun <matze@braunis.de>
Fri, 7 Aug 2009 15:27:39 +0000 (15:27 +0000)
committerMatthias Braun <matze@braunis.de>
Fri, 7 Aug 2009 15:27:39 +0000 (15:27 +0000)
[r26322]

driver/firm_opt.c
driver/firm_timing.def
main.c

index 73923ab..db574c9 100644 (file)
@@ -366,35 +366,35 @@ typedef struct {
 } opt_config_t;
 
 static opt_config_t opts[] = {
-       { OPT_TARGET_IRP, "rts",         (func_ptr_t) rts_map,                 true, true,  true,  -1 },
+       { OPT_TARGET_IRP, "rts",         (func_ptr_t) rts_map,                 true, true,  true,  TV_RTS },
        { OPT_TARGET_IRG, "combo",       (func_ptr_t) combo,                   true, true,  true,  TV_COMBO },
        { OPT_TARGET_IRG, "controlflow", (func_ptr_t) optimize_cf,             true, true,  true,  TV_CF_OPT },
        { OPT_TARGET_IRG, "local",       (func_ptr_t) optimize_graph_df,       true, true,  true,  TV_LOCAL_OPT },
        { OPT_TARGET_IRP, "gc_irgs",     (func_ptr_t) remove_unused_functions, true, false, false, TV_CGANA },
        { OPT_TARGET_IRP, "tailrec",     (func_ptr_t) opt_tail_recursion,      true, true,  true,  TV_TAIL_REC },
        { OPT_TARGET_IRP, "funccalls",   (func_ptr_t) do_optimize_funccalls,   true, true,  true,  TV_REAL_FUNC_CALL },
-       { OPT_TARGET_IRP, "lowerconst",  (func_ptr_t) lower_const_code,        true, false, false, -1 },
-       { OPT_TARGET_IRG, "onereturn",   (func_ptr_t) normalize_one_return,    true, false, false, -1 },
+       { OPT_TARGET_IRP, "lowerconst",  (func_ptr_t) lower_const_code,        true, false, false, TV_LOWER },
+       { OPT_TARGET_IRG, "onereturn",   (func_ptr_t) normalize_one_return,    true, false, false, TV_ONERETURN },
        { OPT_TARGET_IRG, "scalar",      (func_ptr_t) scalar_replacement_opt,  true, true,  true,  TV_SCALAR_REPLACE },
        { OPT_TARGET_IRG, "reassoc",     (func_ptr_t) optimize_reassociation,  true, true,  true,  TV_REASSOCIATION },
        { OPT_TARGET_IRG, "gcse",        (func_ptr_t) do_gcse,                 true, true,  true,  TV_CODE_PLACE },
        { OPT_TARGET_IRG, "place",       (func_ptr_t) place_code,              true, true,  true,  TV_CODE_PLACE },
        { OPT_TARGET_IRG, "confirm",     (func_ptr_t) construct_confirms,      true, true,  true,  TV_CONFIRM_CREATE },
        { OPT_TARGET_IRG, "ldst",        (func_ptr_t) optimize_load_store,     true, true,  true,  TV_LOAD_STORE },
-       { OPT_TARGET_IRG, "sync",        (func_ptr_t) opt_sync,                true, true,  true,  -1 },
-       { OPT_TARGET_IRG, "lower",       (func_ptr_t) do_lower_highlevel,      true, true,  true,  -1 },
+       { OPT_TARGET_IRG, "sync",        (func_ptr_t) opt_sync,                true, true,  true,  TV_SYNC },
+       { OPT_TARGET_IRG, "lower",       (func_ptr_t) do_lower_highlevel,      true, true,  true,  TV_LOWER },
        { OPT_TARGET_IRG, "deconv",      (func_ptr_t) conv_opt,                true, true,  true,  TV_DECONV },
        { OPT_TARGET_IRG, "jumpthreading", (func_ptr_t) opt_jumpthreading,     true, true,  true,  TV_JUMPTHREADING },
        { OPT_TARGET_IRG, "remove_confirms", (func_ptr_t) remove_confirms,     true, false, false, TV_CONFIRM_CREATE },
-       { OPT_TARGET_IRG, "gvnpre",      (func_ptr_t) do_gvn_pre,              true, true,  true,  -1 },
+       { OPT_TARGET_IRG, "gvnpre",      (func_ptr_t) do_gvn_pre,              true, true,  true,  TV_GVNPRE },
        { OPT_TARGET_IRG, "ifconv",      (func_ptr_t) do_if_conv,              true, true,  true,  TV_IF_CONV },
-       { OPT_TARGET_IRG, "bool",        (func_ptr_t) opt_bool,                true, true,  true,  -1 },
+       { OPT_TARGET_IRG, "bool",        (func_ptr_t) opt_bool,                true, true,  true,  TV_BOOLOPT },
        { OPT_TARGET_IRG, "shape-blocks",(func_ptr_t) shape_blocks,            true, true,  true,  TV_END_MELT },
        { OPT_TARGET_IRG, "stred",       (func_ptr_t) do_stred,                true, true,  true,  TV_OSR },
        { OPT_TARGET_IRG, "dead",        (func_ptr_t) dead_node_elimination,   true, false, true,  TV_DEAD_NODE },
-       { OPT_TARGET_IRP, "inline",      (func_ptr_t) do_inline,               true, true,  true,  -1 },
-       { OPT_TARGET_IRP, "clone",       (func_ptr_t) do_cloning,              true, true,  true,  -1 },
-       { OPT_TARGET_IRG, "lower_switch", (func_ptr_t) do_lower_switch,        true, true,  true,  -1 },
+       { OPT_TARGET_IRP, "inline",      (func_ptr_t) do_inline,               true, true,  true,  TV_INLINE },
+       { OPT_TARGET_IRP, "clone",       (func_ptr_t) do_cloning,              true, true,  true,  TV_CLONE },
+       { OPT_TARGET_IRG, "lower_switch", (func_ptr_t) do_lower_switch,        true, true,  true,  TV_LOWER },
 };
 static const int n_opts = sizeof(opts) / sizeof(opts[0]);
 
@@ -600,10 +600,7 @@ static void do_firm_optimizations(const char *input_filename)
 
   DUMP_ALL(firm_dump.ir_graph, "-opt");
   /* verify optimized graphs */
-  for (i = get_irp_n_irgs() - 1; i >= 0; --i) {
-    ir_graph *irg = get_irp_irg(i);
-    irg_verify(irg, VRFY_ENFORCE_SSA);
-  }
+  CHECK_ALL(firm_opt.check_all);
 
   if (firm_dump.statistic & STAT_AFTER_OPT)
     stat_dump_snapshot(input_filename, "opt");
@@ -827,10 +824,7 @@ static void do_firm_lowering(const char *input_filename)
     stat_dump_snapshot(input_filename, "low");
 
   /* verify lowered graphs */
-  timer_push(TV_VERIFY);
-  for (i = get_irp_n_irgs() - 1; i >= 0; --i)
-    irg_verify(get_irp_irg(i), VRFY_ENFORCE_SSA);
-  timer_pop();
+  CHECK_ALL(firm_opt.check_all);
 
   DUMP_ALL(firm_dump.ir_graph, "-low");
 
@@ -1012,6 +1006,7 @@ void gen_firm_finish(FILE *out, const char *input_filename, int c_mode, int new_
   }
 
   /* finalize all graphs */
+  timer_push(TV_CONSTRUCT);
   for (i = get_irp_n_irgs() - 1; i >= 0; --i) {
     ir_graph *irg = get_irp_irg(i);
 
@@ -1019,10 +1014,9 @@ void gen_firm_finish(FILE *out, const char *input_filename, int c_mode, int new_
     DUMP_ONE(firm_dump.ir_graph, irg, "");
 
     /* verify the graph */
-    timer_push(TV_VERIFY);
-      irg_verify(irg, VRFY_ENFORCE_SSA);
-    timer_pop();
+    CHECK_ONE(firm_opt.check_all, irg);
   }
+  timer_pop();
 
   timer_push(TV_VERIFY);
     tr_vrfy();
@@ -1032,10 +1026,12 @@ void gen_firm_finish(FILE *out, const char *input_filename, int c_mode, int new_
   set_irp_phase_state(phase_high);
 
   /* BEWARE: kill unreachable code before doing compound lowering */
+  timer_push(TV_CF_OPT);
   for (i = get_irp_n_irgs() - 1; i >= 0; --i) {
     ir_graph *irg = get_irp_irg(i);
     optimize_cf(irg);
   }
+  timer_pop();
 
   /* lower all compound call return values */
   lower_compound_params();
index cb5d935..3786f4a 100644 (file)
@@ -5,37 +5,47 @@
  *
  * $Id: firm_timing.def 20710 2008-07-26 19:59:07Z beck $
  */
-DEFTIMEVAR(TV_ALL_OPT          , "allopt",     "Firm: all optimizations")
-DEFTIMEVAR(TV_VALUE_NUM        , "valnum",     "Firm: value numbers")
-DEFTIMEVAR(TV_CREATE           , "create",     "Firm: creation")
-DEFTIMEVAR(TV_COMBO            , "combo",      "Firm: combo")
-DEFTIMEVAR(TV_INLINE           , "inline",     "Firm: inlining")
-DEFTIMEVAR(TV_TAIL_REC         , "tailrec",    "Firm: tail-recursion")
-DEFTIMEVAR(TV_COMP_DOMS        , "doms",       "Firm: compute doms")
-DEFTIMEVAR(TV_LOCAL_OPT        , "locopt",     "Firm: local opt")
-DEFTIMEVAR(TV_REASSOCIATION    , "reassoc",    "Firm: reassociation")
-DEFTIMEVAR(TV_CF_OPT           , "cfopt",      "Firm: CF opt")
-DEFTIMEVAR(TV_LOAD_STORE       , "ldst",       "Firm: load/store opt")
-DEFTIMEVAR(TV_LOAD_STORE_2     , "ldst2",      "Firm: enhanced load/store opt")
-DEFTIMEVAR(TV_STRENGTH_REDUCT  , "strength",   "Firm: strength red")
-DEFTIMEVAR(TV_DEAD_NODE        , "deadnode",   "Firm: dead node elim")
-DEFTIMEVAR(TV_DECONV           , "deconv",     "Firm: conv node opt")
+DEFTIMEVAR(TV_ALL_OPT          , "allopt",        "Firm: all optimizations")
+DEFTIMEVAR(TV_VALUE_NUM        , "valnum",        "Firm: value numbers")
+DEFTIMEVAR(TV_CREATE           , "create",        "Firm: creation")
+DEFTIMEVAR(TV_COMBO            , "combo",         "Firm: combo")
+DEFTIMEVAR(TV_INLINE           , "inline",        "Firm: inlining")
+DEFTIMEVAR(TV_TAIL_REC         , "tailrec",       "Firm: tail-recursion")
+DEFTIMEVAR(TV_COMP_DOMS        , "doms",          "Firm: compute doms")
+DEFTIMEVAR(TV_LOCAL_OPT        , "locopt",        "Firm: local opt")
+DEFTIMEVAR(TV_REASSOCIATION    , "reassoc",       "Firm: reassociation")
+DEFTIMEVAR(TV_CF_OPT           , "cfopt",         "Firm: CF opt")
+DEFTIMEVAR(TV_LOAD_STORE       , "ldst",          "Firm: load/store opt")
+DEFTIMEVAR(TV_LOAD_STORE_2     , "ldst2",         "Firm: enhanced load/store opt")
+DEFTIMEVAR(TV_STRENGTH_REDUCT  , "strength",      "Firm: strength red")
+DEFTIMEVAR(TV_DEAD_NODE        , "deadnode",      "Firm: dead node elim")
+DEFTIMEVAR(TV_DECONV           , "deconv",        "Firm: conv node opt")
 DEFTIMEVAR(TV_JUMPTHREADING    , "jumpthreading", "Firm: jump threading")
-DEFTIMEVAR(TV_CODE_PLACE       , "codeplace",  "Firm: code placement")
-DEFTIMEVAR(TV_IF_CONV          , "ifconv",     "Firm: if conversion")
-DEFTIMEVAR(TV_OSR              , "osr",        "Firm: operator strenght reduce")
-DEFTIMEVAR(TV_LOOP_UNROLL      , "lunroll",    "Firm: loop unrolling")
-DEFTIMEVAR(TV_REAL_FUNC_CALL   , "realfunc",   "Firm: real func call")
-DEFTIMEVAR(TV_CGANA            , "cgana",      "Firm: CG analysis")
-DEFTIMEVAR(TV_CONFIRM_CREATE   , "confirm",    "Firm: Confirm creation")
-DEFTIMEVAR(TV_SCALAR_REPLACE   , "scalar",     "Firm: scalar replace")
-DEFTIMEVAR(TV_END_MELT         , "end-melt",   "Firm: melting end blocks")
-DEFTIMEVAR(TV_OPT              , "other",      "Firm: other opt")
-DEFTIMEVAR(TV_VERIFY           , "verify",     "Firm: verify pass")
-DEFTIMEVAR(TV_LOWER            , "lower",      "Firm: lowering")
-DEFTIMEVAR(TV_DW_LOWER         , "dwlower",    "Firm: double word lowering")
-DEFTIMEVAR(TV_FIRM_BE          , "firmbe",     "Firm: backend")
-DEFTIMEVAR(TV_FIRM2C_BE        , "firm2c",     "Firm: C-generating backend")
-DEFTIMEVAR(TV_FIRM_ASM         , "firmasm",    "Firm: Firm assembler")
-DEFTIMEVAR(TV_STAT_OUT         , "statistics", "Firm: statistic output")
-DEFTIMEVAR(TV_VCG_DUMP         , "vcg",        "Firm: vcg dumping")
+DEFTIMEVAR(TV_CODE_PLACE       , "codeplace",     "Firm: code placement")
+DEFTIMEVAR(TV_IF_CONV          , "ifconv",        "Firm: if conversion")
+DEFTIMEVAR(TV_OSR              , "osr",           "Firm: operator strenght reduce")
+DEFTIMEVAR(TV_LOOP_UNROLL      , "lunroll",       "Firm: loop unrolling")
+DEFTIMEVAR(TV_REAL_FUNC_CALL   , "realfunc",      "Firm: real func call")
+DEFTIMEVAR(TV_CGANA            , "cgana",         "Firm: CG analysis")
+DEFTIMEVAR(TV_CONFIRM_CREATE   , "confirm",       "Firm: Confirm creation")
+DEFTIMEVAR(TV_SCALAR_REPLACE   , "scalar",        "Firm: scalar replace")
+DEFTIMEVAR(TV_END_MELT         , "end-melt",      "Firm: melting end blocks")
+DEFTIMEVAR(TV_OPT              , "other",         "Firm: other opt")
+DEFTIMEVAR(TV_VERIFY           , "verify",        "Firm: verify pass")
+DEFTIMEVAR(TV_LOWER            , "lower",         "Firm: lowering")
+DEFTIMEVAR(TV_DW_LOWER         , "dwlower",       "Firm: double word lowering")
+DEFTIMEVAR(TV_FIRM_BE          , "firmbe",        "Firm: backend")
+DEFTIMEVAR(TV_FIRM2C_BE        , "firm2c",        "Firm: C-generating backend")
+DEFTIMEVAR(TV_FIRM_ASM         , "firmasm",       "Firm: Firm assembler")
+DEFTIMEVAR(TV_STAT_OUT         , "statistics",    "Firm: statistic output")
+DEFTIMEVAR(TV_VCG_DUMP         , "vcg",           "Firm: vcg dumping")
+DEFTIMEVAR(TV_SYNC             , "sync",          "Firm: Construct Sync")
+DEFTIMEVAR(TV_GVNPRE           , "gvnpre",        "Firm: GVNPRE")
+DEFTIMEVAR(TV_BOOLOPT          , "bool",          "Firm: Boolean optimisations")
+DEFTIMEVAR(TV_CLONE            , "clone",         "Firm: Procedure cloning")
+DEFTIMEVAR(TV_RTS              , "runtime",       "Firm: Known runtime function optimisation")
+DEFTIMEVAR(TV_ONERETURN        , "oneret",        "Firm: Normalize to one return")
+
+DEFTIMEVAR(TV_PARSING          , "parsing",       "Frontend: Parsing")
+DEFTIMEVAR(TV_CONSTRUCT        , "construction",  "Frontend: Graph construction")
+DEFTIMEVAR(TV_PREPROC          , "preprocess",    "Frontend: Preprocessor")
diff --git a/main.c b/main.c
index eb284fa..dbfa0d2 100644 (file)
--- a/main.c
+++ b/main.c
@@ -71,6 +71,7 @@
 #include "lang_features.h"
 #include "driver/firm_opt.h"
 #include "driver/firm_cmdline.h"
+#include "driver/firm_timing.h"
 #include "adt/error.h"
 #include "wrappergen/write_fluffy.h"
 #include "wrappergen/write_caml.h"
@@ -684,6 +685,7 @@ int main(int argc, char **argv)
        file_list_entry_t *files                = NULL;
        file_list_entry_t *last_file            = NULL;
        bool               construct_dep_target = false;
+       bool               do_timing            = false;
        struct obstack     file_obst;
 
        atexit(free_temp_files);
@@ -1078,6 +1080,8 @@ int main(int argc, char **argv)
                                        mode = PrintCaml;
                                } else if (streq(option, "print-jna")) {
                                        mode = PrintJna;
+                               } else if (streq(option, "time")) {
+                                       do_timing = true;
                                } else if (streq(option, "version")) {
                                        print_cparser_version();
                                        exit(EXIT_SUCCESS);
@@ -1185,6 +1189,9 @@ int main(int argc, char **argv)
        init_ast2firm();
        init_mangle();
 
+       if (do_timing)
+               timer_init();
+
        if (construct_dep_target) {
                if (outname != 0 && strlen(outname) >= 2) {
                        get_output_name(dep_target, sizeof(dep_target), outname, ".d");
@@ -1363,8 +1370,10 @@ do_parsing:
                        c_mode |= features_on;
                        c_mode &= ~features_off;
 
+                       timer_push(TV_PARSING);
                        init_tokens();
                        translation_unit_t *const unit = do_parsing(in, filename);
+                       timer_pop();
 
                        /* prints the AST even if errors occurred */
                        if (mode == PrintAst) {
@@ -1406,7 +1415,9 @@ do_parsing:
                                continue;
                        }
 
+                       timer_push(TV_CONSTRUCT);
                        translation_unit_to_firm(unit);
+                       timer_pop();
 
 graph_built:
                        if (mode == ParseOnly) {
@@ -1539,6 +1550,9 @@ graph_built:
                }
        }
 
+       if (do_timing)
+               timer_term(stderr);
+
        obstack_free(&cppflags_obst, NULL);
        obstack_free(&ldflags_obst, NULL);
        obstack_free(&file_obst, NULL);