[llvm-commits] CVS: llvm/include/llvm/ADT/APInt.h
Zhou Sheng
zhousheng00 at gmail.com
Wed Feb 14 22:36:52 PST 2007
Changes in directory llvm/include/llvm/ADT:
APInt.h updated: 1.8 -> 1.9
---
Log message:
Fix some buges:
1. Make getMinValue() returns the right value.
2. Fix the ByteSwap() crash problem.
3. Make Postfix increment work correctly.
4. Fix some bugs in LogBase2, Hi/LoBits and UDiv.
---
Diffs of the changes: (+9 -6)
APInt.h | 15 +++++++++------
1 files changed, 9 insertions(+), 6 deletions(-)
Index: llvm/include/llvm/ADT/APInt.h
diff -u llvm/include/llvm/ADT/APInt.h:1.8 llvm/include/llvm/ADT/APInt.h:1.9
--- llvm/include/llvm/ADT/APInt.h:1.8 Tue Feb 13 16:41:58 2007
+++ llvm/include/llvm/ADT/APInt.h Thu Feb 15 00:36:31 2007
@@ -143,7 +143,8 @@
/// @brief Postfix increment operator.
inline const APInt operator++(int) {
APInt API(*this);
- return ++API;
+ ++(*this);
+ return API;
}
/// Increments the APInt by one.
@@ -154,7 +155,8 @@
/// @brief Postfix decrement operator.
inline const APInt operator--(int) {
APInt API(*this);
- return --API;
+ --(*this);
+ return API;
}
/// Decrements the APInt by one.
@@ -286,9 +288,9 @@
/// @returns a uint64_t value from this APInt. If this APInt contains a single
/// word, just returns VAL, otherwise pVal[0].
- inline uint64_t getValue() const {
+ inline uint64_t getValue(bool isSigned = false) const {
if (isSingleWord())
- return VAL;
+ return isSigned ? int64_t(VAL << (64 - BitsNum)) >> (64 - BitsNum) : VAL;
unsigned n = getNumWords() * 64 - CountLeadingZeros();
if (n <= 64)
return pVal[0];
@@ -371,8 +373,9 @@
/// @brief Check if this APInt has a N-bits integer value.
inline bool IsIntN(unsigned N) const {
+ assert(N && "N == 0 ???");
if (isSingleWord()) {
- return VAL == VAL & (~uint64_t(0ULL) >> (64 - N));
+ return VAL == (VAL & (~0ULL >> (64 - N)));
} else {
APInt Tmp(N, pVal);
return Tmp == (*this);
@@ -384,7 +387,7 @@
/// @returns the floor log base 2 of this APInt.
inline unsigned LogBase2() const {
- return getNumWords() * APINT_BITS_PER_WORD -
+ return getNumWords() * APINT_BITS_PER_WORD - 1 -
CountLeadingZeros();
}
More information about the llvm-commits
mailing list