]> CyberLeo.Net >> Repos - FreeBSD/releng/9.0.git/blob - contrib/llvm/include/llvm/Support/BranchProbability.h
Copy stable/9 to releng/9.0 as part of the FreeBSD 9.0-RELEASE release
[FreeBSD/releng/9.0.git] / contrib / llvm / include / llvm / Support / BranchProbability.h
1 //===- BranchProbability.h - Branch Probability Wrapper ---------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // Definition of BranchProbability shared by IR and Machine Instructions.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef LLVM_SUPPORT_BRANCHPROBABILITY_H
15 #define LLVM_SUPPORT_BRANCHPROBABILITY_H
16
17 #include "llvm/Support/DataTypes.h"
18
19 namespace llvm {
20
21 class raw_ostream;
22
23 // This class represents Branch Probability as a non-negative fraction.
24 class BranchProbability {
25
26   // Numerator
27   uint32_t N;
28
29   // Denominator
30   uint32_t D;
31
32 public:
33   BranchProbability(uint32_t n, uint32_t d);
34
35   uint32_t getNumerator() const { return N; }
36   uint32_t getDenominator() const { return D; }
37
38   // Return (1 - Probability).
39   BranchProbability getCompl() {
40     return BranchProbability(D - N, D);
41   }
42
43   void print(raw_ostream &OS) const;
44
45   void dump() const;
46 };
47
48 raw_ostream &operator<<(raw_ostream &OS, const BranchProbability &Prob);
49
50 }
51
52 #endif