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