Bugfix in stat, use of stat. Not ready but commited so it will compile.
[libfirm] / ir / be / bemain.c
index 372e695..12fbc01 100644 (file)
@@ -15,6 +15,7 @@
 #include "irprog.h"
 #include "irgraph.h"
 #include "irdump.h"
+#include "phiclass.h"
 
 #include "be_t.h"
 #include "bera_t.h"
@@ -24,9 +25,9 @@
 #include "belive_t.h"
 #include "beutil.h"
 #include "bechordal.h"
-#include "bechordal.h"
-#include "bephiopt.h"
-#include "phistat.h"
+#include "bearch.h"
+#include "becopyoptmain.h"
+#include "becopystat.h"
 
 #include "beasm_dump_globals.h"
 #include "beasm_asm_gnu.h"
@@ -103,16 +104,22 @@ void be_init(void)
        be_numbering_init();
        be_ra_init();
        be_ra_chordal_init();
-       be_phi_opt_init();
+       be_copy_opt_init();
+#ifdef DO_STAT
+       stat_init();
+#endif
 }
 
-extern void be_ra_chordal(ir_graph *irg);
+/* The preliminary Firm backend isa. */
+extern arch_isa_if_t arch_isa_if_firm;
 
 static void be_main_loop(void)
 {
        int i, n;
+       const arch_isa_if_t *isa = &arch_isa_if_firm;
 
        for(i = 0, n = get_irp_n_irgs(); i < n; ++i) {
+               int j, m;
                ir_graph *irg = get_irp_irg(i);
 
                localize_consts(irg);
@@ -121,31 +128,49 @@ static void be_main_loop(void)
                dump_ir_block_graph(irg, "-local-const");
 #endif
                be_numbering(irg);
+
+               /* Schedule the graphs. */
                list_sched(irg, trivial_selector);
+
+               /* Liveness analysis */
                be_liveness(irg);
-               be_ra_chordal(irg);
 
-#ifdef DUMP_ALLOCATED
-               dump_allocated_irg(irg, "");
+#ifdef DO_STAT
+               stat_reset();
 #endif
-               be_phi_opt(irg);
+               /* Perform the following for each register class. */
+               for(j = 0, m = isa->get_n_reg_class(); j < m; ++j) {
+                       const arch_register_class_t *cls = isa->get_reg_class(j);
+
+                       be_ra_chordal(irg, isa, cls);
 
-               be_ra_chordal_done(irg);
-               be_numbering_done(irg);
+#ifdef DUMP_ALLOCATED
+                       dump_allocated_irg(irg, "");
+#endif
+#ifdef DO_STAT
+                       stat_collect_irg(irg);
+#endif
+                       be_copy_opt(irg, isa, cls);
+                       be_ra_chordal_done(irg);
+               }
+#ifdef DO_STAT
+               stat_dump(irg);
+#endif
+           be_numbering_done(irg);
        }
 }
 
 void be_main(int argc, const char *argv[])
 {
-  assembler_t *gnu_assembler;
-  FILE *asm_output_file;
+       assembler_t *gnu_assembler;
+       FILE *asm_output_file;
 
        be_main_loop();
        gnu_assembler = gnuasm_create_assembler();
        asm_output_file = fopen("asm_output.asm", "w");
 
-       asm_dump_globals ( gnu_assembler );
-       gnuasm_dump ( gnu_assembler, asm_output_file );
-       gnuasm_delete_assembler ( gnu_assembler );
+       asm_dump_globals(gnu_assembler);
+       gnuasm_dump(gnu_assembler, asm_output_file);
+       gnuasm_delete_assembler(gnu_assembler);
        fclose(asm_output_file);
 }