[llvm-commits] [llvm] r46894 - /llvm/trunk/include/llvm/ADT/APInt.h

Dan Gohman gohman at apple.com
Fri Feb 8 13:58:15 PST 2008


Author: djg
Date: Fri Feb  8 15:58:15 2008
New Revision: 46894

URL: http://llvm.org/viewvc/llvm-project?rev=46894&view=rev
Log:
Add an isSignedIntN, like isIntN but for signed integer values instead of
unsigned.

Modified:
    llvm/trunk/include/llvm/ADT/APInt.h

Modified: llvm/trunk/include/llvm/ADT/APInt.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/APInt.h?rev=46894&r1=46893&r2=46894&view=diff

==============================================================================
--- llvm/trunk/include/llvm/ADT/APInt.h (original)
+++ llvm/trunk/include/llvm/ADT/APInt.h Fri Feb  8 15:58:15 2008
@@ -280,7 +280,7 @@
                            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 @@
     }
   }
 
+  /// @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 @@
   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) {





More information about the llvm-commits mailing list