1 //===- MachineCycleAnalysis.h - Cycle Info for Machine IR -------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file defines the MachineCycleInfo class, which is a thin wrapper over
10 // the Machine IR instance of GenericCycleInfo.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef LLVM_CODEGEN_MACHINECYCLEANALYSIS_H
15 #define LLVM_CODEGEN_MACHINECYCLEANALYSIS_H
16 
17 #include "llvm/ADT/GenericCycleInfo.h"
18 #include "llvm/CodeGen/MachineFunctionPass.h"
19 #include "llvm/CodeGen/MachineSSAContext.h"
20 
21 namespace llvm {
22 
23 extern template class GenericCycleInfo<MachineSSAContext>;
24 extern template class GenericCycle<MachineSSAContext>;
25 
26 using MachineCycleInfo = GenericCycleInfo<MachineSSAContext>;
27 using MachineCycle = MachineCycleInfo::CycleT;
28 
29 /// Legacy analysis pass which computes a \ref MachineCycleInfo.
30 class MachineCycleInfoWrapperPass : public MachineFunctionPass {
31   MachineFunction *F = nullptr;
32   MachineCycleInfo CI;
33 
34 public:
35   static char ID;
36 
37   MachineCycleInfoWrapperPass();
38 
39   MachineCycleInfo &getCycleInfo() { return CI; }
40   const MachineCycleInfo &getCycleInfo() const { return CI; }
41 
42   bool runOnMachineFunction(MachineFunction &F) override;
43   void getAnalysisUsage(AnalysisUsage &AU) const override;
44   void releaseMemory() override;
45   void print(raw_ostream &OS, const Module *M = nullptr) const override;
46 };
47 
48 // TODO: add this function to GenericCycle template after implementing IR
49 //       version.
50 bool isCycleInvariant(const MachineCycle *Cycle, MachineInstr &I);
51 
52 } // end namespace llvm
53 
54 #endif // LLVM_CODEGEN_MACHINECYCLEANALYSIS_H
55