aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/llvm/Constants.h10
-rw-r--r--lib/VMCore/Constants.cpp15
2 files changed, 10 insertions, 15 deletions
diff --git a/include/llvm/Constants.h b/include/llvm/Constants.h
index 1ee00aadb3..93c298e76e 100644
--- a/include/llvm/Constants.h
+++ b/include/llvm/Constants.h
@@ -44,10 +44,8 @@ protected:
uint64_t Val;
protected:
ConstantInt(const ConstantInt &); // DO NOT IMPLEMENT
- ConstantInt(const Type *Ty, uint64_t V);
- ConstantInt(const Type *Ty, int64_t V);
- ConstantInt(bool V);
- friend struct ConstantCreator<ConstantInt, Type, uint64_t>;
+ ConstantInt(const IntegerType *Ty, uint64_t V);
+ friend struct ConstantCreator<ConstantInt, IntegerType, uint64_t>;
public:
/// Return the constant as a 64-bit unsigned integer value after it
/// has been zero extended as appropriate for the type of this constant.
@@ -77,12 +75,12 @@ public:
static inline ConstantInt *getTrue() {
static ConstantInt *T = 0;
if (T) return T;
- return T = new ConstantInt(true);
+ return T = new ConstantInt(Type::Int1Ty, 1);
}
static inline ConstantInt *getFalse() {
static ConstantInt *F = 0;
if (F) return F;
- return F = new ConstantInt(false);
+ return F = new ConstantInt(Type::Int1Ty, 0);
}
/// Return a ConstantInt with the specified value for the specified type. The
diff --git a/lib/VMCore/Constants.cpp b/lib/VMCore/Constants.cpp
index 58fe8882c8..0d595314a5 100644
--- a/lib/VMCore/Constants.cpp
+++ b/lib/VMCore/Constants.cpp
@@ -140,12 +140,8 @@ ConstantVector *ConstantVector::getAllOnesValue(const VectorType *Ty) {
//===----------------------------------------------------------------------===//
// Normal Constructors
-ConstantInt::ConstantInt(bool V)
- : Constant(Type::Int1Ty, ConstantIntVal, 0, 0), Val(uint64_t(V)) {
-}
-
-ConstantInt::ConstantInt(const Type *Ty, uint64_t V)
- : Constant(Ty, ConstantIntVal, 0, 0), Val(Ty == Type::Int1Ty ? bool(V) : V) {
+ConstantInt::ConstantInt(const IntegerType *Ty, uint64_t V)
+ : Constant(Ty, ConstantIntVal, 0, 0), Val(V) {
}
ConstantFP::ConstantFP(const Type *Ty, double V)
@@ -802,7 +798,7 @@ public:
//---- ConstantInt::get() implementations...
//
-static ManagedStatic<ValueMap<uint64_t, Type, ConstantInt> > IntConstants;
+static ManagedStatic<ValueMap<uint64_t, IntegerType, ConstantInt> >IntConstants;
// Get a ConstantInt from an int64_t. Note here that we canoncialize the value
// to a uint64_t value that has been zero extended down to the size of the
@@ -810,12 +806,13 @@ static ManagedStatic<ValueMap<uint64_t, Type, ConstantInt> > IntConstants;
// just return the stored value while getSExtValue has to convert back to sign
// extended. getZExtValue is more common in LLVM than getSExtValue().
ConstantInt *ConstantInt::get(const Type *Ty, int64_t V) {
- if (Ty == Type::Int1Ty)
+ const IntegerType *ITy = cast<IntegerType>(Ty);
+ if (Ty == Type::Int1Ty)
if (V & 1)
return getTrue();
else
return getFalse();
- return IntConstants->getOrCreate(Ty, V & cast<IntegerType>(Ty)->getBitMask());
+ return IntConstants->getOrCreate(ITy, V & ITy->getBitMask());
}
//---- ConstantFP::get() implementation...