diff --git a/include/llvm/Support/BranchProbability.h b/include/llvm/Support/BranchProbability.h index c1153ea8232..9aab6ace6e3 100644 --- a/include/llvm/Support/BranchProbability.h +++ b/include/llvm/Support/BranchProbability.h @@ -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); +} } diff --git a/lib/Support/BranchProbability.cpp b/lib/Support/BranchProbability.cpp index 9485241707e..65878d6e302 100644 --- a/lib/Support/BranchProbability.cpp +++ b/lib/Support/BranchProbability.cpp @@ -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; -}