2 * Copyright (C) 1995-2009 University of Karlsruhe. All right reserved.
4 * This file is part of libFirm.
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.
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.
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
22 * @brief Manager for transformation passes.
23 * @author Michael Beck
26 #ifndef FIRM_IR_PASS_H
27 #define FIRM_IR_PASS_H
29 #include "firm_types.h"
32 * Creates a new ir_graph pass manager.
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
38 * @return the newly created manager
40 ir_graph_pass_manager_t *new_graph_pass_mgr(
41 const char *name, int verify_all, int dump_all);
44 * Add an ir_graph pass to a graph pass manager.
46 * @param mgr the ir_graph pass manager
47 * @param pass the pass to add
49 void ir_graph_pass_mgr_add(ir_graph_pass_manager_t *mgr, ir_graph_pass_t *pass);
52 * Run all passes of an ir_graph pass manager.
54 * @param mgr the manager
56 * @return 0 if all passes return 0, else 1
58 int ir_graph_pass_mgr_run(ir_graph_pass_manager_t *mgr);
61 * Terminate an ir_graph pass manager and all owned passes.
63 * @param mgr the manager
65 void term_graph_pass_mgr(ir_graph_pass_manager_t *mgr);
68 * Creates a new ir_prog pass manager.
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
74 * @return the newly created manager
76 ir_prog_pass_manager_t *new_prog_pass_mgr(
77 const char *name, int verify_all, int dump_all);
80 * Add an ir_prog pass to an ir_prog pass manager.
82 * @param mgr the ir_prog pass manager
83 * @param pass the pass to add
85 void ir_prog_pass_mgr_add(ir_prog_pass_manager_t *mgr, ir_prog_pass_t *pass);
88 * Add an ir_graph_pass_manager as a pass to an ir_prog pass manager.
90 * @param mgr the ir_prog pass manager
91 * @param graph_mgr the ir_graph pass manager to be added
93 void ir_prog_pass_mgr_add_graph_mgr(
94 ir_prog_pass_manager_t *mgr, ir_graph_pass_manager_t *graph_mgr);
97 * Add an ir_graph_pass as a pass to an ir_prog pass manager.
99 * @param mgr the ir_prog pass manager
100 * @param pass the ir_graph pass to be added
102 void ir_prog_pass_mgr_add_graph_pass(
103 ir_prog_pass_manager_t *mgr, ir_graph_pass_t *pass);
106 * Run all passes of an ir_prog pass manager.
108 * @param mgr the manager
110 * @return 0 if all passes return 0, else 1
112 int ir_prog_pass_mgr_run(ir_prog_pass_manager_t *mgr);
115 * Terminate an ir_prog pass manager and all owned passes.
117 * @param mgr the manager
119 void term_prog_pass_mgr(ir_prog_pass_manager_t *mgr);
122 * Creates an ir_graph pass for running void function(ir_graph *irg).
123 * Uses the default verifier and dumper.
124 * The pass returns always 0.
126 * @param name the name of this pass
127 * @param function the function to run
129 * @return the newly created ir_graph pass
131 ir_graph_pass_t *def_graph_pass(
132 const char *name, void (*function)(ir_graph *irg));
135 * Creates an ir_graph pass for running int function(ir_graph *irg).
136 * Uses the default verifier and dumper.
137 * The pass returns the return value of function.
139 * @param name the name of this pass
140 * @param function the function to run
142 * @return the newly created ir_graph pass
144 ir_graph_pass_t *def_graph_pass_ret(
145 const char *name, int (*function)(ir_graph *irg));
148 * Creates an ir_graph pass for running int function(ir_graph *irg).
149 * Uses the default verifier and dumper.
150 * The pass returns the return value of function.
152 * @param memory if non-NULL, an already allocated ir_graph_pass_t
153 * @param name the name of this pass
154 * @param function the function to run
156 * @return the newly created ir_graph pass
158 ir_graph_pass_t *def_graph_pass_constructor(
159 ir_graph_pass_t *memory,
160 const char *name, int (*function)(ir_graph *irg, void *context));
163 * Creates an ir_prog pass for running void function().
164 * Uses the default verifier and dumper.
165 * The pass returns always 0.
167 * @param name the name of this pass
168 * @param function the function to run
170 * @return the newly created ir_graph pass
172 ir_prog_pass_t *def_prog_pass(
173 const char *name, void (*function)(void));
176 * Creates an ir_prog pass for running void function().
177 * Uses the default verifier and dumper.
178 * The pass returns always 0.
180 * @param memory if non-NULL, an already allocated ir_prog_pass_t
181 * @param name the name of this pass
182 * @param function the function to run
184 * @return the newly created ir_graph pass
186 ir_prog_pass_t *def_prog_pass_constructor(
187 ir_prog_pass_t *memory,
188 const char *name, void (*function)(ir_prog *irp, void *context));