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.
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
//===----------------------------------------------------------------------===//
// 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)
//---- 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
// 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...