- /// getTrue/getFalse - Return the singleton true/false values.
- static inline ConstantInt *getTrue() {
- static ConstantInt *T = 0;
- if (T) return T;
- return T = new ConstantInt(true);
- }
- static inline ConstantInt *getFalse() {
- static ConstantInt *F = 0;
- if (F) return F;
- return F = new ConstantInt(false);
- }
-
- /// @brief Static factory method for getting a ConstantInt instance which
- /// stands for a bool value.
- static ConstantInt *get(bool Value) { return Value ? getTrue() : getFalse();}
-
- /// Return a ConstantInt with the specified value for the specified type. The
- /// value V will be canonicalized to a uint64_t but accessing it with either
- /// getSExtValue() or getZExtValue() (ConstantInt) will yield the correct
- /// sized/signed value for the type Ty.
- /// @brief Get a ConstantInt for a specific value.
- static ConstantInt *get(const Type *Ty, int64_t V);
-
- /// Returns the opposite value of this ConstantInt.
- /// @brief Get inverse value.
- inline ConstantInt *inverted() const {
- static ConstantInt *CI = 0;
- if (CI) return CI;
- return CI = new ConstantInt(getType(),
- Val ^ (getType() == Type::BoolTy ? 1 : -1));
- }
-
- /// @returns the value of this ConstantInt only if it's a boolean type.
- /// @brief return the boolean value of this constant.
- inline bool getBoolValue() const {
- assert(getType() == Type::BoolTy && "Should be a boolean constant!");
- return static_cast<bool>(getZExtValue());
+ /// getType - Specialize the getType() method to always return an IntegerType,
+ /// which reduces the amount of casting needed in parts of the compiler.
+ ///
+ inline const IntegerType *getType() const {
+ return reinterpret_cast<const IntegerType*>(Value::getType());