2 * This file is part of libFirm.
3 * Copyright (C) 2012 University of Karlsruhe.
8 * @brief Optimizations for a whole ir graph, i.e., a procedure.
9 * @author Christian Schaefer, Goetz Lindenmaier, Sebastian Felis
11 #ifndef FIRM_IR_IRGOPT_H
12 #define FIRM_IR_IRGOPT_H
14 #include "firm_types.h"
19 * @defgroup irgopt Graph Transformations
23 /** Applies local optimizations (see iropt.h) to all nodes reachable from node
26 * @param n The node to be optimized.
28 FIRM_API void local_optimize_node(ir_node *n);
30 /** Applies local optimizations (see iropt.h) to all nodes in the graph.
32 * @param irg The graph to be optimized.
34 * After applying local_optimize_graph() to a IR-graph, Bad nodes
35 * only occur as predecessor of Block and Phi nodes.
37 FIRM_API void local_optimize_graph(ir_graph *irg);
39 /** Applies local optimizations (see iropt.h) to all nodes in the graph.
41 * After applying optimize_graph_df() to a IR-graph, Bad nodes
42 * only occur as predecessor of Block and Phi nodes.
44 * This version uses fixpoint iteration.
46 * @param irg The graph to be optimized.
48 * @return non-zero if the optimization could be applied, 0 else
50 FIRM_API void local_opts(ir_graph *irg);
53 * Perform local optimizations on nodes on const code irg
55 FIRM_API void local_opts_const_code(void);
57 /** Same functionality as local_opts above, but without framework wrapper
60 FIRM_API int optimize_graph_df(ir_graph *irg);
63 * Eliminates (obviously) unreachable code
65 FIRM_API void remove_unreachable_code(ir_graph *irg);
68 * Removes all Bad nodes from a graph.
70 * @param irg The graph to be optimized.
72 FIRM_API void remove_bads(ir_graph *irg);
75 * Removes all Tuple nodes from a graph.
77 * @param irg The graph to be optimized.
79 FIRM_API void remove_tuples(ir_graph *irg);
82 * Creates an ir_graph pass for optimize_graph_df().
84 * @param name the name of this pass or NULL
86 * @return the newly created ir_graph pass
88 FIRM_API ir_graph_pass_t *optimize_graph_df_pass(const char *name);
90 /** Places an empty basic block on critical control flow edges thereby
93 * A critical control flow edge is an edge from a block with several
94 * control exits to a block with several control entries (See Muchnic
95 * p. 407). Exception edges are always ignored.
99 FIRM_API void remove_critical_cf_edges(ir_graph *irg);
101 /** Places an empty basic block on critical control flow edges thereby
104 * A critical control flow edge is an edge from a block with several
105 * control exits to a block with several control entries (See Muchnic
108 * @param irg IR Graph
109 * @param ignore_exception_edges if non-zero, exception edges will be ignored
111 FIRM_API void remove_critical_cf_edges_ex(ir_graph *irg,
112 int ignore_exception_edges);