3 * @author Sebastian Hack
23 #include "besched_t.h"
24 #include "belistsched.h"
27 #include "bechordal.h"
29 #include "becopyoptmain.h"
30 #include "becopystat.h"
31 #include "bearch_firm.h"
33 #include "beasm_dump_globals.h"
34 #include "beasm_asm_gnu.h"
55 static void be_init_arch_env(arch_env_t *env)
57 arch_env_init(env, &firm_isa);
58 arch_env_add_irn_handler(env, &firm_irn_handler);
63 static void be_main_loop(void)
67 const arch_isa_if_t *isa;
69 be_init_arch_env(&env);
71 isa = arch_env_get_isa(&env);
73 for(i = 0, n = get_irp_n_irgs(); i < n; ++i) {
75 ir_graph *irg = get_irp_irg(i);
80 dump_ir_block_graph(irg, "-local-const");
84 /* Schedule the graphs. */
85 list_sched(irg, trivial_selector);
87 /* Liveness analysis */
93 /* Perform the following for each register class. */
94 for(j = 0, m = isa->get_n_reg_class(); j < m; ++j) {
95 const arch_register_class_t *cls = isa->get_reg_class(j);
97 be_ra_chordal(irg, &env, cls);
100 dump_allocated_irg(&env, irg, "");
103 stat_collect_irg(irg);
105 be_copy_opt(irg, isa, cls);
106 be_ra_chordal_done(irg);
111 be_numbering_done(irg);
115 void be_main(int argc, const char *argv[])
117 assembler_t *gnu_assembler;
118 FILE *asm_output_file;
121 gnu_assembler = gnuasm_create_assembler();
122 asm_output_file = fopen("asm_output.asm", "w");
124 asm_dump_globals(gnu_assembler);
125 gnuasm_dump(gnu_assembler, asm_output_file);
126 gnuasm_delete_assembler(gnu_assembler);
127 fclose(asm_output_file);