* Creates an ir_graph pass for construct_confirms().
*
* @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 *construct_confirms_pass(const char *name, int verify, int dump);
+ir_graph_pass_t *construct_confirms_pass(const char *name);
/**
* Remove all Confirm nodes from a graph.
* Creates an ir_graph pass for remove_confirms().
*
* @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 *remove_confirms_pass(const char *name, int verify, int dump);
+ir_graph_pass_t *remove_confirms_pass(const char *name);
#endif
* 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
*/
*/
void term_prog_pass_mgr(ir_prog_pass_manager_t *mgr);
+/**
+ * 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 function the function to run
+ *
+ * @return the newly created ir_graph pass
+ */
+ir_graph_pass_t *def_graph_pass(
+ const char *name, 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 function the function to run
+ *
+ * @return the newly created ir_graph pass
+ */
+ir_graph_pass_t *def_graph_pass_ret(
+ const char *name, int (*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 memory if non-NULL, an already allocated ir_graph_pass_t
+ * @param name the name of this pass
+ * @param function the function to run
+ *
+ * @return the newly created ir_graph pass
+ */
+ir_graph_pass_t *def_graph_pass_constructor(
+ ir_graph_pass_t *memory,
+ const char *name, int (*function)(ir_graph *irg, void *context));
+
+/**
+ * Creates an ir_prog pass for running void function().
+ * Uses the default verifier and dumper.
+ * The pass returns always 0.
+ *
+ * @param name the name of this pass
+ * @param function the function to run
+ *
+ * @return the newly created ir_graph pass
+ */
+ir_prog_pass_t *def_prog_pass(
+ const char *name, void (*function)(void));
+
#endif
/*
- * Copyright (C) 1995-2008 University of Karlsruhe. All right reserved.
+ * Copyright (C) 1995-2009 University of Karlsruhe. All right reserved.
*
* This file is part of libFirm.
*
* Flags for irg_verify().
*/
typedef enum _irg_verify_flags_t {
- VRFY_NORMAL = 0, /**< check SSA property only if dominance information is available */
- VRFY_ENFORCE_SSA = 1 /**< check SSA property by enforcing the dominance information recalculation */
+ VRFY_NORMAL = 0, /**< check SSA property only if dominance information is available */
+ VRFY_ENFORCE_SSA = 1 /**< check SSA property by enforcing the dominance information recalculation */
} irg_verify_flags_t;
/**
* Calls irn_vrfy() for each node in irg.
* Graph must be in state "op_pin_state_pinned".
*
+ * @param irg the IR-graph t check
+ * @param flags one of irg_verify_flags_t
+ *
* @return
* NON-zero on success.
*/
*/
#define irg_vrfy(irg) irg_verify(irg, 0)
+/**
+ * Creates an ir_graph pass for irg_verify().
+ *
+ * @param name the name of this pass or NULL
+ * @param flags one of irg_verify_flags_t
+ *
+ * @return the newly created ir_graph pass
+ */
+ir_graph_pass_t *irg_verify_pass(const char *name, unsigned flags);
+
/**
* Possible flags for irg_vrfy_bads().
*/
enum verify_bad_flags_t {
- BAD_CF = 1, /**< Bad nodes are allowed as predecessors of Blocks and Phis. */
- BAD_DF = 2, /**< Bad nodes are allowed as dataflow predecessors. */
- BAD_BLOCK = 4, /**< Bad nodes are allowed as Block input. */
- TUPLE = 8 /**< Tuple nodes are allowed. */
+ BAD_CF = 1, /**< Bad nodes are allowed as predecessors of Blocks and Phis. */
+ BAD_DF = 2, /**< Bad nodes are allowed as dataflow predecessors. */
+ BAD_BLOCK = 4, /**< Bad nodes are allowed as Block input. */
+ TUPLE = 8 /**< Tuple nodes are allowed. */
};
/**
#include "irgwalk.h"
#include "irprintf.h"
#include "irgopt.h"
+#include "irpass.h"
#include "irtools.h"
#include "array_t.h"
#include "debug.h"
ir_fprintf(stderr, "%+F\n", obj);
}
}
-
-/**
- * Wrapper for running void function(ir_graph *irg) as an ir_graph pass.
- */
-static int void_graph_wrapper(ir_graph *irg, void *context) {
- void (*function)(ir_graph *irg) = context;
- function(irg);
- return 0;
-} /* void_graph_wrapper */
-
-/* Creates an ir_graph pass for running void function(ir_graph *irg). */
-ir_graph_pass_t *def_graph_pass(
- const char *name, void (*function)(ir_graph *irg))
-{
- struct ir_graph_pass_t *pass = XMALLOCZ(ir_graph_pass_t);
-
- pass->kind = k_ir_graph_pass;
- pass->run_on_irg = void_graph_wrapper;
- pass->context = function;
- pass->name = name;
-
- 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_graph_wrapper(ir_graph *irg, void *context) {
- int (*function)(ir_graph *irg) = context;
- return function(irg);
-} /* int_graph_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 (*function)(ir_graph *irg))
-{
- struct ir_graph_pass_t *pass = XMALLOCZ(ir_graph_pass_t);
-
- pass->kind = k_ir_graph_pass;
- pass->run_on_irg = int_graph_wrapper;
- pass->context = function;
- pass->name = name;
-
- INIT_LIST_HEAD(&pass->list);
-
- return pass;
-} /* def_graph_pass_ret */
-
-/**
- * Wrapper for running void function(void) as an ir_prog pass.
- */
-static int void_prog_wrapper(ir_prog *irp, void *context) {
- void (*function)(void) = context;
-
- (void)irp;
- function();
- return 0;
-} /* void_graph_wrapper */
-
-/* Creates an ir_prog pass for running void function(void). */
-ir_prog_pass_t *def_prog_pass(
- const char *name,
- void (*function)(void))
-{
- struct ir_prog_pass_t *pass = XMALLOCZ(ir_prog_pass_t);
-
- pass->kind = k_ir_prog_pass;
- pass->run_on_irprog = void_prog_wrapper;
- pass->context = function;
- pass->name = name;
-
- INIT_LIST_HEAD(&pass->list);
-
- return pass;
-} /* def_prog_pass */
*/
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 function the function to run
- *
- * @return the newly created ir_graph pass
- */
-ir_graph_pass_t *def_graph_pass(
- const char *name, 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 function the function to run
- *
- * @return the newly created ir_graph pass
- */
-ir_graph_pass_t *def_graph_pass_ret(
- const char *name, int (*function)(ir_graph *irg));
-
-/**
- * Creates an ir_prog pass for running void function().
- * Uses the default verifier and dumper.
- * The pass returns always 0.
- *
- * @param name the name of this pass
- * @param function the function to run
- *
- * @return the newly created ir_graph pass
- */
-ir_prog_pass_t *def_prog_pass(
- const char *name, void (*function)(void));
-
#endif
{
mgr->run_idx = run_idx;
}
+
+/**
+ * Wrapper for running void function(ir_graph *irg) as an ir_graph pass.
+ */
+static int void_graph_wrapper(ir_graph *irg, void *context) {
+ void (*function)(ir_graph *irg) = context;
+ function(irg);
+ return 0;
+} /* void_graph_wrapper */
+
+/* Creates an ir_graph pass for running void function(ir_graph *irg). */
+ir_graph_pass_t *def_graph_pass(
+ const char *name, void (*function)(ir_graph *irg))
+{
+ struct ir_graph_pass_t *pass = XMALLOCZ(ir_graph_pass_t);
+
+ pass->kind = k_ir_graph_pass;
+ pass->run_on_irg = void_graph_wrapper;
+ pass->context = function;
+ pass->name = name;
+
+ 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_graph_wrapper(ir_graph *irg, void *context) {
+ int (*function)(ir_graph *irg) = context;
+ return function(irg);
+} /* int_graph_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 (*function)(ir_graph *irg))
+{
+ struct ir_graph_pass_t *pass = XMALLOCZ(ir_graph_pass_t);
+
+ pass->kind = k_ir_graph_pass;
+ pass->run_on_irg = int_graph_wrapper;
+ pass->context = function;
+ pass->name = name;
+
+ INIT_LIST_HEAD(&pass->list);
+
+ return pass;
+} /* def_graph_pass_ret */
+
+/* constructor for a default graph pass */
+ir_graph_pass_t *def_graph_pass_constructor(
+ ir_graph_pass_t *pass,
+ const char *name, int (*function)(ir_graph *irg, void *context)) {
+ if (pass == NULL)
+ pass = XMALLOCZ(ir_graph_pass_t);
+ pass->kind = k_ir_graph_pass;
+ pass->run_on_irg = function;
+ pass->context = pass;
+ pass->name = name;
+
+ INIT_LIST_HEAD(&pass->list);
+
+ return pass;
+} /* def_graph_pass_constructor */
+
+
+/**
+ * Wrapper for running void function(void) as an ir_prog pass.
+ */
+static int void_prog_wrapper(ir_prog *irp, void *context) {
+ void (*function)(void) = context;
+
+ (void)irp;
+ function();
+ return 0;
+} /* void_graph_wrapper */
+
+/* Creates an ir_prog pass for running void function(void). */
+ir_prog_pass_t *def_prog_pass(
+ const char *name,
+ void (*function)(void))
+{
+ struct ir_prog_pass_t *pass = XMALLOCZ(ir_prog_pass_t);
+
+ pass->kind = k_ir_prog_pass;
+ pass->run_on_irprog = void_prog_wrapper;
+ pass->context = function;
+ pass->name = name;
+
+ INIT_LIST_HEAD(&pass->list);
+
+ return pass;
+} /* def_prog_pass */
#include "irprintf.h"
#include "irouts.h"
#include "irflag_t.h"
+#include "irpass_t.h"
/** if this flag is set, verify entity types in Load & Store nodes */
static int vrfy_entities = 0;
return res;
}
+struct pass_t {
+ ir_graph_pass_t pass;
+ unsigned flags;
+};
+
+/**
+ * Wrapper to irg_verify to be run as an ir_graph pass.
+ */
+static int irg_verify_wrapper(ir_graph *irg, void *context) {
+ struct pass_t *pass = context;
+ irg_verify(irg, pass->flags);
+ /* do NOT rerun the pass if verify is ok :-) */
+ return 0;
+}
+
+/* Creates an ir_graph pass for irg_verify(). */
+ir_graph_pass_t *irg_verify_pass(const char *name, unsigned flags) {
+ struct pass_t *pass = XMALLOCZ(struct pass_t);
+
+ pass->flags = flags;
+ return def_graph_pass_constructor(
+ &pass->pass, name ? name : "irg_verify", irg_verify_wrapper);
+}
+
int irn_vrfy_irg_dump(ir_node *n, ir_graph *irg, const char **bad_string) {
int res;
firm_verification_t old = get_node_verification_mode();
ir_graph_pass_t *lower_highlevel_graph_pass(const char *name, int lower_bitfields) {
struct pass_t *pass = XMALLOCZ(struct pass_t);
- pass->pass.kind = k_ir_graph_pass;
- pass->pass.run_on_irg = lower_highlevel_graph_wrapper;
- pass->pass.context = pass;
- pass->pass.name = name;
-
- INIT_LIST_HEAD(&pass->pass.list);
-
pass->lower_bitfields = lower_bitfields;
-
- return &pass->pass;
+ return def_graph_pass_constructor(
+ &pass->pass, name ? name : "lower_hl", lower_highlevel_graph_wrapper);
} /* lower_highlevel_graph_pass */
/*
#include "irprintf.h"
#include "irnode_t.h"
#include "tv.h"
-#include "irtools.h"
+#include "irpass.h"
typedef struct cond_pair {
ir_node *cmp_lo;
#include "irflag_t.h"
#include "firmstat.h"
-#include "irtools.h"
+#include "irpass.h"
#include "iropt_dbg.h"
#include "irnode_t.h"
#include "irouts.h"
#include "irgopt.h"
-#include "irtools.h"
+#include "irpass.h"
/**
* Returns non-zero, is a block is not reachable from Start.
#include "array_t.h"
#include "error.h"
#include "irnodeset.h"
-#include "irtools.h"
+#include "irpass.h"
#include "tv_t.h"
#include "irprintf.h"
#include "iredges_t.h"
#include "irgwalk.h"
#include "irprintf.h"
-#include "irtools.h"
+#include "irpass.h"
DEBUG_ONLY(static firm_dbg_module_t *dbg);
#include "iredges.h"
#include "iropt_dbg.h"
#include "debug.h"
+#include "irpass.h"
#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 {
ir_graph_pass_t *opt_if_conv_pass(
const char *name, 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 ? name : "if_conv";
-
+ struct pass_t *pass = XMALLOCZ(struct pass_t);
pass->params = params;
- INIT_LIST_HEAD(&pass->pass.list);
-
- return &pass->pass;
+ return def_graph_pass_constructor(
+ &pass->pass, name ? name : "ifconv", pass_wrapper);
}
#include "ircons.h"
#include "cgana.h"
#include "irtools.h"
+#include "irpass.h"
DEBUG_ONLY(static firm_dbg_module_t *dbg);
#include "tv.h"
#include "opt_confirms.h"
#include "iropt_dbg.h"
-#include "irtools.h"
+#include "irpass.h"
#undef AVOID_PHIB
#include "irdump.h"
#include "irflag_t.h"
#include "irprintf.h"
-#include "irtools.h"
+#include "irpass.h"
#if +0
#define OPTIMISE_LOAD_AFTER_LOAD
#include "array_t.h"
#include "irhooks.h"
#include "iredges.h"
-#include "irtools.h"
+#include "irpass.h"
#include "opt_polymorphy.h"
#include "irmemory.h"
#include "irphase_t.h"
#include "type_t.h"
#include "irouts.h"
#include "iredges.h"
-#include "irtools.h"
+#include "irpass.h"
/*
* Optimize the frame type of an irg by removing
#include "raw_bitset.h"
#include "debug.h"
#include "error.h"
-#include "irtools.h"
+#include "irpass.h"
/* maximum number of output Proj's */
#define MAX_PROJ (pn_Load_max > pn_Store_max ? pn_Load_max : pn_Store_max)
ir_graph_pass_t *opt_osr_pass(const char *name, unsigned flags)
{
- 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 ? name : "osr";
+ struct pass_t *pass = XMALLOCZ(struct pass_t);
pass->flags = flags;
-
- INIT_LIST_HEAD(&pass->pass.list);
-
- return &pass->pass;
+ return def_graph_pass_constructor(
+ &pass->pass, name ? name : "osr", pass_wrapper);
} /* opt_osr_pass */
#include "irloop.h"
#include "pdeq.h"
#include "debug.h"
-#include "irtools.h"
+#include "irpass.h"
//#define NEW_REASSOC
#include "ircons_t.h"
#include "irnode_t.h"
#include "irgmod.h"
-#include "irtools.h"
+#include "irpass.h"
#define set_bit(n) (returns[(n) >> 3] |= 1 << ((n) & 7))
#define get_bit(n) (returns[(n) >> 3] & (1 << ((n) & 7)))
#include "irgwalk.h"
#include "irgmod.h"
#include "irnode_t.h"
+#include "irpass.h"
#include "irtools.h"
#include "xmalloc.h"
#include "debug.h"
#include "irouts.h"
#include "irhooks.h"
#include "ircons_t.h"
-#include "irtools.h"
+#include "irpass.h"
DEBUG_ONLY(static firm_dbg_module_t *dbg);