- unsigned Size = getType()->getPrimitiveSizeInBits();
- return (int64_t(Val) << (64-Size)) >> (64-Size);
- }
-
- /// This function is implemented by subclasses and will return true iff this
- /// constant represents the the "null" value that would be returned by the
- /// getNullValue method.
- /// @returns true if the constant's value is 0.
- /// @brief Determine if the value is null.
- virtual bool isNullValue() const = 0;
-
- /// This function is implemented by sublcasses and will return true iff this
- /// constant represents the the largest value that may be represented by this
- /// constant's type.
- /// @returns true if the constant's value is maximal.
- /// @brief Determine if the value is maximal.
- virtual bool isMaxValue(bool isSigned) const = 0;
-
- /// This function is implemented by subclasses and will return true iff this
- /// constant represents the smallest value that may be represented by this
- /// constant's type.
- /// @returns true if the constant's value is minimal
- /// @brief Determine if the value is minimal.
- virtual bool isMinValue(bool isSigned) const = 0;
-
- /// This function is implemented by subclasses and will return true iff every
- /// bit in this constant is set to true.
- /// @returns true if all bits of the constant are ones.
- /// @brief Determine if the value is all ones.
- virtual bool isAllOnesValue() const = 0;
-
- /// @returns the value for an integer constant of the given type that has all
- /// its bits set to true.
- /// @brief Get the all ones value
- static ConstantIntegral *getAllOnesValue(const Type *Ty);
-
- /// Methods to support type inquiry through isa, cast, and dyn_cast:
- static inline bool classof(const ConstantIntegral *) { return true; }
- static bool classof(const Value *V) {
- return V->getValueType() == ConstantBoolVal ||
- V->getValueType() == ConstantIntVal;
- }
-};
-
-
-//===----------------------------------------------------------------------===//
-/// This concrete class represents constant values of type BoolTy. There are
-/// only two instances of this class constructed: the True and False static
-/// members. The constructor is hidden to ensure this invariant.
-/// @brief Constant Boolean class
-class ConstantBool : public ConstantIntegral {
- ConstantBool(bool V);
-public:
- /// getTrue/getFalse - Return the singleton true/false values.
- static ConstantBool *getTrue();
- static ConstantBool *getFalse();
-
- /// This method is provided mostly for compatibility with the other
- /// ConstantIntegral subclasses.
- /// @brief Static factory method for getting a ConstantBool instance.
- static ConstantBool *get(bool Value) { return Value ? getTrue() : getFalse();}
-
- /// This method is provided mostly for compatibility with the other
- /// ConstantIntegral subclasses.
- /// @brief Static factory method for getting a ConstantBool instance.
- static ConstantBool *get(const Type *Ty, bool Value) { return get(Value); }
-
- /// Returns the opposite value of this ConstantBool value.
- /// @brief Get inverse value.
- inline ConstantBool *inverted() const {
- return getValue() ? getFalse() : getTrue();
- }
-
- /// @returns the value of this ConstantBool
- /// @brief return the boolean value of this constant.
- inline bool getValue() const { return static_cast<bool>(getZExtValue()); }
-
- /// @see ConstantIntegral for details
- /// @brief Implement overrides
- virtual bool isNullValue() const { return getValue() == false; }
- virtual bool isMaxValue(bool isSigned) const { return getValue() == true; }
- virtual bool isMinValue(bool isSigned) const { return getValue() == false; }
- virtual bool isAllOnesValue() const { return getValue() == true; }
-
- /// @brief Methods to support type inquiry through isa, cast, and dyn_cast:
- static inline bool classof(const ConstantBool *) { return true; }
- static bool classof(const Value *V) {
- return V->getValueType() == ConstantBoolVal;