Partly undo r27277 and add a prototype for (formally undocumented) find_value(),...
authorMichael Beck <beck@ipd.info.uni-karlsruhe.de>
Fri, 9 Apr 2010 12:40:01 +0000 (12:40 +0000)
committerMichael Beck <beck@ipd.info.uni-karlsruhe.de>
Fri, 9 Apr 2010 12:40:01 +0000 (12:40 +0000)
[r27363]

include/libfirm/ircons.h
ir/ir/ircons.c

index 7b1ef65..adfa04d 100644 (file)
@@ -4456,6 +4456,16 @@ ir_node *get_value(int pos, ir_mode *mode);
  */
 void set_value(int pos, ir_node *value);
 
+/**
+ * Find the value number for a node in the current block.
+ *
+ * @param value  the searched value
+ *
+ * @return the value number of the value or -1 if this value has
+ * no value number in the current block.
+ */
+int find_value(ir_node *value);
+
 /** Get the current memory state.
  *
  * Use this function to obtain the last definition of the memory
index 42c6b5d..55937c7 100644 (file)
@@ -1390,6 +1390,18 @@ void set_value(int pos, ir_node *value)
        irg->current_block->attr.block.graph_arr[pos + 1] = value;
 }  /* set_value */
 
+/* Find the value number for a node in the current block.*/
+int find_value(ir_node *value)
+{
+       int i;
+       ir_node *bl = current_ir_graph->current_block;
+
+       for (i = ARR_LEN(bl->attr.block.graph_arr) - 1; i >= 1; --i)
+               if (bl->attr.block.graph_arr[i] == value)
+                       return i - 1;
+       return -1;
+}  /* find_value */
+
 /* get the current store */
 ir_node *get_store(void)
 {