diff options
author | Devang Patel <dpatel@apple.com> | 2008-02-20 19:10:47 +0000 |
---|---|---|
committer | Devang Patel <dpatel@apple.com> | 2008-02-20 19:10:47 +0000 |
commit | 23755d8755bc0fc6a4e8f4de51d0ed2a760d23d6 (patch) | |
tree | f820363be63632137c5a72d389feac7a653957c4 /lib | |
parent | fe8276cec27332f590186a78b7d0091ba4a9dbac (diff) | |
download | llvm-23755d8755bc0fc6a4e8f4de51d0ed2a760d23d6.tar.gz llvm-23755d8755bc0fc6a4e8f4de51d0ed2a760d23d6.tar.bz2 llvm-23755d8755bc0fc6a4e8f4de51d0ed2a760d23d6.tar.xz |
Specify GetResultInst index as an unsigned.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47390 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/AsmParser/llvmAsmParser.y | 2 | ||||
-rw-r--r-- | lib/VMCore/Instructions.cpp | 22 |
2 files changed, 13 insertions, 11 deletions
diff --git a/lib/AsmParser/llvmAsmParser.y b/lib/AsmParser/llvmAsmParser.y index 9e9da4723d..effe097258 100644 --- a/lib/AsmParser/llvmAsmParser.y +++ b/lib/AsmParser/llvmAsmParser.y @@ -3132,7 +3132,7 @@ MemoryInst : MALLOC Types OptCAlign { $$ = new StoreInst($3, tmpVal, $1, $7); delete $5; } -| GETRESULT Types LocalName ',' ConstVal { +| GETRESULT Types LocalName ',' EUINT64VAL { ValID TmpVID = ValID::createLocalName(*$3); Value *TmpVal = getVal($2->get(), TmpVID); if (!GetResultInst::isValidOperands(TmpVal, $5)) diff --git a/lib/VMCore/Instructions.cpp b/lib/VMCore/Instructions.cpp index 65bc1830e5..d700902a25 100644 --- a/lib/VMCore/Instructions.cpp +++ b/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; } |