cgana.h 3.38 KB
Newer Older
Götz Lindenmaier's avatar
Götz Lindenmaier committed
1
/*
Michael Beck's avatar
Michael Beck committed
2
 * Copyright (C) 1995-2008 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.
Götz Lindenmaier's avatar
Götz Lindenmaier committed
18
19
20
 */

/**
Matthias Braun's avatar
Matthias Braun committed
21
22
23
24
25
26
27
28
 * @file
 * @brief       Intraprozedural analyses to estimate the call graph.
 * @author      Hubert Schmid
 * @date        09.06.2002
 * @version     $Id$
 * @summary
 * @summary
 *  Interprocedural analysis to estimate the calling relation.
29
 *
Matthias Braun's avatar
Matthias Braun committed
30
31
32
33
 *  This analysis computes all entities representing methods that
 *  can be called at a Call node.  Further it computes a set of
 *  methods that are 'free', i.e., their adress is handled by
 *  the program directly, or they are visible external.
Götz Lindenmaier's avatar
Götz Lindenmaier committed
34
 */
Matthias Braun's avatar
Matthias Braun committed
35
36
#ifndef FIRM_ANA_CGANA_H
#define FIRM_ANA_CGANA_H
37

38
#include "firm_types.h"
39
40

/* Methoden sind "frei", wenn ihr Funktionszeiger (potentiell)
41
 * "explizit" bekannt ist, d.h.:
42
 *
43
 * - die Methode ist von aussen sichtbar (external_visible).
44
45
 *
 * - ihr Funktionszeiger ist "frei", d.h. der Funktionszeiger wurde
46
 *   nicht ausschliesslich an den entsprechenden Eingang eines
47
 *   Call-Knotens weitergegeben, sondern z.B. in den Speicher
48
 *   geschrieben, als Parameter uebergeben, ...
49
50
51
 *
 * Die main-Methode ist immer in der Menge enthalten.
 *
Götz Lindenmaier's avatar
bugfix    
Götz Lindenmaier committed
52
53
 * Die Links an den "ir_node"s werden geloescht.
 */
54

55
/** Analyses a rough estimation of the possible call graph.
56
 *
Götz Lindenmaier's avatar
Götz Lindenmaier committed
57
58
59
 *  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
Götz Lindenmaier's avatar
bugfix    
Götz Lindenmaier committed
60
 *  variable, the array contains the unknown_entity. (See
Michael Beck's avatar
Michael Beck committed
61
 *  set_Call_callee()). cgana() returns the set of 'free' methods, i.e.,
Götz Lindenmaier's avatar
bugfix    
Götz Lindenmaier committed
62
 *  the methods that can be called from external or via function
Michael Beck's avatar
Michael Beck committed
63
64
 *  pointers.  This datastructure must be freed with 'xfree()' by the
 *  caller of cgana().
Götz Lindenmaier's avatar
Götz Lindenmaier committed
65
 *
Michael Beck's avatar
Michael Beck committed
66
 *  cgana() sets the callee_info_state of each graph and the program to
Götz Lindenmaier's avatar
bugfix    
Götz Lindenmaier committed
67
 *  consistent.
Götz Lindenmaier's avatar
Götz Lindenmaier committed
68
 *
69
70
71
72
73
74
 *  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
75
76
77
 *    - Replace SymConst-name nodes by SymConst-entity nodes if possible.
 *    - Replace (Sel-method(Alloc)) by SymConst-entity.
 *    - Replaces Sel-method by SymConst-entity if the method is never overwritten.
78
 */
79
void cgana(int *len, ir_entity ***free_methods);
80

Götz Lindenmaier's avatar
Götz Lindenmaier committed
81
82
/** Free callee information.
 *
Götz Lindenmaier's avatar
Götz Lindenmaier committed
83
84
85
 *  Sets callee_info_state of the graph passed to none.  Sets callee field
 *  in all call nodes to NULL.  Else it happens that the field contains
 *  pointers to other than firm arrays.
Götz Lindenmaier's avatar
Götz Lindenmaier committed
86
87
 */
void free_callee_info(ir_graph *irg);
Götz Lindenmaier's avatar
Götz Lindenmaier committed
88
void free_irp_callee_info(void);
Götz Lindenmaier's avatar
Götz Lindenmaier committed
89

90
91
/* Optimize the address expressions passed to call nodes.
 * Performs only the optimizations done by cgana. */
92
void opt_call_addrs(void);
Götz Lindenmaier's avatar
Götz Lindenmaier committed
93

Matthias Braun's avatar
Matthias Braun committed
94
#endif