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