adapted to new callback
[libfirm] / ir / be / bemain.c
index 05ef2ca..c954cd4 100644 (file)
@@ -72,6 +72,9 @@ static be_options_t be_options = {
        "cplex"                            /* ilp solver */
 };
 
+/* config file. */
+static char config_file[256] = { 0 };
+
 /* dump flags */
 static unsigned dump_flags = 0;
 
@@ -159,13 +162,14 @@ static lc_opt_enum_int_var_t sched_select_var = {
 };
 
 static const lc_opt_table_entry_t be_main_options[] = {
-       LC_OPT_ENT_ENUM_MASK("dump",         "dump irg on several occasions",     &dump_var),
-       LC_OPT_ENT_ENUM_PTR ("ra",           "register allocator",                &ra_var),
-       LC_OPT_ENT_ENUM_PTR ("isa",          "the instruction set architecture",  &isa_var),
-       LC_OPT_ENT_NEGBOOL  ("noomitfp",     "do not omit frame pointer",         &be_omit_fp),
-       LC_OPT_ENT_ENUM_PTR ("vrfy",         "verify the backend irg (off, warn, assert)",  &vrfy_var),
-       LC_OPT_ENT_BOOL     ("time",         "get backend timing statistics",     &be_options.timing),
-       LC_OPT_ENT_BOOL     ("sched.mris",   "enable mris schedule preparation",  &be_options.mris),
+       LC_OPT_ENT_STR      ("config",       "read another config file containing backend options",                 config_file, sizeof(config_file)),
+       LC_OPT_ENT_ENUM_MASK("dump",         "dump irg on several occasions",                                       &dump_var),
+       LC_OPT_ENT_ENUM_PTR ("ra",           "register allocator",                                                  &ra_var),
+       LC_OPT_ENT_ENUM_PTR ("isa",          "the instruction set architecture",                                    &isa_var),
+       LC_OPT_ENT_NEGBOOL  ("noomitfp",     "do not omit frame pointer",                                           &be_omit_fp),
+       LC_OPT_ENT_ENUM_PTR ("vrfy",         "verify the backend irg (off, warn, assert)",                          &vrfy_var),
+       LC_OPT_ENT_BOOL     ("time",         "get backend timing statistics",                                       &be_options.timing),
+       LC_OPT_ENT_BOOL     ("sched.mris",   "enable mris schedule preparation",                                    &be_options.mris),
        LC_OPT_ENT_ENUM_PTR ("sched.select", "schedule node selector (trivial, regpress, muchnik, heur, hmuchnik)", &sched_select_var),
 
 #ifdef WITH_ILP
@@ -568,20 +572,15 @@ static void be_main_loop(FILE *file_handle)
 
                /* fix stack offsets */
                BE_TIMER_PUSH(t_abi);
-               //be_abi_fix_stack_bias(birg.abi);
+               be_abi_fix_stack_nodes(birg.abi, NULL);
+               be_remove_dead_nodes_from_schedule(birg.irg);
+               be_abi_fix_stack_bias(birg.abi);
                BE_TIMER_POP(t_abi);
 
                BE_TIMER_PUSH(t_finish);
                arch_code_generator_finish(birg.cg);
                BE_TIMER_POP(t_finish);
 
-               /* fix stack offsets */
-               BE_TIMER_PUSH(t_abi);
-               be_abi_fix_stack_nodes(birg.abi, NULL);
-               be_remove_dead_nodes_from_schedule(birg.irg);
-               be_abi_fix_stack_bias(birg.abi);
-               BE_TIMER_POP(t_abi);
-
                dump(DUMP_FINAL, irg, "-finish", dump_ir_block_graph_sched);
 
                /* check schedule and register allocation */
@@ -667,6 +666,18 @@ void be_main(FILE *file_handle)
 {
 #ifdef WITH_LIBCORE
        lc_timer_t *t;
+#endif /* WITH_LIBCORE */
+
+#ifdef WITH_LIBCORE
+       /* The user specified another config file to read. do that now. */
+       if(strlen(config_file) > 0) {
+               FILE *f;
+
+               if((f = fopen(config_file, "rt")) != NULL) {
+                       lc_opt_from_file(config_file, f, NULL);
+                       fclose(f);
+               }
+       }
 
        if (be_options.timing == BE_TIME_ON) {
                t = lc_timer_register("bemain", "measure complete bemain loop");