added new function to determine the predecessor position of node for a given predecessor
authorChristian Würdig <chriswue@ipd.info.uni-karlsruhe.de>
Wed, 10 May 2006 14:56:21 +0000 (14:56 +0000)
committerChristian Würdig <chriswue@ipd.info.uni-karlsruhe.de>
Wed, 10 May 2006 14:56:21 +0000 (14:56 +0000)
[r7715]

ir/ir/irnode.c
ir/ir/irnode.h

index dafd5b4..904bd71 100644 (file)
@@ -564,6 +564,15 @@ unsigned (get_irn_idx)(const ir_node *node) {
   return _get_irn_idx(node);
 }
 
+int get_irn_pred_pos(ir_node *node, ir_node *arg) {
+  int i;
+  for (i = get_irn_arity(node) - 1; i >= 0; i--) {
+    if (get_irn_n(node, i) == arg)
+      return i;
+  }
+  return -1;
+}
+
 /** manipulate fields of individual nodes **/
 
 /* this works for all except Block */
index d2d3b3d..ebdbf0a 100644 (file)
@@ -132,6 +132,8 @@ opcode        get_irn_opcode        (const ir_node *node);
 const char   *get_irn_opname        (const ir_node *node);
 /** Get the ident for a string representation of the opcode. */
 ident        *get_irn_opident       (const ir_node *node);
+/** If arg is an argument of the node, returns it's position, -1 otherwise */
+int           get_irn_pred_pos      (ir_node *node, ir_node *arg);
 /** Gets the visited counter of a node. */
 unsigned long get_irn_visited (const ir_node *node);
 /** Sets the visited counter of a node. */