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