add inline functions
[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 "firm_types.h"
31
32 /* The number of array elements we assume if not both bounds are given. */
33 #define DEFAULT_N_ARRAY_ELEMENTS 1
34
35
36 /** The entities that can be accessed by this Sel node. *
37 int     get_Sel_n_accessed_entities(ir_node *sel);
38 entity *get_Sel_accessed_entity    (ir_node *sel, int pos);
39 */
40
41 int get_irn_loop_call_depth(ir_node *n);
42 /** Return loop depth of node.
43  *
44  *  Returns the loop depth of n in the control flow.  I.e., we
45  *  go from the node to the block to the loop the block is in,
46  *  and return its depth.  */
47 int get_irn_cfloop_depth(ir_node *n);
48 int get_irn_recursion_depth(ir_node *n);
49
50 /** Get the weighted interprocedural loop depth of the node.
51     The depth is estimated by a heuristic. The heuristic consideres
52     loop and recursion depth. */
53 int get_weighted_loop_depth(ir_node *n);
54
55 /** Heuristic merging recursion and loop depth. */
56 double get_irn_final_cost(ir_node *n);
57
58 /** Get accumulated(really?) execution frequencies.
59  *  A heuristic weights the recursions. */
60 double get_type_estimated_n_instances(ir_type *clss);
61 double get_type_estimated_mem_consumption_bytes(ir_type *tp);
62 /** Estimates the size of an object.
63  *
64  *  The heuristic mainly affects array sizes.
65  *  Further this ignores padding for alignment, especially of small fields. */
66 int    get_type_estimated_size_bytes(ir_type *tp);
67 /** Estimates the number of fields of a single Object.
68  *  The heuristic mainly affects array sizes.
69  *  @@@ Misses inherited fields! */
70 int    get_type_estimated_n_fields(ir_type *tp);
71 double get_type_estimated_n_casts(ir_type *clss);
72
73 double get_class_estimated_n_upcasts(ir_type *clss);
74 double get_class_estimated_n_downcasts(ir_type *clss);
75 /** Returns the number of accesses to the dispatch table.
76  *
77  *  This includes the initialization of the pointer field, and accesses
78  *  to virtual fields (as instance marker in Java).  Certainly this
79  *  includes virtual method calls. */
80 double get_class_estimated_n_dyncalls(ir_type *clss);
81 /** Returns the number of writes to the dispatch pointer.
82  *  This is the same as the number of allocations. */
83 double get_class_estimated_dispatch_writes(ir_type *clss);
84 /** Returns the number of reads of the dispatch pointer. */
85 double get_class_estimated_dispatch_reads (ir_type *clss);
86
87 double get_entity_estimated_n_loads(entity *ent);
88 double get_entity_estimated_n_stores(entity *ent);
89 double get_entity_estimated_n_calls(entity *ent);
90 /** The number of accesses to dynamically called methods and
91  *  to other static fields that overwrite/are overwritten. */
92 double get_entity_estimated_n_dyncalls(entity *ent);
93
94 /* ------------------------------------------------------------------------- */
95 /* Accumulate information in the type hierarchy.                             */
96 /* ------------------------------------------------------------------------- */
97
98 typedef enum {
99   temperature_none,
100   temperature_consistent,
101   temperature_inconsistent
102 } irp_temperature_state;
103
104 /** An auxiliary/temporary function */
105 int is_jack_rts_class(ir_type *t);
106 int is_jack_rts_entity(entity *e);
107
108 #endif /* _FIELD_TEMPERATURE_H_ */