3 * @author Sebastian Hack
22 #include "bechordal_t.h"
24 #include "besched_t.h"
25 #include "belistsched.h"
28 #include "bechordal.h"
30 #include "becopyoptmain.h"
31 #include "becopystat.h"
32 #include "bearch_firm.h"
35 #include "beasm_dump_globals.h"
36 #include "beasm_asm_gnu.h"
56 static void be_init_arch_env(arch_env_t *env)
58 const arch_isa_if_t *isa = &firm_isa;
59 be_node_factory_t *nf;
61 nf = be_new_node_factory(isa);
63 arch_env_init(env, isa);
66 arch_env_add_irn_handler(env, &firm_irn_handler);
67 arch_env_add_irn_handler(env, be_node_get_irn_handler(nf));
70 static void be_main_loop(void)
74 const arch_isa_if_t *isa;
76 be_init_arch_env(&env);
78 isa = arch_env_get_isa(&env);
80 for(i = 0, n = get_irp_n_irgs(); i < n; ++i) {
82 ir_graph *irg = get_irp_irg(i);
84 remove_critical_cf_edges(irg);
89 dump_ir_block_graph(irg, "-local-const");
93 /* Schedule the graphs. */
94 list_sched(irg, trivial_selector);
96 /* Liveness analysis */
102 /* Perform the following for each register class. */
103 for(j = 0, m = isa->get_n_reg_class(); j < m; ++j) {
104 be_chordal_env_t *chordal_env;
105 const arch_register_class_t *cls = isa->get_reg_class(j);
107 chordal_env = be_ra_chordal(irg, &env, cls);
109 #ifdef DUMP_ALLOCATED
110 dump_allocated_irg(&env, irg, "");
113 stat_collect_irg(irg);
115 be_copy_opt(chordal_env, &env, cls);
116 be_ra_chordal_done(chordal_env);
121 be_numbering_done(irg);
125 void be_main(int argc, const char *argv[])
127 assembler_t *gnu_assembler;
128 FILE *asm_output_file;
131 gnu_assembler = gnuasm_create_assembler();
132 asm_output_file = fopen("asm_output.asm", "w");
134 asm_dump_globals(gnu_assembler);
135 gnuasm_dump(gnu_assembler, asm_output_file);
136 gnuasm_delete_assembler(gnu_assembler);
137 fclose(asm_output_file);