X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fbe%2Fbepressurestat.c;h=4f925f28e82db44a12bec1d81a2203804a7c3b89;hb=a8d6e45f13a40f6c9269608bf937e3e641d0b715;hp=5cae11aa19e9f558fb64f55c82b2e9b9f5515f7d;hpb=02046d6f22e734521c84dfb2f342cf61e6442c2f;p=libfirm diff --git a/ir/be/bepressurestat.c b/ir/be/bepressurestat.c index 5cae11aa1..4f925f28e 100644 --- a/ir/be/bepressurestat.c +++ b/ir/be/bepressurestat.c @@ -1,16 +1,30 @@ -/** vim: set sw=4 ts=4: - * @file bepressurestat.c - * @date 2006-04-06 - * @author Adam M. Szalkowski +/* + * Copyright (C) 1995-2008 University of Karlsruhe. All right reserved. * - * Register Pressure Statistics + * This file is part of libFirm. * - * Copyright (C) 2006 Universitaet Karlsruhe - * Released under the GPL + * 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 Register Pressure Statistics. + * @author Adam M. Szalkowski + * @date 06.04.2006 + * @version $Id$ */ -#ifdef HAVE_CONFIG_H #include "config.h" -#endif #include @@ -27,117 +41,106 @@ #include "irnode_t.h" #include "ircons_t.h" #include "irloop_t.h" -#include "phiclass.h" #include "iredges.h" #include "execfreq.h" - -#include +#include "irtools.h" #include "be_t.h" #include "belive_t.h" -#include "besched_t.h" +#include "besched.h" #include "beirgmod.h" #include "bearch.h" -#include "benode_t.h" +#include "benode.h" #include "beutil.h" -#include "bespillremat.h" #include "bespill.h" - -#include "bechordal_t.h" +#include "beirg.h" #define MAXPRESSURE 128 typedef struct _regpressure_ana_t { - arch_env_t *arch_env; const arch_register_class_t *cls; const be_lv_t *lv; unsigned int *stat; - DEBUG_ONLY(firm_dbg_module_t * dbg); + DEBUG_ONLY(firm_dbg_module_t *dbg); } regpressure_ana_t; -static INLINE int -has_reg_class(const regpressure_ana_t * ra, const ir_node * irn) +static inline int has_reg_class(const regpressure_ana_t *ra, const ir_node *irn) { - return arch_irn_consider_in_reg_alloc(ra->arch_env, ra->cls, irn); + return arch_irn_consider_in_reg_alloc(ra->cls, irn); } -static INLINE int -regpressure(pset * live) -{ +static inline int regpressure(pset *live) { int pressure = pset_count(live); - - return (pressure>MAXPRESSURE)?MAXPRESSURE:pressure; + return MIN(pressure, MAXPRESSURE); } static void -regpressureanawalker(ir_node * bb, void * data) +regpressureanawalker(ir_node *bb, void *data) { - regpressure_ana_t *ra = data; - pset *live = pset_new_ptr_default(); - const ir_node *irn; - unsigned int *stat = ra->stat; - int i; - const be_lv_t *lv = ra->lv; - - be_lv_foreach(lv, bb, be_lv_state_end, i) { - ir_node *value = be_lv_get_irn(lv, bb, i); - if (has_reg_class(ra, value)) { - pset_insert_ptr(live, value); - } - } - stat[regpressure(live)]++; - - sched_foreach_reverse(bb, irn) { - - if(is_Phi(irn)) break; - - if(has_reg_class(ra, irn)) { - pset_remove_ptr(live, irn); - } - - for(i=get_irn_arity(irn)-1; i>=0; --i) { - ir_node *arg = get_irn_n(irn, i); - - if(has_reg_class(ra, arg)) { - pset_insert_ptr(live, arg); - } - } - - if(!is_Proj(irn)) stat[regpressure(live)]++; - } + regpressure_ana_t *ra = data; + pset *live = pset_new_ptr_default(); + const ir_node *irn; + unsigned int *stat = ra->stat; + int i; + const be_lv_t *lv = ra->lv; + + be_lv_foreach(lv, bb, be_lv_state_end, i) { + ir_node *value = be_lv_get_irn(lv, bb, i); + if (has_reg_class(ra, value)) { + pset_insert_ptr(live, value); + } + } + stat[regpressure(live)]++; + + sched_foreach_reverse(bb, irn) { + + if (is_Phi(irn)) break; + + if (has_reg_class(ra, irn)) { + pset_remove_ptr(live, irn); + } + + for (i = get_irn_arity(irn) - 1; i >= 0; --i) { + ir_node *arg = get_irn_n(irn, i); + + if (has_reg_class(ra, arg)) { + pset_insert_ptr(live, arg); + } + } + + if (! is_Proj(irn)) + stat[regpressure(live)]++; + } } -void -be_analyze_regpressure(be_irg_t *birg, const arch_register_class_t *cls, - const char * suffix) +void be_analyze_regpressure(be_irg_t *birg, const arch_register_class_t *cls, const char *suffix) { - regpressure_ana_t ra; - unsigned int stat[MAXPRESSURE+1]; - unsigned int i; - char fname[256]; - FILE *f; - ir_graph *irg = be_get_birg_irg(birg); + regpressure_ana_t ra; + unsigned int stat[MAXPRESSURE+1]; + unsigned int i; + char fname[256]; + FILE *f; + ir_graph *irg = be_get_birg_irg(birg); - ir_snprintf(fname, sizeof(fname), "%F_%s%s_pressure.stat", irg, cls->name, suffix); - f = fopen(fname, "w"); - assert(f); + ir_snprintf(fname, sizeof(fname), "%F_%s%s_pressure.stat", irg, cls->name, suffix); + f = fopen(fname, "w"); + assert(f); - be_assure_liveness(birg); + be_liveness_assure_sets(be_assure_liveness(birg)); - FIRM_DBG_REGISTER(ra.dbg, "firm.be.regpressureana"); + FIRM_DBG_REGISTER(ra.dbg, "firm.be.regpressureana"); - ra.arch_env = birg->main_env->arch_env; - ra.lv = be_get_birg_liveness(birg); - ra.cls = cls; - ra.stat = stat; + ra.lv = be_get_birg_liveness(birg); + ra.cls = cls; + ra.stat = stat; - memset(stat, 0, sizeof(stat)); + memset(stat, 0, sizeof(stat)); - irg_block_walk_graph(irg, regpressureanawalker, NULL, &ra); + irg_block_walk_graph(irg, regpressureanawalker, NULL, &ra); - for(i=0; i<=MAXPRESSURE; ++i) { - fprintf(f,"%d\n",stat[i]); - } + for (i = 0; i <= MAXPRESSURE; ++i) { + fprintf(f, "%d\n", stat[i]); + } - fclose(f); + fclose(f); }