[llvm] r207559 - BranchProb: Simplify printing code
Duncan P. N. Exon Smith
dexonsmith at apple.com
Tue Apr 29 10:07:42 PDT 2014
Author: dexonsmith
Date: Tue Apr 29 12:07:42 2014
New Revision: 207559
URL: http://llvm.org/viewvc/llvm-project?rev=207559&view=rev
Log:
BranchProb: Simplify printing code
Modified:
llvm/trunk/include/llvm/Support/BranchProbability.h
llvm/trunk/lib/Support/BranchProbability.cpp
Modified: llvm/trunk/include/llvm/Support/BranchProbability.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/BranchProbability.h?rev=207559&r1=207558&r2=207559&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/BranchProbability.h (original)
+++ llvm/trunk/include/llvm/Support/BranchProbability.h Tue Apr 29 12:07:42 2014
@@ -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);
+}
}
Modified: llvm/trunk/lib/Support/BranchProbability.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/BranchProbability.cpp?rev=207559&r1=207558&r2=207559&view=diff
==============================================================================
--- llvm/trunk/lib/Support/BranchProbability.cpp (original)
+++ llvm/trunk/lib/Support/BranchProbability.cpp Tue Apr 29 12:07:42 2014
@@ -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
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;
-}
More information about the llvm-commits
mailing list