[llvm-commits] CVS: llvm/include/llvm/iPHINode.h
Chris Lattner
lattner at cs.uiuc.edu
Thu Mar 6 10:38:01 PST 2003
Changes in directory llvm/include/llvm:
iPHINode.h updated: 1.7 -> 1.8
---
Log message:
Add new getIncomingValueForBlock method
Relax a bit about constness
---
Diffs of the changes:
Index: llvm/include/llvm/iPHINode.h
diff -u llvm/include/llvm/iPHINode.h:1.7 llvm/include/llvm/iPHINode.h:1.8
--- llvm/include/llvm/iPHINode.h:1.7 Wed Mar 5 15:15:11 2003
+++ llvm/include/llvm/iPHINode.h Thu Mar 6 10:36:28 2003
@@ -33,13 +33,12 @@
unsigned getNumIncomingValues() const { return Operands.size()/2; }
/// getIncomingValue - Return incoming value #x
- const Value *getIncomingValue(unsigned i) const {
- return Operands[i*2];
- }
- Value *getIncomingValue(unsigned i) {
+ Value *getIncomingValue(unsigned i) const {
+ assert(i*2 < Operands.size() && "Invalid value number!");
return Operands[i*2];
}
void setIncomingValue(unsigned i, Value *V) {
+ assert(i*2 < Operands.size() && "Invalid value number!");
Operands[i*2] = V;
}
inline unsigned getOperandNumForIncomingValue(unsigned i) {
@@ -47,16 +46,15 @@
}
/// getIncomingBlock - Return incoming basic block #x
- const BasicBlock *getIncomingBlock(unsigned i) const {
- return (const BasicBlock*)Operands[i*2+1].get();
- }
- inline BasicBlock *getIncomingBlock(unsigned i) {
+ BasicBlock *getIncomingBlock(unsigned i) const {
+ assert(i*2+1 < Operands.size() && "Invalid value number!");
return (BasicBlock*)Operands[i*2+1].get();
}
- inline void setIncomingBlock(unsigned i, BasicBlock *BB) {
+ void setIncomingBlock(unsigned i, BasicBlock *BB) {
+ assert(i*2+1 < Operands.size() && "Invalid value number!");
Operands[i*2+1] = (Value*)BB;
}
- inline unsigned getOperandNumForIncomingBlock(unsigned i) {
+ unsigned getOperandNumForIncomingBlock(unsigned i) {
return i*2+1;
}
@@ -91,6 +89,10 @@
for (unsigned i = 0; i < Operands.size()/2; ++i)
if (getIncomingBlock(i) == BB) return i;
return -1;
+ }
+
+ Value *getIncomingValueForBlock(const BasicBlock *BB) const {
+ return getIncomingValue(getBasicBlockIndex(BB));
}
/// Methods for support type inquiry through isa, cast, and dyn_cast:
More information about the llvm-commits
mailing list