1 //===-------- BlockFrequency.h - Block Frequency Wrapper --------*- 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 // This file implements Block Frequency class.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_SUPPORT_BLOCKFREQUENCY_H
15 #define LLVM_SUPPORT_BLOCKFREQUENCY_H
17 #include "llvm/Support/DataTypes.h"
22 class BranchProbability;
24 // This class represents Block Frequency as a 64-bit value.
25 class BlockFrequency {
28 static const int64_t ENTRY_FREQ = 1024;
31 BlockFrequency(uint64_t Freq = 0) : Frequency(Freq) { }
33 static uint64_t getEntryFrequency() { return ENTRY_FREQ; }
34 uint64_t getFrequency() const { return Frequency; }
36 BlockFrequency &operator*=(const BranchProbability &Prob);
37 const BlockFrequency operator*(const BranchProbability &Prob) const;
39 BlockFrequency &operator+=(const BlockFrequency &Freq);
40 const BlockFrequency operator+(const BlockFrequency &Freq) const;
42 bool operator<(const BlockFrequency &RHS) const {
43 return Frequency < RHS.Frequency;
46 bool operator<=(const BlockFrequency &RHS) const {
47 return Frequency <= RHS.Frequency;
50 bool operator>(const BlockFrequency &RHS) const {
51 return Frequency > RHS.Frequency;
54 bool operator>=(const BlockFrequency &RHS) const {
55 return Frequency >= RHS.Frequency;
58 void print(raw_ostream &OS) const;
61 raw_ostream &operator<<(raw_ostream &OS, const BlockFrequency &Freq);