/// @returns true if the argument APInt value is a power of two > 0.
bool isPowerOf2() const;
+ /// isSignBit - Return true if this is the value returned by getSignBit.
+ bool isSignBit() const { return isMinSignedValue(); }
+
/// This converts the APInt to a boolean value as a test against zero.
/// @brief Boolean conversion function.
inline bool getBoolValue() const {
- return countLeadingZeros() != BitWidth;
+ return *this != 0;
+ }
+
+ /// getLimitedValue - If this value is smaller than the specified limit,
+ /// return it, otherwise return the limit value. This causes the value
+ /// to saturate to the limit.
+ uint64_t getLimitedValue(uint64_t Limit = ~0ULL) const {
+ return (getActiveBits() > 64 || getZExtValue() > Limit) ?
+ Limit : getZExtValue();
}
/// @}
return &pVal[0];
}
- /// @brief Set a sepcific word in the value to a new value.
- inline void setWordToValue(uint32_t idx, uint64_t Val) {
- assert(idx < getNumWords() && "Invalid word array index");
- if (isSingleWord())
- VAL = Val;
- else
- pVal[idx] = Val;
- }
-
/// @}
/// @name Unary Operators
/// @{
APInt operator-(uint64_t RHS) const {
return (*this) - APInt(BitWidth, RHS);
}
+
+ APInt operator<<(unsigned Bits) const {
+ return shl(Bits);
+ }
/// Arithmetic right-shift this APInt by shiftAmt.
/// @brief Arithmetic right-shift function.
/// @brief Zero extend or truncate to width
APInt &zextOrTrunc(uint32_t width);
- /// This is a help function for convenience. If the given \p width equals to
- /// this APInt's BitWidth, just return this APInt, otherwise, just zero
- /// extend it.
- inline APInt &zextOrCopy(uint32_t width) {
- if (width == BitWidth)
- return *this;
- return zext(width);
- }
-
/// @}
/// @name Bit Manipulation Operators
/// @{