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 17 namespace llvm { 18 19 class raw_ostream; 20 class BranchProbability; 21 22 // This class represents Block Frequency as a 64-bit value. 23 class BlockFrequency { 24 25 uint64_t Frequency; 26 static const int64_t ENTRY_FREQ = 1024; 27 28 public: Frequency(Freq)29 BlockFrequency(uint64_t Freq = 0) : Frequency(Freq) { } 30 getEntryFrequency()31 static uint64_t getEntryFrequency() { return ENTRY_FREQ; } getFrequency()32 uint64_t getFrequency() const { return Frequency; } 33 34 BlockFrequency &operator*=(const BranchProbability &Prob); 35 const BlockFrequency operator*(const BranchProbability &Prob) const; 36 37 BlockFrequency &operator+=(const BlockFrequency &Freq); 38 const BlockFrequency operator+(const BlockFrequency &Freq) const; 39 40 bool operator<(const BlockFrequency &RHS) const { 41 return Frequency < RHS.Frequency; 42 } 43 44 bool operator<=(const BlockFrequency &RHS) const { 45 return Frequency <= RHS.Frequency; 46 } 47 48 bool operator>(const BlockFrequency &RHS) const { 49 return Frequency > RHS.Frequency; 50 } 51 52 bool operator>=(const BlockFrequency &RHS) const { 53 return Frequency >= RHS.Frequency; 54 } 55 56 void print(raw_ostream &OS) const; 57 }; 58 59 raw_ostream &operator<<(raw_ostream &OS, const BlockFrequency &Freq); 60 61 } 62 63 #endif 64