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/MachineSSAContext.h" 19 #include "llvm/CodeGen/MachineFunctionPass.h" 20 #include "llvm/InitializePasses.h" 21 22 namespace llvm { 23 24 extern template class GenericCycleInfo<MachineSSAContext>; 25 extern template class GenericCycle<MachineSSAContext>; 26 27 using MachineCycleInfo = GenericCycleInfo<MachineSSAContext>; 28 using MachineCycle = MachineCycleInfo::CycleT; 29 30 /// Legacy analysis pass which computes a \ref MachineCycleInfo. 31 class MachineCycleInfoWrapperPass : public MachineFunctionPass { 32 MachineFunction *F = nullptr; 33 MachineCycleInfo CI; 34 35 public: 36 static char ID; 37 38 MachineCycleInfoWrapperPass(); 39 40 MachineCycleInfo &getCycleInfo() { return CI; } 41 const MachineCycleInfo &getCycleInfo() const { return CI; } 42 43 bool runOnMachineFunction(MachineFunction &F) override; 44 void getAnalysisUsage(AnalysisUsage &AU) const override; 45 void releaseMemory() override; 46 void print(raw_ostream &OS, const Module *M = nullptr) const override; 47 }; 48 49 // TODO: add this function to GenericCycle template after implementing IR 50 // version. 51 bool isCycleInvariant(const MachineCycle *Cycle, MachineInstr &I); 52 53 } // end namespace llvm 54 55 #endif // LLVM_CODEGEN_MACHINECYCLEANALYSIS_H 56