3 * @author Sebastian Hack
22 #include "besched_t.h"
23 #include "belistsched.h"
26 #include "bechordal.h"
27 #include "bechordal.h"
31 #include "beasm_dump_globals.h"
32 #include "beasm_asm_gnu.h"
34 #define DUMP_ALLOCATED
39 typedef struct _be_graph_info_t {
40 bitset_t *applied_phases;
43 static size_t be_info_offset = 0;
45 #define get_irg_be_info(irg) get_irg_data(irg, be_graph_info_t, be_info_offset)
47 static int phase_ids = 1;
48 static struct obstack obst;
50 int phase_register(phase_t *phase)
52 phase->id = phase_ids;
56 void phase_applied(const ir_graph *irg, const phase_t *phase)
58 be_graph_info_t *info = get_irg_be_info(irg);
60 if(!info->applied_phases)
61 info->applied_phases = bitset_obstack_alloc(&obst, N_PHASES);
63 bitset_set(info->applied_phases, phase->id);
66 int phase_depends_on(const ir_graph *irg, const phase_t *phase, int n, ...)
73 const be_graph_info_t *info = get_irg_be_info(irg);
74 const bitset_t *applied_phases = info->applied_phases;
78 for(i = 0; i < n; ++i) {
79 const phase_t *dep_phase = va_arg(args, const phase_t *);
81 if(!applied_phases || !bitset_is_set(applied_phases, dep_phase->id)) {
83 fprintf(stderr, "phase dependency unfulfilled: \"%s\" depends on \"%s\"\n",
84 phase->name, dep_phase->name);
90 assert(errors > 0 && "There were phase dependency errors");
99 be_info_offset = register_additional_graph_data(sizeof(be_graph_info_t));
105 be_ra_chordal_init();
109 extern void be_ra_chordal(ir_graph *irg);
111 static void be_main_loop(void)
115 for(i = 0, n = get_irp_n_irgs(); i < n; ++i) {
116 ir_graph *irg = get_irp_irg(i);
118 localize_consts(irg);
119 #ifdef DUMP_LOCALIZED
120 dump_consts_local(0);
121 dump_ir_block_graph(irg, "-local-const");
124 list_sched(irg, trivial_selector, NULL);
128 #ifdef DUMP_ALLOCATED
129 dump_allocated_irg(irg, "");
133 be_ra_chordal_done(irg);
134 be_numbering_done(irg);
138 void be_main(int argc, const char *argv[])
140 assembler_t *gnu_assembler;
141 FILE *asm_output_file;
144 gnu_assembler = gnuasm_create_assembler();
145 asm_output_file = fopen("asm_output.asm", "w");
147 asm_dump_globals ( gnu_assembler );
148 gnuasm_dump ( gnu_assembler, asm_output_file );
149 gnuasm_delete_assembler ( gnu_assembler );
150 fclose(asm_output_file);