- add pass for optimize_graph_df()
authorMichael Beck <beck@ipd.info.uni-karlsruhe.de>
Sun, 16 Aug 2009 01:47:41 +0000 (01:47 +0000)
committerMichael Beck <beck@ipd.info.uni-karlsruhe.de>
Sun, 16 Aug 2009 01:47:41 +0000 (01:47 +0000)
[r26348]

include/libfirm/irgopt.h
ir/ir/irgopt.c

index dac94fd..60a528e 100644 (file)
@@ -56,6 +56,17 @@ void local_optimize_graph(ir_graph *irg);
  */
 int optimize_graph_df(ir_graph *irg);
 
+/**
+ * Creates an ir_graph pass for optimize_graph_df().
+ *
+ * @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_graph_df_pass(const char *name, int verify, int dump);
+
 /** Performs dead node elimination by copying the ir graph to a new obstack.
  *
  *  The major intention of this pass is to free memory occupied by
index 0f7437c..acebf48 100644 (file)
@@ -39,6 +39,7 @@
 
 #include "adt/pdeq.h"
 
+#include "irpass_t.h"
 #include "irflag_t.h"
 #include "iredges_t.h"
 #include "irtools.h"
@@ -220,3 +221,27 @@ int optimize_graph_df(ir_graph *irg) {
        current_ir_graph = rem;
        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 */