added a callback function to check whether a given entity is a allocation call
[libfirm] / ir / opt / escape_ana.h
1 /*
2  * Copyright (C) 1995-2007 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   escape analysis and optimization
23  * @author  Michael Beck
24  * @date    03.11.2005
25  * @version $Id$
26  */
27 #ifndef FIRM_OPT_IR_OPT_ESCAPE_ANA_H
28 #define FIRM_OPT_IR_OPT_ESCAPE_ANA_H
29
30 #include "firm_types.h"
31
32 /**
33  * A callback that checks whether a entity is an allocation
34  * routine.
35  */
36 typedef int (*check_alloc_entity_func)(ir_entity *ent);
37
38 /**
39  * Do simple and fast escape analysis for one graph.
40  *
41  * @param irg       the graph
42  * @param callback  a callback function to check whether a
43  *                  given entity is a allocation call
44  */
45 void escape_enalysis_irg(ir_graph *irg, check_alloc_entity_func callback);
46
47 /**
48  * Do simple and fast escape analysis for all graphs.
49  *
50  * This optimization implements a simple and fast but inexact
51  * escape analysis. Some addresses might be marked as 'escaped' even
52  * if they are not.
53  * The advantage is a low memory footprint and fast speed.
54  *
55  * @param run_scalar_replace  if this flag in non-zero, scalar
56  *                            replacement optimization is run on graphs with removed
57  *                            allocation
58  * @param callback            a callback function to check whether a
59  *                            given entity is a allocation call
60  *
61  * This optimization removes allocation which are not used (rare) and replace
62  * allocation that can be proved dead at the end of the graph which stack variables.
63  *
64  * The creation of stack variable allows scalar replacement to be run only
65  * on those graphs that have been changed.
66  *
67  * This is most effective on Java where no other stack variables exists.
68  */
69 void escape_analysis(int run_scalar_replace, check_alloc_entity_func callback);
70
71 #endif