beifg: Remove the unused function be_ifg_nodes_break().
[libfirm] / include / libfirm / irpass.h
1 /*
2  * This file is part of libFirm.
3  * Copyright (C) 2012 University of Karlsruhe.
4  */
5
6 /**
7  * @file
8  * @brief     Manager for transformation passes.
9  * @author    Michael Beck
10  */
11 #ifndef FIRM_IR_PASS_H
12 #define FIRM_IR_PASS_H
13
14 #include "firm_types.h"
15 #include "begin.h"
16
17 /**
18  * Creates a new ir_graph pass manager.
19  *
20  * @param name        the name of the manager
21  * @param verify_all  if non-zero, all passes of this manager will be verified
22  * @param dump_all    if non-zero, all passes results will be dumped
23  *
24  * @return the newly created manager
25  */
26 FIRM_API ir_graph_pass_manager_t *new_graph_pass_mgr(const char *name,
27                                                      int verify_all,
28                                                      int dump_all);
29
30 /**
31  * Adds an ir_graph pass to a graph pass manager.
32  *
33  * @param mgr   the ir_graph pass manager
34  * @param pass  the pass to add
35  */
36 FIRM_API void ir_graph_pass_mgr_add(ir_graph_pass_manager_t *mgr,
37                                     ir_graph_pass_t *pass);
38
39 /**
40  * Runs all passes of an ir_graph pass manager.
41  *
42  * @param mgr   the manager
43  *
44  * @return 0 if all passes return 0, else 1
45  */
46 FIRM_API int ir_graph_pass_mgr_run(ir_graph_pass_manager_t *mgr);
47
48 /**
49  * Terminates an ir_graph pass manager and all owned passes.
50  *
51  * @param mgr   the manager
52  */
53 FIRM_API void term_graph_pass_mgr(ir_graph_pass_manager_t *mgr);
54
55 /**
56  * Creates a new ir_prog pass manager.
57  *
58  * @param name        the name of the manager
59  * @param verify_all  if non-zero, all passes of this manager will be verified
60  * @param dump_all    if non-zero, all passes results will be dumped
61  *
62  * @return  the newly created manager
63  */
64 FIRM_API ir_prog_pass_manager_t *new_prog_pass_mgr(const char *name,
65                                                    int verify_all,
66                                                    int dump_all);
67
68 /**
69  * Adds an ir_prog pass to an ir_prog pass manager.
70  *
71  * @param mgr   the ir_prog pass manager
72  * @param pass  the pass to add
73  */
74 FIRM_API void ir_prog_pass_mgr_add(ir_prog_pass_manager_t *mgr,
75                                    ir_prog_pass_t *pass);
76
77 /**
78  * Adds an ir_graph_pass_manager as a pass to an ir_prog pass manager.
79  *
80  * @param mgr        the ir_prog pass manager
81  * @param graph_mgr  the ir_graph pass manager to be added
82  */
83 FIRM_API void ir_prog_pass_mgr_add_graph_mgr(ir_prog_pass_manager_t *mgr,
84                                             ir_graph_pass_manager_t *graph_mgr);
85
86 /**
87  * Adds an ir_graph_pass as a pass to an ir_prog pass manager.
88  *
89  * @param mgr   the ir_prog pass manager
90  * @param pass  the ir_graph pass to be added
91  */
92 FIRM_API void ir_prog_pass_mgr_add_graph_pass(ir_prog_pass_manager_t *mgr,
93                                               ir_graph_pass_t *pass);
94
95 /**
96  * Runs all passes of an ir_prog pass manager.
97  *
98  * @param mgr   the manager
99  *
100  * @return 0 if all passes return 0, else 1
101  */
102 FIRM_API int ir_prog_pass_mgr_run(ir_prog_pass_manager_t *mgr);
103
104 /**
105  * Terminates an ir_prog pass manager and all owned passes.
106  *
107  * @param mgr   the manager
108  */
109 FIRM_API void term_prog_pass_mgr(ir_prog_pass_manager_t *mgr);
110
111 /**
112  * Sets the run index for an irgraph pass manager.
113  *
114  * @param mgr      the manager
115  * @param run_idx  the index for the first pass of this manager
116  */
117 FIRM_API void ir_graph_pass_mgr_set_run_idx(
118         ir_graph_pass_manager_t *mgr, unsigned run_idx);
119
120 /**
121  * Creates an ir_graph pass for running void function(ir_graph *irg).
122  * Uses the default verifier and dumper.
123  * The pass returns always 0.
124  *
125  * @param name      the name of this pass
126  * @param function  the function to run
127  *
128  * @return  the newly created ir_graph pass
129  */
130 FIRM_API ir_graph_pass_t *def_graph_pass(
131         const char *name, void (*function)(ir_graph *irg));
132
133 /**
134  * Creates an ir_graph pass for running int function(ir_graph *irg).
135  * Uses the default verifier and dumper.
136  * The pass returns the return value of function.
137  *
138  * @param name      the name of this pass
139  * @param function  the function to run
140  *
141  * @return  the newly created ir_graph pass
142  */
143 FIRM_API ir_graph_pass_t *def_graph_pass_ret(
144         const char *name, int (*function)(ir_graph *irg));
145
146 /**
147  * Creates an ir_graph pass for running int function(ir_graph *irg).
148  * Uses the default verifier and dumper.
149  * The pass returns the return value of function.
150  *
151  * @param memory    if non-NULL, an already allocated ir_graph_pass_t
152  * @param name      the name of this pass
153  * @param function  the function to run
154  *
155  * @return  the newly created ir_graph pass
156  */
157 FIRM_API ir_graph_pass_t *def_graph_pass_constructor(
158         ir_graph_pass_t *memory,
159         const char *name, int (*function)(ir_graph *irg, void *context));
160
161 /**
162  * Sets the run_parallel property of a graph pass.
163  * If the flag is set to non-zero, the pass can be executed
164  * parallel on all graphs of a ir_prog.
165  *
166  * @param pass  the pass
167  * @param flag  new flag setting
168  */
169 FIRM_API void ir_graph_pass_set_parallel(ir_graph_pass_t *pass, int flag);
170
171 /**
172  * Creates an ir_prog pass for running void function().
173  * Uses the default verifier and dumper.
174  * The pass returns always 0.
175  *
176  * @param name      the name of this pass
177  * @param function  the function to run
178  *
179  * @return  the newly created ir_graph pass
180  */
181 FIRM_API ir_prog_pass_t *def_prog_pass(
182         const char *name, void (*function)(void));
183
184 /**
185  * Creates an ir_prog pass for running void function().
186  * Uses the default verifier and dumper.
187  * The pass returns always 0.
188  *
189  * @param memory    if non-NULL, an already allocated ir_prog_pass_t
190  * @param name      the name of this pass
191  * @param function  the function to run
192  *
193  * @return  the newly created ir_prog pass
194  */
195 FIRM_API ir_prog_pass_t *def_prog_pass_constructor(
196         ir_prog_pass_t *memory,
197         const char *name, int (*function)(ir_prog *irp, void *context));
198
199 /**
200  * Creates a pass that calls some function.
201  * This pass calls the given function, but has no dump nor verify.
202  *
203  * @param name      the name of this pass
204  * @param function  the function to run
205  * @param context   context parameter
206  *
207  * @return  the newly created ir_prog pass
208  */
209 FIRM_API ir_prog_pass_t *call_function_pass(
210         const char *name, void (*function)(void *context), void *context);
211
212 /**
213  * Sets the run index for an irprog pass manager.
214  *
215  * @param mgr      the manager
216  * @param run_idx  the index for the first pass of this manager
217  */
218 FIRM_API void ir_prog_pass_mgr_set_run_idx(
219         ir_prog_pass_manager_t *mgr, unsigned run_idx);
220
221 #include "end.h"
222
223 #endif