X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fana%2Fexecution_frequency.c;h=76842770a2a5081cafa9758214885318d3533db4;hb=a8d6e45f13a40f6c9269608bf937e3e641d0b715;hp=4dd3e5614bb4fcfcb1c9ade1c1af54122fbafe83;hpb=24404dae722e4648ab1b53740b8a891c0c1da01a;p=libfirm diff --git a/ir/ana/execution_frequency.c b/ir/ana/execution_frequency.c index 4dd3e5614..76842770a 100644 --- a/ir/ana/execution_frequency.c +++ b/ir/ana/execution_frequency.c @@ -1,21 +1,33 @@ /* - * Project: libFIRM - * File name: ir/ana/execution_frequency.c - * Purpose: Compute an estimate of basic block executions. - * Author: Goetz Lindenmaier - * Modified by: - * Created: 5.11.2004 - * CVS-ID: $Id$ - * Copyright: (c) 2004 Universität Karlsruhe - * Licence: This file protected by GPL - GNU GENERAL PUBLIC LICENSE. + * 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 Compute an estimate of basic block executions. + * @author Goetz Lindenmaier + * @date 5.11.2004 + * @version $Id$ */ -#ifdef HAVE_CONFIG_H #include "config.h" -#endif #include "execution_frequency.h" -#include "firm_common_t.h" #include "set.h" #include "pdeq.h" #include "hashptr.h" @@ -47,14 +59,16 @@ static set *exec_freq_set = NULL; static int exec_freq_cmp(const void *e1, const void *e2, size_t size) { reg_exec_freq *ef1 = (reg_exec_freq *)e1; reg_exec_freq *ef2 = (reg_exec_freq *)e2; + (void) size; + return (ef1->reg != ef2->reg); } -static INLINE unsigned int exec_freq_hash(reg_exec_freq *e) { +static inline unsigned int exec_freq_hash(reg_exec_freq *e) { return HASH_PTR(e->reg); } -static INLINE void set_region_exec_freq(void *reg, double freq) { +static inline void set_region_exec_freq(void *reg, double freq) { reg_exec_freq ef; ef.reg = reg; ef.freq = freq; @@ -172,14 +186,15 @@ static void my_irg_walk_current_graph(irg_walk_func *pre, irg_walk_func *post, v } -static void walk_pre(ir_node *n, void *env) { - - if (get_irn_op(n) == op_Raise) +static void walk_pre(ir_node *n, void *env) +{ + (void) env; + if (is_Raise(n)) just_passed_a_Raise = 1; - if ( (get_irn_op(n) == op_Proj) - && (get_irn_op(get_Proj_pred(n)) == op_Cond) - && (just_passed_a_Raise)) { + if (get_irn_op(n) == op_Proj && + is_Cond(get_Proj_pred(n)) && + just_passed_a_Raise) { ir_node *other_proj; ir_node *c = get_Proj_pred(n); @@ -197,21 +212,23 @@ static void walk_pre(ir_node *n, void *env) { } } - if (get_irn_op(n) == op_Cond) { + if (is_Cond(n)) { set_irn_link(n, Cond_list); Cond_list = n; } } -static void walk_post(ir_node *n, void *env) { - - if (get_irn_op(n) == op_Raise) +static void walk_post(ir_node *n, void *env) +{ + (void) env; + if (is_Raise(n)) just_passed_a_Raise = 0; - if ( (get_irn_op(n) == op_Proj) - && (get_irn_op(get_Proj_pred(n)) == op_Cond) - && ((get_ProjX_probability(n) == Cond_prob_exception_taken) || - (get_ProjX_probability(n) == Cond_prob_was_exception_taken) )) { + if (get_irn_op(n) == op_Proj && + is_Cond(get_Proj_pred(n)) && ( + get_ProjX_probability(n) == Cond_prob_exception_taken || + get_ProjX_probability(n) == Cond_prob_was_exception_taken + )) { just_passed_a_Raise = 1; } } @@ -277,15 +294,17 @@ int is_fragile_Proj(ir_node *n) { static double exception_prob = 0.001; -static INLINE int is_loop_head(ir_node *cond) { - return false; +static inline int is_loop_head(ir_node *cond) +{ + (void) cond; + return 0; } /** Weight a single region in edge. * * Given all outs of the predecessor region, we can compute the weight of * this single edge. */ -static INLINE double get_weighted_region_exec_freq(void *reg, int pos) { +static inline double get_weighted_region_exec_freq(void *reg, int pos) { void *pred_reg = get_region_in(reg, pos); double res, full_freq = get_region_exec_freq (pred_reg); int n_outs = get_region_n_outs (pred_reg); @@ -294,7 +313,7 @@ static INLINE double get_weighted_region_exec_freq(void *reg, int pos) { ir_node *cfop; if (is_ir_node(reg)) { cfop = get_Block_cfgpred((ir_node *)reg, pos); - if (is_Proj(cfop) && (get_irn_op(get_Proj_pred(cfop)) != op_Cond)) + if (is_Proj(cfop) && !is_Cond(get_Proj_pred(cfop))) cfop = skip_Proj(cfop); } else { assert(is_ir_loop(reg)); @@ -312,7 +331,7 @@ static INLINE double get_weighted_region_exec_freq(void *reg, int pos) { return res; } -static INLINE void compute_region_freqency(void *reg, double head_weight) { +static inline void compute_region_freqency(void *reg, double head_weight) { int i, n_ins = get_region_n_ins(reg); double my_freq = 0; @@ -332,8 +351,10 @@ static INLINE void compute_region_freqency(void *reg, double head_weight) { set_region_exec_freq(reg, my_freq); } -static void check_proper_head(ir_loop *l, void *reg) { +static void check_proper_head(ir_loop *l, void *reg) +{ int i, n_ins = get_region_n_ins(reg); + (void) l; for (i = 0; i < n_ins; ++i) { assert(!get_region_in(reg, i)); }