Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

65 lines
1.7 KiB

  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. #ifndef LLVM_SUPPORT_BLOCKFREQUENCY_H
  14. #define LLVM_SUPPORT_BLOCKFREQUENCY_H
  15. #include "llvm/Support/DataTypes.h"
  16. namespace llvm {
  17. class raw_ostream;
  18. class BranchProbability;
  19. // This class represents Block Frequency as a 64-bit value.
  20. class BlockFrequency {
  21. uint64_t Frequency;
  22. static const int64_t ENTRY_FREQ = 1024;
  23. public:
  24. BlockFrequency(uint64_t Freq = 0) : Frequency(Freq) { }
  25. static uint64_t getEntryFrequency() { return ENTRY_FREQ; }
  26. uint64_t getFrequency() const { return Frequency; }
  27. BlockFrequency &operator*=(const BranchProbability &Prob);
  28. const BlockFrequency operator*(const BranchProbability &Prob) const;
  29. BlockFrequency &operator+=(const BlockFrequency &Freq);
  30. const BlockFrequency operator+(const BlockFrequency &Freq) const;
  31. bool operator<(const BlockFrequency &RHS) const {
  32. return Frequency < RHS.Frequency;
  33. }
  34. bool operator<=(const BlockFrequency &RHS) const {
  35. return Frequency <= RHS.Frequency;
  36. }
  37. bool operator>(const BlockFrequency &RHS) const {
  38. return Frequency > RHS.Frequency;
  39. }
  40. bool operator>=(const BlockFrequency &RHS) const {
  41. return Frequency >= RHS.Frequency;
  42. }
  43. void print(raw_ostream &OS) const;
  44. };
  45. raw_ostream &operator<<(raw_ostream &OS, const BlockFrequency &Freq);
  46. }
  47. #endif