generate emitter functions from spec
[libfirm] / ir / be / bemain.c
index a7db572..82ed7e4 100644 (file)
 #include "beasm_dump_globals.h"
 #include "beasm_asm_gnu.h"
 
+#include "firm2arch.h"
+
 #undef DUMP_BEGIN
 #undef DUMP_PREPARED
+#define DUMP_TRANSFORM
 #define DUMP_SCHED
 #define DUMP_SPILL
 #undef DUMP_ALLOCATED
@@ -137,13 +140,16 @@ static void be_main_loop(void)
        be_init_env(&env);
        isa = arch_env_get_isa(env.arch_env);
 
+        /* create required irop's */
+        create_bearch_asm_opcodes();
+
        /* For all graphs */
        for(i = 0, n = get_irp_n_irgs(); i < n; ++i) {
                int j, m;
                ir_graph *irg = get_irp_irg(i);
                be_main_session_env_t session;
 
-               DBG((env.dbg, LEVEL_1, "====> IRG: %F\n", irg));
+               DBG((env.dbg, LEVEL_2, "====> IRG: %F\n", irg));
 #ifdef DUMP_BEGIN
                dump_ir_block_graph(irg, "-begin");
 #endif
@@ -153,6 +159,15 @@ static void be_main_loop(void)
 
                /* Compute some analyses and prepare the graph for backend use. */
                prepare_graph(&session);
+
+                transform_firm(irg);
+
+#ifdef DUMP_TRANSFORM
+               dump_ir_block_graph(irg, "-transformed");
+#endif
+
+
+#if 0
 #ifdef DUMP_PREPARED
                dump_dominator_information(true);
                dump_ir_block_graph(irg, "-prepared");
@@ -229,23 +244,17 @@ static void be_main_loop(void)
                dump_ir_block_graph_sched(session.irg, "-end");
 #endif
                copystat_dump(irg);
+#endif /* if 0 */
        }
 }
 
 void be_main(int argc, const char *argv[])
 {
-       assembler_t *gnu_assembler;
-       FILE *asm_output_file;
+  FILE *asm_output_file;
 
-       be_main_loop();
+  be_main_loop();
 
-#if 0
-       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);
-       fclose(asm_output_file);
-#endif
+  asm_output_file = fopen(argv[0], "w");
+  firmbe_gen_code(asm_output_file);
+  fclose(asm_output_file);
 }