Commit 30abccc0 authored by Michael Beck's avatar Michael Beck
Browse files

Add pass creating for loop inversion, unrolling, peeling and mux lowering.

[r27123]
parent 401e322a
......@@ -918,6 +918,33 @@ void do_loop_unrolling(ir_graph *irg);
*/
void do_loop_peeling(ir_graph *irg);
/**
* Creates an ir_graph pass for loop inversion.
*
* @param name the name of this pass or NULL
*
* @return the newly created ir_graph pass
*/
ir_graph_pass_t *loop_inversion_pass(const char *name);
/**
* Creates an ir_graph pass for loop unrolling.
*
* @param name the name of this pass or NULL
*
* @return the newly created ir_graph pass
*/
ir_graph_pass_t *loop_unroll_pass(const char *name);
/**
* Creates an ir_graph pass for loop peeling.
*
* @param name the name of this pass or NULL
*
* @return the newly created ir_graph pass
*/
ir_graph_pass_t *loop_peeling_pass(const char *name);
typedef ir_type *(*get_Alloc_func)(ir_node *n);
/** Set a new get_Alloc_func and returns the old one. */
get_Alloc_func firm_set_Alloc_func(get_Alloc_func newf);
......
......@@ -325,6 +325,17 @@ typedef int lower_mux_callback(ir_node* mux);
*/
void lower_mux(ir_graph *irg, lower_mux_callback *cb_func);
/**
* Creates an ir_graph pass for lower_mux().
*
* @param name the name of this pass or NULL
* @param cb_func The callback function for mux selection. Can be NULL,
* to lower all mux nodes.
*
* @return the newly created ir_graph pass
*/
ir_graph_pass_t *lower_mux_pass(const char *name, lower_mux_callback *cb_func);
/**
* An intrinsic mapper function.
*
......
......@@ -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,27 @@ 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);
}
......@@ -39,6 +39,7 @@
#include "array_t.h" /* automatic array */
#include "beutil.h" /* get_block */
#include "irloop_t.h" /* set_irn_loop*/
#include "irpass.h"
#if 0
#include "irdump_t.h"
......@@ -1581,6 +1582,18 @@ void do_loop_peeling(ir_graph *irg)
}
ir_graph_pass_t *loop_inversion_pass(const char *name) {
return def_graph_pass(name ? name : "loop_inversion", do_loop_inversion);
}
ir_graph_pass_t *loop_unroll_pass(const char *name) {
return def_graph_pass(name ? name : "loop_unroll", do_loop_unrolling);
}
ir_graph_pass_t *loop_peeling_pass(const char *name) {
return def_graph_pass(name ? name : "loop_peeling", do_loop_peeling);
}
void firm_init_loop_opt(void)
{
FIRM_DBG_REGISTER(dbg, "firm.opt.loop");
......
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