1 //===- LoopUnrollPass.h -----------------------------------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 #ifndef LLVM_TRANSFORMS_SCALAR_LOOPUNROLLPASS_H
11 #define LLVM_TRANSFORMS_SCALAR_LOOPUNROLLPASS_H
12 
13 #include "llvm/Analysis/LoopAnalysisManager.h"
14 #include "llvm/IR/PassManager.h"
15 
16 namespace llvm {
17 
18 class Function;
19 class Loop;
20 class LPMUpdater;
21 
22 /// Loop unroll pass that only does full loop unrolling.
23 class LoopFullUnrollPass : public PassInfoMixin<LoopFullUnrollPass> {
24   const int OptLevel;
25 
26 public:
OptLevel(OptLevel)27   explicit LoopFullUnrollPass(int OptLevel = 2) : OptLevel(OptLevel) {}
28 
29   PreservedAnalyses run(Loop &L, LoopAnalysisManager &AM,
30                         LoopStandardAnalysisResults &AR, LPMUpdater &U);
31 };
32 
33 /// Loop unroll pass that will support both full and partial unrolling.
34 /// It is a function pass to have access to function and module analyses.
35 /// It will also put loops into canonical form (simplified and LCSSA).
36 class LoopUnrollPass : public PassInfoMixin<LoopUnrollPass> {
37   const int OptLevel;
38 
39 public:
40   /// This uses the target information (or flags) to control the thresholds for
41   /// different unrolling stategies but supports all of them.
OptLevel(OptLevel)42   explicit LoopUnrollPass(int OptLevel = 2) : OptLevel(OptLevel) {}
43 
44   PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
45 };
46 
47 } // end namespace llvm
48 
49 #endif // LLVM_TRANSFORMS_SCALAR_LOOPUNROLLPASS_H
50