diff options
Diffstat (limited to 'lib/Basic/TargetInfo.cpp')
-rw-r--r-- | lib/Basic/TargetInfo.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/Basic/TargetInfo.cpp b/lib/Basic/TargetInfo.cpp index 4d0664857d..71e39dd7d8 100644 --- a/lib/Basic/TargetInfo.cpp +++ b/lib/Basic/TargetInfo.cpp @@ -168,6 +168,21 @@ TargetInfo::IntType TargetInfo::getIntTypeByWidth( return NoInt; } +TargetInfo::IntType TargetInfo::getLeastIntTypeByWidth(unsigned BitWidth, + bool IsSigned) const { + if (getCharWidth() >= BitWidth) + return IsSigned ? SignedChar : UnsignedChar; + if (getShortWidth() >= BitWidth) + return IsSigned ? SignedShort : UnsignedShort; + if (getIntWidth() >= BitWidth) + return IsSigned ? SignedInt : UnsignedInt; + if (getLongWidth() >= BitWidth) + return IsSigned ? SignedLong : UnsignedLong; + if (getLongLongWidth() >= BitWidth) + return IsSigned ? SignedLongLong : UnsignedLongLong; + return NoInt; +} + TargetInfo::RealType TargetInfo::getRealTypeByWidth(unsigned BitWidth) const { if (getFloatWidth() == BitWidth) return Float; |