cgana.h 2.97 KB
Newer Older
Götz Lindenmaier's avatar
Götz Lindenmaier committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
/*
 * Project:     libFIRM
 * File name:   ir/ana/cgana.h
 * Purpose:     Intraprozedural analyses to estimate the call graph.
 * Author:      Hubert Schmid
 * Modified by:
 * Created:     09.06.2002
 * CVS-ID:      $Id$
 * Copyright:   (c) 1999-2003 Universitt Karlsruhe
 * Licence:     This file protected by GPL -  GNU GENERAL PUBLIC LICENSE.
 */

/**
 * Intraprozedurale Analyse zur Abschtzung der Aufrulrelation. Es
 * wird eine Menge von freien Methoden und anschlieend die an den
16
17
 * Call-Operationen aufrufbaren Methoden bestimmt.
 *
Götz Lindenmaier's avatar
Götz Lindenmaier committed
18
 */
19
20
21
22
23
24
25

#ifndef _CGANA_H_
#define _CGANA_H_

#include "entity.h"

/* Methoden sind "frei", wenn ihr Funktionszeiger (potentiell)
26
 * "explizit" bekannt ist, d.h.:
27
 *
28
 * - die Methode ist von aussen sichtbar (external_visible).
29
30
 *
 * - ihr Funktionszeiger ist "frei", d.h. der Funktionszeiger wurde
31
 *   nicht ausschliesslich an den entsprechenden Eingang eines
32
 *   Call-Knotens weitergegeben, sondern z.B. in den Speicher
33
 *   geschrieben, als Parameter uebergeben, ...
34
35
36
 *
 * Die main-Methode ist immer in der Menge enthalten.
 *
37
 * Die Links an den "ir_node"s werden geloescht. */
38

39
/** Analyses a rough estimation of the possible call graph.
40
 *
Götz Lindenmaier's avatar
Götz Lindenmaier committed
41
42
43
44
45
46
47
48
49
50
51
 *  Determines for each Call node the set of possibly called methods.
 *  Stores the result in the field 'callees' of the Call node.  If the
 *  address can not be analysed, e.g. because it is loaded from a
 *  variable, the array contains NULL. @@@ the array should contain a
 *  special entity 'unknown'. (See "set_Call_callee"). cgana returns
 *  the set of 'free' methods, i.e., the methods that can be called
 *  from external or via function pointers.  This datastructure must
 *  be freed with 'free()' by the caller of cgana.
 *
 *  cgana sets the callee_info_state of each graph to consistent.
 *
52
53
54
55
56
57
 *  The algorithm implements roughly Static Class Hierarchy Analysis
 *  as described in "Optimization of Object-Oriented Programs Using
 *  Static Class Hierarchy Analysis" by Jeffrey Dean and David Grove
 *  and Craig Chambers.
 *
 *  Performs some optimizations possible by the analysed information:
Götz Lindenmaier's avatar
Götz Lindenmaier committed
58
59
60
61
62
63
64
 *    - Replace SymConst-name nodes by SymConst-entity nodes if possible.
 *    - Replace (Sel-method(Alloc)) by SymConst-entity.
 *    - Replaces Sel nodes by Bad if there is no implementation for the
 *         selected entity.  (@@@ was genau meint unreachable?)
 *    - Replaces Sel-method by SymConst-entity if the method is never overwritten.
 *    - Replaces Calls by Tuple containing Bads if callee array is empty
 *         (there is no implementation to call)
65
66
67
 *
 *  Leaves Bad control predecessors in the graph!
 */
Götz Lindenmaier's avatar
Götz Lindenmaier committed
68
void cgana(int *len, entity ***free_methods);
69

Götz Lindenmaier's avatar
Götz Lindenmaier committed
70
71
72
73
74
75
/** Free callee information.
 *
 *  Sets callee_info_state of the graph passed to none.
 */
void free_callee_info(ir_graph *irg);

76
77
/* Optimize the address expressions passed to call nodes.
 * Performs only the optimizations done by cgana. */
78
/* @@@ move to irgopt ?! */
79
/* @@@ not fully implemented as buggy !!!  */
80
void opt_call_addrs(void);
Götz Lindenmaier's avatar
Götz Lindenmaier committed
81
82


83
#endif /* _CGANA_H_ */