X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fana%2Fphiclass.c;h=af8284e296150d5d3ef8091b242c3ded767aec31;hb=58e533a640ff427362877a3d2f1a5142c96391e1;hp=0a5166b1836623731a4e455331d79819bb145f9b;hpb=1a45198099b1f6ce6032c0949f4e85aa8c97b70a;p=libfirm diff --git a/ir/ana/phiclass.c b/ir/ana/phiclass.c index 0a5166b18..af8284e29 100644 --- a/ir/ana/phiclass.c +++ b/ir/ana/phiclass.c @@ -2,8 +2,13 @@ * @author Daniel Grund * @date 09.08.2005 */ +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif -#include +#ifdef HAVE_STDLIB_H +# include +#endif #include "debug.h" #include "irgwalk.h" @@ -11,13 +16,13 @@ #include "iredges_t.h" #include "phiclass_t.h" -#define DEBUG_LVL SET_LEVEL_0 -static firm_dbg_module_t *dbg = NULL; +DEBUG_ONLY(static firm_dbg_module_t *dbg = NULL;) size_t phi_irn_data_offset = 0; static void phi_class_build(ir_node *irn, pset *pc) { int i, max; + const ir_edge_t *edge; /* If irn has a phi class assigned already * return immediately to stop recursion */ @@ -50,7 +55,6 @@ static void phi_class_build(ir_node *irn, pset *pc) { /* Add a user of the irn to the class, * iff it is a phi node */ - const ir_edge_t *edge; foreach_out_edge(irn, edge) { ir_node *user = edge->src; DBG((dbg, LEVEL_2, " checking user %+F\n", user)); @@ -59,20 +63,6 @@ static void phi_class_build(ir_node *irn, pset *pc) { } } -pset *phi_class_compute_by_phis(pset *all_phi_nodes) { - int i; - ir_node *phi; - pset *all_phi_classes = pset_new_ptr_default(); - - for (i = 0, phi=pset_first(all_phi_nodes); phi; phi=pset_next(all_phi_nodes)) { - assert(is_Phi(phi) && mode_is_datab(get_irn_mode(phi))); - phi_class_build(phi, NULL); - pset_insert_ptr(all_phi_classes, _get_phi_class(phi)); - } - - return all_phi_classes; -} - static void phi_class_construction_walker(ir_node *node, void *env) { if (is_Phi(node) && mode_is_datab(get_irn_mode(node))) phi_class_build(node, NULL); @@ -81,8 +71,10 @@ static void phi_class_construction_walker(ir_node *node, void *env) { static void phi_class_destruction_walker(ir_node *node, void *env) { pset *clss = _get_phi_class(node); if (clss) { + ir_node *n; + for(n = pset_first(clss); n; n = pset_next(clss)) + _set_phi_class(n, NULL); del_pset(clss); - _set_phi_class(node, NULL); } } @@ -91,6 +83,26 @@ void phi_class_compute(ir_graph *irg) { irg_walk_graph(irg, phi_class_construction_walker, NULL, NULL); } +pset *phi_class_compute_by_phis(pset *all_phi_nodes) { + int i; + ir_node *phi; + pset *all_phi_classes = pset_new_ptr_default(); + + if (pset_count(all_phi_nodes)) { + ir_graph *irg = get_irn_irg(pset_first(all_phi_nodes)); + pset_break(all_phi_nodes); + irg_walk_graph(irg, phi_class_destruction_walker, NULL, NULL); + + for (i = 0, phi=pset_first(all_phi_nodes); phi; phi=pset_next(all_phi_nodes)) { + assert(is_Phi(phi) && mode_is_datab(get_irn_mode(phi))); + phi_class_build(phi, NULL); + pset_insert_ptr(all_phi_classes, _get_phi_class(phi)); + } + } + + return all_phi_classes; +} + void phi_class_free(ir_graph *irg) { irg_walk_graph(irg, phi_class_destruction_walker, NULL, NULL); } @@ -100,7 +112,6 @@ pset *get_phi_class(const ir_node *irn) { } void phi_class_init(void) { - dbg = firm_dbg_register("ir.ana.phiclass"); - firm_dbg_set_mask(dbg, DEBUG_LVL); + FIRM_DBG_REGISTER(dbg, "ir.ana.phiclass"); phi_irn_data_offset = register_additional_node_data(sizeof(phi_info_t)); }