Move to include/llvm/CodeGen
[oota-llvm.git] / include / llvm / iPHINode.h
index 287ba90bfeff9401c1d62c5070d5d94cb6e42fa6..4e217e971e8c6200b9b844fbafd79fa31265d2f9 100644 (file)
@@ -42,6 +42,9 @@ public:
   void setIncomingValue(unsigned i, Value *V) {
     Operands[i*2] = V;
   }
+  inline unsigned getOperandNumForIncomingValue(unsigned i) {
+    return i*2;
+  }
 
   /// getIncomingBlock - Return incoming basic block #x
   const BasicBlock *getIncomingBlock(unsigned i) const { 
@@ -53,13 +56,23 @@ public:
   inline void setIncomingBlock(unsigned i, BasicBlock *BB) {
     Operands[i*2+1] = (Value*)BB;
   }
+  inline unsigned getOperandNumForIncomingBlock(unsigned i) {
+    return i*2+1;
+  }
 
   /// addIncoming - Add an incoming value to the end of the PHI list
   void addIncoming(Value *D, BasicBlock *BB);
   
   /// removeIncomingValue - Remove an incoming value.  This is useful if a
   /// predecessor basic block is deleted.  The value removed is returned.
-  Value *removeIncomingValue(const BasicBlock *BB);
+  ///
+  /// If the last incoming value for a PHI node is removed (and DeletePHIIfEmpty
+  /// is true), the PHI node is destroyed and any uses of it are replaced with
+  /// dummy values.  The only time there should be zero incoming values to a PHI
+  /// node is when the block is dead, so this strategy is sound.
+  ///
+  Value *removeIncomingValue(const BasicBlock *BB,
+                             bool DeletePHIIfEmpty = true);
 
   /// getBasicBlockIndex - Return the first index of the specified basic 
   /// block in the value list for this PHI.  Returns -1 if no instance.