diff options
author | Nate Begeman <natebegeman@mac.com> | 2008-07-29 15:49:41 +0000 |
---|---|---|
committer | Nate Begeman <natebegeman@mac.com> | 2008-07-29 15:49:41 +0000 |
commit | 5bc1ea0736a5785ed596d58beeff2ab23909e33d (patch) | |
tree | 873c527b697e72ea9a3cc6b65f14717777db584a /lib/VMCore | |
parent | 75cf9cc527c6ef3097dcefab173e93716a5a3e4a (diff) |
Add vector shifts to the IR, patch by Eli Friedman.
CodeGen & Clang work coming next.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@54161 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore')
-rw-r--r-- | lib/VMCore/Instructions.cpp | 7 | ||||
-rw-r--r-- | lib/VMCore/Verifier.cpp | 16 |
2 files changed, 16 insertions, 7 deletions
diff --git a/lib/VMCore/Instructions.cpp b/lib/VMCore/Instructions.cpp index bedf74cd9c..5edd39319b 100644 --- a/lib/VMCore/Instructions.cpp +++ b/lib/VMCore/Instructions.cpp @@ -874,6 +874,7 @@ void LoadInst::setAlignment(unsigned Align) { //===----------------------------------------------------------------------===// void StoreInst::AssertOK() { + assert(getOperand(0) && getOperand(1) && "Both operands must be non-null!"); assert(isa<PointerType>(getOperand(1)->getType()) && "Ptr must have pointer type!"); assert(getOperand(0)->getType() == @@ -1535,8 +1536,10 @@ void BinaryOperator::init(BinaryOps iType) { case AShr: assert(getType() == LHS->getType() && "Shift operation should return same type as operands!"); - assert(getType()->isInteger() && - "Shift operation requires integer operands"); + assert((getType()->isInteger() || + (isa<VectorType>(getType()) && + cast<VectorType>(getType())->getElementType()->isInteger())) && + "Tried to create a shift operation on a non-integral type!"); break; case And: case Or: case Xor: diff --git a/lib/VMCore/Verifier.cpp b/lib/VMCore/Verifier.cpp index 4711689f44..96f2076f1a 100644 --- a/lib/VMCore/Verifier.cpp +++ b/lib/VMCore/Verifier.cpp @@ -973,8 +973,10 @@ void Verifier::visitBinaryOperator(BinaryOperator &B) { case Instruction::Shl: case Instruction::LShr: case Instruction::AShr: - Assert1(B.getType()->isInteger(), - "Shift must return an integer result!", &B); + Assert1(B.getType()->isInteger() || + (isa<VectorType>(B.getType()) && + cast<VectorType>(B.getType())->getElementType()->isInteger()), + "Shifts only work with integral types!", &B); Assert1(B.getType() == B.getOperand(0)->getType(), "Shift return type must be same as operands!", &B); /* FALL THROUGH */ @@ -1041,9 +1043,13 @@ void Verifier::visitShuffleVectorInst(ShuffleVectorInst &SV) { // Check to see if Mask is valid. if (const ConstantVector *MV = dyn_cast<ConstantVector>(SV.getOperand(2))) { for (unsigned i = 0, e = MV->getNumOperands(); i != e; ++i) { - Assert1(isa<ConstantInt>(MV->getOperand(i)) || - isa<UndefValue>(MV->getOperand(i)), - "Invalid shufflevector shuffle mask!", &SV); + if (ConstantInt* CI = dyn_cast<ConstantInt>(MV->getOperand(i))) { + Assert1(!CI->uge(MV->getNumOperands()*2), + "Invalid shufflevector shuffle mask!", &SV); + } else { + Assert1(isa<UndefValue>(MV->getOperand(i)), + "Invalid shufflevector shuffle mask!", &SV); + } } } else { Assert1(isa<UndefValue>(SV.getOperand(2)) || |