Turn const/const& into value type for BlockFrequency in functions of this class. Also fix a naming issue. NFC.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@250074 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Cong Hou 2015-10-12 18:14:15 +00:00
parent 7e08dd1195
commit d4c646110a
2 changed files with 13 additions and 15 deletions

View File

@ -38,7 +38,7 @@ public:
/// \brief Multiplies with a branch probability. The computation will never
/// overflow.
BlockFrequency &operator*=(BranchProbability Prob);
const BlockFrequency operator*(BranchProbability Prob) const;
BlockFrequency operator*(BranchProbability Prob) const;
/// \brief Divide by a non-zero branch probability using saturating
/// arithmetic.
@ -46,25 +46,25 @@ public:
BlockFrequency operator/(BranchProbability Prob) const;
/// \brief Adds another block frequency using saturating arithmetic.
BlockFrequency &operator+=(const BlockFrequency &Freq);
const BlockFrequency operator+(const BlockFrequency &Freq) const;
BlockFrequency &operator+=(BlockFrequency Freq);
BlockFrequency operator+(BlockFrequency Freq) const;
/// \brief Shift block frequency to the right by count digits saturating to 1.
BlockFrequency &operator>>=(const unsigned count);
bool operator<(const BlockFrequency &RHS) const {
bool operator<(BlockFrequency RHS) const {
return Frequency < RHS.Frequency;
}
bool operator<=(const BlockFrequency &RHS) const {
bool operator<=(BlockFrequency RHS) const {
return Frequency <= RHS.Frequency;
}
bool operator>(const BlockFrequency &RHS) const {
bool operator>(BlockFrequency RHS) const {
return Frequency > RHS.Frequency;
}
bool operator>=(const BlockFrequency &RHS) const {
bool operator>=(BlockFrequency RHS) const {
return Frequency >= RHS.Frequency;
}
};

View File

@ -22,8 +22,7 @@ BlockFrequency &BlockFrequency::operator*=(BranchProbability Prob) {
return *this;
}
const BlockFrequency
BlockFrequency::operator*(BranchProbability Prob) const {
BlockFrequency BlockFrequency::operator*(BranchProbability Prob) const {
BlockFrequency Freq(Frequency);
Freq *= Prob;
return Freq;
@ -40,7 +39,7 @@ BlockFrequency BlockFrequency::operator/(BranchProbability Prob) const {
return Freq;
}
BlockFrequency &BlockFrequency::operator+=(const BlockFrequency &Freq) {
BlockFrequency &BlockFrequency::operator+=(BlockFrequency Freq) {
uint64_t Before = Freq.Frequency;
Frequency += Freq.Frequency;
@ -51,11 +50,10 @@ BlockFrequency &BlockFrequency::operator+=(const BlockFrequency &Freq) {
return *this;
}
const BlockFrequency
BlockFrequency::operator+(const BlockFrequency &Prob) const {
BlockFrequency Freq(Frequency);
Freq += Prob;
return Freq;
BlockFrequency BlockFrequency::operator+(BlockFrequency Freq) const {
BlockFrequency NewFreq(Frequency);
NewFreq += Freq;
return NewFreq;
}
BlockFrequency &BlockFrequency::operator>>=(const unsigned count) {