- moved pass constructors from irtools to irpass
authorMichael Beck <beck@ipd.info.uni-karlsruhe.de>
Mon, 17 Aug 2009 21:53:48 +0000 (21:53 +0000)
committerMichael Beck <beck@ipd.info.uni-karlsruhe.de>
Mon, 17 Aug 2009 21:53:48 +0000 (21:53 +0000)
- add an irg_verify_pass()

[r26374]

28 files changed:
include/libfirm/irconsconfirm.h
include/libfirm/iroptimize.h
include/libfirm/irpass.h
include/libfirm/irvrfy.h
ir/ana/irconsconfirm.c
ir/common/irtools.c
ir/common/irtools.h
ir/ir/irpass.c
ir/ir/irvrfy.c
ir/lower/lower_hl.c
ir/opt/boolopt.c
ir/opt/cfopt.c
ir/opt/code_placement.c
ir/opt/combo.c
ir/opt/convopt.c
ir/opt/gvn_pre.c
ir/opt/ifconv.c
ir/opt/ircgopt.c
ir/opt/jumpthreading.c
ir/opt/ldst2.c
ir/opt/ldstopt.c
ir/opt/opt_frame.c
ir/opt/opt_ldst.c
ir/opt/opt_osr.c
ir/opt/reassoc.c
ir/opt/return.c
ir/opt/scalar_replace.c
ir/opt/tailrec.c

index cd7950a..4e83817 100644 (file)
@@ -55,12 +55,10 @@ void construct_confirms(ir_graph *irg);
  * 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.
@@ -74,11 +72,9 @@ void remove_confirms(ir_graph *irg);
  * 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
index c5e1a14..c150b1b 100644 (file)
@@ -48,8 +48,6 @@ 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
  */
index dabfac6..8ab844d 100644 (file)
@@ -118,4 +118,58 @@ int ir_prog_pass_mgr_run(ir_prog_pass_manager_t *mgr);
  */
 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
index e3fde12..a7cbfec 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * 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.
  *
@@ -58,14 +58,17 @@ int irn_vrfy_irg_dump(ir_node *checknode, ir_graph *irg, const char **bad_string
  * 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.
  */
@@ -76,14 +79,24 @@ int irg_verify(ir_graph *irg, unsigned flags);
  */
 #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. */
 };
 
 /**
index 54689d7..1198034 100644 (file)
@@ -35,6 +35,7 @@
 #include "irgwalk.h"
 #include "irprintf.h"
 #include "irgopt.h"
+#include "irpass.h"
 #include "irtools.h"
 #include "array_t.h"
 #include "debug.h"
index bfd5379..d5f5223 100644 (file)
@@ -166,80 +166,3 @@ void firm_pset_dump(pset *set) {
                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 */
index f907286..ae9ba11 100644 (file)
@@ -105,43 +105,4 @@ void copy_irn_to_irg(ir_node *n, ir_graph *irg);
  */
 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
index 0d982e1..0673918 100644 (file)
@@ -339,3 +339,97 @@ void ir_prog_pass_manager_set_run_idx(
 {
        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 */
index 6333bfb..99cd420 100644 (file)
@@ -36,6 +36,7 @@
 #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;
@@ -2064,6 +2065,30 @@ int irg_verify(ir_graph *irg, unsigned flags) {
        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();
index 946b724..7614216 100644 (file)
@@ -596,16 +596,9 @@ static int lower_highlevel_graph_wrapper(ir_graph *irg, void *context) {
 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 */
 
 /*
index 8279fd6..eb80d5a 100644 (file)
@@ -35,7 +35,7 @@
 #include "irprintf.h"
 #include "irnode_t.h"
 #include "tv.h"
-#include "irtools.h"
+#include "irpass.h"
 
 typedef struct cond_pair {
        ir_node *cmp_lo;
index e04ffe7..76160e5 100644 (file)
@@ -50,7 +50,7 @@
 
 #include "irflag_t.h"
 #include "firmstat.h"
-#include "irtools.h"
+#include "irpass.h"
 
 #include "iropt_dbg.h"
 
index 302707e..20ee73f 100644 (file)
@@ -31,7 +31,7 @@
 #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.
index 7cdaa6e..6e9a390 100644 (file)
@@ -81,7 +81,7 @@
 #include "array_t.h"
 #include "error.h"
 #include "irnodeset.h"
-#include "irtools.h"
+#include "irpass.h"
 #include "tv_t.h"
 
 #include "irprintf.h"
index 4d06679..a7f481c 100644 (file)
@@ -49,7 +49,7 @@
 #include "iredges_t.h"
 #include "irgwalk.h"
 #include "irprintf.h"
-#include "irtools.h"
+#include "irpass.h"
 
 DEBUG_ONLY(static firm_dbg_module_t *dbg);
 
index ee16460..129b1e1 100644 (file)
 #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 {
index 0634cc0..db6a992 100644 (file)
@@ -517,16 +517,9 @@ static int pass_wrapper(ir_graph *irg, void *context) {
 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);
 }
index 27940ab..2b28f56 100644 (file)
@@ -43,6 +43,7 @@
 #include "ircons.h"
 #include "cgana.h"
 #include "irtools.h"
+#include "irpass.h"
 
 DEBUG_ONLY(static firm_dbg_module_t *dbg);
 
index 57b53ac..02ca3bf 100644 (file)
@@ -44,7 +44,7 @@
 #include "tv.h"
 #include "opt_confirms.h"
 #include "iropt_dbg.h"
-#include "irtools.h"
+#include "irpass.h"
 
 #undef AVOID_PHIB
 
index c05b330..d73a8f7 100644 (file)
@@ -41,7 +41,7 @@
 #include "irdump.h"
 #include "irflag_t.h"
 #include "irprintf.h"
-#include "irtools.h"
+#include "irpass.h"
 
 #if +0
 #define OPTIMISE_LOAD_AFTER_LOAD
index f8e33df..3cf50ab 100644 (file)
@@ -43,7 +43,7 @@
 #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"
index 5c4217e..9aed1e2 100644 (file)
@@ -33,7 +33,7 @@
 #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
index 2035419..80cb818 100644 (file)
@@ -42,7 +42,7 @@
 #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)
index 135e58f..8569b99 100644 (file)
@@ -1475,16 +1475,9 @@ static int pass_wrapper(ir_graph *irg, void *context) {
 
 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 */
index 5c13a7b..1f02100 100644 (file)
@@ -40,7 +40,7 @@
 #include "irloop.h"
 #include "pdeq.h"
 #include "debug.h"
-#include "irtools.h"
+#include "irpass.h"
 
 //#define NEW_REASSOC
 
index 7ffd2b2..55bde8a 100644 (file)
@@ -30,7 +30,7 @@
 #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)))
index 0725086..59588da 100644 (file)
@@ -40,6 +40,7 @@
 #include "irgwalk.h"
 #include "irgmod.h"
 #include "irnode_t.h"
+#include "irpass.h"
 #include "irtools.h"
 #include "xmalloc.h"
 #include "debug.h"
index 0117e0a..26d4c1f 100644 (file)
@@ -45,7 +45,7 @@
 #include "irouts.h"
 #include "irhooks.h"
 #include "ircons_t.h"
-#include "irtools.h"
+#include "irpass.h"
 
 DEBUG_ONLY(static firm_dbg_module_t *dbg);