Commit d065b1e8 authored by Andreas Seltenreich's avatar Andreas Seltenreich
Browse files

Factor callback version opt_if_conv_cb() out of opt_if_conv().

This allows users - such as Special Instruction creation for
reconfigurable microarchitectures - to override the backend's
predicate.
parent fa6aa94c
......@@ -153,6 +153,17 @@ typedef int (*arch_allow_ifconv_func)(ir_node *sel, ir_node *mux_false,
*/
FIRM_API void opt_if_conv(ir_graph *irg);
/**
* Perform If conversion on a graph - callback version.
*
* @param irg The graph.
* @param callback The predicate.
*
* Like above, but let the caller decide about valid transformations
* by supplying a predicate function.
*/
FIRM_API void opt_if_conv_cb(ir_graph *irg, arch_allow_ifconv_func callback);
/**
* Tries to reduce dependencies for memory nodes where possible by parallelizing
* them and synchronizing with Sync nodes
......
......@@ -434,10 +434,12 @@ static void collect_phis(ir_node *node, void *env)
}
}
void opt_if_conv(ir_graph *irg)
void opt_if_conv_cb(ir_graph *irg, arch_allow_ifconv_func callback)
{
walker_env env;
const backend_params *be_params = be_get_backend_param();
env.allow_ifconv = callback;
env.changed = false;
assure_irg_properties(irg,
IR_GRAPH_PROPERTY_NO_CRITICAL_EDGES
......@@ -445,10 +447,6 @@ void opt_if_conv(ir_graph *irg)
| IR_GRAPH_PROPERTY_NO_BADS
| IR_GRAPH_PROPERTY_ONE_RETURN);
/* get the parameters */
env.allow_ifconv = be_params->allow_ifconv;
env.changed = false;
FIRM_DBG_REGISTER(dbg, "firm.opt.ifconv");
DB((dbg, LEVEL_1, "Running if-conversion on %+F\n", irg));
......@@ -473,3 +471,10 @@ void opt_if_conv(ir_graph *irg)
IR_GRAPH_PROPERTY_NO_CRITICAL_EDGES
| IR_GRAPH_PROPERTY_ONE_RETURN);
}
void opt_if_conv(ir_graph *irg)
{
const backend_params *be_params = be_get_backend_param();
/* get the parameters */
opt_if_conv_cb(irg, be_params->allow_ifconv);
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment