X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fopt%2Ffunccall.c;h=2822dae4fb5f565b615837879c2ffefb5c99a733;hb=c59d37f47fdab6d74f1da6738b2d3f3373a378b9;hp=21ac4daaa7a0e1a74c13f33d9ea7268c20d628de;hpb=c05412296e3c502434a0dbe37c0b8eb2be7d73d0;p=libfirm diff --git a/ir/opt/funccall.c b/ir/opt/funccall.c index 21ac4daaa..2822dae4f 100644 --- a/ir/opt/funccall.c +++ b/ir/opt/funccall.c @@ -27,7 +27,7 @@ #include -#include "funccall_t.h" +#include "opt_init.h" #include "irnode_t.h" #include "irgraph_t.h" @@ -39,6 +39,8 @@ #include "irloop_t.h" #include "ircons.h" #include "iredges_t.h" +#include "irpass_t.h" +#include "iroptimize.h" #include "analyze_irg_args.h" #include "irhooks.h" #include "debug.h" @@ -153,10 +155,9 @@ static void collect_const_and_pure_calls(ir_node *node, void *env) { /* collect the Proj's in the Proj list */ switch (get_Proj_proj(node)) { - case pn_Call_M_regular: + case pn_Call_M: case pn_Call_X_except: case pn_Call_X_regular: - case pn_Call_M_except: set_irn_link(node, ctx->proj_list); ctx->proj_list = node; break; @@ -221,21 +222,20 @@ static void fix_const_call_lists(ir_graph *irg, env_t *ctx) { assert(get_irn_mode(mem) == mode_M); switch (get_Proj_proj(proj)) { - case pn_Call_M_regular: { + case pn_Call_M: { /* in dead code there might be cycles where proj == mem */ if (proj != mem) exchange(proj, mem); break; } case pn_Call_X_except: - case pn_Call_M_except: exc_changed = 1; exchange(proj, get_irg_bad(irg)); break; case pn_Call_X_regular: { ir_node *block = get_nodes_block(call); exc_changed = 1; - exchange(proj, new_r_Jmp(irg, block)); + exchange(proj, new_r_Jmp(block)); break; } default: @@ -319,10 +319,9 @@ static void collect_nothrow_calls(ir_node *node, void *env) { /* collect the Proj's in the Proj list */ switch (get_Proj_proj(node)) { - case pn_Call_M_regular: + case pn_Call_M: case pn_Call_X_except: case pn_Call_X_regular: - case pn_Call_M_except: set_irn_link(node, ctx->proj_list); ctx->proj_list = node; break; @@ -367,14 +366,13 @@ static void fix_nothrow_call_list(ir_graph *irg, ir_node *call_list, ir_node *pr /* kill any exception flow */ switch (get_Proj_proj(proj)) { case pn_Call_X_except: - case pn_Call_M_except: exc_changed = 1; exchange(proj, get_irg_bad(irg)); break; case pn_Call_X_regular: { ir_node *block = get_nodes_block(call); exc_changed = 1; - exchange(proj, new_r_Jmp(irg, block)); + exchange(proj, new_r_Jmp(block)); break; } default: @@ -1073,3 +1071,35 @@ void optimize_funccalls(int force_run, check_alloc_entity_func callback) void firm_init_funccalls(void) { FIRM_DBG_REGISTER(dbg, "firm.opt.funccalls"); } /* firm_init_funccalls */ + +struct pass_t { + ir_prog_pass_t pass; + int force_run; + check_alloc_entity_func callback; +}; + +/** + * Wrapper for running optimize_funccalls() as an ir_prog pass. + */ +static int pass_wrapper(ir_prog *irp, void *context) +{ + struct pass_t *pass = context; + + (void)irp; + optimize_funccalls(pass->force_run, pass->callback); + return 0; +} /* pass_wrapper */ + +/* Creates an ir_prog pass for optimize_funccalls. */ +ir_prog_pass_t *optimize_funccalls_pass( + const char *name, + int force_run, check_alloc_entity_func callback) +{ + struct pass_t *pass = XMALLOCZ(struct pass_t); + + pass->force_run = force_run; + pass->callback = callback; + + return def_prog_pass_constructor( + &pass->pass, name ? name : "funccall", pass_wrapper); +} /* optimize_funccalls_pass */