79f10298a5b47e05ce11d4847ba9c1a18b49eaec
[oota-llvm.git] / include / llvm / Transforms / Scalar.h
1 //===-- Scalar.h - Scalar Transformations ------------------------*- C++ -*-==//
2 //
3 // This header file defines prototypes for accessor functions that expose passes
4 // in the Scalar transformations library.
5 //
6 //===----------------------------------------------------------------------===//
7
8 #ifndef LLVM_TRANSFORMS_SCALAR_H
9 #define LLVM_TRANSFORMS_SCALAR_H
10
11 class Pass;
12 class GetElementPtrInst;
13 class PassInfo;
14
15 //===----------------------------------------------------------------------===//
16 //
17 // Constant Propogation Pass - A worklist driven constant propogation pass
18 //
19 Pass *createConstantPropogationPass();
20
21
22 //===----------------------------------------------------------------------===//
23 //
24 // Sparse Conditional Constant Propogation Pass
25 //
26 Pass *createSCCPPass();
27
28
29 //===----------------------------------------------------------------------===//
30 //
31 // DeadInstElimination - This pass quickly removes trivially dead instructions
32 // without modifying the CFG of the function.  It is a BasicBlockPass, so it
33 // runs efficiently when queued next to other BasicBlockPass's.
34 //
35 Pass *createDeadInstEliminationPass();
36
37
38 //===----------------------------------------------------------------------===//
39 //
40 // DeadCodeElimination - This pass is more powerful than DeadInstElimination,
41 // because it is worklist driven that can potentially revisit instructions when
42 // their other instructions become dead, to eliminate chains of dead
43 // computations.
44 //
45 Pass *createDeadCodeEliminationPass();
46
47
48 //===----------------------------------------------------------------------===//
49 //
50 // AggressiveDCE - This pass uses the SSA based Aggressive DCE algorithm.  This
51 // algorithm assumes instructions are dead until proven otherwise, which makes
52 // it more successful are removing non-obviously dead instructions.
53 //
54 Pass *createAggressiveDCEPass();
55
56
57 //===----------------------------------------------------------------------===//
58 // 
59 // DecomposeMultiDimRefs - Convert multi-dimensional references consisting of
60 // any combination of 2 or more array and structure indices into a sequence of
61 // instructions (using getelementpr and cast) so that each instruction has at
62 // most one index (except structure references, which need an extra leading
63 // index of [0]).
64
65 // This pass decomposes all multi-dimensional references in a function.
66 Pass *createDecomposeMultiDimRefsPass();
67
68 // This function decomposes a single instance of such a reference.
69 // Return value: true if the instruction was replaced; false otherwise.
70 // 
71 bool DecomposeArrayRef(GetElementPtrInst* GEP);
72
73 //===----------------------------------------------------------------------===//
74 //
75 // GCSE - This pass is designed to be a very quick global transformation that
76 // eliminates global common subexpressions from a function.  It does this by
77 // examining the SSA value graph of the function, instead of doing slow
78 // bit-vector computations.
79 //
80 Pass *createGCSEPass();
81
82
83 //===----------------------------------------------------------------------===//
84 //
85 // InductionVariableSimplify - Transform induction variables in a program to all
86 // use a single cannonical induction variable per loop.
87 //
88 Pass *createIndVarSimplifyPass();
89
90
91 //===----------------------------------------------------------------------===//
92 //
93 // InstructionCombining - Combine instructions to form fewer, simple
94 //   instructions.  This pass does not modify the CFG, and has a tendancy to
95 //   make instructions dead, so a subsequent DCE pass is useful.
96 //
97 // This pass combines things like:
98 //    %Y = add int 1, %X
99 //    %Z = add int 1, %Y
100 // into:
101 //    %Z = add int 2, %X
102 //
103 Pass *createInstructionCombiningPass();
104
105
106 //===----------------------------------------------------------------------===//
107 //
108 // LICM - This pass is a simple natural loop based loop invariant code motion
109 // pass.
110 //
111 Pass *createLICMPass();
112
113
114 //===----------------------------------------------------------------------===//
115 //
116 // PiNodeInsertion - This pass inserts single entry Phi nodes into basic blocks
117 // that are preceeded by a conditional branch, where the branch gives
118 // information about the operands of the condition.  For example, this C code:
119 //   if (x == 0) { ... = x + 4;
120 // becomes:
121 //   if (x == 0) {
122 //     x2 = phi(x);    // Node that can hold data flow information about X
123 //     ... = x2 + 4;
124 //
125 // Since the direction of the condition branch gives information about X itself
126 // (whether or not it is zero), some passes (like value numbering or ABCD) can
127 // use the inserted Phi/Pi nodes as a place to attach information, in this case
128 // saying that X has a value of 0 in this scope.  The power of this analysis
129 // information is that "in the scope" translates to "for all uses of x2".
130 //
131 // This special form of Phi node is refered to as a Pi node, following the
132 // terminology defined in the "Array Bounds Checks on Demand" paper.
133 //
134 Pass *createPiNodeInsertionPass();
135
136
137 //===----------------------------------------------------------------------===//
138 //
139 // This pass is used to promote memory references to be register references.  A
140 // simple example of the transformation performed by this pass is:
141 //
142 //        FROM CODE                           TO CODE
143 //   %X = alloca int, uint 1                 ret int 42
144 //   store int 42, int *%X
145 //   %Y = load int* %X
146 //   ret int %Y
147 //
148 Pass *createPromoteMemoryToRegister();
149
150
151 //===----------------------------------------------------------------------===//
152 //
153 // This pass reassociates commutative expressions in an order that is designed
154 // to promote better constant propogation, GCSE, LICM, PRE...
155 //
156 // For example:  4 + (x + 5)  ->  x + (4 + 5)
157 //
158 Pass *createReassociatePass();
159
160 //===----------------------------------------------------------------------===//
161 //
162 // This pass eliminates correlated conditions, such as these:
163 //  if (X == 0)
164 //    if (X > 2) ;   // Known false
165 //    else
166 //      Y = X * Z;   // = 0
167 //
168 Pass *createCorrelatedExpressionEliminationPass();
169
170 //===----------------------------------------------------------------------===//
171 //
172 // CFG Simplification - Merge basic blocks, eliminate unreachable blocks,
173 // simplify terminator instructions, etc...
174 //
175 Pass *createCFGSimplificationPass();
176
177 //===----------------------------------------------------------------------===//
178 //
179 // BreakCriticalEdges pass - Break all of the critical edges in the CFG by
180 // inserting a dummy basic block.  This pass may be "required" by passes that
181 // cannot deal with critical edges.  For this usage, a pass must call:
182 //
183 //   AU.addRequiredID(BreakCriticalEdgesID);
184 //
185 // This pass obviously invalidates the CFG, but can update forward dominator
186 // (set, immediate dominators, and tree) information.
187 //
188 Pass *createBreakCriticalEdgesPass();
189 extern const PassInfo *BreakCriticalEdgesID;
190
191 //===----------------------------------------------------------------------===//
192 // These two passes convert malloc and free instructions to and from %malloc &
193 // %free function calls.
194 //
195 Pass *createLowerAllocationsPass();
196 Pass *createRaiseAllocationsPass();
197
198
199 //===----------------------------------------------------------------------===//
200 //
201 // These functions removes symbols from functions and modules.
202 //
203 Pass *createSymbolStrippingPass();
204 Pass *createFullSymbolStrippingPass();
205
206 #endif