initial checkin of Neil's APFloat work.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@41203 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Support/APInt.cpp b/lib/Support/APInt.cpp
index 0aec2a6..173f28c 100644
--- a/lib/Support/APInt.cpp
+++ b/lib/Support/APInt.cpp
@@ -2018,19 +2018,39 @@
 
 /* Assumed by lowHalf, highHalf, partMSB and partLSB.  A fairly safe
    and unrestricting assumption.  */
-compileTimeAssert(integerPartWidth % 2 == 0);
-
-#define lowBitMask(bits) (~(integerPart) 0 >> (integerPartWidth - (bits)))
-#define lowHalf(part) ((part) & lowBitMask(integerPartWidth / 2))
-#define highHalf(part) ((part) >> (integerPartWidth / 2))
+COMPILE_TIME_ASSERT(integerPartWidth % 2 == 0);
 
 /* Some handy functions local to this file.  */
 namespace {
 
+  /* Returns the integer part with the least significant BITS set.
+     BITS cannot be zero.  */
+  inline integerPart
+  lowBitMask(unsigned int bits)
+  {
+    assert (bits != 0 && bits <= integerPartWidth);
+
+    return ~(integerPart) 0 >> (integerPartWidth - bits);
+  }
+
+  /* Returns the value of the lower nibble of PART.  */
+  inline integerPart
+  lowHalf(integerPart part)
+  {
+    return part & lowBitMask(integerPartWidth / 2);
+  }
+
+  /* Returns the value of the upper nibble of PART.  */
+  inline integerPart
+  highHalf(integerPart part)
+  {
+    return part >> (integerPartWidth / 2);
+  }
+
   /* Returns the bit number of the most significant bit of a part.  If
      the input number has no bits set -1U is returned.  */
   unsigned int
-  PartMSB(integerPart value)
+  partMSB(integerPart value)
   {
     unsigned int n, msb;
 
@@ -2157,7 +2177,7 @@
       --n;
 
       if (parts[n] != 0) {
-          msb = PartMSB(parts[n]);
+          msb = partMSB(parts[n]);
 
           return msb + n * integerPartWidth;
       }
@@ -2388,11 +2408,11 @@
 
   assert(lhs != remainder && lhs != srhs && remainder != srhs);
 
-  shiftCount = tcMSB(rhs, parts);
-  if (shiftCount == -1U)
+  shiftCount = tcMSB(rhs, parts) + 1;
+  if (shiftCount == 0)
     return true;
 
-  shiftCount = parts * integerPartWidth - shiftCount - 1;
+  shiftCount = parts * integerPartWidth - shiftCount;
   n = shiftCount / integerPartWidth;
   mask = (integerPart) 1 << (shiftCount % integerPartWidth);