Reimplement DefineTypeSize in terms of APInt. This eliminates some

magic integer arithmetic and allows it to work with types larger
than 64 bits.

llvm-svn: 126365
This commit is contained in:
Chris Lattner
2011-02-24 06:54:56 +00:00
parent 190aa10fe6
commit d767a0300e

View File

@@ -174,15 +174,10 @@ static void DefineFloatMacros(MacroBuilder &Builder, llvm::StringRef Prefix,
/// signedness of 'isSigned' and with a value suffix of 'ValSuffix' (e.g. LL).
static void DefineTypeSize(llvm::StringRef MacroName, unsigned TypeWidth,
llvm::StringRef ValSuffix, bool isSigned,
MacroBuilder& Builder) {
long long MaxVal;
if (isSigned) {
assert(TypeWidth != 1);
MaxVal = ~0ULL >> (65-TypeWidth);
} else
MaxVal = ~0ULL >> (64-TypeWidth);
Builder.defineMacro(MacroName, llvm::Twine(MaxVal) + ValSuffix);
MacroBuilder &Builder) {
llvm::APInt MaxVal = isSigned ? llvm::APInt::getSignedMaxValue(TypeWidth)
: llvm::APInt::getMaxValue(TypeWidth);
Builder.defineMacro(MacroName, MaxVal.toString(10, isSigned) + ValSuffix);
}
/// DefineTypeSize - An overloaded helper that uses TargetInfo to determine