Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:43:12

0001 //===- CycleAnalysis.h - Cycle Info for LLVM IR -----------------*- C++ -*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 /// \file
0009 ///
0010 /// This file declares an analysis pass that computes CycleInfo for
0011 /// LLVM IR, specialized from GenericCycleInfo.
0012 ///
0013 //===----------------------------------------------------------------------===//
0014 
0015 #ifndef LLVM_ANALYSIS_CYCLEANALYSIS_H
0016 #define LLVM_ANALYSIS_CYCLEANALYSIS_H
0017 
0018 #include "llvm/IR/CycleInfo.h"
0019 #include "llvm/IR/PassManager.h"
0020 #include "llvm/Pass.h"
0021 
0022 namespace llvm {
0023 
0024 /// Legacy analysis pass which computes a \ref CycleInfo.
0025 class CycleInfoWrapperPass : public FunctionPass {
0026   Function *F = nullptr;
0027   CycleInfo CI;
0028 
0029 public:
0030   static char ID;
0031 
0032   CycleInfoWrapperPass();
0033 
0034   CycleInfo &getResult() { return CI; }
0035   const CycleInfo &getResult() const { return CI; }
0036 
0037   bool runOnFunction(Function &F) override;
0038   void getAnalysisUsage(AnalysisUsage &AU) const override;
0039   void releaseMemory() override;
0040   void print(raw_ostream &OS, const Module *M = nullptr) const override;
0041 
0042   // TODO: verify analysis?
0043 };
0044 
0045 /// Analysis pass which computes a \ref CycleInfo.
0046 class CycleAnalysis : public AnalysisInfoMixin<CycleAnalysis> {
0047   friend AnalysisInfoMixin<CycleAnalysis>;
0048   static AnalysisKey Key;
0049 
0050 public:
0051   /// Provide the result typedef for this analysis pass.
0052   using Result = CycleInfo;
0053 
0054   using LegacyWrapper = CycleInfoWrapperPass;
0055 
0056   /// Run the analysis pass over a function and produce a dominator tree.
0057   CycleInfo run(Function &F, FunctionAnalysisManager &);
0058 
0059   // TODO: verify analysis?
0060 };
0061 
0062 class CycleInfoPrinterPass : public PassInfoMixin<CycleInfoPrinterPass> {
0063   raw_ostream &OS;
0064 
0065 public:
0066   explicit CycleInfoPrinterPass(raw_ostream &OS);
0067   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
0068   static bool isRequired() { return true; }
0069 };
0070 
0071 struct CycleInfoVerifierPass : public PassInfoMixin<CycleInfoVerifierPass> {
0072   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
0073   static bool isRequired() { return true; }
0074 };
0075 
0076 } // end namespace llvm
0077 
0078 #endif // LLVM_ANALYSIS_CYCLEANALYSIS_H