Branch profiling: floating-point avoidance.
[oota-llvm.git] / include / llvm / Support / BranchProbability.h
1 //===- BranchProbability.h - Branch Probability Analysis --------*- 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 class BranchProbabilityInfo;
23 class MachineBranchProbabilityInfo;
24 class MachineBasicBlock;
25
26 // This class represents Branch Probability as a non-negative fraction.
27 class BranchProbability {
28   friend class BranchProbabilityInfo;
29   friend class MachineBranchProbabilityInfo;
30   friend class MachineBasicBlock;
31
32   // Numerator
33   uint32_t N;
34
35   // Denominator
36   uint32_t D;
37
38   BranchProbability(uint32_t n, uint32_t d);
39
40 public:
41   raw_ostream &print(raw_ostream &OS) const;
42
43   void dump() const;
44 };
45
46 raw_ostream &operator<<(raw_ostream &OS, const BranchProbability &Prob);
47
48 }
49
50 #endif