Use Type::isIntOrIntVector and Type::isFPOrFPVector.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73433 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Dan Gohman 2009-06-15 22:25:12 +00:00
parent 6de29f8d96
commit f57478f381
2 changed files with 15 additions and 20 deletions

View File

@ -2246,34 +2246,30 @@ Constant *ConstantExpr::get(unsigned Opcode, Constant *C1, Constant *C2) {
case Instruction::UDiv:
case Instruction::SDiv:
assert(C1->getType() == C2->getType() && "Op types should be identical!");
assert((C1->getType()->isInteger() || (isa<VectorType>(C1->getType()) &&
cast<VectorType>(C1->getType())->getElementType()->isInteger())) &&
assert(C1->getType()->isIntOrIntVector() &&
"Tried to create an arithmetic operation on a non-arithmetic type!");
break;
case Instruction::FDiv:
assert(C1->getType() == C2->getType() && "Op types should be identical!");
assert((C1->getType()->isFloatingPoint() || (isa<VectorType>(C1->getType())
&& cast<VectorType>(C1->getType())->getElementType()->isFloatingPoint()))
&& "Tried to create an arithmetic operation on a non-arithmetic type!");
assert(C1->getType()->isFPOrFPVector() &&
"Tried to create an arithmetic operation on a non-arithmetic type!");
break;
case Instruction::URem:
case Instruction::SRem:
assert(C1->getType() == C2->getType() && "Op types should be identical!");
assert((C1->getType()->isInteger() || (isa<VectorType>(C1->getType()) &&
cast<VectorType>(C1->getType())->getElementType()->isInteger())) &&
assert(C1->getType()->isIntOrIntVector() &&
"Tried to create an arithmetic operation on a non-arithmetic type!");
break;
case Instruction::FRem:
assert(C1->getType() == C2->getType() && "Op types should be identical!");
assert((C1->getType()->isFloatingPoint() || (isa<VectorType>(C1->getType())
&& cast<VectorType>(C1->getType())->getElementType()->isFloatingPoint()))
&& "Tried to create an arithmetic operation on a non-arithmetic type!");
assert(C1->getType()->isFPOrFPVector() &&
"Tried to create an arithmetic operation on a non-arithmetic type!");
break;
case Instruction::And:
case Instruction::Or:
case Instruction::Xor:
assert(C1->getType() == C2->getType() && "Op types should be identical!");
assert((C1->getType()->isInteger() || isa<VectorType>(C1->getType())) &&
assert(C1->getType()->isIntOrIntVector() &&
"Tried to create a logical operation on a non-integral type!");
break;
case Instruction::Shl:

View File

@ -1576,9 +1576,8 @@ void BinaryOperator::init(BinaryOps iType) {
case FDiv:
assert(getType() == LHS->getType() &&
"Arithmetic operation should return same type as operands!");
assert((getType()->isFloatingPoint() || (isa<VectorType>(getType()) &&
cast<VectorType>(getType())->getElementType()->isFloatingPoint()))
&& "Incorrect operand type (not floating point) for FDIV");
assert(getType()->isFPOrFPVector() &&
"Incorrect operand type (not floating point) for FDIV");
break;
case URem:
case SRem:
@ -1591,9 +1590,8 @@ void BinaryOperator::init(BinaryOps iType) {
case FRem:
assert(getType() == LHS->getType() &&
"Arithmetic operation should return same type as operands!");
assert((getType()->isFloatingPoint() || (isa<VectorType>(getType()) &&
cast<VectorType>(getType())->getElementType()->isFloatingPoint()))
&& "Incorrect operand type (not floating point) for FREM");
assert(getType()->isFPOrFPVector() &&
"Incorrect operand type (not floating point) for FREM");
break;
case Shl:
case LShr:
@ -2137,7 +2135,8 @@ CastInst *CastInst::CreateIntegerCast(Value *C, const Type *Ty,
CastInst *CastInst::CreateIntegerCast(Value *C, const Type *Ty,
bool isSigned, const std::string &Name,
BasicBlock *InsertAtEnd) {
assert(C->getType()->isInteger() && Ty->isInteger() && "Invalid cast");
assert(C->getType()->isIntOrIntVector() && Ty->isIntOrIntVector() &&
"Invalid cast");
unsigned SrcBits = C->getType()->getScalarSizeInBits();
unsigned DstBits = Ty->getScalarSizeInBits();
Instruction::CastOps opcode =
@ -2150,7 +2149,7 @@ CastInst *CastInst::CreateIntegerCast(Value *C, const Type *Ty,
CastInst *CastInst::CreateFPCast(Value *C, const Type *Ty,
const std::string &Name,
Instruction *InsertBefore) {
assert(C->getType()->isFloatingPoint() && Ty->isFloatingPoint() &&
assert(C->getType()->isFPOrFPVector() && Ty->isFPOrFPVector() &&
"Invalid cast");
unsigned SrcBits = C->getType()->getScalarSizeInBits();
unsigned DstBits = Ty->getScalarSizeInBits();
@ -2163,7 +2162,7 @@ CastInst *CastInst::CreateFPCast(Value *C, const Type *Ty,
CastInst *CastInst::CreateFPCast(Value *C, const Type *Ty,
const std::string &Name,
BasicBlock *InsertAtEnd) {
assert(C->getType()->isFloatingPoint() && Ty->isFloatingPoint() &&
assert(C->getType()->isFPOrFPVector() && Ty->isFPOrFPVector() &&
"Invalid cast");
unsigned SrcBits = C->getType()->getScalarSizeInBits();
unsigned DstBits = Ty->getScalarSizeInBits();