- Renamed Type::isIntegral() to Type::isInteger()
- Added new method Type::isIntegral() that is the same as isInteger, but
also accepts bool.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@3574 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/InstrSelection/InstrSelectionSupport.cpp b/lib/CodeGen/InstrSelection/InstrSelectionSupport.cpp
index 5004d90..870bbbd 100644
--- a/lib/CodeGen/InstrSelection/InstrSelectionSupport.cpp
+++ b/lib/CodeGen/InstrSelection/InstrSelectionSupport.cpp
@@ -72,12 +72,12 @@
isValidConstant = true;
if (isa<Constant>(V))
- if (V->getType() == Type::BoolTy)
- return (int64_t) cast<ConstantBool>(V)->getValue();
- else if (V->getType()->isIntegral())
- return (V->getType()->isUnsigned()
- ? cast<ConstantUInt>(V)->getValue()
- : (uint64_t) cast<ConstantSInt>(V)->getValue());
+ if (const ConstantBool *CB = dyn_cast<ConstantBool>(V))
+ return (int64_t)CB->getValue();
+ else if (const ConstantSInt *CS = dyn_cast<ConstantSInt>(V))
+ return (uint64_t)CS->getValue();
+ else if (const ConstantUInt *CU = dyn_cast<ConstantUInt>(V))
+ return CU->getValue();
isValidConstant = false;
return 0;
@@ -343,7 +343,7 @@
}
// Otherwise it needs to be an integer or a NULL pointer
- if (! CPV->getType()->isIntegral() &&
+ if (! CPV->getType()->isInteger() &&
! (isa<PointerType>(CPV->getType()) &&
CPV->isNullValue()))
return opType;
diff --git a/lib/ExecutionEngine/Interpreter/Execution.cpp b/lib/ExecutionEngine/Interpreter/Execution.cpp
index 12ec82a..868bfbe 100644
--- a/lib/ExecutionEngine/Interpreter/Execution.cpp
+++ b/lib/ExecutionEngine/Interpreter/Execution.cpp
@@ -1094,7 +1094,7 @@
cout << "\n";
if (RetTy->isIntegral())
- ExitCode = Result.SByteVal; // Capture the exit code of the program
+ ExitCode = Result.IntVal; // Capture the exit code of the program
}
}
diff --git a/lib/ExecutionEngine/Interpreter/UserInput.cpp b/lib/ExecutionEngine/Interpreter/UserInput.cpp
index 91addb6..4ef7fdc 100644
--- a/lib/ExecutionEngine/Interpreter/UserInput.cpp
+++ b/lib/ExecutionEngine/Interpreter/UserInput.cpp
@@ -294,8 +294,8 @@
}
// fallthrough
case 1:
- if (!MT->getParamTypes()[0]->isIntegral()) {
- cout << "First argument of '" << Name << "' should be integral!\n";
+ if (!MT->getParamTypes()[0]->isInteger()) {
+ cout << "First argument of '" << Name << "' should be an integer!\n";
return true;
} else {
GenericValue GV; GV.UIntVal = InputArgv.size();
diff --git a/lib/Target/SparcV9/InstrSelection/InstrSelectionSupport.cpp b/lib/Target/SparcV9/InstrSelection/InstrSelectionSupport.cpp
index 5004d90..870bbbd 100644
--- a/lib/Target/SparcV9/InstrSelection/InstrSelectionSupport.cpp
+++ b/lib/Target/SparcV9/InstrSelection/InstrSelectionSupport.cpp
@@ -72,12 +72,12 @@
isValidConstant = true;
if (isa<Constant>(V))
- if (V->getType() == Type::BoolTy)
- return (int64_t) cast<ConstantBool>(V)->getValue();
- else if (V->getType()->isIntegral())
- return (V->getType()->isUnsigned()
- ? cast<ConstantUInt>(V)->getValue()
- : (uint64_t) cast<ConstantSInt>(V)->getValue());
+ if (const ConstantBool *CB = dyn_cast<ConstantBool>(V))
+ return (int64_t)CB->getValue();
+ else if (const ConstantSInt *CS = dyn_cast<ConstantSInt>(V))
+ return (uint64_t)CS->getValue();
+ else if (const ConstantUInt *CU = dyn_cast<ConstantUInt>(V))
+ return CU->getValue();
isValidConstant = false;
return 0;
@@ -343,7 +343,7 @@
}
// Otherwise it needs to be an integer or a NULL pointer
- if (! CPV->getType()->isIntegral() &&
+ if (! CPV->getType()->isInteger() &&
! (isa<PointerType>(CPV->getType()) &&
CPV->isNullValue()))
return opType;
diff --git a/lib/Target/SparcV9/SparcV9InstrInfo.cpp b/lib/Target/SparcV9/SparcV9InstrInfo.cpp
index 9c82d80..4212101 100644
--- a/lib/Target/SparcV9/SparcV9InstrInfo.cpp
+++ b/lib/Target/SparcV9/SparcV9InstrInfo.cpp
@@ -308,7 +308,7 @@
mcfi.addTemp(tmpReg);
CreateSETXLabel(target, val, tmpReg, dest, mvec);
}
- else if (valType->isIntegral() || valType == Type::BoolTy)
+ else if (valType->isIntegral())
{
bool isValidConstant;
unsigned opSize = target.DataLayout.getTypeSize(val->getType());
@@ -396,8 +396,8 @@
vector<MachineInstr*>& mvec,
MachineCodeForInstruction& mcfi) const
{
- assert((val->getType()->isIntegral() || isa<PointerType>(val->getType()))
- && "Source type must be integral");
+ assert((val->getType()->isInteger() || isa<PointerType>(val->getType()))
+ && "Source type must be integer or pointer");
assert(dest->getType()->isFloatingPoint()
&& "Dest type must be float/double");
@@ -445,8 +445,8 @@
const Type* destTy = dest->getType();
assert(opTy->isFloatingPoint() && "Source type must be float/double");
- assert((destTy->isIntegral() || isa<PointerType>(destTy))
- && "Dest type must be integral");
+ assert((destTy->isInteger() || isa<PointerType>(destTy))
+ && "Dest type must be integer or pointer");
int offset = MachineCodeForMethod::get(F).allocateLocalVar(target, val);
diff --git a/lib/Target/SparcV9/SparcV9InstrSelection.cpp b/lib/Target/SparcV9/SparcV9InstrSelection.cpp
index 050ca8e..a68331b 100644
--- a/lib/Target/SparcV9/SparcV9InstrSelection.cpp
+++ b/lib/Target/SparcV9/SparcV9InstrSelection.cpp
@@ -396,7 +396,7 @@
{
MachineOpCode opCode = INVALID_OPCODE;
- if (resultType->isIntegral() || isa<PointerType>(resultType))
+ if (resultType->isInteger() || isa<PointerType>(resultType))
{
opCode = SUB;
}
@@ -474,7 +474,7 @@
{
MachineOpCode opCode = INVALID_OPCODE;
- if (resultType->isIntegral())
+ if (resultType->isInteger())
opCode = MULX;
else
switch(resultType->getPrimitiveID())
@@ -577,7 +577,7 @@
//
const Type* resultType = destVal->getType();
- if (resultType->isIntegral() || isa<PointerType>(resultType))
+ if (resultType->isInteger() || isa<PointerType>(resultType))
{
bool isValidConst;
int64_t C = GetConstantValueAsSignedInt(constOp, isValidConst);
@@ -719,7 +719,7 @@
const Type* resultType = instrNode->getInstruction()->getType();
- if (resultType->isIntegral())
+ if (resultType->isInteger())
opCode = resultType->isSigned()? SDIVX : UDIVX;
else
switch(resultType->getPrimitiveID())
@@ -752,7 +752,7 @@
//
const Type* resultType = instrNode->getInstruction()->getType();
- if (resultType->isIntegral())
+ if (resultType->isInteger())
{
unsigned pow;
bool isValidConst;
@@ -1296,7 +1296,7 @@
Constant *constVal = cast<Constant>(constNode->getValue());
bool isValidConst;
- if ((constVal->getType()->isIntegral()
+ if ((constVal->getType()->isInteger()
|| isa<PointerType>(constVal->getType()))
&& GetConstantValueAsSignedInt(constVal, isValidConst) == 0
&& isValidConst)
@@ -1432,8 +1432,7 @@
case 22: // reg: ToBoolTy(reg):
{
const Type* opType = subtreeRoot->leftChild()->getValue()->getType();
- assert(opType->isIntegral() || isa<PointerType>(opType)
- || opType == Type::BoolTy);
+ assert(opType->isIntegral() || isa<PointerType>(opType));
forwardOperandNum = 0; // forward first operand to user
break;
}
@@ -1446,9 +1445,7 @@
Instruction* destI = subtreeRoot->getInstruction();
Value* opVal = subtreeRoot->leftChild()->getValue();
const Type* opType = subtreeRoot->leftChild()->getValue()->getType();
- if (opType->isIntegral()
- || isa<PointerType>(opType)
- || opType == Type::BoolTy)
+ if (opType->isIntegral() || isa<PointerType>(opType))
{
unsigned opSize = target.DataLayout.getTypeSize(opType);
unsigned destSize = target.DataLayout.getTypeSize(destI->getType());
@@ -1490,9 +1487,7 @@
MachineCodeForInstruction& mcfi =MachineCodeForInstruction::get(destI);
const Type* opType = opVal->getType();
- if (opType->isIntegral()
- || isa<PointerType>(opType)
- || opType == Type::BoolTy)
+ if (opType->isIntegral() || isa<PointerType>(opType))
{
// These operand types have the same format as the destination,
// but may have different size: add sign bits or mask as needed.
@@ -2091,9 +2086,8 @@
Instruction* shlInstr = subtreeRoot->getInstruction();
const Type* opType = argVal1->getType();
- assert(opType->isIntegral()
- || opType == Type::BoolTy
- || isa<PointerType>(opType)&&"Shl unsupported for other types");
+ assert((opType->isInteger() || isa<PointerType>(opType)) &&
+ "Shl unsupported for other types");
CreateShiftInstructions(target, shlInstr->getParent()->getParent(),
(opType == Type::LongTy)? SLLX : SLL,
@@ -2104,8 +2098,8 @@
case 63: // reg: Shr(reg, reg)
{ const Type* opType = subtreeRoot->leftChild()->getValue()->getType();
- assert(opType->isIntegral()
- || isa<PointerType>(opType)&&"Shr unsupported for other types");
+ assert((opType->isInteger() || isa<PointerType>(opType)) &&
+ "Shr unsupported for other types");
mvec.push_back(new MachineInstr((opType->isSigned()
? ((opType == Type::LongTy)? SRAX : SRA)
: ((opType == Type::LongTy)? SRLX : SRL))));
diff --git a/lib/Target/SparcV9/SparcV9InstrSelectionSupport.h b/lib/Target/SparcV9/SparcV9InstrSelectionSupport.h
index b076db1..9038a4d 100644
--- a/lib/Target/SparcV9/SparcV9InstrSelectionSupport.h
+++ b/lib/Target/SparcV9/SparcV9InstrSelectionSupport.h
@@ -62,8 +62,7 @@
if (resultType->isIntegral() ||
isa<PointerType>(resultType) ||
isa<FunctionType>(resultType) ||
- resultType == Type::LabelTy ||
- resultType == Type::BoolTy)
+ resultType == Type::LabelTy)
{
opCode = ADD;
}
diff --git a/lib/Target/SparcV9/SparcV9RegInfo.cpp b/lib/Target/SparcV9/SparcV9RegInfo.cpp
index 4625773..f55e56d 100644
--- a/lib/Target/SparcV9/SparcV9RegInfo.cpp
+++ b/lib/Target/SparcV9/SparcV9RegInfo.cpp
@@ -651,7 +651,7 @@
const Value *argCopy = argDesc->getArgInfo(i).getArgCopy();
if (argCopy != NULL)
{
- assert(regType != IntRegType && argCopy->getType()->isIntegral()
+ assert(regType != IntRegType && argCopy->getType()->isInteger()
&& "Must be passing copy of FP argument in int register");
int copyRegNum = regNumForIntArg(/*inCallee*/false, /*isVarArgs*/false,
argNo, intArgNo, fpArgNo-1,
@@ -907,7 +907,7 @@
const Value *argCopy = argDesc->getArgInfo(i).getArgCopy();
if (argCopy != NULL)
{
- assert(regType != IntRegType && argCopy->getType()->isIntegral()
+ assert(regType != IntRegType && argCopy->getType()->isInteger()
&& "Must be passing copy of FP argument in int register");
unsigned copyRegClassID = getRegClassIDOfValue(argCopy);
diff --git a/lib/Transforms/LevelRaise.cpp b/lib/Transforms/LevelRaise.cpp
index 327735c..8a08e9d 100644
--- a/lib/Transforms/LevelRaise.cpp
+++ b/lib/Transforms/LevelRaise.cpp
@@ -165,7 +165,7 @@
}
// Only proceed if we have detected all of our conditions successfully...
- if (!CompTy || !SrcPtr || !OffsetVal->getType()->isIntegral())
+ if (!CompTy || !SrcPtr || !OffsetVal->getType()->isInteger())
return false;
std::vector<Value*> Indices;
diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp
index 128d766..785eb70 100644
--- a/lib/Transforms/Scalar/InstructionCombining.cpp
+++ b/lib/Transforms/Scalar/InstructionCombining.cpp
@@ -217,10 +217,10 @@
// Simplify mul instructions with a constant RHS...
if (Constant *Op2 = dyn_cast<Constant>(I.getOperand(1))) {
- if (I.getType()->isIntegral() && cast<ConstantInt>(Op2)->equalsInt(1))
+ if (I.getType()->isInteger() && cast<ConstantInt>(Op2)->equalsInt(1))
return ReplaceInstUsesWith(I, Op1); // Eliminate 'mul int %X, 1'
- if (I.getType()->isIntegral() && cast<ConstantInt>(Op2)->equalsInt(2))
+ if (I.getType()->isInteger() && cast<ConstantInt>(Op2)->equalsInt(2))
// Convert 'mul int %X, 2' to 'add int %X, %X'
return BinaryOperator::create(Instruction::Add, Op1, Op1, I.getName());
@@ -499,13 +499,6 @@
}
-// isCIntegral - For the purposes of casting, we allow conversion of sizes and
-// stuff as long as the value type acts basically integral like.
-//
-static bool isCIntegral(const Type *Ty) {
- return Ty->isIntegral() || Ty == Type::BoolTy;
-}
-
// isEliminableCastOfCast - Return true if it is valid to eliminate the CI
// instruction.
//
@@ -524,7 +517,7 @@
// Allow free casting and conversion of sizes as long as the sign doesn't
// change...
- if (isCIntegral(SrcTy) && isCIntegral(MidTy) && isCIntegral(DstTy)) {
+ if (SrcTy->isIntegral() && MidTy->isIntegral() && DstTy->isIntegral()) {
unsigned SrcSize = SrcTy->getPrimitiveSize();
unsigned MidSize = MidTy->getPrimitiveSize();
unsigned DstSize = DstTy->getPrimitiveSize();
@@ -597,7 +590,7 @@
// to convert this into a logical 'and' instruction.
//
if (CSrc->getOperand(0)->getType() == CI.getType() &&
- CI.getType()->isIntegral() && CSrc->getType()->isIntegral() &&
+ CI.getType()->isInteger() && CSrc->getType()->isInteger() &&
CI.getType()->isUnsigned() && CSrc->getType()->isUnsigned() &&
CSrc->getType()->getPrimitiveSize() < CI.getType()->getPrimitiveSize()){
assert(CSrc->getType() != Type::ULongTy &&
diff --git a/lib/VMCore/Constants.cpp b/lib/VMCore/Constants.cpp
index 40c714e..146f307 100644
--- a/lib/VMCore/Constants.cpp
+++ b/lib/VMCore/Constants.cpp
@@ -236,12 +236,11 @@
// classof implementations
bool ConstantIntegral::classof(const Constant *CPV) {
- return (CPV->getType()->isIntegral() || CPV->getType() == Type::BoolTy) &&
- !isa<ConstantExpr>(CPV);
+ return CPV->getType()->isIntegral() && !isa<ConstantExpr>(CPV);
}
bool ConstantInt::classof(const Constant *CPV) {
- return CPV->getType()->isIntegral() && !isa<ConstantExpr>(CPV);
+ return CPV->getType()->isInteger() && !isa<ConstantExpr>(CPV);
}
bool ConstantSInt::classof(const Constant *CPV) {
return CPV->getType()->isSigned() && !isa<ConstantExpr>(CPV);
diff --git a/lib/VMCore/Type.cpp b/lib/VMCore/Type.cpp
index e4a0dca..4990700 100644
--- a/lib/VMCore/Type.cpp
+++ b/lib/VMCore/Type.cpp
@@ -151,36 +151,28 @@
// These classes are used to implement specialized behavior for each different
// type.
//
-class SignedIntType : public Type {
- int Size;
-public:
- SignedIntType(const string &Name, PrimitiveID id, int size) : Type(Name, id) {
- Size = size;
- }
+struct SignedIntType : public Type {
+ SignedIntType(const string &Name, PrimitiveID id) : Type(Name, id) {}
// isSigned - Return whether a numeric type is signed.
virtual bool isSigned() const { return 1; }
- // isIntegral - Equivalent to isSigned() || isUnsigned, but with only a single
+ // isInteger - Equivalent to isSigned() || isUnsigned, but with only a single
// virtual function invocation.
//
- virtual bool isIntegral() const { return 1; }
+ virtual bool isInteger() const { return 1; }
};
-class UnsignedIntType : public Type {
- uint64_t Size;
-public:
- UnsignedIntType(const string &N, PrimitiveID id, int size) : Type(N, id) {
- Size = size;
- }
+struct UnsignedIntType : public Type {
+ UnsignedIntType(const string &N, PrimitiveID id) : Type(N, id) {}
// isUnsigned - Return whether a numeric type is signed.
virtual bool isUnsigned() const { return 1; }
- // isIntegral - Equivalent to isSigned() || isUnsigned, but with only a single
+ // isInteger - Equivalent to isSigned() || isUnsigned, but with only a single
// virtual function invocation.
//
- virtual bool isIntegral() const { return 1; }
+ virtual bool isInteger() const { return 1; }
};
static struct TypeType : public Type {
@@ -194,14 +186,14 @@
Type *Type::VoidTy = new Type("void" , VoidTyID),
*Type::BoolTy = new Type("bool" , BoolTyID),
- *Type::SByteTy = new SignedIntType("sbyte" , SByteTyID, 1),
- *Type::UByteTy = new UnsignedIntType("ubyte" , UByteTyID, 1),
- *Type::ShortTy = new SignedIntType("short" , ShortTyID, 2),
- *Type::UShortTy = new UnsignedIntType("ushort", UShortTyID, 2),
- *Type::IntTy = new SignedIntType("int" , IntTyID, 4),
- *Type::UIntTy = new UnsignedIntType("uint" , UIntTyID, 4),
- *Type::LongTy = new SignedIntType("long" , LongTyID, 8),
- *Type::ULongTy = new UnsignedIntType("ulong" , ULongTyID, 8),
+ *Type::SByteTy = new SignedIntType("sbyte" , SByteTyID),
+ *Type::UByteTy = new UnsignedIntType("ubyte" , UByteTyID),
+ *Type::ShortTy = new SignedIntType("short" , ShortTyID),
+ *Type::UShortTy = new UnsignedIntType("ushort", UShortTyID),
+ *Type::IntTy = new SignedIntType("int" , IntTyID),
+ *Type::UIntTy = new UnsignedIntType("uint" , UIntTyID),
+ *Type::LongTy = new SignedIntType("long" , LongTyID),
+ *Type::ULongTy = new UnsignedIntType("ulong" , ULongTyID),
*Type::FloatTy = new Type("float" , FloatTyID),
*Type::DoubleTy = new Type("double", DoubleTyID),
*Type::TypeTy = &TheTypeType,