Skip to content
Snippets Groups Projects
Commit 5c363ba2 authored by Vikram S. Adve's avatar Vikram S. Adve
Browse files

Add routines to update or erase operands (and to do so without external

assumptions about which operand number stores what operand).

llvm-svn: 3750
parent 4b775b27
No related branches found
No related tags found
No related merge requests found
...@@ -34,6 +34,10 @@ public: ...@@ -34,6 +34,10 @@ public:
assert(i < Operands.size() && "setOperand() out of range!"); assert(i < Operands.size() && "setOperand() out of range!");
Operands[i] = Val; 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(); } inline unsigned getNumOperands() const { return Operands.size(); }
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
......
...@@ -150,6 +150,7 @@ public: ...@@ -150,6 +150,7 @@ public:
Value *getPointerOperand() { return getOperand(0); } Value *getPointerOperand() { return getOperand(0); }
const Value *getPointerOperand() const { 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: // Methods for support type inquiry through isa, cast, and dyn_cast:
static inline bool classof(const LoadInst *) { return true; } static inline bool classof(const LoadInst *) { return true; }
...@@ -180,6 +181,7 @@ public: ...@@ -180,6 +181,7 @@ public:
Value *getPointerOperand() { return getOperand(1); } Value *getPointerOperand() { return getOperand(1); }
const Value *getPointerOperand() const { 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: // Methods for support type inquiry through isa, cast, and dyn_cast:
static inline bool classof(const StoreInst *) { return true; } static inline bool classof(const StoreInst *) { return true; }
...@@ -238,7 +240,10 @@ public: ...@@ -238,7 +240,10 @@ public:
const Value *getPointerOperand() const { const Value *getPointerOperand() const {
return getOperand(0); return getOperand(0);
} }
static unsigned getPointerOperandIndex() {
return 0U; // get index for modifying correct operand
}
inline unsigned getNumIndices() const { // Note: always non-negative inline unsigned getNumIndices() const { // Note: always non-negative
return getNumOperands() - 1; return getNumOperands() - 1;
} }
......
...@@ -42,6 +42,9 @@ public: ...@@ -42,6 +42,9 @@ public:
void setIncomingValue(unsigned i, Value *V) { void setIncomingValue(unsigned i, Value *V) {
Operands[i*2] = V; Operands[i*2] = V;
} }
inline unsigned getOperandNumForIncomingValue(unsigned i) {
return i*2;
}
/// getIncomingBlock - Return incoming basic block #x /// getIncomingBlock - Return incoming basic block #x
const BasicBlock *getIncomingBlock(unsigned i) const { const BasicBlock *getIncomingBlock(unsigned i) const {
...@@ -53,6 +56,9 @@ public: ...@@ -53,6 +56,9 @@ public:
inline void setIncomingBlock(unsigned i, BasicBlock *BB) { inline void setIncomingBlock(unsigned i, BasicBlock *BB) {
Operands[i*2+1] = (Value*)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 /// addIncoming - Add an incoming value to the end of the PHI list
void addIncoming(Value *D, BasicBlock *BB); void addIncoming(Value *D, BasicBlock *BB);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment