gas on cygwin doesn't like section type (althought that's not what the docu says...
[libfirm] / ir / common / irtools.h
index 2367fc5..afa6e7f 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1995-2007 University of Karlsruhe.  All right reserved.
+ * Copyright (C) 1995-2008 University of Karlsruhe.  All right reserved.
  *
  * This file is part of libFirm.
  *
 #ifndef FIRM_COMMON_IRTOOLS_H
 #define FIRM_COMMON_IRTOOLS_H
 
-#include "firm_config.h"
 #include "firm_types.h"
 
-#ifdef WITH_LIBCORE
-#include <libcore/lc_opts.h>
+#include "lc_opts.h"
 lc_opt_entry_t *firm_opt_get_root(void);
-#endif
 
 #include "pset.h"
 
@@ -41,6 +38,10 @@ lc_opt_entry_t *firm_opt_get_root(void);
 #define MAX(x, y) ((x) > (y) ? (x) : (y))
 #define MIN(x, y) ((x) < (y) ? (x) : (y))
 
+/* calculate the address of the one past last element of an array whose size is
+ * known statically */
+#define ENDOF(x) ((x) + sizeof(x) / sizeof(*(x)))
+
 /**
  * Three valued compare as demanded by e.g. qsort(3)
  * @param c A number.
@@ -67,11 +68,47 @@ void firm_pset_dump(pset *set);
 
 /**
  * The famous clear_link() walker-function.
- * Do not implement it by yourself, use this one
+ * Sets all links fields of visited nodes to NULL.
+ * Do not implement it by yourself, use this one.
  */
 void firm_clear_link(ir_node *n, void *env);
 
 /**
+ * The famous clear_link_and_block_lists() walker-function.
+ * Sets all links fields of visited nodes to NULL.
+ * Additionally, clear all Phi-lists of visited blocks.
+ * Do not implement it by yourself, use this one
+ */
+void firm_clear_node_and_phi_links(ir_node *n, void *env);
+
+/**
+ * Creates an exact copy of a node with same inputs and attributes in the
+ * same block.
+ *
+ * @param node   the node to copy
+ */
+ir_node *exact_copy(const ir_node *node);
+
+/**
+ * Create an exact copy of a node with same inputs and attributes in the same
+ * block but puts the node on a graph which might be different than the graph
+ * of the original node.
+ * Note: You have to fixup the inputs/block later
+ */
+ir_node *irn_copy_into_irg(const ir_node *node, ir_graph *irg);
+
+/**
+ * This is a helper function used by some routines copying irg graphs
+ * This assumes that we have "old" nodes which have been copied to "new"
+ * nodes; The inputs of the new nodes still point to old nodes.
+ *
+ * Given an old(!) node this function rewires the matching new_node
+ * so that all its inputs point to new nodes afterwards.
+ */
+void irn_rewire_inputs(ir_node *node);
+
+/**
+ * @deprecated
  * Copies a node to a new irg. The Ins of the new node point to
  * the predecessors on the old irg.  n->link points to the new node.
  *
@@ -84,15 +121,4 @@ void firm_clear_link(ir_node *n, void *env);
  */
 void copy_irn_to_irg(ir_node *n, ir_graph *irg);
 
-/**
- * Creates an exact copy of a node.
- * The copy resists on the same graph in the same block.
- *
- * @param n   the node to copy
- *
- * @note If the copy is not changed, the next CSE operation will
- *       replace it by the original, so beware.
- */
-ir_node *exact_copy(const ir_node *n);
-
 #endif