X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fbe%2Fbeirgmod.c;h=843b670892ea298f1e5e7847804924d68d8a060a;hb=0f3f5dcf8b021c4c43eb8b47f59c6aad0972ce0e;hp=e692c5bd684b82355ce7f2f5e29738f0f6da3918;hpb=205396c4f4f5abe7abd6dc2350c8c398a7623afc;p=libfirm diff --git a/ir/be/beirgmod.c b/ir/be/beirgmod.c index e692c5bd6..843b67089 100644 --- a/ir/be/beirgmod.c +++ b/ir/be/beirgmod.c @@ -1,16 +1,33 @@ +/* + * 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 + * @brief Backend IRG modification routines. + * @author Sebastian Hack, Daniel Grund, Matthias Braun, Christian Wuerdig + * @date 04.05.2005 + * @version $Id$ + * * This file contains the following IRG modifications for be routines: * - insertion of Perm nodes * - empty block elimination * - a simple dead node elimination (set inputs of unreachable nodes to BAD) - * - * @author Sebastian Hack, Daniel Grund, Matthias Braun, Christian Wuerdig - * @date 04.05.2005 - * @version $Id$ - * Copyright: (c) Universitaet Karlsruhe - * Licence: This file protected by GPL - GNU GENERAL PUBLIC LICENSE. */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -48,8 +65,9 @@ #include "beutil.h" #include "beinsn_t.h" #include "bessaconstr.h" - +#include "beirg_t.h" #include "beirgmod.h" +#include "bemodule.h" DEBUG_ONLY(static firm_dbg_module_t *dbg = NULL;) @@ -70,30 +88,33 @@ ir_node *insert_Perm_after(be_irg_t *birg, be_lv_t *lv = birg->lv; ir_node *bl = is_Block(pos) ? pos : get_nodes_block(pos); ir_graph *irg = get_irn_irg(bl); - pset *live = pset_new_ptr_default(); + ir_nodeset_t live; + ir_nodeset_iterator_t iter; ir_node *curr, *irn, *perm, **nodes; - int i, n; + size_t i, n; DBG((dbg, LEVEL_1, "Insert Perm after: %+F\n", pos)); - be_liveness_nodes_live_at(lv, arch_env, cls, pos, live); - - n = pset_count(live); + ir_nodeset_init(&live); + be_liveness_nodes_live_at(lv, arch_env, cls, pos, &live); + n = ir_nodeset_size(&live); if(n == 0) { - del_pset(live); + ir_nodeset_destroy(&live); return NULL; } nodes = xmalloc(n * sizeof(nodes[0])); DBG((dbg, LEVEL_1, "live:\n")); - for(irn = pset_first(live), i = 0; irn; irn = pset_next(live), i++) { + i = 0; + foreach_ir_nodeset(&live, irn, iter) { DBG((dbg, LEVEL_1, "\t%+F\n", irn)); nodes[i] = irn; + i++; } - del_pset(live); + ir_nodeset_destroy(&live); perm = be_new_Perm(cls, irg, bl, n, nodes); sched_add_after(pos, perm); @@ -109,7 +130,6 @@ ir_node *insert_Perm_after(be_irg_t *birg, ir_node *proj = new_r_Proj(irg, bl, perm, mode, i); arch_set_irn_register(arch_env, proj, reg); - sched_add_after(curr, proj); curr = proj; be_ssa_construction_init(&senv, birg);