As requested by Chris. Neil. -------------- next part -------------- Index: include/llvm/ADT/APInt.h ==================================================================--- include/llvm/ADT/APInt.h (revision 41148) +++ include/llvm/ADT/APInt.h (working copy) @@ -19,9 +19,7 @@ #include <cassert> #include <string> -#define HOST_CHAR_BIT 8 -#define compileTimeAssert(cond) extern int CTAssert[(cond) ? 1 : -1] -#define integerPartWidth (HOST_CHAR_BIT * sizeof(llvm::integerPart)) +#define COMPILE_TIME_ASSERT(cond) extern int CTAssert[(cond) ? 1 : -1] namespace llvm { @@ -29,6 +27,9 @@ bignum. */ typedef uint64_t integerPart; + const unsigned int host_char_bit = 8; + const unsigned int integerPartWidth = host_char_bit * sizeof(integerPart); + //===----------------------------------------------------------------------===// // APInt Class //===----------------------------------------------------------------------===// Index: lib/Support/APInt.cpp ==================================================================--- lib/Support/APInt.cpp (revision 41148) +++ lib/Support/APInt.cpp (working copy) @@ -2018,15 +2018,29 @@ /* Assumed by lowHalf, highHalf, partMSB and partLSB. A fairly safe and unrestricting assumption. */ -compileTimeAssert(integerPartWidth % 2 == 0); +COMPILE_TIME_ASSERT(integerPartWidth % 2 == 0); -#define lowBitMask(bits) (~(integerPart) 0 >> (integerPartWidth - (bits))) -#define lowHalf(part) ((part) & lowBitMask(integerPartWidth / 2)) -#define highHalf(part) ((part) >> (integerPartWidth / 2)) - /* Some handy functions local to this file. */ namespace { + inline integerPart + lowBitMask(unsigned int bits) + { + return ~(integerPart) 0 >> (integerPartWidth - bits); + } + + inline integerPart + lowHalf(integerPart part) + { + return part & lowBitMask(integerPartWidth / 2); + } + + 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