llvm-6502/include/llvm/Support/BranchProbability.h
Jakub Staszak 687dc24e1d - Make BranchProbability constructor public.
- Add getCompl() method.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@134857 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-10 02:12:39 +00:00

53 lines
1.2 KiB
C++

//===- BranchProbability.h - Branch Probability Analysis --------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// Definition of BranchProbability shared by IR and Machine Instructions.
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_SUPPORT_BRANCHPROBABILITY_H
#define LLVM_SUPPORT_BRANCHPROBABILITY_H
#include "llvm/Support/DataTypes.h"
namespace llvm {
class raw_ostream;
// This class represents Branch Probability as a non-negative fraction.
class BranchProbability {
// Numerator
uint32_t N;
// Denominator
uint32_t D;
public:
BranchProbability(uint32_t n, uint32_t d);
uint32_t getNumerator() const { return N; }
uint32_t getDenominator() const { return D; }
// Return (1 - Probability).
BranchProbability getCompl() {
return BranchProbability(D - N, D);
}
raw_ostream &print(raw_ostream &OS) const;
void dump() const;
};
raw_ostream &operator<<(raw_ostream &OS, const BranchProbability &Prob);
}
#endif