summaryrefslogtreecommitdiffstats
path: root/include/llvm
diff options
context:
space:
mode:
authorVikram S. Adve <vadve@cs.uiuc.edu>2002-09-16 16:06:12 +0000
committerVikram S. Adve <vadve@cs.uiuc.edu>2002-09-16 16:06:12 +0000
commite8f1df6446bf6ebf368401b813a0ca8eee69d871 (patch)
tree98f38cb3f251e85f173c8cb7cbbd3b7c5d459aed /include/llvm
parent46fece70c231ed5103253d1e151d4ad4fc1e129a (diff)
downloadexternal_llvm-e8f1df6446bf6ebf368401b813a0ca8eee69d871.zip
external_llvm-e8f1df6446bf6ebf368401b813a0ca8eee69d871.tar.gz
external_llvm-e8f1df6446bf6ebf368401b813a0ca8eee69d871.tar.bz2
Add routines to update or erase operands (and to do so without external
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
Diffstat (limited to 'include/llvm')
-rw-r--r--include/llvm/User.h4
-rw-r--r--include/llvm/iMemory.h7
-rw-r--r--include/llvm/iPHINode.h6
3 files changed, 16 insertions, 1 deletions
diff --git a/include/llvm/User.h b/include/llvm/User.h
index e9dea8b..1bd275a 100644
--- a/include/llvm/User.h
+++ b/include/llvm/User.h
@@ -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(); }
// ---------------------------------------------------------------------------
diff --git a/include/llvm/iMemory.h b/include/llvm/iMemory.h
index c198aeb..e42f5b9 100644
--- a/include/llvm/iMemory.h
+++ b/include/llvm/iMemory.h
@@ -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;
}
diff --git a/include/llvm/iPHINode.h b/include/llvm/iPHINode.h
index 287ba90..93b6e7c 100644
--- a/include/llvm/iPHINode.h
+++ b/include/llvm/iPHINode.h
@@ -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);