aboutsummaryrefslogtreecommitdiffstats
path: root/include/llvm
diff options
context:
space:
mode:
authorGabor Greif <ggreif@gmail.com>2009-09-03 00:18:58 +0000
committerGabor Greif <ggreif@gmail.com>2009-09-03 00:18:58 +0000
commit190390b8d31af0a549827478911b322af4bc111a (patch)
treed509b4c1e1a00b7fa417aea5f7894dc3be00685d /include/llvm
parent9947bbb2979d9e33366ac767c7677bc69b5252e6 (diff)
downloadexternal_llvm-190390b8d31af0a549827478911b322af4bc111a.zip
external_llvm-190390b8d31af0a549827478911b322af4bc111a.tar.gz
external_llvm-190390b8d31af0a549827478911b322af4bc111a.tar.bz2
re-commit r66920 (which has been backed out in r66953) I may have more luck this time. I'll back out if needed...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@80858 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm')
-rw-r--r--include/llvm/Instructions.h18
-rw-r--r--include/llvm/Support/CallSite.h30
2 files changed, 33 insertions, 15 deletions
diff --git a/include/llvm/Instructions.h b/include/llvm/Instructions.h
index e6f1c54..ee5af69 100644
--- a/include/llvm/Instructions.h
+++ b/include/llvm/Instructions.h
@@ -2466,27 +2466,26 @@ public:
/// indirect function invocation.
///
Function *getCalledFunction() const {
- return dyn_cast<Function>(getOperand(0));
+ return dyn_cast<Function>(Op<-3>());
}
/// getCalledValue - Get a pointer to the function that is invoked by this
/// instruction
- const Value *getCalledValue() const { return getOperand(0); }
- Value *getCalledValue() { return getOperand(0); }
+ const Value *getCalledValue() const { return Op<-3>(); }
+ Value *getCalledValue() { return Op<-3>(); }
// get*Dest - Return the destination basic blocks...
BasicBlock *getNormalDest() const {
- return cast<BasicBlock>(getOperand(1));
+ return cast<BasicBlock>(Op<-2>());
}
BasicBlock *getUnwindDest() const {
- return cast<BasicBlock>(getOperand(2));
+ return cast<BasicBlock>(Op<-1>());
}
void setNormalDest(BasicBlock *B) {
- setOperand(1, B);
+ Op<-2>() = B;
}
-
void setUnwindDest(BasicBlock *B) {
- setOperand(2, B);
+ Op<-1>() = B;
}
BasicBlock *getSuccessor(unsigned i) const {
@@ -2496,7 +2495,7 @@ public:
void setSuccessor(unsigned idx, BasicBlock *NewSucc) {
assert(idx < 2 && "Successor # out of range for invoke!");
- setOperand(idx+1, NewSucc);
+ *(&Op<-2>() + idx) = NewSucc;
}
unsigned getNumSuccessors() const { return 2; }
@@ -2509,6 +2508,7 @@ public:
static inline bool classof(const Value *V) {
return isa<Instruction>(V) && classof(cast<Instruction>(V));
}
+
private:
virtual BasicBlock *getSuccessorV(unsigned idx) const;
virtual unsigned getNumSuccessorsV() const;
diff --git a/include/llvm/Support/CallSite.h b/include/llvm/Support/CallSite.h
index 285b558..5bfcc6d 100644
--- a/include/llvm/Support/CallSite.h
+++ b/include/llvm/Support/CallSite.h
@@ -118,7 +118,7 @@ public:
///
Value *getCalledValue() const {
assert(getInstruction() && "Not a call or invoke instruction!");
- return getInstruction()->getOperand(0);
+ return *getCallee();
}
/// getCalledFunction - Return the function being called if this is a direct
@@ -132,7 +132,7 @@ public:
///
void setCalledFunction(Value *V) {
assert(getInstruction() && "Not a call or invoke instruction!");
- getInstruction()->setOperand(0, V);
+ *getCallee() = V;
}
Value *getArgument(unsigned ArgNo) const {
@@ -146,6 +146,16 @@ public:
getInstruction()->setOperand(getArgumentOffset() + ArgNo, newVal);
}
+ /// Given a value use iterator, returns the argument that corresponds to it.
+ /// Iterator must actually correspond to an argument.
+ unsigned getArgumentNo(Value::use_iterator I) const {
+ assert(getInstruction() && "Not a call or invoke instruction!");
+ assert(arg_begin() <= &I.getUse() && &I.getUse() < arg_end()
+ && "Argument # out of range!");
+
+ return &I.getUse() - arg_begin();
+ }
+
/// Given an operand number, returns the argument that corresponds to it.
/// OperandNo must be a valid operand number that actually corresponds to an
/// argument.
@@ -171,7 +181,7 @@ public:
return getInstruction()->op_begin() + getArgumentOffset();
}
- arg_iterator arg_end() const { return getInstruction()->op_end(); }
+ arg_iterator arg_end() const { return getInstruction()->op_end() - getArgumentEndOffset(); }
bool arg_empty() const { return arg_end() == arg_begin(); }
unsigned arg_size() const { return unsigned(arg_end() - arg_begin()); }
@@ -180,17 +190,25 @@ public:
}
bool isCallee(Value::use_iterator UI) const {
- return getInstruction()->op_begin() == &UI.getUse();
+ return getCallee() == &UI.getUse();
}
-
private:
/// Returns the operand number of the first argument
unsigned getArgumentOffset() const {
if (isCall())
return 1; // Skip Function
else
- return 3; // Skip Function, BB, BB
+ return 0; // Args are at the front
}
+
+ unsigned getArgumentEndOffset() const {
+ if (isCall())
+ return 0; // Unchanged
+ else
+ return 3; // Skip BB, BB, Function
+ }
+
+ User::op_iterator getCallee() const;
};
} // End llvm namespace