*/
void optimize_cf(ir_graph *irg);
+/**
+ * Creates an ir_graph pass for optimize_cf().
+ *
+ * @param name the name of this pass or NULL
+ * @param verify should this pass be verified?
+ * @param dump should this pass result be dumped?
+ *
+ * @return the newly created ir_graph pass
+ */
+ir_graph_pass_t *optimize_cf_pass(const char *name, int verify, int dump);
+
/**
* Perform path-sensitive jump threading on the given graph.
*
*/
void opt_jumpthreading(ir_graph* irg);
+/**
+ * Creates an ir_graph pass for opt_jumpthreading().
+ *
+ * @param name the name of this pass or NULL
+ * @param verify should this pass be verified?
+ * @param dump should this pass result be dumped?
+ *
+ * @return the newly created ir_graph pass
+ */
+ir_graph_pass_t *opt_jumpthreading_pass(const char *name, int verify, int dump);
+
/**
* Try to simplify boolean expression in the given ir graph.
* eg. x < 5 && x < 6 becomes x < 5
*/
void opt_bool(ir_graph *irg);
+/**
+ * Creates an ir_graph pass for opt_bool().
+ *
+ * @param name the name of this pass or NULL
+ * @param verify should this pass be verified?
+ * @param dump should this pass result be dumped?
+ *
+ * @return the newly created ir_graph pass
+ */
+ir_graph_pass_t *opt_bool_pass(const char *name, int verify, int dump);
+
/**
* Try to reduce the number of conv nodes in the given ir graph.
*
*/
int conv_opt(ir_graph *irg);
+/**
+ * Creates an ir_graph pass for conv_opt().
+ *
+ * @param name the name of this pass or NULL
+ * @param verify should this pass be verified?
+ * @param dump should this pass result be dumped?
+ *
+ * @return the newly created ir_graph pass
+ */
+ir_graph_pass_t *conv_opt_pass(const char *name, int verify, int dump);
+
/**
* Do the scalar replacement optimization.
* Make a date flow analyze and split the
*/
void optimize_funccalls(int force_run, check_alloc_entity_func callback);
+/**
+ * Creates an ir_prog pass for optimize_funccalls().
+ *
+ * @param name the name of this pass or NULL
+ * @param verify should this pass be verified?
+ * @param dump should this pass result be dumped?
+ * @param force_run if non-zero, an optimization run is started even
+ * if no const function graph was detected.
+ * Else calls are only optimized if at least one
+ * const function graph was detected.
+ * @param callback a callback function to check whether a
+ * given entity is a allocation call
+ *
+ * @return the newly created ir_prog pass
+ */
+ir_prog_pass_t *optimize_funccalls_pass(
+ const char *name, int verify, int dump,
+ int force_run, check_alloc_entity_func callback);
+
/**
* Does Partial Redundancy Elimination combined with
* Global Value Numbering.
*/
void do_gvn_pre(ir_graph *irg);
+/**
+ * Creates an ir_graph pass for do_gvn_pre().
+ *
+ * @param name the name of this pass or NULL
+ * @param verify should this pass be verified?
+ * @param dump should this pass result be dumped?
+ *
+ * @return the newly created ir_graph pass
+ */
+ir_graph_pass_t *do_gvn_pre_pass(const char *name, int verify, int dump);
+
/**
* This function is called to evaluate, if a mux can build
* of the current architecture.
*/
void opt_if_conv(ir_graph *irg, const ir_settings_if_conv_t *params);
+/**
+ * Creates an ir_graph pass for opt_if_conv().
+ *
+ * @param name the name of this pass or NULL
+ * @param verify should this pass be verified?
+ * @param dump should this pass result be dumped?
+ * @param params The parameters for the if conversion.
+ *
+ * @return the newly created ir_graph pass
+ */
+ir_graph_pass_t *opt_if_conv_pass(
+ const char *name, int verify, int dump, const ir_settings_if_conv_t *params);
+
void opt_sync(ir_graph *irg);
/*
#include "irbackedge_t.h"
#include "irtools.h"
#include "irprintf.h"
+#include "irpass_t.h"
/* the famous clear_link implementation. */
void firm_clear_link(ir_node *n, void *env) {
ir_fprintf(stderr, "%+F\n", obj);
}
}
+
+/**
+ * Wrapper for running void function(ir_graph *irg) as an ir_graph pass.
+ */
+static int void_pass_wrapper(ir_graph *irg, void *context) {
+ void (*function)(ir_graph *irg) = context;
+ function(irg);
+ return 0;
+} /* void_pass_wrapper */
+
+/* Creates an ir_graph pass for running void function(ir_graph *irg). */
+ir_graph_pass_t *def_graph_pass(
+ const char *name, int verify, int dump,
+ void (*function)(ir_graph *irg))
+{
+ struct ir_graph_pass_t *pass = XMALLOCZ(ir_graph_pass_t);
+
+ pass->kind = k_ir_prog_pass;
+ pass->run_on_irg = void_pass_wrapper;
+ pass->context = function;
+ pass->name = name;
+ pass->verify = verify != 0;
+ pass->dump = dump != 0;
+
+ INIT_LIST_HEAD(&pass->list);
+
+ return pass;
+} /* def_graph_pass */
+
+/**
+ * Wrapper for running void function(ir_graph *irg) as an ir_graph pass.
+ */
+static int int_pass_wrapper(ir_graph *irg, void *context) {
+ int (*function)(ir_graph *irg) = context;
+ return function(irg);
+} /* int_pass_wrapper */
+
+/* Creates an ir_graph pass for running void function(ir_graph *irg). */
+ir_graph_pass_t *def_graph_pass_ret(
+ const char *name, int verify, int dump,
+ int (*function)(ir_graph *irg))
+{
+ struct ir_graph_pass_t *pass = XMALLOCZ(ir_graph_pass_t);
+
+ pass->kind = k_ir_prog_pass;
+ pass->run_on_irg = int_pass_wrapper;
+ pass->context = function;
+ pass->name = name;
+ pass->verify = verify != 0;
+ pass->dump = dump != 0;
+
+ INIT_LIST_HEAD(&pass->list);
+
+ return pass;
+} /* def_graph_pass_ret */
*/
ir_node *exact_copy(const ir_node *n);
+/**
+ * Creates an ir_graph pass for running void function(ir_graph *irg).
+ * Uses the default verifier and dumper.
+ * The pass returns always 0.
+ *
+ * @param name the name of this pass
+ * @param verify should this pass be verified?
+ * @param dump should this pass result be dumped?
+ * @param params The parameters for the if conversion.
+ *
+ * @return the newly created ir_graph pass
+ */
+ir_graph_pass_t *def_graph_pass(
+ const char *name, int verify, int dump,
+ void (*function)(ir_graph *irg));
+
+/**
+ * Creates an ir_graph pass for running int function(ir_graph *irg).
+ * Uses the default verifier and dumper.
+ * The pass returns the return value of function.
+ *
+ * @param name the name of this pass
+ * @param verify should this pass be verified?
+ * @param dump should this pass result be dumped?
+ * @param params The parameters for the if conversion.
+ *
+ * @return the newly created ir_graph pass
+ */
+ir_graph_pass_t *def_graph_pass_ret(
+ const char *name, int verify, int dump,
+ int (*function)(ir_graph *irg));
+
#endif
return changed;
}
-/**
- * Wrapper for running optimize_graph_df() as an ir_graph pass.
- */
-static int pass_wrapper(ir_graph *irg, void *context) {
- (void)context;
- return optimize_graph_df(irg);
-} /* pass_wrapper */
-
/* Creates an ir_graph pass for optimize_graph_df. */
-ir_graph_pass_t *optimize_graph_df_pass(const char *name, int verify, int dump) {
- struct ir_graph_pass_t *pass = XMALLOCZ(ir_graph_pass_t);
-
- pass->kind = k_ir_prog_pass;
- pass->run_on_irg = pass_wrapper;
- pass->context = pass;
- pass->name = name ? name : "optimize_graph_df";
- pass->verify = verify != 0;
- pass->dump = dump != 0;
-
- INIT_LIST_HEAD(&pass->list);
-
- return pass;
-} /* combo_pass */
+ir_graph_pass_t *optimize_graph_df_pass(const char *name, int verify, int dump)
+{
+ return def_graph_pass_ret(name ? name : "optimize_graph_df", verify, dump, optimize_graph_df);
+} /* optimize_graph_df_pass */
#include "irprintf.h"
#include "irnode_t.h"
#include "tv.h"
+#include "irtools.h"
typedef struct cond_pair {
ir_node *cmp_lo;
ir_free_resources(irg, IR_RESOURCE_BLOCK_MARK | IR_RESOURCE_PHI_LIST);
}
+
+/* Creates an ir_graph pass for opt_bool. */
+ir_graph_pass_t *opt_bool_pass(const char *name, int verify, int dump)
+{
+ return def_graph_pass(name ? name : "opt_bool", verify, dump, opt_bool);
+} /* opt_bool_pass */
#include "irflag_t.h"
#include "firmstat.h"
+#include "irtools.h"
#include "iropt_dbg.h"
current_ir_graph = rem;
}
+
+/* Creates an ir_graph pass for optimize_cf. */
+ir_graph_pass_t *optimize_cf_pass(const char *name, int verify, int dump)
+{
+ return def_graph_pass(name ? name : "optimize_cf", verify, dump, optimize_cf);
+} /* optimize_cf_pass */
#include "irgraph_t.h"
#include "irnode_t.h"
#include "iropt_t.h"
-#include "irpass_t.h"
#include "irgwalk.h"
#include "irop.h"
#include "irouts.h"
#include "array_t.h"
#include "error.h"
#include "irnodeset.h"
-
+#include "irtools.h"
#include "tv_t.h"
#include "irprintf.h"
current_ir_graph = rem;
} /* combo */
-/**
- * Wrapper for running combo() as an ir_graph pass.
- */
-static int pass_wrapper(ir_graph *irg, void *context) {
- (void)context;
- combo(irg);
- /* combo is a fix-point iteration */
- return 0;
-} /* pass_wrapper */
-
/* Creates an ir_graph pass for combo. */
-ir_graph_pass_t *combo_pass(const char *name, int verify, int dump) {
- struct ir_graph_pass_t *pass = XMALLOCZ(ir_graph_pass_t);
-
- pass->kind = k_ir_prog_pass;
- pass->run_on_irg = pass_wrapper;
- pass->context = pass;
- pass->name = name ? name : "combo";
- pass->verify = verify != 0;
- pass->dump = dump != 0;
-
- INIT_LIST_HEAD(&pass->list);
-
- return pass;
+ir_graph_pass_t *combo_pass(const char *name, int verify, int dump)
+{
+ return def_graph_pass(name ? name : "combo", verify, dump, combo);
} /* combo_pass */
#include "iredges_t.h"
#include "irgwalk.h"
#include "irprintf.h"
+#include "irtools.h"
DEBUG_ONLY(static firm_dbg_module_t *dbg);
}
return invalidate;
}
+
+/* Creates an ir_graph pass for conv_opt. */
+ir_graph_pass_t *conv_opt_pass(const char *name, int verify, int dump)
+{
+ return def_graph_pass_ret(name ? name : "conv_opt", verify, dump, conv_opt);
+} /* conv_opt_pass */
#include "irloop_t.h"
#include "ircons.h"
#include "iredges_t.h"
+#include "irpass_t.h"
#include "analyze_irg_args.h"
#include "irhooks.h"
#include "debug.h"
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_graph *irg, void *context) {
+ struct pass_t *pass = context;
+ 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 verify, int dump,
+ int force_run, check_alloc_entity_func callback)
+{
+ struct pass_t *pass = xmalloc(sizeof(*pass));
+
+ pass->pass.kind = k_ir_prog_pass;
+ pass->pass.run_on_irprog = pass_wrapper;
+ pass->pass.context = pass;
+ pass->pass.name = name ? name : "funccalls";
+ pass->pass.verify = verify != 0;
+ pass->pass.dump = dump != 0;
+
+ INIT_LIST_HEAD(&pass->pass.list);
+
+ pass->force_run = force_run;
+ pass->callback = callback;
+
+ return &pass->pass;
+} /* optimize_funccalls_pass */
#include "irgraph_t.h"
#include "irnode_t.h"
#include "iropt_t.h"
+#include "irtools.h"
/** Additional info we need for every block. */
typedef struct block_info {
set_irg_loopinfo_inconsistent(irg);
}
} /* do_gvn_pre */
+
+/* Creates an ir_graph pass for do_gvn_pre. */
+ir_graph_pass_t *do_gvn_pre_pass(const char *name, int verify, int dump)
+{
+ return def_graph_pass(name ? name : "gvn_pre", verify, dump, do_gvn_pre);
+} /* do_gvn_pre_pass */
#include "irgwalk.h"
#include "irtools.h"
#include "array_t.h"
+#include "irpass_t.h"
// debug
#include "irdump.h"
free_cdep(irg);
}
+
+struct pass_t {
+ ir_graph_pass_t pass;
+ const ir_settings_if_conv_t *params;
+};
+
+/**
+ * Wrapper for running opt_if_conv() as an ir_graph pass.
+ */
+static int pass_wrapper(ir_graph *irg, void *context) {
+ struct pass_t *pass = context;
+ opt_if_conv(irg, pass->params);
+ return 0;
+} /* pass_wrapper */
+
+ir_graph_pass_t *opt_if_conv_pass(
+ const char *name, int verify, int dump, const ir_settings_if_conv_t *params)
+{
+ struct pass_t *pass = xmalloc(sizeof(*pass));
+
+ pass->pass.kind = k_ir_prog_pass;
+ pass->pass.run_on_irg = pass_wrapper;
+ pass->pass.context = pass;
+ pass->pass.name = name;
+ pass->pass.verify = verify != 0;
+ pass->pass.dump = dump != 0;
+
+ pass->params = params;
+
+ INIT_LIST_HEAD(&pass->pass.list);
+
+ return &pass->pass;
+}
#include "tv.h"
#include "opt_confirms.h"
#include "iropt_dbg.h"
+#include "irtools.h"
#undef AVOID_PHIB
optimize_cf(irg);
}
}
+
+/* Creates an ir_graph pass for opt_jumpthreading. */
+ir_graph_pass_t *opt_jumpthreading_pass(const char *name, int verify, int dump)
+{
+ return def_graph_pass(name ? name : "jumpthreading", verify, dump, opt_jumpthreading);
+} /* opt_jumpthreading_pass */