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