Add routines to update or erase operands (and to do so without external
authorVikram S. Adve <vadve@cs.uiuc.edu>
Mon, 16 Sep 2002 16:06:12 +0000 (16:06 +0000)
committerVikram S. Adve <vadve@cs.uiuc.edu>
Mon, 16 Sep 2002 16:06:12 +0000 (16:06 +0000)
assumptions about which operand number stores what operand).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@3750 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/User.h
include/llvm/iMemory.h
include/llvm/iPHINode.h

index e9dea8bcbff7b84908e348a8ea10de717b323c9b..1bd275a02b1ca6f7ab851d7c6379ccb10da80cb2 100644 (file)
@@ -34,6 +34,10 @@ public:
     assert(i < Operands.size() && "setOperand() out of range!");
     Operands[i] = Val;
   }
+  inline void eraseOperand(unsigned i) {
+    assert(i < Operands.size() && "setOperand() out of range!");
+    Operands.erase(Operands.begin() + i);
+  }
   inline unsigned getNumOperands() const { return Operands.size(); }
 
   // ---------------------------------------------------------------------------
index c198aebd70c6d958bcc32de35d741e41b94ffb45..e42f5b993b85c924a66abf00169ae3ae2e76c81f 100644 (file)
@@ -150,6 +150,7 @@ public:
 
   Value *getPointerOperand() { return getOperand(0); }
   const Value *getPointerOperand() const { return getOperand(0); }
+  static unsigned getPointerOperandIndex() { return 0U; }
 
   // Methods for support type inquiry through isa, cast, and dyn_cast:
   static inline bool classof(const LoadInst *) { return true; }
@@ -180,6 +181,7 @@ public:
 
   Value *getPointerOperand() { return getOperand(1); }
   const Value *getPointerOperand() const { return getOperand(1); }
+  static unsigned getPointerOperandIndex() { return 1U; }
 
   // Methods for support type inquiry through isa, cast, and dyn_cast:
   static inline bool classof(const StoreInst *) { return true; }
@@ -238,7 +240,10 @@ public:
   const Value *getPointerOperand() const {
     return getOperand(0);
   }
-  
+  static unsigned getPointerOperandIndex() {
+    return 0U;                      // get index for modifying correct operand
+  }
+
   inline unsigned getNumIndices() const {  // Note: always non-negative
     return getNumOperands() - 1;
   }
index 287ba90bfeff9401c1d62c5070d5d94cb6e42fa6..93b6e7cc80e50cc3f870e1d09b739bfb52732308 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,6 +56,9 @@ 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);