execution_frequency.h 3.56 KB
Newer Older
1
/*
2
 * Copyright (C) 1995-2007 University of Karlsruhe.  All right reserved.
Matthias Braun's avatar
Matthias Braun committed
3
4
 *
 * This file is part of libFirm.
5
 *
Matthias Braun's avatar
Matthias Braun committed
6
7
8
9
 * 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.
10
 *
Matthias Braun's avatar
Matthias Braun committed
11
12
13
 * Licensees holding valid libFirm Professional Edition licenses may use
 * this file in accordance with the libFirm Commercial License.
 * Agreement provided with the Software.
14
 *
Matthias Braun's avatar
Matthias Braun committed
15
16
17
18
19
20
21
22
23
24
25
26
 * 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$
 * @summary
27
28
29
 * We assume the start block of a procedure is executed once.  Based on this we
 * compute the execution freqency of all blocks.
 *
30
 * The computation of the frequencies depends on the count of exception control
Matthias Braun's avatar
Matthias Braun committed
31
 * flow computed during the interval analysis. The interval analysis again
Götz Lindenmaier's avatar
Götz Lindenmaier committed
32
 * depends on stuff computed here.
33
 */
Matthias Braun's avatar
Matthias Braun committed
34
35
#ifndef FIRM_ANA_EXECUTION_FREQUENCY_H
#define FIRM_ANA_EXECUTION_FREQUENCY_H
36

37
#include "firm_types.h"
38

Götz Lindenmaier's avatar
Götz Lindenmaier committed
39
40
/* A proj from a Cond that goes to an exception handler. */
int is_fragile_Proj(ir_node *n);
41

42
/** Returns the number of times the block/region is executed according to
Götz Lindenmaier's avatar
Götz Lindenmaier committed
43
44
45
 *  our estimate. Gives a number relative to the Start node of the procedure
 *  the block is in, which is weighted with 1. */
double get_irn_exec_freq   (ir_node *n);
46
47
double get_Block_exec_freq (ir_node *b);
double get_region_exec_freq(void *reg);
48
49
50
51

/** Compute the execution frequency for all blocks in the given
 *  graph.
 *
Götz Lindenmaier's avatar
Götz Lindenmaier committed
52
53
54
55
56
 * @param irg                   The graph to be analyzed.
 * @param default_loop_weight   The default number of executions of a loop.
 * @param exception_probability The probability that a fragile operation causes an exception.
 *
 * Uses link field.
57
58
 */
void compute_execution_frequency(ir_graph *irg, int default_loop_weight, double exception_probability);
Götz Lindenmaier's avatar
Götz Lindenmaier committed
59
60
61
62
63
64
65

/** Compute the execution frequency for all graphs.
 *
 * @param default_loop_weight   The default number of executions of a loop.
 * @param exception_probability The probability that a fragile operation causes an exception.
 *
 */
66
67
void compute_execution_frequencies(int default_loop_weight, double exception_probability);

Götz Lindenmaier's avatar
Götz Lindenmaier committed
68
/** Free occupied memory, reset for all graphs. */
69
70
void free_execution_frequency(void);

71
/** State of execution frequencies for graphs and the whole program.
Götz Lindenmaier's avatar
Götz Lindenmaier committed
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
 *
 * The exec_freq_state in irp is consistent, if the state of all graphs is consistent.
 * It is none, if the state of all graphs is none.  Else it is inconsistent. */
typedef enum {
  exec_freq_none,             /**< Execution frequencies are not computed, no memory is
				   allocated, access fails. */
  exec_freq_consistent,       /**< Execution frequency information is computed and correct. */
  exec_freq_inconsistent      /**< Execution frequency is computed but the graph has been
				   changed since. */
} exec_freq_state;

exec_freq_state get_irg_exec_freq_state(ir_graph *irg);
void            set_irg_exec_freq_state(ir_graph *irg, exec_freq_state s);
/* Sets irg and irp exec freq state to inconsistent if it is set to consistent. */
void            set_irg_exec_freq_state_inconsistent(ir_graph *irg);

exec_freq_state get_irp_exec_freq_state(void);
/* Sets irp and all irg exec freq states to inconsistent if it is set to consistent. */
void            set_irp_exec_freq_state_inconsistent(void);


Matthias Braun's avatar
Matthias Braun committed
93
#endif