diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2011-06-12 18:01:31 +0000 | 
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2011-06-12 18:01:31 +0000 | 
| commit | bd5abe19687421cb3ad4dca066732ed0b437531b (patch) | |
| tree | a9b264321873e7d25e69b8671c9f705ebc6d30ee /contrib/llvm/lib/Support/BranchProbability.cpp | |
| parent | 74d92904a6e0f2d301cdeec3f8af4fbe4a968146 (diff) | |
| parent | 56fe8f14099930935e3870e3e823c322a85c1c89 (diff) | |
Notes
Diffstat (limited to 'contrib/llvm/lib/Support/BranchProbability.cpp')
| -rw-r--r-- | contrib/llvm/lib/Support/BranchProbability.cpp | 44 | 
1 files changed, 44 insertions, 0 deletions
| diff --git a/contrib/llvm/lib/Support/BranchProbability.cpp b/contrib/llvm/lib/Support/BranchProbability.cpp new file mode 100644 index 000000000000..97342da3f078 --- /dev/null +++ b/contrib/llvm/lib/Support/BranchProbability.cpp @@ -0,0 +1,44 @@ +//===-------------- 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/raw_ostream.h" + +using namespace llvm; + +BranchProbability::BranchProbability(uint32_t n, uint32_t d) { +  assert(d > 0 && "Denomiator cannot be 0!"); +  assert(n <= d && "Probability cannot be bigger than 1!"); +  N = n; +  D = d; +} + +raw_ostream &BranchProbability::print(raw_ostream &OS) const { +  OS << N << " / " << D << " = " << ((double)N / D); +  return OS; +} + +void BranchProbability::dump() const { +  print(dbgs()); +  dbgs() << "\n"; +} + +namespace llvm { + +raw_ostream &operator<<(raw_ostream &OS, const BranchProbability &Prob) { +  Prob.print(OS); +  return OS; +} + +} | 
