BranchProb: Simplify printing code

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207559 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Duncan P. N. Exon Smith 2014-04-29 17:07:42 +00:00
parent a70510a1c6
commit 67f5fcac4b
2 changed files with 8 additions and 12 deletions

View File

@ -46,7 +46,7 @@ public:
return BranchProbability(D - N, D);
}
void print(raw_ostream &OS) const;
raw_ostream &print(raw_ostream &OS) const;
void dump() const;
@ -80,7 +80,9 @@ public:
bool operator>=(BranchProbability RHS) const { return !(*this < RHS); }
};
raw_ostream &operator<<(raw_ostream &OS, const BranchProbability &Prob);
inline raw_ostream &operator<<(raw_ostream &OS, const BranchProbability &Prob) {
return Prob.print(OS);
}
}

View File

@ -18,13 +18,12 @@
using namespace llvm;
void BranchProbability::print(raw_ostream &OS) const {
OS << N << " / " << D << " = " << format("%g%%", ((double)N / D) * 100.0);
raw_ostream &BranchProbability::print(raw_ostream &OS) const {
return OS << N << " / " << D << " = "
<< format("%g%%", ((double)N / D) * 100.0);
}
void BranchProbability::dump() const {
dbgs() << *this << '\n';
}
void BranchProbability::dump() const { print(dbgs()) << '\n'; }
static uint64_t scale(uint64_t Num, uint32_t N, uint32_t D) {
assert(D && "divide by 0");
@ -72,8 +71,3 @@ uint64_t BranchProbability::scale(uint64_t Num) const {
uint64_t BranchProbability::scaleByInverse(uint64_t Num) const {
return ::scale(Num, D, N);
}
raw_ostream &llvm::operator<<(raw_ostream &OS, const BranchProbability &Prob) {
Prob.print(OS);
return OS;
}