moved external headers into include dir
[libfirm] / ir / be / bespillslots.c
1 /*
2  * Copyright (C) 1995-2007 University of Karlsruhe.  All right reserved.
3  *
4  * This file is part of libFirm.
5  *
6  * This file may be distributed and/or modified under the terms of the
7  * GNU General Public License version 2 as published by the Free Software
8  * Foundation and appearing in the file LICENSE.GPL included in the
9  * packaging of this file.
10  *
11  * Licensees holding valid libFirm Professional Edition licenses may use
12  * this file in accordance with the libFirm Commercial License.
13  * Agreement provided with the Software.
14  *
15  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
16  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17  * PURPOSE.
18  */
19
20 /**
21  * @file
22  * @brief       Spillslot coalescer.
23  * @author      Matthias Braun
24  * @date        26.07.2006
25  * @version     $Id$
26  */
27 #ifdef HAVE_CONFIG_H
28 #include "config.h"
29 #endif
30
31 #include <stdlib.h>
32
33 #include "set.h"
34 #include "array.h"
35 #include "irgwalk.h"
36 #include "ircons.h"
37 #include "irprintf.h"
38 #include "execfreq.h"
39 #include "unionfind.h"
40 #include "irdump_t.h"
41
42 #include "benode_t.h"
43 #include "besched.h"
44 #include "bespillslots.h"
45 #include "bechordal_t.h"
46 #include "bejavacoal.h"
47 #include "benodesets.h"
48 #include "bestatevent.h"
49 #include "bespilloptions.h"
50 #include "bemodule.h"
51 #include "beintlive_t.h"
52 #include "beirg_t.h"
53 #include "bearch_t.h"
54
55 #define DBG_COALESCING          1
56 #define DBG_INTERFERENCES       2
57
58 DEBUG_ONLY(
59 static firm_dbg_module_t *dbg = NULL;
60 )
61
62 typedef struct _spill_t {
63         ir_node *spill;
64         /** mode of the spilled value */
65         const ir_mode *mode;
66         /** alignment for the spilled value */
67         int alignment;
68         /** index into spillslot_unionfind unionfind structure */
69         int spillslot;
70 } spill_t;
71
72 typedef struct _affinity_edge_t {
73         double affinity;
74         int slot1, slot2;
75 } affinity_edge_t;
76
77 struct _be_fec_env_t {
78         struct obstack obst;
79         const arch_env_t *arch_env;
80         be_irg_t *birg;
81         set *spills;
82         ir_node **reloads;
83         affinity_edge_t **affinity_edges;
84         set *memperms;
85 };
86
87 /** Compare 2 affinity edges (used in quicksort) */
88 static int cmp_affinity(const void *d1, const void *d2)
89 {
90         const affinity_edge_t * const *e1 = d1;
91         const affinity_edge_t * const *e2 = d2;
92
93         // sort in descending order
94         return (*e1)->affinity < (*e2)->affinity ? 1 : -1;
95 }
96
97 static int cmp_spill(const void* d1, const void* d2, size_t size)
98 {
99         const spill_t* s1 = d1;
100         const spill_t* s2 = d2;
101         return s1->spill != s2->spill;
102 }
103
104 static spill_t *get_spill(be_fec_env_t *env, ir_node *node)
105 {
106         spill_t spill, *res;
107         int hash = nodeset_hash(node);
108
109         spill.spill = node;
110         res = set_find(env->spills, &spill, sizeof(spill), hash);
111
112         return res;
113 }
114
115 /*
116  *   ____      _ _           _     ____        _ _ _
117  *  / ___|___ | | | ___  ___| |_  / ___| _ __ (_) | |___
118  * | |   / _ \| | |/ _ \/ __| __| \___ \| '_ \| | | / __|
119  * | |__| (_) | | |  __/ (__| |_   ___) | |_) | | | \__ \
120  *  \____\___/|_|_|\___|\___|\__| |____/| .__/|_|_|_|___/
121  *                                      |_|
122  */
123
124 static INLINE ir_node *get_memory_edge(const ir_node *node)
125 {
126         int i, arity;
127
128         arity = get_irn_arity(node);
129         for(i = arity - 1; i >= 0; --i) {
130                 ir_node *arg = get_irn_n(node, i);
131                 if(get_irn_mode(arg) == mode_M)
132                         return arg;
133         }
134
135         return NULL;
136 }
137
138 static spill_t *collect_spill(be_fec_env_t *env, ir_node *node,
139                                       const ir_mode *mode, int align)
140 {
141         spill_t spill, *res;
142         int hash = nodeset_hash(node);
143
144         /* insert into set of spills if not already there */
145         spill.spill = node;
146         res = set_find(env->spills, &spill, sizeof(spill), hash);
147
148         if(res == NULL) {
149                 spill.spillslot = set_count(env->spills);
150                 spill.mode = mode;
151                 spill.alignment = align;
152                 res = set_insert(env->spills, &spill, sizeof(spill), hash);
153         } else {
154                 assert(res->mode == mode);
155                 assert(res->alignment == align);
156         }
157
158         return res;
159 }
160
161 static spill_t *collect_memphi(be_fec_env_t *env, ir_node *node,
162                                const ir_mode *mode, int align)
163 {
164         int i, arity;
165         spill_t spill, *res;
166         int hash = nodeset_hash(node);
167         const ir_exec_freq *exec_freq = be_get_birg_exec_freq(env->birg);
168
169         assert(is_Phi(node));
170
171         spill.spill = node;
172         res = set_find(env->spills, &spill, sizeof(spill), hash);
173         if(res != NULL) {
174                 assert(res->mode == mode);
175                 assert(res->alignment == align);
176                 return res;
177         }
178
179         spill.spillslot = set_count(env->spills);
180         spill.mode = mode;
181         spill.alignment = align;
182         res = set_insert(env->spills, &spill, sizeof(spill), hash);
183
184         // collect attached spills and mem-phis
185         arity = get_irn_arity(node);
186         for(i = 0; i < arity; ++i) {
187                 affinity_edge_t *affinty_edge;
188                 ir_node *arg = get_irn_n(node, i);
189                 spill_t *arg_spill;
190
191                 if(is_Phi(arg)) {
192                         arg_spill = collect_memphi(env, arg, mode, align);
193                 } else {
194                         arg_spill = collect_spill(env, arg, mode, align);
195                 }
196
197                 // add an affinity edge
198                 affinty_edge = obstack_alloc(&env->obst, sizeof(affinty_edge[0]));
199                 affinty_edge->affinity = get_block_execfreq(exec_freq, get_nodes_block(arg));
200                 affinty_edge->slot1 = res->spillslot;
201                 affinty_edge->slot2 = arg_spill->spillslot;
202                 ARR_APP1(affinity_edge_t*, env->affinity_edges, affinty_edge);
203         }
204
205         return res;
206 }
207
208 void be_node_needs_frame_entity(be_fec_env_t *env, ir_node *node,
209                                 const ir_mode *mode, int align)
210 {
211         ir_node *spillnode = get_memory_edge(node);
212         spill_t *spill;
213
214         assert(spillnode != NULL);
215
216         if (is_Phi(spillnode)) {
217                 spill = collect_memphi(env, spillnode, mode, align);
218         } else {
219                 spill = collect_spill(env, spillnode, mode, align);
220         }
221
222         ARR_APP1(ir_node *, env->reloads, node);
223 }
224
225 /*
226  *   ____            _                      ____  _       _
227  *  / ___|___   __ _| | ___  ___  ___ ___  / ___|| | ___ | |_ ___
228  * | |   / _ \ / _` | |/ _ \/ __|/ __/ _ \ \___ \| |/ _ \| __/ __|
229  * | |__| (_) | (_| | |  __/\__ \ (_|  __/  ___) | | (_) | |_\__ \
230  *  \____\___/ \__,_|_|\___||___/\___\___| |____/|_|\___/ \__|___/
231  */
232
233 static int merge_interferences(be_fec_env_t *env, bitset_t** interferences,
234                                int* spillslot_unionfind, int s1, int s2)
235 {
236         int res;
237         int i;
238         int spillcount;
239
240         // merge spillslots and interferences
241         res = uf_union(spillslot_unionfind, s1, s2);
242         // we assume that we always merge s2 to s1 so swap s1, s2 if necessary
243         if(res != 0) {
244                 int t = s1;
245                 s1 = s2;
246                 s2 = t;
247         }
248
249         bitset_or(interferences[s1], interferences[s2]);
250
251         // update other interferences
252         spillcount = set_count(env->spills);
253         for(i = 0; i < spillcount; ++i) {
254                 bitset_t *intfs = interferences[i];
255                 if(bitset_is_set(intfs, s2))
256                         bitset_set(intfs, s1);
257         }
258
259         return res;
260 }
261
262 /**
263  * A greedy coalescing algorithm for spillslots:
264  *  1. Sort the list of affinity edges
265  *  2. Try to merge slots with affinity edges (most expensive slots first)
266  *  3. Try to merge everything else that is possible
267  */
268 static void do_greedy_coalescing(be_fec_env_t *env)
269 {
270         int spillcount;
271         spill_t **spilllist;
272         spill_t *spill;
273         int i, i2;
274         int affinity_edge_count;
275         bitset_t **interferences;
276         int* spillslot_unionfind;
277
278         spillcount = set_count(env->spills);
279         if(spillcount == 0)
280                 return;
281
282         DBG((dbg, DBG_COALESCING, "Coalescing %d spillslots\n", spillcount));
283
284         interferences = alloca(spillcount * sizeof(interferences[0]));
285         spillslot_unionfind = alloca(spillcount * sizeof(spillslot_unionfind[0]));
286         spilllist = alloca(spillcount * sizeof(spilllist[0]));
287
288         uf_init(spillslot_unionfind, 0, spillcount);
289
290         DEBUG_ONLY(
291                 memset(spilllist, 0, spillcount * sizeof(spilllist[0]));
292         );
293
294         for(spill = set_first(env->spills), i = 0; spill != NULL; spill = set_next(env->spills), ++i) {
295                 assert(spill->spillslot < spillcount);
296                 spilllist[spill->spillslot] = spill;
297         }
298
299         for(i = 0; i < spillcount; ++i) {
300                 interferences[i] = bitset_alloca(spillcount);
301         }
302
303         /* construct interferences */
304         for (i = 0; i < spillcount; ++i) {
305                 ir_node *spill1 = spilllist[i]->spill;
306
307                 if (is_NoMem(spill1))
308                         continue;
309
310                 for(i2 = i+1; i2 < spillcount; ++i2) {
311                         ir_node *spill2 = spilllist[i2]->spill;
312
313                         if (is_NoMem(spill2))
314                                 continue;
315
316                         if (values_interfere(env->birg, spill1, spill2)) {
317                                 DBG((dbg, DBG_INTERFERENCES, "Slot %d and %d interfere\n", i, i2));
318                                 bitset_set(interferences[i], i2);
319                                 bitset_set(interferences[i2], i);
320                         }
321                 }
322         }
323
324         /* sort affinity edges */
325         affinity_edge_count = ARR_LEN(env->affinity_edges);
326         qsort(env->affinity_edges, affinity_edge_count, sizeof(env->affinity_edges[0]), cmp_affinity);
327
328         //dump_interference_graph(env, interferences, "before");
329
330         /* try to merge affine nodes */
331         for(i = 0; i < affinity_edge_count; ++i) {
332                 const affinity_edge_t *edge = env->affinity_edges[i];
333                 int s1 = uf_find(spillslot_unionfind, edge->slot1);
334                 int s2 = uf_find(spillslot_unionfind, edge->slot2);
335
336                 /* test if values interfere */
337                 if (bitset_is_set(interferences[s1], s2)) {
338                         assert(bitset_is_set(interferences[s2], s1));
339                         continue;
340                 }
341
342                 DBG((dbg, DBG_COALESCING, "Merging %d and %d because of affinity edge\n", s1, s2));
343
344                 merge_interferences(env, interferences, spillslot_unionfind, s1, s2);
345         }
346
347         // try to merge as much remaining spillslots as possible
348         for(i = 0; i < spillcount; ++i) {
349                 int s1 = uf_find(spillslot_unionfind, i);
350                 if(s1 != i)
351                         continue;
352
353                 for(i2 = i+1; i2 < spillcount; ++i2) {
354                         int s2 = uf_find(spillslot_unionfind, i2);
355                         if(s2 != i2)
356                                 continue;
357
358                         /* test if values interfere
359                          * we have to test n1-n2 and n2-n1, because only 1 side gets updated
360                          * when node merging occurs
361                          */
362                         if(bitset_is_set(interferences[s1], s2)) {
363                                 assert(bitset_is_set(interferences[s2], s1));
364                                 continue;
365                         }
366
367                         DBG((dbg, DBG_COALESCING, "Merging %d and %d because it is possible\n", s1, s2));
368
369                         if(merge_interferences(env, interferences, spillslot_unionfind, s1, s2) != 0) {
370                                 // we can break the loop here, because s2 is the new supernode now
371                                 // and we'll test s2 again later anyway
372                                 break;
373                         }
374                 }
375         }
376
377         // assign spillslots to spills
378         for(i = 0; i < spillcount; ++i) {
379                 spill_t *spill = spilllist[i];
380
381                 spill->spillslot = uf_find(spillslot_unionfind, i);
382         }
383
384         //dump_interference_graph(env, interferences, "after");
385 }
386
387 /*
388  *     _            _               _____       _   _ _   _
389  *    / \   ___ ___(_) __ _ _ __   | ____|_ __ | |_(_) |_(_) ___  ___
390  *   / _ \ / __/ __| |/ _` | '_ \  |  _| | '_ \| __| | __| |/ _ \/ __|
391  *  / ___ \\__ \__ \ | (_| | | | | | |___| | | | |_| | |_| |  __/\__ \
392  * /_/   \_\___/___/_|\__, |_| |_| |_____|_| |_|\__|_|\__|_|\___||___/
393  *                    |___/
394  */
395
396 typedef struct _spill_slot_t {
397         int size;
398         int align;
399         ir_entity *entity;
400 } spill_slot_t;
401
402 typedef struct _memperm_entry_t {
403         ir_node* node;
404         int pos;
405         ir_entity *in;
406         ir_entity *out;
407         struct _memperm_entry_t *next;
408 } memperm_entry_t;
409
410 typedef struct _memperm_t {
411         ir_node *block;
412         int entrycount;
413         memperm_entry_t *entries;
414 } memperm_t;
415
416 static int cmp_memperm(const void* d1, const void* d2, size_t size)
417 {
418         const memperm_t* e1 = d1;
419         const memperm_t* e2 = d2;
420         return e1->block != e2->block;
421 }
422
423 static memperm_t *get_memperm(be_fec_env_t *env, ir_node *block)
424 {
425         memperm_t entry, *res;
426         int hash;
427
428         entry.block = block;
429         hash = nodeset_hash(block);
430
431         res = set_find(env->memperms, &entry, sizeof(entry), hash);
432
433         if(res == NULL) {
434                 entry.entrycount = 0;
435                 entry.entries = NULL;
436                 res = set_insert(env->memperms, &entry, sizeof(entry), hash);
437         }
438
439         return res;
440 }
441
442 static ir_entity* create_stack_entity(be_fec_env_t *env, spill_slot_t *slot)
443 {
444         ir_graph *irg = be_get_birg_irg(env->birg);
445         ir_type *frame = get_irg_frame_type(irg);
446         ir_entity *res = frame_alloc_area(frame, slot->size, slot->align, 0);
447
448         /* adjust size of the entity type... */
449         ir_type *enttype = get_entity_type(res);
450         set_type_size_bytes(enttype, slot->size);
451
452         slot->entity = res;
453
454         return res;
455 }
456
457 /**
458  * Enlarges a spillslot (if necessary) so that it can carry a value of size
459  * @p othersize and alignment @p otheralign.
460  */
461 static void enlarge_spillslot(spill_slot_t *slot, int otheralign, int othersize)
462 {
463         if(othersize > slot->size) {
464                 slot->size = othersize;
465         }
466         if(otheralign > slot->align) {
467                 if(otheralign % slot->align != 0)
468                         slot->align *= otheralign;
469                 else
470                         slot->align = otheralign;
471         } else if(slot->align % otheralign != 0) {
472                 slot->align *= otheralign;
473         }
474 }
475
476 /**
477  * Create stack entities for the spillslots and assign them to the spill and
478  * reload nodes.
479  */
480 static void assign_spillslots(be_fec_env_t *env)
481 {
482         const arch_env_t *arch_env = env->arch_env;
483         int i;
484         int spillcount;
485         spill_t *spill;
486         spill_slot_t* spillslots;
487
488         spillcount = set_count(env->spills);
489         spillslots = alloca(spillcount * sizeof(spillslots[0]));
490
491         memset(spillslots, 0, spillcount * sizeof(spillslots[0]));
492
493         // construct spillslots
494         for(spill = set_first(env->spills); spill != NULL; spill = set_next(env->spills)) {
495                 int slotid = spill->spillslot;
496                 const ir_mode *mode = spill->mode;
497                 spill_slot_t *slot = & (spillslots[slotid]);
498                 int size = get_mode_size_bytes(mode);
499                 int align = spill->alignment;
500
501                 if(slot->align == 0 && slot->size == 0) {
502                         slot->align = align;
503                         slot->size = size;
504                 } else {
505                         enlarge_spillslot(slot, align, size);
506                 }
507         }
508
509         for(spill = set_first(env->spills); spill != NULL; spill = set_next(env->spills)) {
510                 spill_slot_t *slot;
511                 ir_node *node = spill->spill;
512                 int slotid = spill->spillslot;
513
514                 slot = &spillslots[slotid];
515                 if(slot->entity == NULL) {
516                         create_stack_entity(env, slot);
517                 }
518
519                 if(is_Phi(node)) {
520                         int i, arity;
521                         ir_node *block = get_nodes_block(node);
522
523                         // should be a PhiM
524                         assert(is_Phi(node));
525
526                         for(i = 0, arity = get_irn_arity(node); i < arity; ++i) {
527                                 ir_node *arg = get_irn_n(node, i);
528                                 ir_node *predblock = get_Block_cfgpred_block(block, i);
529                                 spill_t *argspill;
530                                 int argslotid;
531
532                                 argspill = get_spill(env, arg);
533                                 assert(argspill != NULL);
534
535                                 argslotid = argspill->spillslot;
536                                 if(slotid != argslotid) {
537                                         memperm_t *memperm;
538                                         memperm_entry_t *entry;
539                                         spill_slot_t *argslot = &spillslots[argslotid];
540                                         if(argslot->entity == NULL) {
541                                                 create_stack_entity(env, argslot);
542                                         }
543
544                                         memperm = get_memperm(env, predblock);
545
546                                         entry = obstack_alloc(&env->obst, sizeof(entry[0]));
547                                         entry->node = node;
548                                         entry->pos = i;
549                                         entry->in = argslot->entity;
550                                         entry->out = slot->entity;
551                                         entry->next = memperm->entries;
552                                         memperm->entrycount++;
553                                         memperm->entries = entry;
554                                 }
555                         }
556                 } else {
557                         if(!is_NoMem(node))
558                                 arch_set_frame_entity(arch_env, node, slot->entity);
559                 }
560         }
561
562         for(i = 0; i < ARR_LEN(env->reloads); ++i) {
563                 ir_node* reload = env->reloads[i];
564                 ir_node* spillnode = get_memory_edge(reload);
565                 spill_t *spill = get_spill(env, spillnode);
566                 const spill_slot_t *slot = & spillslots[spill->spillslot];
567
568                 assert(slot->entity != NULL);
569
570                 arch_set_frame_entity(arch_env, reload, slot->entity);
571         }
572 }
573
574 /**
575  * Returns the last node in a block which is no control flow changing node
576  */
577 static ir_node *get_end_of_block_insertion_point(ir_node* block)
578 {
579         ir_node* ins = sched_last(block);
580         while(is_Proj(ins) && get_irn_mode(ins) == mode_X) {
581                 ins = sched_prev(ins);
582                 assert(ins != NULL);
583         }
584
585         if(is_cfop(ins)) {
586                 while(1) {
587                         ir_node *prev = sched_prev(ins);
588                         if(!is_cfop(prev))
589                                 break;
590                         ins = prev;
591                 }
592         }
593
594         return ins;
595 }
596
597 static void create_memperms(be_fec_env_t *env)
598 {
599         const arch_env_t *arch_env = env->arch_env;
600         ir_graph *irg = be_get_birg_irg(env->birg);
601         memperm_t *memperm;
602
603         for(memperm = set_first(env->memperms); memperm != NULL; memperm = set_next(env->memperms)) {
604                 int i;
605                 memperm_entry_t *entry;
606                 ir_node *blockend;
607                 ir_node** nodes = alloca(memperm->entrycount * sizeof(nodes[0]));
608                 ir_node* mempermnode;
609
610                 assert(memperm->entrycount > 0);
611
612                 for(entry = memperm->entries, i = 0; entry != NULL; entry = entry->next, ++i) {
613                         ir_node* arg = get_irn_n(entry->node, entry->pos);
614                         nodes[i] = arg;
615                 }
616
617                 mempermnode = be_new_MemPerm(arch_env, irg, memperm->block,
618                                              memperm->entrycount, nodes);
619
620                 // insert node into schedule
621                 blockend = get_end_of_block_insertion_point(memperm->block);
622                 sched_add_before(blockend, mempermnode);
623                 be_stat_ev("mem_perm", memperm->entrycount);
624
625                 i = 0;
626                 for(entry = memperm->entries; entry != NULL; entry = entry->next, ++i) {
627                         ir_node *proj;
628                         ir_node* arg = get_irn_n(entry->node, entry->pos);
629
630                         be_set_MemPerm_in_entity(mempermnode, i, entry->in);
631                         be_set_MemPerm_out_entity(mempermnode, i, entry->out);
632                         set_irg_current_block(irg, memperm->block);
633                         proj = new_Proj(mempermnode, get_irn_mode(arg), i);
634                         sched_add_before(blockend, proj);
635
636                         set_irn_n(entry->node, entry->pos, proj);
637                 }
638         }
639 }
640
641 static int count_spillslots(const be_fec_env_t *env)
642 {
643         const spill_t *spill;
644         int spillcount = set_count(env->spills);
645         bitset_t *counted = bitset_alloca(spillcount);
646         int slotcount;
647
648         slotcount = 0;
649         for(spill = set_first(env->spills); spill != NULL;
650             spill = set_next(env->spills)) {
651                 int spillslot = spill->spillslot;
652                 if(!bitset_is_set(counted, spillslot)) {
653                         slotcount++;
654                         bitset_set(counted, spillslot);
655                 }
656         }
657
658         return slotcount;
659 }
660
661 be_fec_env_t *be_new_frame_entity_coalescer(be_irg_t *birg)
662 {
663         const arch_env_t *arch_env = birg->main_env->arch_env;
664         be_fec_env_t     *env      = xmalloc(sizeof(env[0]));
665
666         be_assure_liveness(birg);
667
668         obstack_init(&env->obst);
669         env->arch_env       = arch_env;
670         env->birg           = birg;
671         env->spills         = new_set(cmp_spill, 10);
672         env->reloads        = NEW_ARR_F(ir_node*, 0);
673         env->affinity_edges = NEW_ARR_F(affinity_edge_t*, 0);
674         env->memperms       = new_set(cmp_memperm, 10);
675
676         return env;
677 }
678
679 void be_free_frame_entity_coalescer(be_fec_env_t *env)
680 {
681         del_set(env->memperms);
682         DEL_ARR_F(env->reloads);
683         DEL_ARR_F(env->affinity_edges);
684         del_set(env->spills);
685         obstack_free(&env->obst, NULL);
686
687         free(env);
688 }
689
690 void be_assign_entities(be_fec_env_t *env)
691 {
692         if(be_stat_ev_is_active()) {
693                 int count = set_count(env->spills);
694                 be_stat_ev("spillslots", count);
695         }
696
697         if(be_coalesce_spill_slots) {
698                 do_greedy_coalescing(env);
699         }
700
701         if(be_stat_ev_is_active()) {
702                 int count = count_spillslots(env);
703                 be_stat_ev("spillslots_after_coalescing", count);
704         }
705
706         assign_spillslots(env);
707
708         create_memperms(env);
709 }
710
711 /**
712  * This walker function searches for reloads and collects all the spills
713  * and memphis attached to them.
714  */
715 static void collect_spills_walker(ir_node *node, void *data)
716 {
717         be_fec_env_t *env = data;
718         const arch_env_t *arch_env = env->arch_env;
719         const ir_mode *mode;
720         const arch_register_class_t *cls;
721         int align;
722
723         /* classify returns classification of the irn the proj is attached to */
724         if (is_Proj(node))
725                 return;
726
727         if (!arch_irn_class_is(arch_env, node, reload))
728                 return;
729
730         mode  = get_irn_mode(node);
731         cls   = arch_get_irn_reg_class(arch_env, node, -1);
732         align = arch_isa_get_reg_class_alignment(arch_env_get_isa(arch_env), cls);
733
734         be_node_needs_frame_entity(env, node, mode, align);
735 }
736
737 void be_coalesce_spillslots(be_irg_t *birg)
738 {
739         be_fec_env_t *env = be_new_frame_entity_coalescer(birg);
740
741         /* collect reloads */
742         irg_walk_graph(birg->irg, NULL, collect_spills_walker, env);
743
744         be_assign_entities(env);
745
746         be_free_frame_entity_coalescer(env);
747 }
748
749 void be_init_spillslots(void)
750 {
751         FIRM_DBG_REGISTER(dbg, "firm.be.spillslots");
752 }
753
754 BE_REGISTER_MODULE_CONSTRUCTOR(be_init_spillslots);