2 * This file is part of libFirm.
3 * Copyright (C) 2012 University of Karlsruhe.
5 #ifndef FIRM_IR_PASS_T_H
6 #define FIRM_IR_PASS_T_H
10 * @brief Manager for optimization passes. Private Header
11 * @author Michael Beck
13 #include "firm_types.h"
14 #include "firm_common.h"
19 * Pass function on an ir_graph.
21 typedef int (*RUN_ON_IRG_FUNC)(ir_graph *irg, void *ctx);
24 * Dump function on an ir_graph.
26 typedef void (*DUMP_ON_IRG_FUNC)(ir_graph *irg, void *ctx, unsigned idx);
29 * Pass function on an ir_prog.
31 typedef int (*RUN_ON_IRPROG_FUNC)(ir_prog *prog, void *ctx);
34 * Dump function on an ir_prog.
36 typedef void (*DUMP_ON_IRPROG_FUNC)(ir_prog *irg, void *ctx, unsigned idx);
39 * Init/Term function on an pass.
41 typedef void (*INIT_TERM_FUNC)(void *ctx);
46 struct ir_graph_pass_t {
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;
59 /** context parameter for this pass */
62 /** The name of the pass. */
65 /** Links all passes. */
68 unsigned run_parallel:1; /**< if set this pass can run parallel on all graphs. */
74 struct ir_prog_pass_t {
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;
87 /** context parameter for this pass */
90 /** The name of the pass. */
93 /** Links all passes */
96 unsigned is_wrapper:1; /**< set if this is a wrapper pass. */
100 * An ir_graph pass manager.
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. */
113 * An ir_prog pass manager.
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. */
126 * Ensure that no verifier is run an ir_prog pass.
128 int ir_prog_no_verify(ir_prog *prog, void *ctx);
131 * Ensure that no dumper is run from an ir_prog pass.
133 void ir_prog_no_dump(ir_prog *prog, void *ctx, unsigned idx);