X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fbe%2Fbespillslots.c;h=e06fa91808fd9fab54684552a20f4729ebbf974e;hb=9276447aec4972df060349e162f583c4898dfec8;hp=2b3ece63de3914ace091e279b5e079074db6b3bd;hpb=111132c624cc0db52da15f582d2f3c60adf4f968;p=libfirm diff --git a/ir/be/bespillslots.c b/ir/be/bespillslots.c index 2b3ece63d..e06fa9180 100644 --- a/ir/be/bespillslots.c +++ b/ir/be/bespillslots.c @@ -1,17 +1,37 @@ /* - * Author: Matthias Braun - * Date: 26.7.06 - * Copyright: (c) Universitaet Karlsruhe - * Licence: This file protected by GPL - GNU GENERAL PUBLIC LICENSE. + * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved. + * + * This file is part of libFirm. + * + * This file may be distributed and/or modified under the terms of the + * GNU General Public License version 2 as published by the Free Software + * Foundation and appearing in the file LICENSE.GPL included in the + * packaging of this file. + * + * Licensees holding valid libFirm Professional Edition licenses may use + * this file in accordance with the libFirm Commercial License. + * Agreement provided with the Software. + * + * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE + * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE. + */ + +/** + * @file + * @brief Spillslot coalescer. + * @author Matthias Braun + * @date 26.07.2006 + * @version $Id$ */ #ifdef HAVE_CONFIG_H -#include +#include "config.h" #endif #include #include "set.h" - +#include "array.h" #include "irgwalk.h" #include "ircons.h" #include "irprintf.h" @@ -28,6 +48,10 @@ #include "benodesets.h" #include "bestatevent.h" #include "bespilloptions.h" +#include "bemodule.h" +#include "beintlive_t.h" +#include "beirg_t.h" +#include "bearch_t.h" #define DBG_COALESCING 1 #define DBG_INTERFERENCES 2 @@ -251,7 +275,6 @@ static void do_greedy_coalescing(be_fec_env_t *env) int affinity_edge_count; bitset_t **interferences; int* spillslot_unionfind; - const be_lv_t *lv = be_get_birg_liveness(env->birg); spillcount = set_count(env->spills); if(spillcount == 0) @@ -278,10 +301,20 @@ static void do_greedy_coalescing(be_fec_env_t *env) interferences[i] = bitset_alloca(spillcount); } - // construct interferences - for(i = 0; i < spillcount; ++i) { + /* construct interferences */ + for (i = 0; i < spillcount; ++i) { + ir_node *spill1 = spilllist[i]->spill; + + if (is_NoMem(spill1)) + continue; + for(i2 = i+1; i2 < spillcount; ++i2) { - if(values_interfere(lv, spilllist[i]->spill, spilllist[i2]->spill)) { + ir_node *spill2 = spilllist[i2]->spill; + + if (is_NoMem(spill2)) + continue; + + if (values_interfere(env->birg, spill1, spill2)) { DBG((dbg, DBG_INTERFERENCES, "Slot %d and %d interfere\n", i, i2)); bitset_set(interferences[i], i2); bitset_set(interferences[i2], i); @@ -289,20 +322,20 @@ static void do_greedy_coalescing(be_fec_env_t *env) } } - // sort affinity edges + /* sort affinity edges */ affinity_edge_count = ARR_LEN(env->affinity_edges); qsort(env->affinity_edges, affinity_edge_count, sizeof(env->affinity_edges[0]), cmp_affinity); //dump_interference_graph(env, interferences, "before"); - // try to merge affine nodes + /* try to merge affine nodes */ for(i = 0; i < affinity_edge_count; ++i) { const affinity_edge_t *edge = env->affinity_edges[i]; int s1 = uf_find(spillslot_unionfind, edge->slot1); int s2 = uf_find(spillslot_unionfind, edge->slot2); /* test if values interfere */ - if(bitset_is_set(interferences[s1], s2)) { + if (bitset_is_set(interferences[s1], s2)) { assert(bitset_is_set(interferences[s2], s1)); continue; } @@ -413,7 +446,7 @@ static ir_entity* create_stack_entity(be_fec_env_t *env, spill_slot_t *slot) ir_type *frame = get_irg_frame_type(irg); ir_entity *res = frame_alloc_area(frame, slot->size, slot->align, 0); - // adjust size of the entity type... + /* adjust size of the entity type... */ ir_type *enttype = get_entity_type(res); set_type_size_bytes(enttype, slot->size); @@ -522,7 +555,8 @@ static void assign_spillslots(be_fec_env_t *env) } } } else { - arch_set_frame_entity(arch_env, node, slot->entity); + if(!is_NoMem(node)) + arch_set_frame_entity(arch_env, node, slot->entity); } } @@ -628,19 +662,17 @@ static int count_spillslots(const be_fec_env_t *env) be_fec_env_t *be_new_frame_entity_coalescer(be_irg_t *birg) { const arch_env_t *arch_env = birg->main_env->arch_env; - - be_fec_env_t *env = xmalloc(sizeof(env[0])); + be_fec_env_t *env = xmalloc(sizeof(env[0])); be_assure_liveness(birg); obstack_init(&env->obst); - env->arch_env = arch_env; - env->birg = birg; - env->spills = new_set(cmp_spill, 10); - env->reloads = NEW_ARR_F(ir_node*, 0); + env->arch_env = arch_env; + env->birg = birg; + env->spills = new_set(cmp_spill, 10); + env->reloads = NEW_ARR_F(ir_node*, 0); env->affinity_edges = NEW_ARR_F(affinity_edge_t*, 0); - env->memperms = new_set(cmp_memperm, 10); - FIRM_DBG_REGISTER(dbg, "firm.be.spillslots"); + env->memperms = new_set(cmp_memperm, 10); return env; } @@ -696,8 +728,8 @@ static void collect_spills_walker(ir_node *node, void *data) if (!arch_irn_class_is(arch_env, node, reload)) return; - mode = get_irn_mode(node); - cls = arch_get_irn_reg_class(arch_env, node, -1); + mode = get_irn_mode(node); + cls = arch_get_irn_reg_class(arch_env, node, -1); align = arch_isa_get_reg_class_alignment(arch_env_get_isa(arch_env), cls); be_node_needs_frame_entity(env, node, mode, align); @@ -714,3 +746,10 @@ void be_coalesce_spillslots(be_irg_t *birg) be_free_frame_entity_coalescer(env); } + +void be_init_spillslots(void) +{ + FIRM_DBG_REGISTER(dbg, "firm.be.spillslots"); +} + +BE_REGISTER_MODULE_CONSTRUCTOR(be_init_spillslots);