- fix most of the -Wunreachable-code and -Wlogical-op warnings
[libfirm] / ir / ir / irpass_t.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 #ifndef FIRM_IR_PASS_T_H
20 #define FIRM_IR_PASS_T_H
21
22 /**
23  * @file
24  * @brief     Manager for optimization passes. Private Header
25  * @author    Michael Beck
26  * @version   $Id$
27  */
28 #include "firm_types.h"
29 #include "firm_common.h"
30 #include "adt/list.h"
31 #include "irpass.h"
32
33 /**
34  * Pass function on an ir_graph.
35  */
36 typedef int (*RUN_ON_IRG_FUNC)(ir_graph *irg, void *ctx);
37
38 /**
39  * Dump function on an ir_graph.
40  */
41 typedef void (*DUMP_ON_IRG_FUNC)(ir_graph *irg, void *ctx, unsigned idx);
42
43 /**
44  * Pass function on an ir_prog.
45  */
46 typedef int (*RUN_ON_IRPROG_FUNC)(ir_prog *prog, void *ctx);
47
48 /**
49  * Dump function on an ir_prog.
50  */
51 typedef void (*DUMP_ON_IRPROG_FUNC)(ir_prog *irg, void *ctx, unsigned idx);
52
53 /**
54  * Init/Term function on an pass.
55  */
56 typedef void (*INIT_TERM_FUNC)(void *ctx);
57
58 /**
59  * An ir_sgraph pass.
60  */
61 struct ir_graph_pass_t {
62         /** The firm kind. */
63         firm_kind          kind;
64
65         /** This function is run on every graph on an ir_prog. */
66         RUN_ON_IRG_FUNC    run_on_irg;
67         RUN_ON_IRG_FUNC    verify_irg;
68         DUMP_ON_IRG_FUNC   dump_irg;
69         /** This function is called if this pass is added. */
70         INIT_TERM_FUNC     add_to_mgr;
71         /** This function is called if this pass is removed. */
72         INIT_TERM_FUNC     rem_from_mgr;
73
74         /** context parameter for this pass */
75         void               *context;
76
77         /** The name of the pass. */
78         const char         *name;
79
80         /** Links all passes. */
81         list_head          list;
82
83         unsigned run_parallel:1;       /**< if set this pass can run parallel on all graphs. */
84 };
85
86 /**
87  * An ir_prog pass.
88  */
89 struct ir_prog_pass_t {
90         /** The firm kind. */
91         firm_kind           kind;
92
93         /** This function is on an ir_prog. */
94         RUN_ON_IRPROG_FUNC  run_on_irprog;
95         RUN_ON_IRPROG_FUNC  verify_irprog;
96         DUMP_ON_IRPROG_FUNC dump_irprog;
97         /** This function is called if this pass is added. */
98         INIT_TERM_FUNC      add_to_mgr;
99         /** This function is called if this pass is removed. */
100         INIT_TERM_FUNC      rem_from_mgr;
101
102         /** context parameter for this pass */
103         void                *context;
104
105         /** The name of the pass. */
106         const char          *name;
107
108         /** Links all passes */
109         list_head           list;
110
111         unsigned is_wrapper:1; /**< set if this is a wrapper pass. */
112 };
113
114 /**
115  * An ir_graph pass manager.
116  */
117 struct ir_graph_pass_manager_t {
118         firm_kind  kind;           /**< The firm kind. */
119         list_head  passes;         /**< The list of passes. */
120         unsigned   n_passes;       /**< Number of added passes. */
121         const char *name;          /**< the name of the manager. */
122         unsigned   run_idx;        /**< The run number for the first pass of this manager. */
123         unsigned   verify_all:1;   /**< Set if every pass should be verified. */
124         unsigned   dump_all:1;     /**< Set if every pass should be dumped. */
125 };
126
127 /**
128  * An ir_prog pass manager.
129  */
130 struct ir_prog_pass_manager_t {
131         firm_kind  kind;           /**< The firm kind. */
132         list_head  passes;         /**< The list of passes. */
133         unsigned   n_passes;       /**< Number of added passes. */
134         const char *name;          /**< the name of the manager. */
135         unsigned   run_idx;        /**< The run number for the first pass of this manager. */
136         unsigned   verify_all:1;   /**< Set if every pass should be verified. */
137         unsigned   dump_all:1;     /**< Set if every pass should be dumped. */
138 };
139
140 /**
141  * Ensure that no verifier is run an ir_prog pass.
142  */
143 int ir_prog_no_verify(ir_prog *prog, void *ctx);
144
145 /**
146  * Ensure that no dumper is run from an ir_prog pass.
147  */
148 void ir_prog_no_dump(ir_prog *prog, void *ctx, unsigned idx);
149
150 #endif