Implement TLSLDM.
[oota-llvm.git] / include / llvm / ADT / SmallBitVector.h
index 884e631c88bce368e0fe37f1c82b70c53d1c2932..b15b3ee0418f9ce1f0b5f131058f0cda4ffc87da 100644 (file)
@@ -187,6 +187,13 @@ public:
     return getPointer()->any();
   }
 
+  /// all - Returns true if all bits are set.
+  bool all() const {
+    if (isSmall())
+      return getSmallBits() == (uintptr_t(1) << getSmallSize()) - 1;
+    return getPointer()->all();
+  }
+
   /// none - Returns true if none of the bits are set.
   bool none() const {
     if (isSmall())
@@ -199,13 +206,12 @@ public:
   int find_first() const {
     if (isSmall()) {
       uintptr_t Bits = getSmallBits();
-      if (sizeof(uintptr_t) * CHAR_BIT == 32) {
-        size_t FirstBit = CountTrailingZeros_32(Bits);
-        return FirstBit == 32 ? -1 : FirstBit;
-      } else if (sizeof(uintptr_t) * CHAR_BIT == 64) {
-        size_t FirstBit = CountTrailingZeros_64(Bits);
-        return FirstBit == 64 ? -1 : FirstBit;
-      }
+      if (Bits == 0)
+        return -1;
+      if (sizeof(uintptr_t) * CHAR_BIT == 32)
+        return CountTrailingZeros_32(Bits);
+      if (sizeof(uintptr_t) * CHAR_BIT == 64)
+        return CountTrailingZeros_64(Bits);
       assert(0 && "Unsupported!");
     }
     return getPointer()->find_first();
@@ -218,13 +224,12 @@ public:
       uintptr_t Bits = getSmallBits();
       // Mask off previous bits.
       Bits &= ~uintptr_t(0) << (Prev + 1);
-      if (sizeof(uintptr_t) * CHAR_BIT == 32) {
-        size_t FirstBit = CountTrailingZeros_32(Bits);
-        return FirstBit == 32 ? -1 : FirstBit;
-      } else if (sizeof(uintptr_t) * CHAR_BIT == 64) {
-        size_t FirstBit = CountTrailingZeros_64(Bits);
-        return FirstBit == 64 ? -1 : FirstBit;
-      }
+      if (Bits == 0 || Prev + 1 >= getSmallSize())
+        return -1;
+      if (sizeof(uintptr_t) * CHAR_BIT == 32)
+        return CountTrailingZeros_32(Bits);
+      if (sizeof(uintptr_t) * CHAR_BIT == 64)
+        return CountTrailingZeros_64(Bits);
       assert(0 && "Unsupported!");
     }
     return getPointer()->find_next(Prev);