Commit 18329a03 authored by Matthias Braun's avatar Matthias Braun
Browse files

remove return values from graph transformations

Noone was really using the return values anyway. This change makes the
API more consistent.
parent 4c1ef8f3
......@@ -77,19 +77,15 @@ FIRM_API void remove_unreachable_code(ir_graph *irg);
* Removes all Bad nodes from a graph.
*
* @param irg The graph to be optimized.
*
* @return non-zero if at least one Bad was removed, otherwise 0
*/
FIRM_API int remove_bads(ir_graph *irg);
FIRM_API void remove_bads(ir_graph *irg);
/**
* Removes all Tuple nodes from a graph.
*
* @param irg The graph to be optimized.
*
* @return non-zero if at least one Tuple was removed, otherwise 0
*/
FIRM_API int remove_tuples(ir_graph *irg);
FIRM_API void remove_tuples(ir_graph *irg);
/**
* Creates an ir_graph pass for optimize_graph_df().
......
......@@ -92,10 +92,8 @@ FIRM_API ir_graph_pass_t *opt_bool_pass(const char *name);
* Reduces the number of Conv nodes in the given ir graph.
*
* @param irg the graph
*
* @return non-zero if the optimization could be applied, 0 else
*/
FIRM_API int conv_opt(ir_graph *irg);
FIRM_API void conv_opt(ir_graph *irg);
/**
* Creates an ir_graph pass for conv_opt().
......@@ -285,10 +283,8 @@ FIRM_API ir_node *can_replace_load_by_const(const ir_node *load, ir_node *c);
*
* Store after Load: A Store after a Load is removed, if the
* Store doesn't have an exception handler.
*
* @return non-zero if the optimization could be applied, 0 else
*/
FIRM_API int optimize_load_store(ir_graph *irg);
FIRM_API void optimize_load_store(ir_graph *irg);
/**
* Creates an ir_graph pass for optimize_load_store().
......@@ -304,7 +300,7 @@ FIRM_API ir_graph_pass_t *optimize_load_store_pass(const char *name);
* Based on a dataflow analysis, so load/stores are moved out of loops
* where possible
*/
FIRM_API int opt_ldst(ir_graph *irg);
FIRM_API void opt_ldst(ir_graph *irg);
/**
* Creates an ir_graph pass for opt_ldst().
......@@ -491,10 +487,8 @@ FIRM_API ir_prog_pass_t *proc_cloning_pass(const char *name, float threshold);
*
* See Muchnik 12.3.1 Algebraic Simplification and Reassociation of
* Addressing Expressions.
*
* @return non-zero if the optimization could be applied, 0 else
*/
FIRM_API int optimize_reassociation(ir_graph *irg);
FIRM_API void optimize_reassociation(ir_graph *irg);
/**
* Creates an ir_graph pass for optimize_reassociation().
......@@ -573,10 +567,8 @@ FIRM_API ir_graph_pass_t *normalize_n_returns_pass(const char *name);
* with atomic values if possible. Does not handle classes yet.
*
* @param irg the graph which should be optimized
*
* @return non-zero, if at least one entity was replaced
*/
FIRM_API int scalar_replacement_opt(ir_graph *irg);
FIRM_API void scalar_replacement_opt(ir_graph *irg);
/**
* Creates an ir_graph pass for scalar_replacement_opt().
......@@ -600,10 +592,8 @@ FIRM_API ir_graph_pass_t *scalar_replacement_opt_pass(const char *name);
* Does not work for Calls that use the exception stuff.
*
* @param irg the graph to be optimized
*
* @return non-zero if the optimization could be applied, 0 else
*/
FIRM_API int opt_tail_rec_irg(ir_graph *irg);
FIRM_API void opt_tail_rec_irg(ir_graph *irg);
/**
* Creates an ir_graph pass for opt_tail_rec_irg().
......@@ -834,10 +824,8 @@ FIRM_API ir_prog_pass_t *inline_functions_pass(const char *name,
* Combines congruent blocks into one.
*
* @param irg The IR-graph to optimize.
*
* @return non-zero if the graph was transformed
*/
FIRM_API int shape_blocks(ir_graph *irg);
FIRM_API void shape_blocks(ir_graph *irg);
/**
* Creates an ir_graph pass for shape_blocks().
......
......@@ -125,7 +125,7 @@ static void collect(ir_node *node, void *env)
}
}
int remove_bads(ir_graph *irg)
void remove_bads(ir_graph *irg)
{
size_t i;
size_t n_to_process;
......@@ -145,8 +145,5 @@ int remove_bads(ir_graph *irg)
edges_deactivate(irg);
clear_irg_properties(irg, IR_GRAPH_PROPERTY_CONSISTENT_OUTS);
clear_irg_properties(irg, IR_GRAPH_PROPERTY_CONSISTENT_DOMINANCE);
return 1;
}
return 0;
}
......@@ -39,9 +39,9 @@
*/
static void exchange_tuple_projs(ir_node *node, void *env)
{
bool *changed = (bool*)env;
ir_node *pred;
int proj;
(void)env;
if (!is_Proj(node)) return;
......@@ -52,12 +52,9 @@ static void exchange_tuple_projs(ir_node *node, void *env)
pred = get_Tuple_pred(pred, proj);
exchange(node, pred);
*changed = true;
}
int remove_tuples(ir_graph *irg)
void remove_tuples(ir_graph *irg)
{
bool changed = 0;
irg_walk_graph(irg, exchange_tuple_projs, NULL, &changed);
return changed;
irg_walk_graph(irg, exchange_tuple_projs, NULL, NULL);
}
......@@ -325,16 +325,15 @@ static optdesc_t opt_deconv = {
do_deconv,
};
int conv_opt(ir_graph *irg)
void conv_opt(ir_graph *irg)
{
perform_irg_optimization(irg, &opt_deconv);
return 1;
}
/* Creates an ir_graph pass for conv_opt. */
ir_graph_pass_t *conv_opt_pass(const char *name)
{
ir_graph_pass_t *path = def_graph_pass_ret(name ? name : "conv_opt", conv_opt);
ir_graph_pass_t *path = def_graph_pass(name ? name : "conv_opt", conv_opt);
/* safe to run parallel on all irgs */
ir_graph_pass_set_parallel(path, 1);
......
......@@ -2128,13 +2128,12 @@ static optdesc_t opt_loadstore = {
do_loadstore_opt,
};
int optimize_load_store(ir_graph *irg)
void optimize_load_store(ir_graph *irg)
{
perform_irg_optimization(irg, &opt_loadstore);
return 1;
}
ir_graph_pass_t *optimize_load_store_pass(const char *name)
{
return def_graph_pass_ret(name ? name : "ldst", optimize_load_store);
return def_graph_pass(name ? name : "ldst", optimize_load_store);
} /* optimize_load_store_pass */
......@@ -1192,7 +1192,7 @@ static void add_roots(ir_graph *irg, environment_t *env)
#endif /* GENERAL_SHAPE */
/* Combines congruent end blocks into one. */
int shape_blocks(ir_graph *irg)
void shape_blocks(ir_graph *irg)
{
environment_t env;
partition_t *part;
......@@ -1270,11 +1270,9 @@ int shape_blocks(ir_graph *irg)
DEL_ARR_F(env.live_outs);
del_set(env.opcode2id_map);
obstack_free(&env.obst, NULL);
return res;
} /* shape_blocks */
ir_graph_pass_t *shape_blocks_pass(const char *name)
{
return def_graph_pass_ret(name ? name : "shape_blocks", shape_blocks);
return def_graph_pass(name ? name : "shape_blocks", shape_blocks);
} /* shape_blocks_pass */
......@@ -2157,7 +2157,7 @@ static void kill_unreachable_blocks(ir_graph *irg)
}
} /* kill_unreachable_blocks */
int opt_ldst(ir_graph *irg)
void opt_ldst(ir_graph *irg)
{
block_t *bl;
......@@ -2295,11 +2295,9 @@ end:
#ifdef DEBUG_libfirm
DEL_ARR_F(env.id_2_address);
#endif
return env.changed != 0;
} /* opt_ldst */
ir_graph_pass_t *opt_ldst_pass(const char *name)
{
return def_graph_pass_ret(name ? name : "ldst_df", opt_ldst);
return def_graph_pass(name ? name : "ldst_df", opt_ldst);
} /* opt_ldst_pass */
......@@ -921,7 +921,7 @@ static void reverse_rules(ir_node *node, void *env)
/*
* do the reassociation
*/
int optimize_reassociation(ir_graph *irg)
void optimize_reassociation(ir_graph *irg)
{
walker_t env;
......@@ -964,13 +964,12 @@ int optimize_reassociation(ir_graph *irg)
#endif
del_waitq(env.wq);
return env.changes;
} /* optimize_reassociation */
/* create a pass for the reassociation */
ir_graph_pass_t *optimize_reassociation_pass(const char *name)
{
return def_graph_pass_ret(name ? name : "reassoc", optimize_reassociation);
return def_graph_pass(name ? name : "reassoc", optimize_reassociation);
} /* optimize_reassociation_pass */
/* Sets the default reassociation operation for an ir_op_ops. */
......
......@@ -773,16 +773,14 @@ static optdesc_t opt_scalar_rep = {
do_scalar_replacement,
};
int scalar_replacement_opt(ir_graph *irg)
void scalar_replacement_opt(ir_graph *irg)
{
perform_irg_optimization(irg, &opt_scalar_rep);
return 1;
}
ir_graph_pass_t *scalar_replacement_opt_pass(const char *name)
{
return def_graph_pass_ret(name ? name : "scalar_rep",
scalar_replacement_opt);
return def_graph_pass(name ? name : "scalar_rep", scalar_replacement_opt);
}
void firm_init_scalar_replace(void)
......
......@@ -701,14 +701,14 @@ static optdesc_t opt_tailrec = {
do_tailrec,
};
int opt_tail_rec_irg(ir_graph *irg) {
void opt_tail_rec_irg(ir_graph *irg)
{
perform_irg_optimization(irg, &opt_tailrec);
return 1; /* conservatively report changes */
}
ir_graph_pass_t *opt_tail_rec_irg_pass(const char *name)
{
return def_graph_pass_ret(name ? name : "tailrec", opt_tail_rec_irg);
return def_graph_pass(name ? name : "tailrec", opt_tail_rec_irg);
}
/*
......@@ -717,20 +717,14 @@ ir_graph_pass_t *opt_tail_rec_irg_pass(const char *name)
void opt_tail_recursion(void)
{
size_t i, n;
size_t n_opt_applications = 0;
FIRM_DBG_REGISTER(dbg, "firm.opt.tailrec");
DB((dbg, LEVEL_1, "Performing tail recursion ...\n"));
for (i = 0, n = get_irp_n_irgs(); i < n; ++i) {
ir_graph *irg = get_irp_irg(i);
if (opt_tail_rec_irg(irg))
++n_opt_applications;
opt_tail_rec_irg(irg);
}
DB((dbg, LEVEL_1, "Done for %zu of %zu graphs.\n",
n_opt_applications, get_irp_n_irgs()));
}
ir_prog_pass_t *opt_tail_recursion_pass(const char *name)
......
Markdown is supported
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