Changes in directory llvm/include/llvm/ADT:

BitVector.h updated: 1.16 -> 1.17
---
Log message:

Make it 64-bit safe.

---
Diffs of the changes:  (+25 -7)

 BitVector.h |   32 +++++++++++++++++++++++++-------
 1 files changed, 25 insertions(+), 7 deletions(-)


Index: llvm/include/llvm/ADT/BitVector.h
diff -u llvm/include/llvm/ADT/BitVector.h:1.16 
llvm/include/llvm/ADT/BitVector.h:1.17
--- llvm/include/llvm/ADT/BitVector.h:1.16      Thu Feb 15 15:38:15 2007
+++ llvm/include/llvm/ADT/BitVector.h   Thu Mar  1 20:31:37 2007
@@ -120,8 +120,14 @@
   /// of the bits are set.
   int find_first() const {
     for (unsigned i = 0; i < NumBitWords(size()); ++i)
-      if (Bits[i] != 0)
-        return i * BITS_PER_WORD + CountTrailingZeros_32(Bits[i]);
+      if (Bits[i] != 0) {
+       if (sizeof(BitWord) == 4)
+         return i * BITS_PER_WORD + CountTrailingZeros_32(Bits[i]);
+       else if (sizeof(BitWord) == 8)
+         return i * BITS_PER_WORD + CountTrailingZeros_64(Bits[i]);
+       else
+         assert(0 && "Unsupported!");
+      }
     return -1;
   }
 
@@ -136,15 +142,27 @@
     unsigned BitPos = Prev % BITS_PER_WORD;
     BitWord Copy = Bits[WordPos];
     // Mask off previous bits.
-    Copy &= ~0 << BitPos;
+    Copy &= ~0L << BitPos;
 
-    if (Copy != 0)
-      return WordPos * BITS_PER_WORD + CountTrailingZeros_32(Copy);
+    if (Copy != 0) {
+      if (sizeof(BitWord) == 4)
+       return WordPos * BITS_PER_WORD + CountTrailingZeros_32(Copy);
+      else if (sizeof(BitWord) == 8)
+       return WordPos * BITS_PER_WORD + CountTrailingZeros_64(Copy);
+      else
+       assert(0 && "Unsupported!");
+    }
 
     // Check subsequent words.
     for (unsigned i = WordPos+1; i < NumBitWords(size()); ++i)
-      if (Bits[i] != 0)
-        return i * BITS_PER_WORD + CountTrailingZeros_32(Bits[i]);
+      if (Bits[i] != 0) {
+       if (sizeof(BitWord) == 4)
+         return i * BITS_PER_WORD + CountTrailingZeros_32(Bits[i]);
+       else if (sizeof(BitWord) == 8)
+         return i * BITS_PER_WORD + CountTrailingZeros_64(Bits[i]);
+       else
+         assert(0 && "Unsupported!");
+      }
     return -1;
   }
 



_______________________________________________
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits

Reply via email to