Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
14 | pmbaty | 1 | //===- CycleAnalysis.h - Cycle Info for LLVM 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 | /// \file |
||
9 | /// |
||
10 | /// This file declares an analysis pass that computes CycleInfo for |
||
11 | /// LLVM IR, specialized from GenericCycleInfo. |
||
12 | /// |
||
13 | //===----------------------------------------------------------------------===// |
||
14 | |||
15 | #ifndef LLVM_ANALYSIS_CYCLEANALYSIS_H |
||
16 | #define LLVM_ANALYSIS_CYCLEANALYSIS_H |
||
17 | |||
18 | #include "llvm/ADT/GenericCycleInfo.h" |
||
19 | #include "llvm/IR/PassManager.h" |
||
20 | #include "llvm/IR/SSAContext.h" |
||
21 | #include "llvm/Pass.h" |
||
22 | |||
23 | namespace llvm { |
||
24 | extern template class GenericCycleInfo<SSAContext>; |
||
25 | extern template class GenericCycle<SSAContext>; |
||
26 | |||
27 | using CycleInfo = GenericCycleInfo<SSAContext>; |
||
28 | using Cycle = CycleInfo::CycleT; |
||
29 | |||
30 | /// Legacy analysis pass which computes a \ref CycleInfo. |
||
31 | class CycleInfoWrapperPass : public FunctionPass { |
||
32 | Function *F = nullptr; |
||
33 | CycleInfo CI; |
||
34 | |||
35 | public: |
||
36 | static char ID; |
||
37 | |||
38 | CycleInfoWrapperPass(); |
||
39 | |||
40 | CycleInfo &getResult() { return CI; } |
||
41 | const CycleInfo &getResult() const { return CI; } |
||
42 | |||
43 | bool runOnFunction(Function &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 | // TODO: verify analysis? |
||
49 | }; |
||
50 | |||
51 | /// Analysis pass which computes a \ref CycleInfo. |
||
52 | class CycleAnalysis : public AnalysisInfoMixin<CycleAnalysis> { |
||
53 | friend AnalysisInfoMixin<CycleAnalysis>; |
||
54 | static AnalysisKey Key; |
||
55 | |||
56 | public: |
||
57 | /// Provide the result typedef for this analysis pass. |
||
58 | using Result = CycleInfo; |
||
59 | |||
60 | using LegacyWrapper = CycleInfoWrapperPass; |
||
61 | |||
62 | /// Run the analysis pass over a function and produce a dominator tree. |
||
63 | CycleInfo run(Function &F, FunctionAnalysisManager &); |
||
64 | |||
65 | // TODO: verify analysis? |
||
66 | }; |
||
67 | |||
68 | /// Printer pass for the \c DominatorTree. |
||
69 | class CycleInfoPrinterPass : public PassInfoMixin<CycleInfoPrinterPass> { |
||
70 | raw_ostream &OS; |
||
71 | |||
72 | public: |
||
73 | explicit CycleInfoPrinterPass(raw_ostream &OS); |
||
74 | |||
75 | PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM); |
||
76 | }; |
||
77 | |||
78 | } // end namespace llvm |
||
79 | |||
80 | #endif // LLVM_ANALYSIS_CYCLEANALYSIS_H |