X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Flower%2Flower_mux.c;h=b9654429990203a2150e961ebb443137d1d4c68b;hb=bf9be89cbbf5d6ca1b80fd5736b80f47c1a14e90;hp=1a676b6a5b758d77d90b57599c61d56eb55db426;hpb=35099ea6c11611260e43beb02a413aca6c499c19;p=libfirm diff --git a/ir/lower/lower_mux.c b/ir/lower/lower_mux.c index 1a676b6a5..b96544299 100644 --- a/ir/lower/lower_mux.c +++ b/ir/lower/lower_mux.c @@ -35,6 +35,7 @@ #include "irgmod.h" #include "ircons.h" #include "irvrfy.h" +#include "irpass_t.h" typedef struct walk_env { lower_mux_callback *cb_func; @@ -144,3 +145,28 @@ void lower_mux(ir_graph *irg, lower_mux_callback *cb_func) } DEL_ARR_F(env.muxes); } + +struct pass_t { + ir_graph_pass_t pass; + lower_mux_callback *cb_func; +}; + +/** + * Wrapper to run ir_lower_mux() as an ir_graph pass + */ +static int pass_wrapper(ir_graph *irg, void *context) +{ + struct pass_t *pass = context; + + lower_mux(irg, pass->cb_func); + return 0; +} + +ir_graph_pass_t *lower_mux_pass(const char *name, lower_mux_callback *cb_func) +{ + struct pass_t *pass = XMALLOCZ(struct pass_t); + + pass->cb_func = cb_func; + return def_graph_pass_constructor( + &pass->pass, name ? name : "lower_mux", pass_wrapper); +}