MachineCycleAnalysis.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //===- MachineCycleAnalysis.h - Cycle Info for Machine IR -------*- 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 file defines the MachineCycleInfo class, which is a thin wrapper over
  15. // the Machine IR instance of GenericCycleInfo.
  16. //
  17. //===----------------------------------------------------------------------===//
  18. #ifndef LLVM_CODEGEN_MACHINECYCLEANALYSIS_H
  19. #define LLVM_CODEGEN_MACHINECYCLEANALYSIS_H
  20. #include "llvm/ADT/GenericCycleInfo.h"
  21. #include "llvm/CodeGen/MachineFunctionPass.h"
  22. #include "llvm/CodeGen/MachineSSAContext.h"
  23. namespace llvm {
  24. extern template class GenericCycleInfo<MachineSSAContext>;
  25. extern template class GenericCycle<MachineSSAContext>;
  26. using MachineCycleInfo = GenericCycleInfo<MachineSSAContext>;
  27. using MachineCycle = MachineCycleInfo::CycleT;
  28. /// Legacy analysis pass which computes a \ref MachineCycleInfo.
  29. class MachineCycleInfoWrapperPass : public MachineFunctionPass {
  30. MachineFunction *F = nullptr;
  31. MachineCycleInfo CI;
  32. public:
  33. static char ID;
  34. MachineCycleInfoWrapperPass();
  35. MachineCycleInfo &getCycleInfo() { return CI; }
  36. const MachineCycleInfo &getCycleInfo() const { return CI; }
  37. bool runOnMachineFunction(MachineFunction &F) override;
  38. void getAnalysisUsage(AnalysisUsage &AU) const override;
  39. void releaseMemory() override;
  40. void print(raw_ostream &OS, const Module *M = nullptr) const override;
  41. };
  42. // TODO: add this function to GenericCycle template after implementing IR
  43. // version.
  44. bool isCycleInvariant(const MachineCycle *Cycle, MachineInstr &I);
  45. } // end namespace llvm
  46. #endif // LLVM_CODEGEN_MACHINECYCLEANALYSIS_H
  47. #ifdef __GNUC__
  48. #pragma GCC diagnostic pop
  49. #endif