summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEvan Cheng <evan.cheng@apple.com>2007-03-02 02:31:37 +0000
committerEvan Cheng <evan.cheng@apple.com>2007-03-02 02:31:37 +0000
commit934405cf03937f623da51269cdc384c5a883e7e6 (patch)
treea9316edb23ef9f39843b089161a8d50adef8231a
parentc44bdae16b03832ce7f8ed19aed250e77db6a5f2 (diff)
downloadbcm5719-llvm-934405cf03937f623da51269cdc384c5a883e7e6.tar.gz
bcm5719-llvm-934405cf03937f623da51269cdc384c5a883e7e6.zip
Make it 64-bit safe.
llvm-svn: 34829
-rw-r--r--llvm/include/llvm/ADT/BitVector.h32
1 files changed, 25 insertions, 7 deletions
diff --git a/llvm/include/llvm/ADT/BitVector.h b/llvm/include/llvm/ADT/BitVector.h
index 269621313fa..2b0e127265d 100644
--- a/llvm/include/llvm/ADT/BitVector.h
+++ b/llvm/include/llvm/ADT/BitVector.h
@@ -120,8 +120,14 @@ public:
/// 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 @@ public:
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;
}
OpenPOWER on IntegriCloud