summaryrefslogtreecommitdiffstats
path: root/llvm/lib/VMCore
diff options
context:
space:
mode:
authorReid Spencer <rspencer@reidspencer.com>2007-01-19 21:13:56 +0000
committerReid Spencer <rspencer@reidspencer.com>2007-01-19 21:13:56 +0000
commita94d394ad2ae63071ae1fd203ea28f50066a5879 (patch)
treeac27c27212b5f7fefcab4a0e19f9053c8ce7a6c8 /llvm/lib/VMCore
parenteaedf70eea55bda4689f5ceaa73fed2e95143173 (diff)
downloadbcm5719-llvm-a94d394ad2ae63071ae1fd203ea28f50066a5879.tar.gz
bcm5719-llvm-a94d394ad2ae63071ae1fd203ea28f50066a5879.zip
For PR1043:
This is the final patch for this PR. It implements some minor cleanup in the use of IntegerType, to wit: 1. Type::getIntegerTypeMask -> IntegerType::getBitMask 2. Type::Int*Ty changed to IntegerType* from Type* 3. ConstantInt::getType() returns IntegerType* now, not Type* This also fixes PR1120. Patch by Sheng Zhou. llvm-svn: 33370
Diffstat (limited to 'llvm/lib/VMCore')
-rw-r--r--llvm/lib/VMCore/ConstantFolding.cpp7
-rw-r--r--llvm/lib/VMCore/Constants.cpp4
-rw-r--r--llvm/lib/VMCore/Type.cpp11
-rw-r--r--llvm/lib/VMCore/ValueTypes.cpp1
4 files changed, 14 insertions, 9 deletions
diff --git a/llvm/lib/VMCore/ConstantFolding.cpp b/llvm/lib/VMCore/ConstantFolding.cpp
index 549ac20c3db..521f6b84a25 100644
--- a/llvm/lib/VMCore/ConstantFolding.cpp
+++ b/llvm/lib/VMCore/ConstantFolding.cpp
@@ -295,13 +295,8 @@ Constant *llvm::ConstantFoldCastInstruction(unsigned opc, const Constant *V,
// Handle ConstantFP input.
if (const ConstantFP *FP = dyn_cast<ConstantFP>(V)) {
// FP -> Integral.
- if (DestTy->isInteger()) {
- if (DestTy == Type::Int32Ty)
- return ConstantInt::get(DestTy, FloatToBits(FP->getValue()));
- assert(DestTy == Type::Int64Ty &&
- "Incorrect integer type for bitcast!");
+ if (DestTy->isInteger())
return ConstantInt::get(DestTy, DoubleToBits(FP->getValue()));
- }
}
return 0;
default:
diff --git a/llvm/lib/VMCore/Constants.cpp b/llvm/lib/VMCore/Constants.cpp
index 85598830887..1a650cc5e1c 100644
--- a/llvm/lib/VMCore/Constants.cpp
+++ b/llvm/lib/VMCore/Constants.cpp
@@ -568,7 +568,7 @@ bool ConstantInt::isValueValidForType(const Type *Ty, int64_t Val) {
unsigned NumBits = cast<IntegerType>(Ty)->getBitWidth(); // assert okay
assert(NumBits <= 64 && "Not implemented: integers > 64-bits");
if (Ty == Type::Int1Ty)
- return Val == 0 || Val == 1;
+ return Val == 0 || Val == 1 || Val == -1;
if (NumBits == 64)
return true; // always true, has to fit in largest type
int64_t Min = -(1ll << (NumBits-1));
@@ -849,7 +849,7 @@ ConstantInt *ConstantInt::get(const Type *Ty, int64_t V) {
return getTrue();
else
return getFalse();
- return IntConstants->getOrCreate(Ty, V & Ty->getIntegerTypeMask());
+ return IntConstants->getOrCreate(Ty, V & cast<IntegerType>(Ty)->getBitMask());
}
//---- ConstantFP::get() implementation...
diff --git a/llvm/lib/VMCore/Type.cpp b/llvm/lib/VMCore/Type.cpp
index 00c6d48dceb..0e9e25cf8b9 100644
--- a/llvm/lib/VMCore/Type.cpp
+++ b/llvm/lib/VMCore/Type.cpp
@@ -81,6 +81,15 @@ const Type *Type::getPrimitiveType(TypeID IDNumber) {
}
}
+const Type *Type::getVAArgsPromotedType() const {
+ if (ID == IntegerTyID && getSubclassData() < 32)
+ return Type::Int32Ty;
+ else if (ID == FloatTyID)
+ return Type::DoubleTy;
+ else
+ return this;
+}
+
/// isFPOrFPVector - Return true if this is a FP type or a vector of FP types.
///
bool Type::isFPOrFPVector() const {
@@ -352,7 +361,7 @@ const Type *StructType::getTypeAtIndex(const Value *V) const {
}; \
} \
static ManagedStatic<TY##Type> The##TY##Ty; \
- const Type *Type::TY##Ty = &*The##TY##Ty
+ const IntegerType *Type::TY##Ty = &*The##TY##Ty
DeclarePrimType(Void, "void");
DeclarePrimType(Float, "float");
diff --git a/llvm/lib/VMCore/ValueTypes.cpp b/llvm/lib/VMCore/ValueTypes.cpp
index 006d7ca1031..8732d641983 100644
--- a/llvm/lib/VMCore/ValueTypes.cpp
+++ b/llvm/lib/VMCore/ValueTypes.cpp
@@ -13,6 +13,7 @@
#include "llvm/CodeGen/ValueTypes.h"
#include "llvm/Type.h"
+#include "llvm/DerivedTypes.h"
using namespace llvm;
/// MVT::getValueTypeString - This function returns value type as a string,
OpenPOWER on IntegriCloud