Added missing API docu, improved existing API docu
[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  * @brief
26  *  Interprocedural analysis to estimate the calling relation.
27  *
28  *  This analysis computes all entities representing methods that
29  *  can be called at a Call node.  Further it computes a set of
30  *  methods that are 'free', i.e., their adress is handled by
31  *  the program directly, or they are visible external.
32  */
33 #ifndef FIRM_ANA_CGANA_H
34 #define FIRM_ANA_CGANA_H
35
36 #include "firm_types.h"
37 #include "begin.h"
38
39 /** @addtogroup callgraph
40  * @{
41  */
42
43 /** Analyses a rough estimation of the possible call graph.
44  *
45  *  Determines for each Call node the set of possibly called methods.
46  *  Stores the result in the field 'callees' of the Call node.  If the
47  *  address can not be analysed, e.g. because it is loaded from a
48  *  variable, the array contains the unknown_entity. (See
49  *  set_Call_callee()). cgana() returns the set of 'free' methods, i.e.,
50  *  the methods that can be called from external or via function
51  *  pointers.  This datastructure must be freed with 'xfree()' by the
52  *  caller of cgana().
53  *
54  *  cgana() sets the callee_info_state of each graph and the program to
55  *  consistent.
56  *
57  *  The algorithm implements roughly Static Class Hierarchy Analysis
58  *  as described in "Optimization of Object-Oriented Programs Using
59  *  Static Class Hierarchy Analysis" by Jeffrey Dean and David Grove
60  *  and Craig Chambers.
61  *
62  *  Performs some optimizations possible by the analysed information:
63  *  - Replace SymConst-name nodes by SymConst-entity nodes if possible.
64  *  - Replace (Sel-method(Alloc)) by SymConst-entity.
65  *  - Replaces Sel-method by SymConst-entity if the method is never overwritten.
66  */
67 FIRM_API size_t cgana(ir_entity ***free_methods);
68
69 /**
70  * Frees callee information.
71  *
72  * Sets callee_info_state of the graph passed to none.  Sets callee field
73  * in all call nodes to NULL.  Else it happens that the field contains
74  * pointers to other than firm arrays.
75  */
76 FIRM_API void free_callee_info(ir_graph *irg);
77 /** Frees callee information for all graphs in the current program. */
78 FIRM_API void free_irp_callee_info(void);
79
80 /**
81  * Optimizes the address expressions passed to call nodes.
82  * Performs only the optimizations done by cgana.
83  */
84 FIRM_API void opt_call_addrs(void);
85
86 /** @} */
87
88 #include "end.h"
89
90 #endif