Update the Verifier to be aware of the difference between Add and FAdd, etc.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72946 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Dan Gohman 2009-06-05 16:10:00 +00:00
parent f01a457026
commit 11cc35de41

View File

@ -1069,13 +1069,40 @@ void Verifier::visitBinaryOperator(BinaryOperator &B) {
"Both operands to a binary operator are not of the same type!", &B);
switch (B.getOpcode()) {
// Check that integer arithmetic operators are only used with
// integral operands.
case Instruction::Add:
case Instruction::Sub:
case Instruction::Mul:
case Instruction::SDiv:
case Instruction::UDiv:
case Instruction::SRem:
case Instruction::URem:
Assert1(B.getType()->isIntOrIntVector(),
"Integer arithmetic operators only work with integral types!", &B);
Assert1(B.getType() == B.getOperand(0)->getType(),
"Integer arithmetic operators must have same type "
"for operands and result!", &B);
break;
// Check that floating-point arithmetic operators are only used with
// floating-point operands.
case Instruction::FAdd:
case Instruction::FSub:
case Instruction::FMul:
case Instruction::FDiv:
case Instruction::FRem:
Assert1(B.getType()->isFPOrFPVector(),
"Floating-point arithmetic operators only work with "
"integral types!", &B);
Assert1(B.getType() == B.getOperand(0)->getType(),
"Floating-point arithmetic operators must have same type "
"for operands and result!", &B);
break;
// Check that logical operators are only used with integral operands.
case Instruction::And:
case Instruction::Or:
case Instruction::Xor:
Assert1(B.getType()->isInteger() ||
(isa<VectorType>(B.getType()) &&
cast<VectorType>(B.getType())->getElementType()->isInteger()),
Assert1(B.getType()->isIntOrIntVector(),
"Logical operators only work with integral types!", &B);
Assert1(B.getType() == B.getOperand(0)->getType(),
"Logical operators must have same type for operands and result!",
@ -1084,22 +1111,13 @@ void Verifier::visitBinaryOperator(BinaryOperator &B) {
case Instruction::Shl:
case Instruction::LShr:
case Instruction::AShr:
Assert1(B.getType()->isInteger() ||
(isa<VectorType>(B.getType()) &&
cast<VectorType>(B.getType())->getElementType()->isInteger()),
Assert1(B.getType()->isIntOrIntVector(),
"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 */
default:
// Arithmetic operators only work on integer or fp values
Assert1(B.getType() == B.getOperand(0)->getType(),
"Arithmetic operators must have same type for operands and result!",
&B);
Assert1(B.getType()->isInteger() || B.getType()->isFloatingPoint() ||
isa<VectorType>(B.getType()),
"Arithmetic operators must have integer, fp, or vector type!", &B);
break;
default:
assert(0 && "Unknown BinaryOperator opcode!");
}
visitInstruction(B);