2 * Copyright (C) 1995-2008 University of Karlsruhe. All right reserved.
4 * This file is part of libFirm.
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.
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.
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
22 * @brief Optimizations for a whole ir graph, i.e., a procedure.
23 * @author Christian Schaefer, Goetz Lindenmaier, Sebastian Felis
25 #ifndef FIRM_IR_IRGOPT_H
26 #define FIRM_IR_IRGOPT_H
28 #include "firm_types.h"
31 /** Applies local optimizations (see iropt.h) to all nodes reachable from node
34 * @param n The node to be optimized.
36 FIRM_API void local_optimize_node(ir_node *n);
38 /** Applies local optimizations (see iropt.h) to all nodes in the graph.
40 * @param irg The graph to be optimized.
42 * After applying local_optimize_graph() to a IR-graph, Bad nodes
43 * only occur as predecessor of Block and Phi nodes.
45 FIRM_API void local_optimize_graph(ir_graph *irg);
47 /** Applies local optimizations (see iropt.h) to all nodes in the graph.
49 * After applying optimize_graph_df() to a IR-graph, Bad nodes
50 * only occur as predecessor of Block and Phi nodes.
52 * This version uses fixpoint iteration.
54 * @param irg The graph to be optimized.
56 * @return non-zero if the optimization could be applied, 0 else
58 FIRM_API void local_opts(ir_graph *irg);
60 /** Same functionality as local_opts above, but without framework wrapper
63 FIRM_API int optimize_graph_df(ir_graph *irg);
66 * Eliminates (obviously) unreachable code
68 FIRM_API void remove_unreachable_code(ir_graph *irg);
71 * Removes all Bad nodes from a graph.
73 * @param irg The graph to be optimized.
75 * @return non-zero if at least one Bad was removed, otherwise 0
77 FIRM_API int remove_bads(ir_graph *irg);
80 * Removes all Tuple nodes from a graph.
82 * @param irg The graph to be optimized.
84 * @return non-zero if at least one Tuple was removed, otherwise 0
86 FIRM_API int remove_tuples(ir_graph *irg);
89 * Creates an ir_graph pass for optimize_graph_df().
91 * @param name the name of this pass or NULL
93 * @return the newly created ir_graph pass
95 FIRM_API ir_graph_pass_t *optimize_graph_df_pass(const char *name);
97 /** Places an empty basic block on critical control flow edges thereby
100 * A critical control flow edge is an edge from a block with several
101 * control exits to a block with several control entries (See Muchnic
102 * p. 407). Exception edges are always ignored.
104 * @param irg IR Graph
106 FIRM_API void remove_critical_cf_edges(ir_graph *irg);
108 /** Places an empty basic block on critical control flow edges thereby
111 * A critical control flow edge is an edge from a block with several
112 * control exits to a block with several control entries (See Muchnic
115 * @param irg IR Graph
116 * @param ignore_exception_edges if non-zero, exception edges will be ignored
118 FIRM_API void remove_critical_cf_edges_ex(ir_graph *irg,
119 int ignore_exception_edges);