summaryrefslogtreecommitdiff
path: root/lib/VMCore/Verifier.cpp
diff options
context:
space:
mode:
authorReid Spencer <rspencer@reidspencer.com>2007-01-12 07:05:14 +0000
committerReid Spencer <rspencer@reidspencer.com>2007-01-12 07:05:14 +0000
commita54b7cbd452b3adb2f51346140d996b29c2cdb30 (patch)
tree00514e24a3fab3804f1a99557ebd343382d0dc27 /lib/VMCore/Verifier.cpp
parented3098989580ecaee7fc89de548afb4c811bea31 (diff)
downloadllvm-a54b7cbd452b3adb2f51346140d996b29c2cdb30.tar.gz
llvm-a54b7cbd452b3adb2f51346140d996b29c2cdb30.tar.bz2
llvm-a54b7cbd452b3adb2f51346140d996b29c2cdb30.tar.xz
For PR1064:
Implement the arbitrary bit-width integer feature. The feature allows integers of any bitwidth (up to 64) to be defined instead of just 1, 8, 16, 32, and 64 bit integers. This change does several things: 1. Introduces a new Derived Type, IntegerType, to represent the number of bits in an integer. The Type classes SubclassData field is used to store the number of bits. This allows 2^23 bits in an integer type. 2. Removes the five integer Type::TypeID values for the 1, 8, 16, 32 and 64-bit integers. These are replaced with just IntegerType which is not a primitive any more. 3. Adjust the rest of LLVM to account for this change. Note that while this incremental change lays the foundation for arbitrary bit-width integers, LLVM has not yet been converted to actually deal with them in any significant way. Most optimization passes, for example, will still only deal with the byte-width integer types. Future increments will rectify this situation. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@33113 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore/Verifier.cpp')
-rw-r--r--lib/VMCore/Verifier.cpp41
1 files changed, 33 insertions, 8 deletions
diff --git a/lib/VMCore/Verifier.cpp b/lib/VMCore/Verifier.cpp
index 4431c81d29..05b8514d9d 100644
--- a/lib/VMCore/Verifier.cpp
+++ b/lib/VMCore/Verifier.cpp
@@ -743,7 +743,7 @@ void Verifier::visitICmpInst(ICmpInst& IC) {
Assert1(Op0Ty == Op1Ty,
"Both operands to ICmp instruction are not of the same type!", &IC);
// Check that the operands are the right type
- Assert1(Op0Ty->isIntegral() || Op0Ty->getTypeID() == Type::PointerTyID,
+ Assert1(Op0Ty->isIntegral() || isa<PointerType>(Op0Ty),
"Invalid operand types for ICmp instruction", &IC);
visitInstruction(IC);
}
@@ -1005,7 +1005,7 @@ void Verifier::VerifyIntrinsicPrototype(Function *F, ...) {
else
Ty = FTy->getParamType(ArgNo-1);
- if (Ty->getTypeID() != TypeID) {
+ if (TypeID != Ty->getTypeID()) {
if (ArgNo == 0)
CheckFailed("Intrinsic prototype has incorrect result type!", F);
else
@@ -1013,18 +1013,43 @@ void Verifier::VerifyIntrinsicPrototype(Function *F, ...) {
break;
}
- // If this is a packed argument, verify the number and type of elements.
- if (TypeID == Type::PackedTyID) {
+ if (TypeID == Type::IntegerTyID) {
+ unsigned GotBits = (unsigned) va_arg(VA, int);
+ unsigned ExpectBits = cast<IntegerType>(Ty)->getBitWidth();
+ if (GotBits != ExpectBits) {
+ std::string bitmsg = " Expecting " + utostr(ExpectBits) + " but got " +
+ utostr(GotBits) + " bits.";
+ if (ArgNo == 0)
+ CheckFailed("Intrinsic prototype has incorrect integer result width!"
+ + bitmsg, F);
+ else
+ CheckFailed("Intrinsic parameter #" + utostr(ArgNo-1) + " has "
+ "incorrect integer width!" + bitmsg, F);
+ break;
+ }
+ } else if (TypeID == Type::PackedTyID) {
+ // If this is a packed argument, verify the number and type of elements.
const PackedType *PTy = cast<PackedType>(Ty);
- if (va_arg(VA, int) != PTy->getElementType()->getTypeID()) {
- CheckFailed("Intrinsic prototype has incorrect vector element type!",F);
+ int ElemTy = va_arg(VA, int);
+ if (ElemTy != PTy->getElementType()->getTypeID()) {
+ CheckFailed("Intrinsic prototype has incorrect vector element type!",
+ F);
break;
}
-
+ if (ElemTy == Type::IntegerTyID) {
+ unsigned NumBits = (unsigned)va_arg(VA, int);
+ unsigned ExpectedBits =
+ cast<IntegerType>(PTy->getElementType())->getBitWidth();
+ if (NumBits != ExpectedBits) {
+ CheckFailed("Intrinsic prototype has incorrect vector element type!",
+ F);
+ break;
+ }
+ }
if ((unsigned)va_arg(VA, int) != PTy->getNumElements()) {
CheckFailed("Intrinsic prototype has incorrect number of "
"vector elements!",F);
- break;
+ break;
}
}
}