Implement binary emitter for fpush.
[libfirm] / ir / opt / ifconv.c
index 1fda437..db6a992 100644 (file)
@@ -37,6 +37,7 @@
 #include "irgwalk.h"
 #include "irtools.h"
 #include "array_t.h"
+#include "irpass_t.h"
 
 // debug
 #include "irdump.h"
@@ -377,7 +378,7 @@ restart:
                                                        f = val_i;
                                                }
 
-                                               mux = new_rd_Mux(cond_dbg, current_ir_graph, mux_block, sel, f, t, get_irn_mode(phi));
+                                               mux = new_rd_Mux(cond_dbg, mux_block, sel, f, t, get_irn_mode(phi));
                                                DB((dbg, LEVEL_2, "Generating %+F for %+F\n", mux, phi));
                                        }
 
@@ -416,7 +417,7 @@ restart:
 #endif
                                        return;
                                } else {
-                                       rewire(block, i, j, new_r_Jmp(current_ir_graph, mux_block));
+                                       rewire(block, i, j, new_r_Jmp(mux_block));
                                        goto restart;
                                }
                        }
@@ -498,3 +499,27 @@ void opt_if_conv(ir_graph *irg, const ir_settings_if_conv_t *params)
 
        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, const ir_settings_if_conv_t *params)
+{
+       struct pass_t *pass = XMALLOCZ(struct pass_t);
+       pass->params = params;
+
+       return def_graph_pass_constructor(
+               &pass->pass, name ? name : "ifconv", pass_wrapper);
+}