MBFIWrapper.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //===- llvm/CodeGen/MBFIWrapper.h -------------------------------*- C++ -*-===//
  7. //
  8. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  9. // See https://llvm.org/LICENSE.txt for license information.
  10. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  11. //
  12. //===----------------------------------------------------------------------===//
  13. //
  14. // This class keeps track of branch frequencies of newly created blocks and
  15. // tail-merged blocks. Used by the TailDuplication and MachineBlockPlacement.
  16. //
  17. //===----------------------------------------------------------------------===//
  18. #ifndef LLVM_CODEGEN_MBFIWRAPPER_H
  19. #define LLVM_CODEGEN_MBFIWRAPPER_H
  20. #include "llvm/ADT/DenseMap.h"
  21. #include "llvm/ADT/Optional.h"
  22. #include "llvm/Support/BlockFrequency.h"
  23. namespace llvm {
  24. class MachineBasicBlock;
  25. class MachineBlockFrequencyInfo;
  26. class MBFIWrapper {
  27. public:
  28. MBFIWrapper(const MachineBlockFrequencyInfo &I) : MBFI(I) {}
  29. BlockFrequency getBlockFreq(const MachineBasicBlock *MBB) const;
  30. void setBlockFreq(const MachineBasicBlock *MBB, BlockFrequency F);
  31. Optional<uint64_t> getBlockProfileCount(const MachineBasicBlock *MBB) const;
  32. raw_ostream &printBlockFreq(raw_ostream &OS,
  33. const MachineBasicBlock *MBB) const;
  34. raw_ostream &printBlockFreq(raw_ostream &OS,
  35. const BlockFrequency Freq) const;
  36. void view(const Twine &Name, bool isSimple = true);
  37. uint64_t getEntryFreq() const;
  38. const MachineBlockFrequencyInfo &getMBFI() { return MBFI; }
  39. private:
  40. const MachineBlockFrequencyInfo &MBFI;
  41. DenseMap<const MachineBasicBlock *, BlockFrequency> MergedBBFreq;
  42. };
  43. } // end namespace llvm
  44. #endif // LLVM_CODEGEN_MBFIWRAPPER_H
  45. #ifdef __GNUC__
  46. #pragma GCC diagnostic pop
  47. #endif