fdae80df12b0eca2eee135adade6dd1c558c52da
[oota-llvm.git] / include / llvm / Transforms / Utils / LoopUtils.h
1 //===- llvm/Transforms/Utils/LoopUtils.h - Loop utilities -*- 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 // This file defines some loop transformation utilities.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #ifndef LLVM_TRANSFORMS_UTILS_LOOPUTILS_H
15 #define LLVM_TRANSFORMS_UTILS_LOOPUTILS_H
16
17 namespace llvm {
18 class AliasAnalysis;
19 class AssumptionTracker;
20 class BasicBlock;
21 class DataLayout;
22 class DominatorTree;
23 class Loop;
24 class LoopInfo;
25 class Pass;
26 class ScalarEvolution;
27
28 BasicBlock *InsertPreheaderForLoop(Loop *L, Pass *P);
29
30 /// \brief Simplify each loop in a loop nest recursively.
31 ///
32 /// This takes a potentially un-simplified loop L (and its children) and turns
33 /// it into a simplified loop nest with preheaders and single backedges. It
34 /// will optionally update \c AliasAnalysis and \c ScalarEvolution analyses if
35 /// passed into it.
36 bool simplifyLoop(Loop *L, DominatorTree *DT, LoopInfo *LI, Pass *PP,
37                   AliasAnalysis *AA = nullptr, ScalarEvolution *SE = nullptr,
38                   const DataLayout *DL = nullptr,
39                   AssumptionTracker *AT = nullptr);
40
41 /// \brief Put loop into LCSSA form.
42 ///
43 /// Looks at all instructions in the loop which have uses outside of the
44 /// current loop. For each, an LCSSA PHI node is inserted and the uses outside
45 /// the loop are rewritten to use this node.
46 ///
47 /// LoopInfo and DominatorTree are required and preserved.
48 ///
49 /// If ScalarEvolution is passed in, it will be preserved.
50 ///
51 /// Returns true if any modifications are made to the loop.
52 bool formLCSSA(Loop &L, DominatorTree &DT, ScalarEvolution *SE = nullptr);
53
54 /// \brief Put a loop nest into LCSSA form.
55 ///
56 /// This recursively forms LCSSA for a loop nest.
57 ///
58 /// LoopInfo and DominatorTree are required and preserved.
59 ///
60 /// If ScalarEvolution is passed in, it will be preserved.
61 ///
62 /// Returns true if any modifications are made to the loop.
63 bool formLCSSARecursively(Loop &L, DominatorTree &DT,
64                           ScalarEvolution *SE = nullptr);
65 }
66
67 #endif