field_temperature.h 4.23 KB
Newer Older
1
/*
2
 * Copyright (C) 1995-2007 University of Karlsruhe.  All right reserved.
Matthias Braun's avatar
Matthias Braun committed
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
 *
 * This file is part of libFirm.
 *
 * This file may be distributed and/or modified under the terms of the
 * GNU General Public License version 2 as published by the Free Software
 * Foundation and appearing in the file LICENSE.GPL included in the
 * packaging of this file.
 *
 * Licensees holding valid libFirm Professional Edition licenses may use
 * this file in accordance with the libFirm Commercial License.
 * Agreement provided with the Software.
 *
 * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
 * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE.
18
19
20
 */

/**
Matthias Braun's avatar
Matthias Braun committed
21
22
23
24
25
26
 * @file
 * @brief    Compute an estimate of field temperature, i.e., field access heuristic.
 * @author   Goetz Lindenmaier
 * @date     21.7.2004
 * @version  $Id$
 * @note
27
28
29
30
31
32
33
34
 *  Watch it! This is highly java dependent.
 *
 * - All Sel nodes get an array with possibly accessed entities.
 *   (resolve polymorphy on base of inherited entities.)
 *   (the mentioned entity in first approximation.)
 *
 * - We compute a value for the entity based on the Sel nodes.
 */
Matthias Braun's avatar
Matthias Braun committed
35
36
#ifndef FIRM_ANA_FIELD_TEMPERATURE_H
#define FIRM_ANA_FIELD_TEMPERATURE_H
37

Michael Beck's avatar
Michael Beck committed
38
#include "firm_types.h"
39

Götz Lindenmaier's avatar
Götz Lindenmaier committed
40
41
42
/* The number of array elements we assume if not both bounds are given. */
#define DEFAULT_N_ARRAY_ELEMENTS 1

Götz Lindenmaier's avatar
Götz Lindenmaier committed
43
/** The entities that can be accessed by this Sel node. *
44
45
int       get_Sel_n_accessed_entities(ir_node *sel);
ir_entity *get_Sel_accessed_entity    (ir_node *sel, int pos);
Götz Lindenmaier's avatar
Götz Lindenmaier committed
46
*/
47

Michael Beck's avatar
Michael Beck committed
48
int get_irn_loop_call_depth(ir_node *n);
49
50
51
52
53
54
/** Return loop depth of node.
 *
 *  Returns the loop depth of n in the control flow.  I.e., we
 *  go from the node to the block to the loop the block is in,
 *  and return its depth.  */
int get_irn_cfloop_depth(ir_node *n);
Michael Beck's avatar
Michael Beck committed
55
int get_irn_recursion_depth(ir_node *n);
Götz Lindenmaier's avatar
more...    
Götz Lindenmaier committed
56
57

/** Get the weighted interprocedural loop depth of the node.
Michael Beck's avatar
Michael Beck committed
58
    The depth is estimated by a heuristic. The heuristic considers
Götz Lindenmaier's avatar
Götz Lindenmaier committed
59
    loop and recursion depth. */
60
int get_weighted_loop_depth(ir_node *n);
61

Götz Lindenmaier's avatar
Götz Lindenmaier committed
62
63
/** Heuristic merging recursion and loop depth. */
double get_irn_final_cost(ir_node *n);
Götz Lindenmaier's avatar
more...    
Götz Lindenmaier committed
64

65
/** Get accumulated(really?) execution frequencies.
Götz Lindenmaier's avatar
Götz Lindenmaier committed
66
 *  A heuristic weights the recursions. */
Michael Beck's avatar
Michael Beck committed
67
68
double get_type_estimated_n_instances(ir_type *clss);
double get_type_estimated_mem_consumption_bytes(ir_type *tp);
Götz Lindenmaier's avatar
Götz Lindenmaier committed
69
70
71
72
/** Estimates the size of an object.
 *
 *  The heuristic mainly affects array sizes.
 *  Further this ignores padding for alignment, especially of small fields. */
Michael Beck's avatar
Michael Beck committed
73
int    get_type_estimated_size_bytes(ir_type *tp);
Götz Lindenmaier's avatar
Götz Lindenmaier committed
74
/** Estimates the number of fields of a single Object.
Götz Lindenmaier's avatar
Götz Lindenmaier committed
75
76
 *  The heuristic mainly affects array sizes.
 *  @@@ Misses inherited fields! */
Michael Beck's avatar
Michael Beck committed
77
78
int    get_type_estimated_n_fields(ir_type *tp);
double get_type_estimated_n_casts(ir_type *clss);
Götz Lindenmaier's avatar
more...    
Götz Lindenmaier committed
79

Michael Beck's avatar
Michael Beck committed
80
81
double get_class_estimated_n_upcasts(ir_type *clss);
double get_class_estimated_n_downcasts(ir_type *clss);
Götz Lindenmaier's avatar
Götz Lindenmaier committed
82
83
84
85
86
/** Returns the number of accesses to the dispatch table.
 *
 *  This includes the initialization of the pointer field, and accesses
 *  to virtual fields (as instance marker in Java).  Certainly this
 *  includes virtual method calls. */
Michael Beck's avatar
Michael Beck committed
87
double get_class_estimated_n_dyncalls(ir_type *clss);
Götz Lindenmaier's avatar
Götz Lindenmaier committed
88
89
/** Returns the number of writes to the dispatch pointer.
 *  This is the same as the number of allocations. */
Michael Beck's avatar
Michael Beck committed
90
double get_class_estimated_dispatch_writes(ir_type *clss);
Götz Lindenmaier's avatar
Götz Lindenmaier committed
91
/** Returns the number of reads of the dispatch pointer. */
Michael Beck's avatar
Michael Beck committed
92
double get_class_estimated_dispatch_reads (ir_type *clss);
Götz Lindenmaier's avatar
more...    
Götz Lindenmaier committed
93

94
95
96
double get_entity_estimated_n_loads(ir_entity *ent);
double get_entity_estimated_n_stores(ir_entity *ent);
double get_entity_estimated_n_calls(ir_entity *ent);
Götz Lindenmaier's avatar
Götz Lindenmaier committed
97
98
/** The number of accesses to dynamically called methods and
 *  to other static fields that overwrite/are overwritten. */
99
double get_entity_estimated_n_dyncalls(ir_entity *ent);
100

101
102
103
104
105
106
107
108
109
110
/* ------------------------------------------------------------------------- */
/* Accumulate information in the type hierarchy.                             */
/* ------------------------------------------------------------------------- */

typedef enum {
  temperature_none,
  temperature_consistent,
  temperature_inconsistent
} irp_temperature_state;

111
/** An auxiliary/temporary function */
Michael Beck's avatar
Michael Beck committed
112
int is_jack_rts_class(ir_type *t);
113
int is_jack_rts_entity(ir_entity *e);
114

Matthias Braun's avatar
Matthias Braun committed
115
#endif