llvm.org GIT mirror llvm / 67f5fca
BranchProb: Simplify printing code git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207559 91177308-0d34-0410-b5e6-96231b3b80d8 Duncan P. N. Exon Smith 6 years ago
2 changed file(s) with 8 addition(s) and 12 deletion(s). Raw diff Collapse all Expand all
4545 return BranchProbability(D - N, D);
4646 }
4747
48 void print(raw_ostream &OS) const;
48 raw_ostream &print(raw_ostream &OS) const;
4949
5050 void dump() const;
5151
7979 bool operator>=(BranchProbability RHS) const { return !(*this < RHS); }
8080 };
8181
82 raw_ostream &operator<<(raw_ostream &OS, const BranchProbability &Prob);
82 inline raw_ostream &operator<<(raw_ostream &OS, const BranchProbability &Prob) {
83 return Prob.print(OS);
84 }
8385
8486 }
8587
1717
1818 using namespace llvm;
1919
20 void BranchProbability::print(raw_ostream &OS) const {
21 OS << N << " / " << D << " = " << format("%g%%", ((double)N / D) * 100.0);
20 raw_ostream &BranchProbability::print(raw_ostream &OS) const {
21 return OS << N << " / " << D << " = "
22 << format("%g%%", ((double)N / D) * 100.0);
2223 }
2324
24 void BranchProbability::dump() const {
25 dbgs() << *this << '\n';
26 }
25 void BranchProbability::dump() const { print(dbgs()) << '\n'; }
2726
2827 static uint64_t scale(uint64_t Num, uint32_t N, uint32_t D) {
2928 assert(D && "divide by 0");
7170 uint64_t BranchProbability::scaleByInverse(uint64_t Num) const {
7271 return ::scale(Num, D, N);
7372 }
74
75 raw_ostream &llvm::operator<<(raw_ostream &OS, const BranchProbability &Prob) {
76 Prob.print(OS);
77 return OS;
78 }