make firm compile again
[libfirm] / include / libfirm / cgana.h
1 /*
2  * Copyright (C) 1995-2008 University of Karlsruhe.  All right reserved.
3  *
4  * This file is part of libFirm.
5  *
6  * This file may be distributed and/or modified under the terms of the
7  * GNU General Public License version 2 as published by the Free Software
8  * Foundation and appearing in the file LICENSE.GPL included in the
9  * packaging of this file.
10  *
11  * Licensees holding valid libFirm Professional Edition licenses may use
12  * this file in accordance with the libFirm Commercial License.
13  * Agreement provided with the Software.
14  *
15  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
16  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17  * PURPOSE.
18  */
19
20 /**
21  * @file
22  * @brief       Intraprozedural analyses to estimate the call graph.
23  * @author      Hubert Schmid
24  * @date        09.06.2002
25  * @version     $Id$
26  * @brief
27  *  Interprocedural analysis to estimate the calling relation.
28  *
29  *  This analysis computes all entities representing methods that
30  *  can be called at a Call node.  Further it computes a set of
31  *  methods that are 'free', i.e., their adress is handled by
32  *  the program directly, or they are visible external.
33  */
34 #ifndef FIRM_ANA_CGANA_H
35 #define FIRM_ANA_CGANA_H
36
37 #include "firm_types.h"
38
39 /* Methoden sind "frei", wenn ihr Funktionszeiger (potentiell)
40  * "explizit" bekannt ist, d.h.:
41  *
42  * - die Methode ist von aussen sichtbar (external_visible).
43  *
44  * - ihr Funktionszeiger ist "frei", d.h. der Funktionszeiger wurde
45  *   nicht ausschliesslich an den entsprechenden Eingang eines
46  *   Call-Knotens weitergegeben, sondern z.B. in den Speicher
47  *   geschrieben, als Parameter uebergeben, ...
48  *
49  * Die main-Methode ist immer in der Menge enthalten.
50  *
51  * Die Links an den "ir_node"s werden geloescht.
52  */
53
54 /** Analyses a rough estimation of the possible call graph.
55  *
56  *  Determines for each Call node the set of possibly called methods.
57  *  Stores the result in the field 'callees' of the Call node.  If the
58  *  address can not be analysed, e.g. because it is loaded from a
59  *  variable, the array contains the unknown_entity. (See
60  *  set_Call_callee()). cgana() returns the set of 'free' methods, i.e.,
61  *  the methods that can be called from external or via function
62  *  pointers.  This datastructure must be freed with 'xfree()' by the
63  *  caller of cgana().
64  *
65  *  cgana() sets the callee_info_state of each graph and the program to
66  *  consistent.
67  *
68  *  The algorithm implements roughly Static Class Hierarchy Analysis
69  *  as described in "Optimization of Object-Oriented Programs Using
70  *  Static Class Hierarchy Analysis" by Jeffrey Dean and David Grove
71  *  and Craig Chambers.
72  *
73  *  Performs some optimizations possible by the analysed information:
74  *    - Replace SymConst-name nodes by SymConst-entity nodes if possible.
75  *    - Replace (Sel-method(Alloc)) by SymConst-entity.
76  *    - Replaces Sel-method by SymConst-entity if the method is never overwritten.
77  */
78 void cgana(int *len, ir_entity ***free_methods);
79
80 /** Free callee information.
81  *
82  *  Sets callee_info_state of the graph passed to none.  Sets callee field
83  *  in all call nodes to NULL.  Else it happens that the field contains
84  *  pointers to other than firm arrays.
85  */
86 void free_callee_info(ir_graph *irg);
87 void free_irp_callee_info(void);
88
89 /* Optimize the address expressions passed to call nodes.
90  * Performs only the optimizations done by cgana. */
91 void opt_call_addrs(void);
92
93 #endif