becopyheur2: Remove unnecessary indirection.
[libfirm] / include / libfirm / irgopt.h
1 /*
2  * This file is part of libFirm.
3  * Copyright (C) 2012 University of Karlsruhe.
4  */
5
6 /**
7  * @file
8  * @brief   Optimizations for a whole ir graph, i.e., a procedure.
9  * @author  Christian Schaefer, Goetz Lindenmaier, Sebastian Felis
10  */
11 #ifndef FIRM_IR_IRGOPT_H
12 #define FIRM_IR_IRGOPT_H
13
14 #include "firm_types.h"
15 #include "begin.h"
16
17 /**
18  * @ingroup iroptimize
19  * @defgroup irgopt  Graph Transformations
20  * @{
21  */
22
23 /** Applies local optimizations (see iropt.h) to all nodes reachable from node
24  * @p n.
25  *
26  * @param n The node to be optimized.
27  */
28 FIRM_API void local_optimize_node(ir_node *n);
29
30 /** Applies local optimizations (see iropt.h) to all nodes in the graph.
31  *
32  * @param irg  The graph to be optimized.
33  *
34  * After applying local_optimize_graph() to a IR-graph, Bad nodes
35  * only occur as predecessor of Block and Phi nodes.
36  */
37 FIRM_API void local_optimize_graph(ir_graph *irg);
38
39 /** Applies local optimizations (see iropt.h) to all nodes in the graph.
40  *
41  * After applying optimize_graph_df() to a IR-graph, Bad nodes
42  * only occur as predecessor of Block and Phi nodes.
43  *
44  * This version uses fixpoint iteration.
45  *
46  * @param irg  The graph to be optimized.
47  *
48  * @return non-zero if the optimization could be applied, 0 else
49  */
50 FIRM_API void local_opts(ir_graph *irg);
51
52 /**
53  * Perform local optimizations on nodes on const code irg
54  */
55 FIRM_API void local_opts_const_code(void);
56
57 /** Same functionality as local_opts above, but without framework wrapper
58  * @deprecated
59  */
60 FIRM_API int optimize_graph_df(ir_graph *irg);
61
62 /**
63  * Eliminates (obviously) unreachable code
64  */
65 FIRM_API void remove_unreachable_code(ir_graph *irg);
66
67 /**
68  * Removes all Bad nodes from a graph.
69  *
70  * @param irg  The graph to be optimized.
71  */
72 FIRM_API void remove_bads(ir_graph *irg);
73
74 /**
75  * Removes all Tuple nodes from a graph.
76  *
77  * @param irg  The graph to be optimized.
78  */
79 FIRM_API void remove_tuples(ir_graph *irg);
80
81 /**
82  * Creates an ir_graph pass for optimize_graph_df().
83  *
84  * @param name     the name of this pass or NULL
85  *
86  * @return  the newly created ir_graph pass
87  */
88 FIRM_API ir_graph_pass_t *optimize_graph_df_pass(const char *name);
89
90 /** Places an empty basic block on critical control flow edges thereby
91  * removing them.
92  *
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.
96  *
97  * @param irg  IR Graph
98  */
99 FIRM_API void remove_critical_cf_edges(ir_graph *irg);
100
101 /** Places an empty basic block on critical control flow edges thereby
102  * removing them.
103  *
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
106  * p. 407).
107  *
108  * @param irg                     IR Graph
109  * @param ignore_exception_edges  if non-zero, exception edges will be ignored
110  */
111 FIRM_API void remove_critical_cf_edges_ex(ir_graph *irg,
112                                           int ignore_exception_edges);
113
114 /** @} */
115
116 #include "end.h"
117
118 #endif