[llvm-commits] CVS: llvm/lib/Support/APInt.cpp

Reid Spencer reid at x10sys.com
Mon Mar 19 13:38:04 PDT 2007



Changes in directory llvm/lib/Support:

APInt.cpp updated: 1.71 -> 1.72
---
Log message:

Implement extension of sign bits for negative values in the uint64_t
constructor. This helps to fix test/Assembler/2007-03-19-NegValue.ll


---
Diffs of the changes:  (+5 -1)

 APInt.cpp |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletion(-)


Index: llvm/lib/Support/APInt.cpp
diff -u llvm/lib/Support/APInt.cpp:1.71 llvm/lib/Support/APInt.cpp:1.72
--- llvm/lib/Support/APInt.cpp:1.71	Mon Mar 12 13:37:25 2007
+++ llvm/lib/Support/APInt.cpp	Mon Mar 19 15:37:47 2007
@@ -43,7 +43,8 @@
   return result;
 }
 
-APInt::APInt(uint32_t numBits, uint64_t val) : BitWidth(numBits), VAL(0) {
+APInt::APInt(uint32_t numBits, uint64_t val, bool isSigned ) 
+  : BitWidth(numBits), VAL(0) {
   assert(BitWidth >= IntegerType::MIN_INT_BITS && "bitwidth too small");
   assert(BitWidth <= IntegerType::MAX_INT_BITS && "bitwidth too large");
   if (isSingleWord())
@@ -51,6 +52,9 @@
   else {
     pVal = getClearedMemory(getNumWords());
     pVal[0] = val;
+    if (isSigned && int64_t(val) < 0) 
+      for (unsigned i = 1; i < getNumWords(); ++i)
+        pVal[i] = -1ULL;
   }
   clearUnusedBits();
 }






More information about the llvm-commits mailing list