2011-06-12 15:42:51 +00:00
|
|
|
//===-------------- 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"
|
2012-04-14 13:54:10 +00:00
|
|
|
#include "llvm/Support/Format.h"
|
2011-06-12 15:42:51 +00:00
|
|
|
#include "llvm/Support/raw_ostream.h"
|
|
|
|
|
|
|
|
using namespace llvm;
|
|
|
|
|
2011-10-20 21:10:27 +00:00
|
|
|
void BranchProbability::print(raw_ostream &OS) const {
|
2012-04-14 13:54:10 +00:00
|
|
|
OS << N << " / " << D << " = " << format("%g%%", ((double)N / D) * 100.0);
|
2011-06-12 15:42:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void BranchProbability::dump() const {
|
2012-04-14 13:54:10 +00:00
|
|
|
dbgs() << *this << '\n';
|
2011-06-12 15:42:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
|
|
|
|
raw_ostream &operator<<(raw_ostream &OS, const BranchProbability &Prob) {
|
|
|
|
Prob.print(OS);
|
|
|
|
return OS;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|