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"
42 /* The number of array elements we assume if not both bounds are given. */
43 #define DEFAULT_N_ARRAY_ELEMENTS 1
45 FIRM_API int get_irn_loop_call_depth(ir_node *n);
46 /** Return loop depth of node.
48 * Returns the loop depth of n in the control flow. I.e., we
49 * go from the node to the block to the loop the block is in,
50 * and return its depth. */
51 FIRM_API int get_irn_cfloop_depth(ir_node *n);
52 FIRM_API int get_irn_recursion_depth(ir_node *n);
54 /** Get the weighted interprocedural loop depth of the node.
55 The depth is estimated by a heuristic. The heuristic considers
56 loop and recursion depth. */
57 FIRM_API int get_weighted_loop_depth(ir_node *n);
59 /** Heuristic merging recursion and loop depth. */
60 FIRM_API double get_irn_final_cost(ir_node *n);
62 /** Get accumulated(really?) execution frequencies.
63 * A heuristic weights the recursions. */
64 FIRM_API double get_type_estimated_n_instances(ir_type *clss);
65 FIRM_API double get_type_estimated_mem_consumption_bytes(ir_type *tp);
67 /** Estimates the size of an object.
69 * The heuristic mainly affects array sizes.
70 * Further this ignores padding for alignment, especially of small fields. */
71 FIRM_API int get_type_estimated_size_bytes(ir_type *tp);
72 /** Estimates the number of fields of a single Object.
73 * The heuristic mainly affects array sizes.
74 * @@@ Misses inherited fields! */
75 FIRM_API int get_type_estimated_n_fields(ir_type *tp);
76 FIRM_API double get_type_estimated_n_casts(ir_type *clss);
78 FIRM_API double get_class_estimated_n_upcasts(ir_type *clss);
79 FIRM_API double get_class_estimated_n_downcasts(ir_type *clss);
81 /** Returns the number of accesses to the dispatch table.
83 * This includes the initialization of the pointer field, and accesses
84 * to virtual fields (as instance marker in Java). Certainly this
85 * includes virtual method calls. */
86 FIRM_API double get_class_estimated_n_dyncalls(ir_type *clss);
87 /** Returns the number of writes to the dispatch pointer.
88 * This is the same as the number of allocations. */
89 FIRM_API double get_class_estimated_dispatch_writes(ir_type *clss);
90 /** Returns the number of reads of the dispatch pointer. */
91 FIRM_API double get_class_estimated_dispatch_reads (ir_type *clss);
93 FIRM_API double get_entity_estimated_n_loads(ir_entity *ent);
94 FIRM_API double get_entity_estimated_n_stores(ir_entity *ent);
95 FIRM_API double get_entity_estimated_n_calls(ir_entity *ent);
96 /** The number of accesses to dynamically called methods and
97 * to other static fields that overwrite/are overwritten. */
98 FIRM_API double get_entity_estimated_n_dyncalls(ir_entity *ent);
100 /* ------------------------------------------------------------------------- */
101 /* Accumulate information in the type hierarchy. */
102 /* ------------------------------------------------------------------------- */
106 temperature_consistent,
107 temperature_inconsistent
108 } irp_temperature_state;