aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Support/BranchProbability.cpp
blob: e8b83e59802d167ef45f0d80d612786803e7c1fe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
//===-------------- lib/Support/BranchProbability.cpp -----------*- C++ -*-===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// This file implements Branch Probability class.
//
//===----------------------------------------------------------------------===//

#include "llvm/Support/BranchProbability.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/Format.h"
#include "llvm/Support/raw_ostream.h"

using namespace llvm;

void BranchProbability::print(raw_ostream &OS) const {
  OS << N << " / " << D << " = " << format("%g%%", ((double)N / D) * 100.0);
}

void BranchProbability::dump() const {
  dbgs() << *this << '\n';
}

namespace llvm {

raw_ostream &operator<<(raw_ostream &OS, const BranchProbability &Prob) {
  Prob.print(OS);
  return OS;
}

}