doxygen comment updated
[libfirm] / ir / ana / execution_frequency.h
1 /*
2  * Project:     libFIRM
3  * File name:   ir/ana/execution_frequency.h
4  * Purpose:     Compute an estimate of basic block executions.
5  * Author:      Goetz Lindenmaier
6  * Modified by:
7  * Created:     5.11.2004
8  * CVS-ID:      $Id$
9  * Copyright:   (c) 2004 Universität Karlsruhe
10  * Licence:     This file protected by GPL -  GNU GENERAL PUBLIC LICENSE.
11  */
12
13 #ifndef _EXECUTION_FREQUENCY_H_
14 #define _EXECUTION_FREQUENCY_H_
15
16 /** @file execution_frequency.h
17  *
18  * Estimate exectution frequencies of blocks.
19  *
20  * @author Goetz Lindenmaier
21  *
22  * We assume the start block of a procedure is executed once.  Based on this we
23  * compute the execution freqency of all blocks.
24  *
25  * The computation of the frequencies depends on the count of exception control
26  * flow computed during the interval analysis.  The interval analysis again
27  * depends on stuff computed here.
28  */
29
30 #include "firm_types.h"
31
32 /* A proj from a Cond that goes to an exception handler. */
33 int is_fragile_Proj(ir_node *n);
34
35 /** Returns the number of times the block/region is executed according to
36  *  our estimate. Gives a number relative to the Start node of the procedure
37  *  the block is in, which is weighted with 1. */
38 double get_irn_exec_freq   (ir_node *n);
39 double get_Block_exec_freq (ir_node *b);
40 double get_region_exec_freq(void *reg);
41
42 /** Compute the execution frequency for all blocks in the given
43  *  graph.
44  *
45  * @param irg                   The graph to be analyzed.
46  * @param default_loop_weight   The default number of executions of a loop.
47  * @param exception_probability The probability that a fragile operation causes an exception.
48  *
49  * Uses link field.
50  */
51 void compute_execution_frequency(ir_graph *irg, int default_loop_weight, double exception_probability);
52
53 /** Compute the execution frequency for all graphs.
54  *
55  * @param default_loop_weight   The default number of executions of a loop.
56  * @param exception_probability The probability that a fragile operation causes an exception.
57  *
58  */
59 void compute_execution_frequencies(int default_loop_weight, double exception_probability);
60
61 /** Free occupied memory, reset for all graphs. */
62 void free_execution_frequency(void);
63
64 /** State of execution frequencies for graphs and the whole program.
65  *
66  * The exec_freq_state in irp is consistent, if the state of all graphs is consistent.
67  * It is none, if the state of all graphs is none.  Else it is inconsistent. */
68 typedef enum {
69   exec_freq_none,             /**< Execution frequencies are not computed, no memory is
70                                    allocated, access fails. */
71   exec_freq_consistent,       /**< Execution frequency information is computed and correct. */
72   exec_freq_inconsistent      /**< Execution frequency is computed but the graph has been
73                                    changed since. */
74 } exec_freq_state;
75
76 exec_freq_state get_irg_exec_freq_state(ir_graph *irg);
77 void            set_irg_exec_freq_state(ir_graph *irg, exec_freq_state s);
78 /* Sets irg and irp exec freq state to inconsistent if it is set to consistent. */
79 void            set_irg_exec_freq_state_inconsistent(ir_graph *irg);
80
81 exec_freq_state get_irp_exec_freq_state(void);
82 /* Sets irp and all irg exec freq states to inconsistent if it is set to consistent. */
83 void            set_irp_exec_freq_state_inconsistent(void);
84
85
86
87
88 #endif /* _EXECUTION_FREQUENCY_H_ */