switch_lowerer: cast to backend specified Switch mode
[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  */
25 #ifndef FIRM_IR_IRGOPT_H
26 #define FIRM_IR_IRGOPT_H
27
28 #include "firm_types.h"
29 #include "begin.h"
30
31 /**
32  * @ingroup iroptimize
33  * @defgroup irgopt  Graph Transformations
34  * @{
35  */
36
37 /** Applies local optimizations (see iropt.h) to all nodes reachable from node
38  * @p n.
39  *
40  * @param n The node to be optimized.
41  */
42 FIRM_API void local_optimize_node(ir_node *n);
43
44 /** Applies local optimizations (see iropt.h) to all nodes in the graph.
45  *
46  * @param irg  The graph to be optimized.
47  *
48  * After applying local_optimize_graph() to a IR-graph, Bad nodes
49  * only occur as predecessor of Block and Phi nodes.
50  */
51 FIRM_API void local_optimize_graph(ir_graph *irg);
52
53 /** Applies local optimizations (see iropt.h) to all nodes in the graph.
54  *
55  * After applying optimize_graph_df() to a IR-graph, Bad nodes
56  * only occur as predecessor of Block and Phi nodes.
57  *
58  * This version uses fixpoint iteration.
59  *
60  * @param irg  The graph to be optimized.
61  *
62  * @return non-zero if the optimization could be applied, 0 else
63  */
64 FIRM_API void local_opts(ir_graph *irg);
65
66 /**
67  * Perform local optimizations on nodes on const code irg
68  */
69 FIRM_API void local_opts_const_code(void);
70
71 /** Same functionality as local_opts above, but without framework wrapper
72  * @deprecated
73  */
74 FIRM_API int optimize_graph_df(ir_graph *irg);
75
76 /**
77  * Eliminates (obviously) unreachable code
78  */
79 FIRM_API void remove_unreachable_code(ir_graph *irg);
80
81 /**
82  * Removes all Bad nodes from a graph.
83  *
84  * @param irg  The graph to be optimized.
85  */
86 FIRM_API void remove_bads(ir_graph *irg);
87
88 /**
89  * Removes all Tuple nodes from a graph.
90  *
91  * @param irg  The graph to be optimized.
92  */
93 FIRM_API void remove_tuples(ir_graph *irg);
94
95 /**
96  * Creates an ir_graph pass for optimize_graph_df().
97  *
98  * @param name     the name of this pass or NULL
99  *
100  * @return  the newly created ir_graph pass
101  */
102 FIRM_API ir_graph_pass_t *optimize_graph_df_pass(const char *name);
103
104 /** Places an empty basic block on critical control flow edges thereby
105  * removing them.
106  *
107  * A critical control flow edge is an edge from a block with several
108  * control exits to a block with several control entries (See Muchnic
109  * p. 407). Exception edges are always ignored.
110  *
111  * @param irg  IR Graph
112  */
113 FIRM_API void remove_critical_cf_edges(ir_graph *irg);
114
115 /** Places an empty basic block on critical control flow edges thereby
116  * removing them.
117  *
118  * A critical control flow edge is an edge from a block with several
119  * control exits to a block with several control entries (See Muchnic
120  * p. 407).
121  *
122  * @param irg                     IR Graph
123  * @param ignore_exception_edges  if non-zero, exception edges will be ignored
124  */
125 FIRM_API void remove_critical_cf_edges_ex(ir_graph *irg,
126                                           int ignore_exception_edges);
127
128 /** @} */
129
130 #include "end.h"
131
132 #endif