merge common graph copying code; move dead code elimination into an own file
[libfirm] / include / libfirm / irgopt.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   Optimizations for a whole ir graph, i.e., a procedure.
23  * @author  Christian Schaefer, Goetz Lindenmaier, Sebastian Felis
24  * @version $Id$
25  */
26 #ifndef FIRM_IR_IRGOPT_H
27 #define FIRM_IR_IRGOPT_H
28
29 #include "firm_types.h"
30
31 /** Applies local optimizations (see iropt.h) to all nodes reachable from node n.
32  *
33  * @param n The node to be optimized.
34  */
35 void local_optimize_node(ir_node *n);
36
37 /** Applies local optimizations (see iropt.h) to all nodes in the graph.
38  *
39  * @param irg  The graph to be optimized.
40  *
41  * After applying local_optimize_graph() to a IR-graph, Bad nodes
42  * only occur as predecessor of Block and Phi nodes.
43  */
44 void local_optimize_graph(ir_graph *irg);
45
46 /** Applies local optimizations (see iropt.h) to all nodes in the graph.
47  *
48  * After applying optimize_graph_df() to a IR-graph, Bad nodes
49  * only occur as predecessor of Block and Phi nodes.
50  *
51  * This version uses fixpoint iteration.
52  *
53  * @param irg  The graph to be optimized.
54  *
55  * @return non-zero if the optimization could be applied, 0 else
56  */
57 int optimize_graph_df(ir_graph *irg);
58
59 /**
60  * Creates an ir_graph pass for optimize_graph_df().
61  *
62  * @param name     the name of this pass or NULL
63  *
64  * @return  the newly created ir_graph pass
65  */
66 ir_graph_pass_t *optimize_graph_df_pass(const char *name);
67
68 /** Places an empty basic block on critical control flow edges thereby
69  * removing them.
70  *
71  * A critical control flow edge is an edge from a block with several
72  * control exits to a block with several control entries (See Muchnic
73  * p. 407). Exception edges are always ignored.
74  *
75  * @param irg  IR Graph
76  */
77 void remove_critical_cf_edges(ir_graph *irg);
78
79 /** Places an empty basic block on critical control flow edges thereby
80  * removing them.
81  *
82  * A critical control flow edge is an edge from a block with several
83  * control exits to a block with several control entries (See Muchnic
84  * p. 407).
85  *
86  * @param irg                     IR Graph
87  * @param ignore_exception_edges  if non-zero, exception edges will be ignored
88  */
89 void remove_critical_cf_edges_ex(ir_graph *irg, int ignore_exception_edges);
90
91 #endif