diff options
author | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2014-06-24 00:15:19 +0000 |
---|---|---|
committer | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2014-06-24 00:15:19 +0000 |
commit | 784bb5992ac36b693dbca9e9e5b03b76756dcdd9 (patch) | |
tree | 69021b3d48769611e73897cdf4f3a45d63dee662 /include | |
parent | 747b62f119668e2c4d8622242fbc4b581c34084e (diff) | |
download | llvm-784bb5992ac36b693dbca9e9e5b03b76756dcdd9.tar.gz llvm-784bb5992ac36b693dbca9e9e5b03b76756dcdd9.tar.bz2 llvm-784bb5992ac36b693dbca9e9e5b03b76756dcdd9.tar.xz |
Support: Extract ScaledNumbers::MinScale and MaxScale
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211558 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r-- | include/llvm/Analysis/BlockFrequencyInfoImpl.h | 15 | ||||
-rw-r--r-- | include/llvm/Support/ScaledNumber.h | 6 |
2 files changed, 13 insertions, 8 deletions
diff --git a/include/llvm/Analysis/BlockFrequencyInfoImpl.h b/include/llvm/Analysis/BlockFrequencyInfoImpl.h index 618b6e3366..02ffbed83a 100644 --- a/include/llvm/Analysis/BlockFrequencyInfoImpl.h +++ b/include/llvm/Analysis/BlockFrequencyInfoImpl.h @@ -42,8 +42,6 @@ namespace llvm { class ScaledNumberBase { public: - static const int32_t MaxScale = 16383; - static const int32_t MinScale = -16382; static const int DefaultPrecision = 10; static void dump(uint64_t D, int16_t E, int Width); @@ -146,7 +144,7 @@ public: static ScaledNumber getZero() { return ScaledNumber(0, 0); } static ScaledNumber getOne() { return ScaledNumber(1, 0); } static ScaledNumber getLargest() { - return ScaledNumber(DigitsLimits::max(), MaxScale); + return ScaledNumber(DigitsLimits::max(), ScaledNumbers::MaxScale); } static ScaledNumber getFloat(uint64_t N) { return adjustToWidth(N, 0); } static ScaledNumber getInverseFloat(uint64_t N) { @@ -235,7 +233,7 @@ public: std::tie(Digits, Scale) = ScaledNumbers::getSum(Digits, Scale, X.Digits, X.Scale); // Check for exponent past MaxScale. - if (Scale > MaxScale) + if (Scale > ScaledNumbers::MaxScale) *this = getLargest(); return *this; } @@ -331,8 +329,9 @@ private: /// /// \pre Shift >= MinScale && Shift + 64 <= MaxScale. static ScaledNumber adjustToWidth(uint64_t N, int32_t Shift) { - assert(Shift >= MinScale && "Shift should be close to 0"); - assert(Shift <= MaxScale - 64 && "Shift should be close to 0"); + assert(Shift >= ScaledNumbers::MinScale && "Shift should be close to 0"); + assert(Shift <= ScaledNumbers::MaxScale - 64 && + "Shift should be close to 0"); auto Adjusted = ScaledNumbers::getAdjusted<DigitsT>(N, Shift); return Adjusted; } @@ -462,7 +461,7 @@ template <class DigitsT> void ScaledNumber<DigitsT>::shiftLeft(int32_t Shift) { } // Shift as much as we can in the exponent. - int32_t ScaleShift = std::min(Shift, MaxScale - Scale); + int32_t ScaleShift = std::min(Shift, ScaledNumbers::MaxScale - Scale); Scale += ScaleShift; if (ScaleShift == Shift) return; @@ -493,7 +492,7 @@ template <class DigitsT> void ScaledNumber<DigitsT>::shiftRight(int32_t Shift) { } // Shift as much as we can in the exponent. - int32_t ScaleShift = std::min(Shift, Scale - MinScale); + int32_t ScaleShift = std::min(Shift, Scale - ScaledNumbers::MinScale); Scale -= ScaleShift; if (ScaleShift == Shift) return; diff --git a/include/llvm/Support/ScaledNumber.h b/include/llvm/Support/ScaledNumber.h index a561def037..b12f347806 100644 --- a/include/llvm/Support/ScaledNumber.h +++ b/include/llvm/Support/ScaledNumber.h @@ -32,6 +32,12 @@ namespace llvm { namespace ScaledNumbers { +/// \brief Maximum scale; same as APFloat for easy debug printing. +const int32_t MaxScale = 16383; + +/// \brief Maximum scale; same as APFloat for easy debug printing. +const int32_t MinScale = -16382; + /// \brief Get the width of a number. template <class DigitsT> inline int getWidth() { return sizeof(DigitsT) * 8; } |