X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fana%2Finterval_analysis.c;h=9db46b6047a8775003699db2a4ded5988d4939a8;hb=a9eee95c42def4095dad5214b493aa0e3ab5a1f7;hp=26a362efd85d476a047599f7580cd6e61224fe89;hpb=5ea9d0c93d64963b085ff10cde05f739e1c2606b;p=libfirm diff --git a/ir/ana/interval_analysis.c b/ir/ana/interval_analysis.c index 26a362efd..9db46b604 100644 --- a/ir/ana/interval_analysis.c +++ b/ir/ana/interval_analysis.c @@ -1,4 +1,27 @@ +/* + * Copyright (C) 1995-2008 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 Implementation of interval analysis + * @version $Id$ + */ #ifdef HAVE_CONFIG_H #include "config.h" #endif @@ -7,6 +30,7 @@ #include #endif +#include "debug.h" #include "interval_analysis.h" #include "execution_frequency.h" #include "firm_common_t.h" @@ -18,8 +42,11 @@ #include "irdump_t.h" #include "irdom.h" #include "irflag.h" +#include "irprintf.h" #include "hashptr.h" +DEBUG_ONLY(static firm_dbg_module_t *dbg); + /*------------------------------------------------------------------*/ /* A new in array via a hashmap. */ /* The in array refers to the loop the block is contained in if the */ @@ -39,6 +66,7 @@ static set *region_attr_set = NULL; int region_attr_cmp(const void *e1, const void *e2, size_t size) { region_attr *ra1 = (region_attr *)e1; region_attr *ra2 = (region_attr *)e2; + (void) size; return (ra1->reg != ra2->reg); } @@ -167,10 +195,13 @@ static int find_inner_loop(ir_node *b, ir_loop *l, ir_node *pred, ir_node *cfop) } -static int find_previous_loop(ir_loop *l, ir_loop *pred_l, ir_node *b, ir_node *pred_b, ir_node *cfop) { +static int find_previous_loop(ir_loop *l, ir_loop *pred_l, ir_node *b, + ir_node *pred_b, ir_node *cfop) +{ ir_loop *outer = get_loop_outer_loop(l); int found, i; int l_pos = get_loop_element_pos(outer, l); + (void) pred_l; assert(l_pos > -1); assert(l_pos > 0 && "Is this a necessary condition? There could be a perfect nest ..."); @@ -188,14 +219,6 @@ static int find_previous_loop(ir_loop *l, ir_loop *pred_l, ir_node *b, ir_node * } } - if (!found) { - DDMG(current_ir_graph); - DDML(l); - DDML(pred_l); - DDMN(b); - DDMN(pred_b); - } - return found; } @@ -229,9 +252,7 @@ static void construct_interval_block(ir_node *b, ir_loop *l) { if (is_backedge(b, i)) { if (b != get_loop_element(l, 0).node) { - if (get_firm_verbosity()) { - printf("Loophead not at loop position 0. "); DDMN(b); - } + DB((dbg, LEVEL_1, "Loophead not at loop position 0. %+F\n", b)); } /* There are no backedges in the interval decomposition. */ add_region_in(b, NULL); @@ -260,9 +281,7 @@ static void construct_interval_block(ir_node *b, ir_loop *l) { int found = find_inner_loop(b, l, pred, cfop); if (!found) { if (b != get_loop_element(l, 0).node) { - if (get_firm_verbosity()) { - printf("Loop entry not at loop position 0. "); DDMN(b); - } + DB((dbg, LEVEL_1, "Loop entry not at loop position 0. %+F\n", b)); } found = find_outer_loop(l, pred_l, pred, cfop); if (found) add_region_in(b, NULL); /* placeholder */ @@ -271,9 +290,6 @@ static void construct_interval_block(ir_node *b, ir_loop *l) { found = find_previous_loop(l, pred_l, b, pred, cfop); } if (!found) { - DDMG(current_ir_graph); - DDMN(b); - DDMN(pred); assert(is_backedge(b, i)); assert(found && "backedge from inner loop"); } @@ -282,10 +298,7 @@ static void construct_interval_block(ir_node *b, ir_loop *l) { if (b != get_loop_element(l, 0).node) { /* Check for improper region */ if (has_backedges(b)) { - printf("Improper Region!!!!!!\n"); - DDMG(current_ir_graph); - DDMN(b); - DDML(l); + ir_fprintf(stderr, "Improper Region!!!!!! %+F\n", b); } } } @@ -312,6 +325,8 @@ void construct_intervals(ir_graph *irg) { ir_graph *rem = current_ir_graph; current_ir_graph = irg; + FIRM_DBG_REGISTER(dbg, "firm.ana.interval"); + if (!region_attr_set) region_attr_set = new_set(region_attr_cmp, 256); @@ -364,8 +379,7 @@ void dump_region_edges(FILE *F, void *reg) { if (is_ir_node(reg)) { if (get_Block_n_cfgpreds((ir_node *)reg) != get_region_n_ins(reg)) { - printf("n_cfgpreds = %d, n_ins = %d\n", get_Block_n_cfgpreds((ir_node *)reg), get_region_n_ins(reg)); - DDMN((ir_node *)reg); + ir_printf("n_cfgpreds = %d, n_ins = %d\n %+F\n", get_Block_n_cfgpreds((ir_node *)reg), get_region_n_ins(reg), (ir_node*) reg); } } @@ -485,11 +499,12 @@ void dump_interval_graph(ir_graph *irg, const char *suffix) { return; f = vcg_open(irg, suffix, "-intervals"); - dump_vcg_header(f, get_irg_dump_name(irg), NULL); + dump_vcg_header(f, get_irg_dump_name(irg), NULL, NULL); current_ir_graph = irg; dump_interval_loop(f, get_irg_loop(current_ir_graph)); - vcg_close(f); + dump_vcg_footer(f); + fclose(f); }