summaryrefslogtreecommitdiffstats
path: root/llvm/lib/VMCore/Instructions.cpp
diff options
context:
space:
mode:
authorDevang Patel <dpatel@apple.com>2008-02-20 19:10:47 +0000
committerDevang Patel <dpatel@apple.com>2008-02-20 19:10:47 +0000
commit666d45195a8d52d5eee1de9cd22e212511a76e2d (patch)
tree17470627d4f688810d0dc3af24d5e9792f184ded /llvm/lib/VMCore/Instructions.cpp
parent0b7221968159709914e9f930a4bfdc17096d380d (diff)
downloadbcm5719-llvm-666d45195a8d52d5eee1de9cd22e212511a76e2d.tar.gz
bcm5719-llvm-666d45195a8d52d5eee1de9cd22e212511a76e2d.zip
Specify GetResultInst index as an unsigned.
llvm-svn: 47390
Diffstat (limited to 'llvm/lib/VMCore/Instructions.cpp')
-rw-r--r--llvm/lib/VMCore/Instructions.cpp22
1 files changed, 12 insertions, 10 deletions
diff --git a/llvm/lib/VMCore/Instructions.cpp b/llvm/lib/VMCore/Instructions.cpp
index 65bc1830e5f..d700902a256 100644
--- a/llvm/lib/VMCore/Instructions.cpp
+++ b/llvm/lib/VMCore/Instructions.cpp
@@ -2705,23 +2705,25 @@ void SwitchInst::setSuccessorV(unsigned idx, BasicBlock *B) {
// GetResultInst Implementation
//===----------------------------------------------------------------------===//
-GetResultInst::GetResultInst(Value *Aggr, Value *Index,
+GetResultInst::GetResultInst(Value *Aggregate, unsigned Index,
const std::string &Name,
Instruction *InsertBef)
: Instruction(Aggr->getType(),
- GetResult, Ops, 2, InsertBef) {
- assert(isValidOperands(Aggr, Index) && "Invalid GetResultInst operands!");
- Ops[0].init(Aggr, this);
- Ops[1].init(Index, this);
+ GetResult, &Aggr, 1, InsertBef) {
+ assert(isValidOperands(Aggregate, Index) && "Invalid GetResultInst operands!");
+ Aggr.init(Aggregate, this);
+ Idx = Index;
setName(Name);
}
-bool GetResultInst::isValidOperands(const Value *Aggr, const Value *Index) {
- if (!Aggr || !Index)
- return false;
- if (!isa<StructType>(Aggr->getType()) || Index->getType() != Type::Int32Ty)
+bool GetResultInst::isValidOperands(const Value *Aggregate, unsigned Index) {
+ if (!Aggregate)
return false;
- return true;
+ if (const StructType *STy = dyn_cast<StructType>(Aggregate->getType()))
+ if (Index < STy->getNumElements())
+ return true;
+
+ return false;
}
OpenPOWER on IntegriCloud