2011-06-11 03:05:22 +02: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"
|
2011-10-23 13:32:54 +02:00
|
|
|
#include "llvm/Support/Format.h"
|
2011-06-11 03:05:22 +02:00
|
|
|
#include "llvm/Support/raw_ostream.h"
|
|
|
|
|
|
|
|
using namespace llvm;
|
|
|
|
|
2011-07-26 00:27:42 +02:00
|
|
|
void BranchProbability::print(raw_ostream &OS) const {
|
2011-10-23 13:32:54 +02:00
|
|
|
OS << N << " / " << D << " = " << format("%g%%", ((double)N / D) * 100.0);
|
2011-06-11 03:05:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void BranchProbability::dump() const {
|
2011-10-23 13:32:54 +02:00
|
|
|
dbgs() << *this << '\n';
|
2011-06-11 03:05:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
|
|
|
|
raw_ostream &operator<<(raw_ostream &OS, const BranchProbability &Prob) {
|
|
|
|
Prob.print(OS);
|
|
|
|
return OS;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|