3 * @author Sebastian Hack
22 #include "besched_t.h"
23 #include "belistsched.h"
26 #include "phiclass_t.h"
27 #include "bechordal.h"
28 #include "bechordal.h"
32 #define DUMP_ALLOCATED
33 #define DUMP_LOCALIZED
37 typedef struct _be_graph_info_t {
38 bitset_t *applied_phases;
41 static size_t be_info_offset = 0;
43 #define get_irg_be_info(irg) get_irg_data(irg, be_graph_info_t, be_info_offset)
45 static int phase_ids = 1;
46 static struct obstack obst;
48 int phase_register(phase_t *phase)
50 phase->id = phase_ids;
54 void phase_applied(const ir_graph *irg, const phase_t *phase)
56 be_graph_info_t *info = get_irg_be_info(irg);
58 if(!info->applied_phases)
59 info->applied_phases = bitset_obstack_alloc(&obst, N_PHASES);
61 bitset_set(info->applied_phases, phase->id);
64 int phase_depends_on(const ir_graph *irg, const phase_t *phase, int n, ...)
71 const be_graph_info_t *info = get_irg_be_info(irg);
72 const bitset_t *applied_phases = info->applied_phases;
76 for(i = 0; i < n; ++i) {
77 const phase_t *dep_phase = va_arg(args, const phase_t *);
79 if(!applied_phases || !bitset_is_set(applied_phases, dep_phase->id)) {
81 fprintf(stderr, "phase dependency unfulfilled: \"%s\" depends on \"%s\"\n",
82 phase->name, dep_phase->name);
88 assert(errors > 0 && "There were phase dependency errors");
97 be_info_offset = register_additional_graph_data(sizeof(be_graph_info_t));
103 be_ra_chordal_init();
107 extern void be_ra_chordal(ir_graph *irg);
109 static void be_main_loop(void)
113 for(i = 0, n = get_irp_n_irgs(); i < n; ++i) {
114 ir_graph *irg = get_irp_irg(i);
116 localize_consts(irg);
117 #ifdef DUMP_LOCALIZED
118 dump_consts_local(0);
119 dump_ir_block_graph(irg, "-local-const");
122 list_sched(irg, trivial_selector, NULL);
126 #ifdef DUMP_ALLOCATED
127 dump_allocated_irg(irg);
130 //??be_phi_destruction(irg);
132 be_ra_chordal_done(irg);
133 be_numbering_done(irg);
137 void be_main(int argc, const char *argv[])