added license infos
[libfirm] / ir / ana / field_temperature.h
1 /*
2  * Copyrigth (C) 1995-2007 University of Karlsruhe.  All right reserved.
3  *
4  * This file is part of libFirm.
5  *
6  * This file may be distributed and/or modified under the terms of the
7  * GNU General Public License version 2 as published by the Free Software
8  * Foundation and appearing in the file LICENSE.GPL included in the
9  * packaging of this file.
10  *
11  * Licensees holding valid libFirm Professional Edition licenses may use
12  * this file in accordance with the libFirm Commercial License.
13  * Agreement provided with the Software.
14  *
15  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
16  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17  * PURPOSE.
18  */
19
20 /**
21  * @file
22  * @brief    Compute an estimate of field temperature, i.e., field access heuristic.
23  * @author   Goetz Lindenmaier
24  * @date     21.7.2004
25  * @version  $Id$
26  * @note
27  *  Watch it! This is highly java dependent.
28  *
29  * - All Sel nodes get an array with possibly accessed entities.
30  *   (resolve polymorphy on base of inherited entities.)
31  *   (the mentioned entity in first approximation.)
32  *
33  * - We compute a value for the entity based on the Sel nodes.
34  */
35 #ifndef FIRM_ANA_FIELD_TEMPERATURE_H
36 #define FIRM_ANA_FIELD_TEMPERATURE_H
37
38 #include "firm_types.h"
39
40 /* The number of array elements we assume if not both bounds are given. */
41 #define DEFAULT_N_ARRAY_ELEMENTS 1
42
43 /** The entities that can be accessed by this Sel node. *
44 int       get_Sel_n_accessed_entities(ir_node *sel);
45 ir_entity *get_Sel_accessed_entity    (ir_node *sel, int pos);
46 */
47
48 int get_irn_loop_call_depth(ir_node *n);
49 /** Return loop depth of node.
50  *
51  *  Returns the loop depth of n in the control flow.  I.e., we
52  *  go from the node to the block to the loop the block is in,
53  *  and return its depth.  */
54 int get_irn_cfloop_depth(ir_node *n);
55 int get_irn_recursion_depth(ir_node *n);
56
57 /** Get the weighted interprocedural loop depth of the node.
58     The depth is estimated by a heuristic. The heuristic considers
59     loop and recursion depth. */
60 int get_weighted_loop_depth(ir_node *n);
61
62 /** Heuristic merging recursion and loop depth. */
63 double get_irn_final_cost(ir_node *n);
64
65 /** Get accumulated(really?) execution frequencies.
66  *  A heuristic weights the recursions. */
67 double get_type_estimated_n_instances(ir_type *clss);
68 double get_type_estimated_mem_consumption_bytes(ir_type *tp);
69 /** Estimates the size of an object.
70  *
71  *  The heuristic mainly affects array sizes.
72  *  Further this ignores padding for alignment, especially of small fields. */
73 int    get_type_estimated_size_bytes(ir_type *tp);
74 /** Estimates the number of fields of a single Object.
75  *  The heuristic mainly affects array sizes.
76  *  @@@ Misses inherited fields! */
77 int    get_type_estimated_n_fields(ir_type *tp);
78 double get_type_estimated_n_casts(ir_type *clss);
79
80 double get_class_estimated_n_upcasts(ir_type *clss);
81 double get_class_estimated_n_downcasts(ir_type *clss);
82 /** Returns the number of accesses to the dispatch table.
83  *
84  *  This includes the initialization of the pointer field, and accesses
85  *  to virtual fields (as instance marker in Java).  Certainly this
86  *  includes virtual method calls. */
87 double get_class_estimated_n_dyncalls(ir_type *clss);
88 /** Returns the number of writes to the dispatch pointer.
89  *  This is the same as the number of allocations. */
90 double get_class_estimated_dispatch_writes(ir_type *clss);
91 /** Returns the number of reads of the dispatch pointer. */
92 double get_class_estimated_dispatch_reads (ir_type *clss);
93
94 double get_entity_estimated_n_loads(ir_entity *ent);
95 double get_entity_estimated_n_stores(ir_entity *ent);
96 double get_entity_estimated_n_calls(ir_entity *ent);
97 /** The number of accesses to dynamically called methods and
98  *  to other static fields that overwrite/are overwritten. */
99 double get_entity_estimated_n_dyncalls(ir_entity *ent);
100
101 /* ------------------------------------------------------------------------- */
102 /* Accumulate information in the type hierarchy.                             */
103 /* ------------------------------------------------------------------------- */
104
105 typedef enum {
106   temperature_none,
107   temperature_consistent,
108   temperature_inconsistent
109 } irp_temperature_state;
110
111 /** An auxiliary/temporary function */
112 int is_jack_rts_class(ir_type *t);
113 int is_jack_rts_entity(ir_entity *e);
114
115 #endif