becopyopt: Inline the thin wrapper nodes_interfere(), so we do not need to fetch...
[libfirm] / include / libfirm / cgana.h
1 /*
2  * This file is part of libFirm.
3  * Copyright (C) 2012 University of Karlsruhe.
4  */
5
6 /**
7  * @file
8  * @brief       Intraprozedural analyses to estimate the call graph.
9  * @author      Hubert Schmid
10  * @date        09.06.2002
11  * @brief
12  *  Interprocedural analysis to estimate the calling relation.
13  *
14  *  This analysis computes all entities representing methods that
15  *  can be called at a Call node.  Further it computes a set of
16  *  methods that are 'free', i.e., their adress is handled by
17  *  the program directly, or they are visible external.
18  */
19 #ifndef FIRM_ANA_CGANA_H
20 #define FIRM_ANA_CGANA_H
21
22 #include "firm_types.h"
23 #include "begin.h"
24
25 /** @addtogroup callgraph
26  * @{
27  */
28
29 /** Analyses a rough estimation of the possible call graph.
30  *
31  *  Determines for each Call node the set of possibly called methods.
32  *  Stores the result in the field 'callees' of the Call node.  If the
33  *  address can not be analysed, e.g. because it is loaded from a
34  *  variable, the array contains the unknown_entity. (See
35  *  set_Call_callee()). cgana() returns the set of 'free' methods, i.e.,
36  *  the methods that can be called from external or via function
37  *  pointers.  This datastructure must be freed with 'xfree()' by the
38  *  caller of cgana().
39  *
40  *  cgana() sets the callee_info_state of each graph and the program to
41  *  consistent.
42  *
43  *  The algorithm implements roughly Static Class Hierarchy Analysis
44  *  as described in "Optimization of Object-Oriented Programs Using
45  *  Static Class Hierarchy Analysis" by Jeffrey Dean and David Grove
46  *  and Craig Chambers.
47  *
48  *  Performs some optimizations possible by the analysed information:
49  *  - Replace SymConst-name nodes by SymConst-entity nodes if possible.
50  *  - Replace (Sel-method(Alloc)) by SymConst-entity.
51  *  - Replaces Sel-method by SymConst-entity if the method is never overwritten.
52  */
53 FIRM_API size_t cgana(ir_entity ***free_methods);
54
55 /**
56  * Frees callee information.
57  *
58  * Sets callee_info_state of the graph passed to none.  Sets callee field
59  * in all call nodes to NULL.  Else it happens that the field contains
60  * pointers to other than firm arrays.
61  */
62 FIRM_API void free_callee_info(ir_graph *irg);
63 /** Frees callee information for all graphs in the current program. */
64 FIRM_API void free_irp_callee_info(void);
65
66 /**
67  * Optimizes the address expressions passed to call nodes.
68  * Performs only the optimizations done by cgana.
69  */
70 FIRM_API void opt_call_addrs(void);
71
72 /** @} */
73
74 #include "end.h"
75
76 #endif