5a5e07583d90beb308edbe401c50dac32aa5abf6
[oota-llvm.git] / lib / Support / BranchProbability.cpp
1 //===-------------- lib/Support/BranchProbability.cpp -----------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file implements Branch Probability class.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #include "llvm/Support/BranchProbability.h"
15 #include "llvm/Support/Debug.h"
16 #include "llvm/Support/raw_ostream.h"
17
18 using namespace llvm;
19
20 void BranchProbability::print(raw_ostream &OS) const {
21   OS << N << " / " << D << " = " << ((double)N / D);
22 }
23
24 void BranchProbability::dump() const {
25   print(dbgs());
26   dbgs() << "\n";
27 }
28
29 namespace llvm {
30
31 raw_ostream &operator<<(raw_ostream &OS, const BranchProbability &Prob) {
32   Prob.print(OS);
33   return OS;
34 }
35
36 }