change unreachable code elmination to the simpler remove links into unreachable code...
[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 #include "begin.h"
31
32 /** Applies local optimizations (see iropt.h) to all nodes reachable from node
33  * @p n.
34  *
35  * @param n The node to be optimized.
36  */
37 FIRM_API void local_optimize_node(ir_node *n);
38
39 /** Applies local optimizations (see iropt.h) to all nodes in the graph.
40  *
41  * @param irg  The graph to be optimized.
42  *
43  * After applying local_optimize_graph() to a IR-graph, Bad nodes
44  * only occur as predecessor of Block and Phi nodes.
45  */
46 FIRM_API void local_optimize_graph(ir_graph *irg);
47
48 /** Applies local optimizations (see iropt.h) to all nodes in the graph.
49  *
50  * After applying optimize_graph_df() to a IR-graph, Bad nodes
51  * only occur as predecessor of Block and Phi nodes.
52  *
53  * This version uses fixpoint iteration.
54  *
55  * @param irg  The graph to be optimized.
56  *
57  * @return non-zero if the optimization could be applied, 0 else
58  */
59 FIRM_API int optimize_graph_df(ir_graph *irg);
60
61 /**
62  * Eliminates (obviously) unreachable code
63  */
64 FIRM_API void remove_unreachable_code(ir_graph *irg);
65
66 /**
67  * Removes all Bad nodes from a graph.
68  *
69  * @param irg  The graph to be optimized.
70  *
71  * @return non-zero if at least one Bad was removed, otherwise 0
72  */
73 FIRM_API int remove_bads(ir_graph *irg);
74
75 /**
76  * Creates an ir_graph pass for optimize_graph_df().
77  *
78  * @param name     the name of this pass or NULL
79  *
80  * @return  the newly created ir_graph pass
81  */
82 FIRM_API ir_graph_pass_t *optimize_graph_df_pass(const char *name);
83
84 /** Places an empty basic block on critical control flow edges thereby
85  * removing them.
86  *
87  * A critical control flow edge is an edge from a block with several
88  * control exits to a block with several control entries (See Muchnic
89  * p. 407). Exception edges are always ignored.
90  *
91  * @param irg  IR Graph
92  */
93 FIRM_API void remove_critical_cf_edges(ir_graph *irg);
94
95 /** Places an empty basic block on critical control flow edges thereby
96  * removing them.
97  *
98  * A critical control flow edge is an edge from a block with several
99  * control exits to a block with several control entries (See Muchnic
100  * p. 407).
101  *
102  * @param irg                     IR Graph
103  * @param ignore_exception_edges  if non-zero, exception edges will be ignored
104  */
105 FIRM_API void remove_critical_cf_edges_ex(ir_graph *irg,
106                                           int ignore_exception_edges);
107
108 #include "end.h"
109
110 #endif