moved some code to cacheopt
[libfirm] / ir / ana / field_temperature.h
1 /*
2  * Project:     libFIRM
3  * File name:   ir/ana/field_temperature.h
4  * Purpose:     Compute an estimate of field temperature, i.e., field access heuristic.
5  * Author:      Goetz Lindenmaier
6  * Modified by:
7  * Created:     21.7.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 _FIELD_TEMPERATURE_H_
14 #define _FIELD_TEMPERATURE_H_
15
16 /**
17  * @file field_temperature.h
18  *
19  *  @author Goetz Lindenmaier
20  *
21  *  Watch it! This is highly java dependent.
22  *
23  * - All Sel nodes get an array with possibly accessed entities.
24  *   (resolve polymorphy on base of inherited entities.)
25  *   (the mentioned entity in first approximation.)
26  *
27  * - We compute a value for the entity based on the Sel nodes.
28  */
29
30 #include "irnode.h"
31 #include "entity.h"
32 #include "type.h"
33
34
35 /* The number of array elements we assume if not both bounds are given. */
36 #define DEFAULT_N_ARRAY_ELEMENTS 1
37
38
39 /** The entities that can be accessed by this Sel node. *
40 int     get_Sel_n_accessed_entities(ir_node *sel);
41 entity *get_Sel_accessed_entity    (ir_node *sel, int pos);
42 */
43
44
45 /** Get the weighted interprocedural loop depth of the node.
46     The depth is estimated by a heuristic. The heuristic consideres
47     loop and recursion depth. */
48 int get_weighted_loop_depth(ir_node *n);
49
50 /** Heuristic merging recursion and loop depth. */
51 double get_irn_final_cost(ir_node *n);
52
53 /** Get accumulated(really?) execution frequencies.
54  *  A heuristic weights the recursions. */
55 double get_type_estimated_n_instances(type *clss);
56 double get_type_estimated_mem_consumption_bytes(type *tp);
57 /** Estimates the size of an object.
58  *
59  *  The heuristic mainly affects array sizes.
60  *  Further this ignores padding for alignment, especially of small fields. */
61 int    get_type_estimated_size_bytes(type *tp);
62 /** Estimates the number of fields of a single Object.
63  *  The heuristic mainly affects array sizes. */
64 int    get_type_estimated_n_fields(type *tp);
65 double get_type_estimated_n_casts(type *clss);
66
67 double get_class_estimated_n_upcasts(type *clss);
68 double get_class_estimated_n_downcasts(type *clss);
69 /** Returns the number of accesses to the dispatch table.
70  *
71  *  This includes the initialization of the pointer field, and accesses
72  *  to virtual fields (as instance marker in Java).  Certainly this
73  *  includes virtual method calls. */
74 double get_class_estimated_n_dyncalls(type *clss);
75 /** Returns the number of writes to the dispatch pointer.
76  *  This is the same as the number of allocations. */
77 double get_class_estimated_dispatch_writes(type *clss);
78 /** Returns the number of reads of the dispatch pointer. */
79 double get_class_estimated_dispatch_reads (type *clss);
80
81 double get_entity_estimated_n_loads(entity *ent);
82 double get_entity_estimated_n_stores(entity *ent);
83 double get_entity_estimated_n_calls(entity *ent);
84 /** The number of accesses to dynamically called methods and
85  *  to other static fields that overwrite/are overwritten. */
86 double get_entity_estimated_n_dyncalls(entity *ent);
87
88 /* ------------------------------------------------------------------------- */
89 /* Accumulate information in the type hierarchy.                             */
90 /* ------------------------------------------------------------------------- */
91
92 typedef enum {
93   temperature_none,
94   temperature_consistent,
95   temperature_inconsistent
96 } irp_temperature_state;
97
98 /** An auxiliary/temporary function */
99 int is_jack_rts_class(type *t);
100 int is_jack_rts_entity(entity *e);
101
102 #endif /* _FIELD_TEMPERATURE_H_ */