Deleted Added
full compact
BranchProbability.cpp (226890) BranchProbability.cpp (235633)
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"
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/Format.h"
16#include "llvm/Support/raw_ostream.h"
17
18using namespace llvm;
19
17#include "llvm/Support/raw_ostream.h"
18
19using namespace llvm;
20
20BranchProbability::BranchProbability(uint32_t n, uint32_t d) {
21 assert(d > 0 && "Denomiator cannot be 0!");
22 assert(n <= d && "Probability cannot be bigger than 1!");
23 N = n;
24 D = d;
25}
26
27void BranchProbability::print(raw_ostream &OS) const {
21void BranchProbability::print(raw_ostream &OS) const {
28 OS << N << " / " << D << " = " << ((double)N / D);
22 OS << N << " / " << D << " = " << format("%g%%", ((double)N / D) * 100.0);
29}
30
31void BranchProbability::dump() const {
23}
24
25void BranchProbability::dump() const {
32 print(dbgs());
33 dbgs() << "\n";
26 dbgs() << *this << '\n';
34}
35
36namespace llvm {
37
38raw_ostream &operator<<(raw_ostream &OS, const BranchProbability &Prob) {
39 Prob.print(OS);
40 return OS;
41}
42
43}
27}
28
29namespace llvm {
30
31raw_ostream &operator<<(raw_ostream &OS, const BranchProbability &Prob) {
32 Prob.print(OS);
33 return OS;
34}
35
36}