keep_alive_barrier operand used wrong block; schedule keep behind phi sequences
[libfirm] / ir / be / bemain.c
index fa74656..1ad8993 100644 (file)
@@ -154,7 +154,7 @@ static const lc_opt_table_entry_t be_main_options[] = {
 static be_module_list_entry_t *isa_ifs = NULL;
 
 
-unsigned short asm_constraint_flags[256];
+asm_constraint_flags_t asm_constraint_flags[256];
 
 void be_init_default_asm_constraint_flags(void)
 {
@@ -219,7 +219,7 @@ void be_init_default_asm_constraint_flags(void)
 
 asm_constraint_flags_t be_parse_asm_constraints(const char *constraint)
 {
-       asm_constraint_flags_t  flags = 0;
+       asm_constraint_flags_t  flags = ASM_CONSTRAINT_FLAG_NONE;
        const char             *c;
        asm_constraint_flags_t  tflags;
 
@@ -476,6 +476,19 @@ static const char *get_timer_name(be_timer_id_t id)
 }
 ir_timer_t *be_timers[T_LAST+1];
 
+void be_lower_for_target(void)
+{
+       int i;
+
+       isa_if->lower_for_target();
+       /* set the phase to low */
+       for (i = get_irp_n_irgs() - 1; i >= 0; --i) {
+               ir_graph *irg = get_irp_irg(i);
+               set_irg_phase_state(irg, phase_low);
+       }
+       set_irp_phase_state(phase_low);
+}
+
 /**
  * The Firm backend main loop.
  * Do architecture specific lowering for all graphs
@@ -534,9 +547,7 @@ static void be_main_loop(FILE *file_handle, const char *cup_name)
                Get the filename for the profiling data.
                Beware: '\0' is already included in sizeof(suffix)
        */
-       memset(prof_filename, 0, sizeof(prof_filename));
-       strncpy(prof_filename, cup_name, sizeof(prof_filename) - sizeof(suffix));
-       strcat(prof_filename, suffix);
+       sprintf(prof_filename, "%.*s%s\n", (int)(sizeof(prof_filename) - sizeof(suffix)), cup_name, suffix);
 
        /*
                Next: Either instruments all irgs with profiling code
@@ -591,11 +602,10 @@ static void be_main_loop(FILE *file_handle, const char *cup_name)
                        arch_env->impl->before_abi(irg);
 
                /* implement the ABI conventions. */
-               be_timer_push(T_ABI);
-               be_abi_introduce(irg);
-               be_timer_pop(T_ABI);
-
                if (!arch_env->custom_abi) {
+                       be_timer_push(T_ABI);
+                       be_abi_introduce(irg);
+                       be_timer_pop(T_ABI);
                        dump(DUMP_ABI, irg, "abi");
                }
 
@@ -760,18 +770,20 @@ static void be_main_loop(FILE *file_handle, const char *cup_name)
 
                dump(DUMP_FINAL, irg, "end");
 
-               be_timer_push(T_ABI);
-               be_abi_free(irg);
-               be_timer_pop(T_ABI);
+               if (!arch_env->custom_abi) {
+                       be_timer_push(T_ABI);
+                       be_abi_free(irg);
+                       be_timer_pop(T_ABI);
+               }
 
                restore_optimization_state(&state);
 
                be_timer_pop(T_OTHER);
 
                if (be_timing) {
-                       int t;
+                       be_timer_id_t t;
                        if (stat_ev_enabled) {
-                               for (t = 0; t < T_LAST+1; ++t) {
+                               for (t = T_FIRST; t < T_LAST+1; ++t) {
                                        char buf[128];
                                        snprintf(buf, sizeof(buf), "bemain_time_%s",
                                                 get_timer_name(t));
@@ -780,12 +792,12 @@ static void be_main_loop(FILE *file_handle, const char *cup_name)
                        } else {
                                printf("==>> IRG %s <<==\n",
                                       get_entity_name(get_irg_entity(irg)));
-                               for (t = 0; t < T_LAST+1; ++t) {
+                               for (t = T_FIRST; t < T_LAST+1; ++t) {
                                        double val = ir_timer_elapsed_usec(be_timers[t]) / 1000.0;
                                        printf("%-20s: %8.3lf msec\n", get_timer_name(t), val);
                                }
                        }
-                       for (t = 0; t < T_LAST+1; ++t) {
+                       for (t = T_FIRST; t < T_LAST+1; ++t) {
                                ir_timer_stop(be_timers[t]);
                                ir_timer_reset(be_timers[t]);
                        }
@@ -864,8 +876,7 @@ void be_main(FILE *file_handle, const char *cup_name)
 
 static int do_lower_for_target(ir_prog *irp, void *context)
 {
-       const backend_params *be_params = be_get_backend_param();
-       be_params->lower_for_target();
+       be_lower_for_target();
        (void) context;
        (void) irp;
        return 0;