X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;ds=sidebyside;f=lib%2FVMCore%2FiOperators.cpp;h=20e60cf8741bafbaf0659b459e99e3d28ba58b29;hb=f90a0e4bd7c99788d85655e9f52c63a3a58f7431;hp=956d7d5bdba38f23ceb219447d735483027abe94;hpb=2aa831120c97fa4725aea97b0b3e67e8d95b4f38;p=oota-llvm.git diff --git a/lib/VMCore/iOperators.cpp b/lib/VMCore/iOperators.cpp index 956d7d5bdba..20e60cf8741 100644 --- a/lib/VMCore/iOperators.cpp +++ b/lib/VMCore/iOperators.cpp @@ -17,11 +17,36 @@ BinaryOperator::BinaryOperator(BinaryOps iType, Value *S1, Value *S2, const Type *Ty, const std::string &Name, Instruction *InsertBefore) : Instruction(Ty, iType, Name, InsertBefore) { + Operands.reserve(2); Operands.push_back(Use(S1, this)); Operands.push_back(Use(S2, this)); - assert(Operands[0] && Operands[1] && - Operands[0]->getType() == Operands[1]->getType()); + assert(S1 && S2 && S1->getType() == S2->getType()); + +#ifndef NDEBUG + switch (iType) { + case Add: case Sub: + case Mul: case Div: + case Rem: + assert(Ty == S1->getType() && + "Arithmetic operation should return same type as operands!"); + assert((Ty->isInteger() || Ty->isFloatingPoint()) && + "Tried to create an arithmetic operation on a non-arithmetic type!"); + break; + case And: case Or: + case Xor: + assert(Ty == S1->getType() && + "Logical operation should return same type as operands!"); + assert(Ty->isIntegral() && + "Tried to create an logical operation on a non-integral type!"); + break; + case SetLT: case SetGT: case SetLE: + case SetGE: case SetEQ: case SetNE: + assert(Ty == Type::BoolTy && "Setcc must return bool!"); + default: + break; + } +#endif }