3 #include "irprintf_t.h"
20 #include "iredges_t.h"
26 #include "firm/bearch_firm.h"
27 #include "ia32/bearch_ia32.h"
28 #include "arm/bearch_arm.h"
29 #include "ppc32/bearch_ppc32.h"
30 #include "mips/bearch_mips.h"
37 #include "besched_t.h"
38 #include "belistsched.h"
40 #include "bespillilp.h"
41 #include "bespillbelady.h"
43 #include "beraextern.h"
44 #include "bechordal_t.h"
46 #include "beifg_impl.h"
47 #include "becopyopt.h"
48 #include "becopystat.h"
49 #include "bessadestr.h"
58 typedef struct _spilloc_env_t {
68 typedef struct _vertex {
76 typedef struct _edge {
78 unsigned int wt_val_interfere;
79 unsigned int wt_con_interfere;
84 #define STRUCTSIZE sizeof(vertex)
88 static void add_ent(entity *ent, void *env) {
89 spilloc_env_t *spi = env;
90 entity *e = obstack_alloc(&spi->ob, sizeof(*e));
93 pset_insert_ptr(spi->ents, e);
97 static void data_init(spilloc_env_t *env) {
98 pset *ps = pset_new_ptr_default();
101 foreach_pset(env->ents, e) {
102 pmap_insert(env->nodents, e, ps);
106 static void get_entity_nodes(ir_node *irn, void *env) {
108 spilloc_env_t *spi = env;
110 e = get_irn_entity_attr(irn);
111 //get_entity_additional_properties();
114 foreach_pset(spi->ents, ent) {
116 if ((ent->nr == e->nr) && (ent->ld_name == e->ld_name) )
118 pset *ps = pmap_get(spi->nodents, ent);
119 if (ps && (!pset_find_ptr(pmap_get(spi->nodents, ent),irn))) {
120 pset_insert_ptr(pmap_get(spi->nodents, ent), irn);
127 pset *get_entity_irn(entity *ent, void *env) {
128 spilloc_env_t *spi = env;
130 pset *pirn = pmap_get(spi->nodents, ent);
138 int entities_interfere(entity *e1, entity *e2, void *env) {
139 spilloc_env_t *spi = env;
142 pset *pe1 = pmap_get(spi->nodents, e1);
143 pset *pe2 = pmap_get(spi->nodents, e2);
145 foreach_pset(pe1, n1) {
146 foreach_pset(pe2, n2) {
147 if (values_interfere(n1, n2)) return 1;
153 static void set_aff_graph(void *env) {
154 spilloc_env_t *spi = env;
159 foreach_pset(spi->ents, e) {
160 vertex *ver = obstack_alloc(&spi->ob, sizeof(*ver));
161 ver->edges = pset_new_ptr_default();
164 pmap_insert(spi->afgraph, e, ver);
168 foreach_pset(spi->ents, e) {
169 foreach_pset(spi->ents, cmp) {
170 if (entities_interfere(e, cmp, &spi) == 1) {
171 v = pmap_get(spi->afgraph, e);
172 pset_insert_ptr(v->edges, cmp);
178 void be_spill_loc(const be_chordal_env_t *chordal_env) {
182 // create initial graph representing data structure
183 obstack_init(&spi.ob);
184 spi.ents = pset_new_ptr_default();
186 spi.irg = chordal_env->irg;
187 spi.nodents = pmap_create();
188 spi.afgraph = pmap_create();
191 /* Walks over all entities in the type */
192 walk_types_entities(get_irg_frame_type(chordal_env->irg), add_ent, &spi);
195 irg_walk_blkwise_graph(chordal_env->irg, NULL, get_entity_nodes, &spi);
200 pmap_destroy(spi.nodents);
201 pmap_destroy(spi.afgraph);
202 obstack_free(&spi.ob, NULL);