add irmemory.h
[libfirm] / ir / common / irtools.c
index 1962b52..37eae69 100644 (file)
 # include "config.h"
 #endif
 
+#include "pset.h"
+
 #include <stdlib.h>
 #include "irnode_t.h"
 #include "irbackedge_t.h"
 #include "irtools.h"
+#include "irprintf.h"
 
 /* the famous clear_link implementation. */
 void firm_clear_link(ir_node *n, void *env) {
@@ -96,14 +99,14 @@ copy_irn_to_irg(ir_node *n, ir_graph *irg)
 
 /*
  * Creates an exact copy of a node.
- * The copy resists on the sane graph in the same block.
+ * The copy resides in the same graph in the same block.
  */
-ir_node *exact_copy(ir_node *n) {
+ir_node *exact_copy(const ir_node *n) {
   ir_graph *irg = get_irn_irg(n);
   ir_node *res, *block = NULL;
 
   if (is_no_Block(n))
-    block = get_irn_n(n, -1);
+               block = get_nodes_block(n);
 
   res = new_ir_node(get_irn_dbg_info(n),
                     irg,
@@ -121,3 +124,12 @@ ir_node *exact_copy(ir_node *n) {
   new_backedge_info(res);
   return res;
 }
+
+void firm_pset_dump(pset *set)
+{
+       void *obj;
+
+       foreach_pset(set, obj) {
+               ir_fprintf(stderr, "%+F\n", obj);
+       }
+}