1 //===- BranchProbability.h - Branch Probability Analysis --------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // Definition of BranchProbability shared by IR and Machine Instructions.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_SUPPORT_BRANCHPROBABILITY_H
15 #define LLVM_SUPPORT_BRANCHPROBABILITY_H
17 #include "llvm/Support/DataTypes.h"
23 // This class represents Branch Probability as a non-negative fraction.
24 class BranchProbability {
33 BranchProbability(uint32_t n, uint32_t d);
35 uint32_t getNumerator() const { return N; }
36 uint32_t getDenominator() const { return D; }
38 // Return (1 - Probability).
39 BranchProbability getCompl() {
40 return BranchProbability(D - N, D);
43 raw_ostream &print(raw_ostream &OS) const;
48 raw_ostream &operator<<(raw_ostream &OS, const BranchProbability &Prob);