LLVM  6.0.0svn
BlockFrequency.h
Go to the documentation of this file.
1 //===-------- BlockFrequency.h - Block Frequency 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 // This file implements Block Frequency class.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef LLVM_SUPPORT_BLOCKFREQUENCY_H
15 #define LLVM_SUPPORT_BLOCKFREQUENCY_H
16 
18 #include "llvm/Support/DataTypes.h"
19 
20 namespace llvm {
21 
22 class raw_ostream;
23 
24 // This class represents Block Frequency as a 64-bit value.
26  uint64_t Frequency;
27 
28 public:
29  BlockFrequency(uint64_t Freq = 0) : Frequency(Freq) { }
30 
31  /// \brief Returns the maximum possible frequency, the saturation value.
32  static uint64_t getMaxFrequency() { return -1ULL; }
33 
34  /// \brief Returns the frequency as a fixpoint number scaled by the entry
35  /// frequency.
36  uint64_t getFrequency() const { return Frequency; }
37 
38  /// \brief Multiplies with a branch probability. The computation will never
39  /// overflow.
42 
43  /// \brief Divide by a non-zero branch probability using saturating
44  /// arithmetic.
47 
48  /// \brief Adds another block frequency using saturating arithmetic.
51 
52  /// \brief Subtracts another block frequency using saturating arithmetic.
55 
56  /// \brief Shift block frequency to the right by count digits saturating to 1.
57  BlockFrequency &operator>>=(const unsigned count);
58 
59  bool operator<(BlockFrequency RHS) const {
60  return Frequency < RHS.Frequency;
61  }
62 
63  bool operator<=(BlockFrequency RHS) const {
64  return Frequency <= RHS.Frequency;
65  }
66 
67  bool operator>(BlockFrequency RHS) const {
68  return Frequency > RHS.Frequency;
69  }
70 
71  bool operator>=(BlockFrequency RHS) const {
72  return Frequency >= RHS.Frequency;
73  }
74 
75  bool operator==(BlockFrequency RHS) const {
76  return Frequency == RHS.Frequency;
77  }
78 };
79 
80 }
81 
82 #endif
Compute iterated dominance frontiers using a linear time algorithm.
Definition: AllocatorList.h:24
bool operator==(BlockFrequency RHS) const
uint64_t getFrequency() const
Returns the frequency as a fixpoint number scaled by the entry frequency.
bool operator<(BlockFrequency RHS) const
BlockFrequency operator*(BranchProbability Prob) const
BlockFrequency & operator/=(BranchProbability Prob)
Divide by a non-zero branch probability using saturating arithmetic.
BlockFrequency operator/(BranchProbability Prob) const
BlockFrequency(uint64_t Freq=0)
auto count(R &&Range, const E &Element) -> typename std::iterator_traits< decltype(adl_begin(Range))>::difference_type
Wrapper function around std::count to count the number of times an element Element occurs in the give...
Definition: STLExtras.h:874
BlockFrequency & operator+=(BlockFrequency Freq)
Adds another block frequency using saturating arithmetic.
bool operator<=(BlockFrequency RHS) const
bool operator>(BlockFrequency RHS) const
BlockFrequency operator+(BlockFrequency Freq) const
BlockFrequency operator-(BlockFrequency Freq) const
BlockFrequency & operator-=(BlockFrequency Freq)
Subtracts another block frequency using saturating arithmetic.
BlockFrequency & operator*=(BranchProbability Prob)
Multiplies with a branch probability.
static uint64_t getMaxFrequency()
Returns the maximum possible frequency, the saturation value.
bool operator>=(BlockFrequency RHS) const
BlockFrequency & operator>>=(const unsigned count)
Shift block frequency to the right by count digits saturating to 1.