diff options
author | Dan Gohman <gohman@apple.com> | 2008-02-08 21:58:15 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2008-02-08 21:58:15 +0000 |
commit | ec646cfd07f1354364e0899561aabffef5b702fd (patch) | |
tree | 26c3b357325ab70813da7b621c7148d5864ea8aa /include/llvm/ADT/APInt.h | |
parent | 5fd79d0560570fed977788a86fa038b898564dfa (diff) | |
download | llvm-ec646cfd07f1354364e0899561aabffef5b702fd.tar.gz llvm-ec646cfd07f1354364e0899561aabffef5b702fd.tar.bz2 llvm-ec646cfd07f1354364e0899561aabffef5b702fd.tar.xz |
Add an isSignedIntN, like isIntN but for signed integer values instead of
unsigned.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@46894 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/ADT/APInt.h')
-rw-r--r-- | include/llvm/ADT/APInt.h | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/include/llvm/ADT/APInt.h b/include/llvm/ADT/APInt.h index a6ec167da3..7fe79e2cca 100644 --- a/include/llvm/ADT/APInt.h +++ b/include/llvm/ADT/APInt.h @@ -280,7 +280,7 @@ public: isNegative() && countPopulation() == 1; } - /// @brief Check if this APInt has an N-bits integer value. + /// @brief Check if this APInt has an N-bits unsigned integer value. inline bool isIntN(uint32_t N) const { assert(N && "N == 0 ???"); if (isSingleWord()) { @@ -291,6 +291,12 @@ public: } } + /// @brief Check if this APInt has an N-bits signed integer value. + inline bool isSignedIntN(uint32_t N) const { + assert(N && "N == 0 ???"); + return getMinSignedBits() <= N; + } + /// @returns true if the argument APInt value is a power of two > 0. bool isPowerOf2() const; @@ -1221,11 +1227,16 @@ inline APInt umax(const APInt &A, const APInt &B) { return A.ugt(B) ? A : B; } -/// @brief Check if the specified APInt has a N-bits integer value. +/// @brief Check if the specified APInt has a N-bits unsigned integer value. inline bool isIntN(uint32_t N, const APInt& APIVal) { return APIVal.isIntN(N); } +/// @brief Check if the specified APInt has a N-bits signed integer value. +inline bool isSignedIntN(uint32_t N, const APInt& APIVal) { + return APIVal.isSignedIntN(N); +} + /// @returns true if the argument APInt value is a sequence of ones /// starting at the least significant bit with the remainder zero. inline bool isMask(uint32_t numBits, const APInt& APIVal) { |