2 * Copyright (C) 1995-2008 University of Karlsruhe. All right reserved.
4 * This file is part of libFirm.
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.
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.
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
22 * @brief Compute an estimate of field temperature, i.e., field access heuristic.
23 * @author Goetz Lindenmaier
27 * Watch it! This is highly java dependent.
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.)
33 * - We compute a value for the entity based on the Sel nodes.
35 #ifndef FIRM_ANA_FIELD_TEMPERATURE_H
36 #define FIRM_ANA_FIELD_TEMPERATURE_H
38 #include "firm_types.h"
40 /* The number of array elements we assume if not both bounds are given. */
41 #define DEFAULT_N_ARRAY_ELEMENTS 1
43 int get_irn_loop_call_depth(ir_node *n);
44 /** Return loop depth of node.
46 * Returns the loop depth of n in the control flow. I.e., we
47 * go from the node to the block to the loop the block is in,
48 * and return its depth. */
49 int get_irn_cfloop_depth(ir_node *n);
50 int get_irn_recursion_depth(ir_node *n);
52 /** Get the weighted interprocedural loop depth of the node.
53 The depth is estimated by a heuristic. The heuristic considers
54 loop and recursion depth. */
55 int get_weighted_loop_depth(ir_node *n);
57 /** Heuristic merging recursion and loop depth. */
58 double get_irn_final_cost(ir_node *n);
60 /** Get accumulated(really?) execution frequencies.
61 * A heuristic weights the recursions. */
62 double get_type_estimated_n_instances(ir_type *clss);
63 double get_type_estimated_mem_consumption_bytes(ir_type *tp);
64 /** Estimates the size of an object.
66 * The heuristic mainly affects array sizes.
67 * Further this ignores padding for alignment, especially of small fields. */
68 int get_type_estimated_size_bytes(ir_type *tp);
69 /** Estimates the number of fields of a single Object.
70 * The heuristic mainly affects array sizes.
71 * @@@ Misses inherited fields! */
72 int get_type_estimated_n_fields(ir_type *tp);
73 double get_type_estimated_n_casts(ir_type *clss);
75 double get_class_estimated_n_upcasts(ir_type *clss);
76 double get_class_estimated_n_downcasts(ir_type *clss);
77 /** Returns the number of accesses to the dispatch table.
79 * This includes the initialization of the pointer field, and accesses
80 * to virtual fields (as instance marker in Java). Certainly this
81 * includes virtual method calls. */
82 double get_class_estimated_n_dyncalls(ir_type *clss);
83 /** Returns the number of writes to the dispatch pointer.
84 * This is the same as the number of allocations. */
85 double get_class_estimated_dispatch_writes(ir_type *clss);
86 /** Returns the number of reads of the dispatch pointer. */
87 double get_class_estimated_dispatch_reads (ir_type *clss);
89 double get_entity_estimated_n_loads(ir_entity *ent);
90 double get_entity_estimated_n_stores(ir_entity *ent);
91 double get_entity_estimated_n_calls(ir_entity *ent);
92 /** The number of accesses to dynamically called methods and
93 * to other static fields that overwrite/are overwritten. */
94 double get_entity_estimated_n_dyncalls(ir_entity *ent);
96 /* ------------------------------------------------------------------------- */
97 /* Accumulate information in the type hierarchy. */
98 /* ------------------------------------------------------------------------- */
102 temperature_consistent,
103 temperature_inconsistent
104 } irp_temperature_state;