e6db624cb8e97e9317582a01c6a2af13ddfacab6
[oota-llvm.git] / include / llvm / Transforms / Scalar.h
1 //===-- Scalar.h - Scalar Transformations -----------------------*- C++ -*-===//
2 // 
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file was developed by the LLVM research group and is distributed under
6 // the University of Illinois Open Source License. See LICENSE.TXT for details.
7 // 
8 //===----------------------------------------------------------------------===//
9 //
10 // This header file defines prototypes for accessor functions that expose passes
11 // in the Scalar transformations library.
12 //
13 //===----------------------------------------------------------------------===//
14
15 #ifndef LLVM_TRANSFORMS_SCALAR_H
16 #define LLVM_TRANSFORMS_SCALAR_H
17
18 namespace llvm {
19
20 class ModulePass;
21 class FunctionPass;
22 class GetElementPtrInst;
23 class PassInfo;
24 class TerminatorInst;
25
26 //===----------------------------------------------------------------------===//
27 //
28 // RaisePointerReferences - Try to eliminate as many pointer arithmetic
29 // expressions as possible, by converting expressions to use getelementptr and
30 // friends.
31 //
32 FunctionPass *createRaisePointerReferencesPass();
33
34 //===----------------------------------------------------------------------===//
35 //
36 // Constant Propagation Pass - A worklist driven constant propagation pass
37 //
38 FunctionPass *createConstantPropagationPass();
39
40
41 //===----------------------------------------------------------------------===//
42 //
43 // Sparse Conditional Constant Propagation Pass
44 //
45 FunctionPass *createSCCPPass();
46
47
48 //===----------------------------------------------------------------------===//
49 //
50 // DeadInstElimination - This pass quickly removes trivially dead instructions
51 // without modifying the CFG of the function.  It is a BasicBlockPass, so it
52 // runs efficiently when queued next to other BasicBlockPass's.
53 //
54 FunctionPass *createDeadInstEliminationPass();
55
56
57 //===----------------------------------------------------------------------===//
58 //
59 // DeadCodeElimination - This pass is more powerful than DeadInstElimination,
60 // because it is worklist driven that can potentially revisit instructions when
61 // their other instructions become dead, to eliminate chains of dead
62 // computations.
63 //
64 FunctionPass *createDeadCodeEliminationPass();
65
66 //===----------------------------------------------------------------------===//
67 //
68 // DeadStoreElimination - This pass deletes stores that are post-dominated by
69 // must-aliased stores and are not loaded used between the stores.
70 //
71 FunctionPass *createDeadStoreEliminationPass();
72
73 //===----------------------------------------------------------------------===//
74 //
75 // AggressiveDCE - This pass uses the SSA based Aggressive DCE algorithm.  This
76 // algorithm assumes instructions are dead until proven otherwise, which makes
77 // it more successful are removing non-obviously dead instructions.
78 //
79 FunctionPass *createAggressiveDCEPass();
80
81
82 //===----------------------------------------------------------------------===//
83 //
84 // Scalar Replacement of Aggregates - Break up alloca's of aggregates into
85 // multiple allocas if possible.
86 //
87 FunctionPass *createScalarReplAggregatesPass();
88
89
90 //===----------------------------------------------------------------------===//
91 //
92 // GCSE - This pass is designed to be a very quick global transformation that
93 // eliminates global common subexpressions from a function.  It does this by
94 // examining the SSA value graph of the function, instead of doing slow
95 // bit-vector computations.
96 //
97 FunctionPass *createGCSEPass();
98
99
100 //===----------------------------------------------------------------------===//
101 //
102 // InductionVariableSimplify - Transform induction variables in a program to all
103 // use a single canonical induction variable per loop.
104 //
105 FunctionPass *createIndVarSimplifyPass();
106
107
108 //===----------------------------------------------------------------------===//
109 //
110 // InstructionCombining - Combine instructions to form fewer, simple
111 //   instructions.  This pass does not modify the CFG, and has a tendency to
112 //   make instructions dead, so a subsequent DCE pass is useful.
113 //
114 // This pass combines things like:
115 //    %Y = add int 1, %X
116 //    %Z = add int 1, %Y
117 // into:
118 //    %Z = add int 2, %X
119 //
120 FunctionPass *createInstructionCombiningPass();
121
122
123 //===----------------------------------------------------------------------===//
124 //
125 // LICM - This pass is a loop invariant code motion and memory promotion pass.
126 //
127 FunctionPass *createLICMPass();
128
129 //===----------------------------------------------------------------------===//
130 //
131 // LoopStrengthReduce - This pass is strength reduces GEP instructions that use
132 // a loop's canonical induction variable as one of their indices.  The
133 // MaxTargetAMSize is the largest element size that the target architecture
134 // can handle in its addressing modes.  Power of two multipliers less than or
135 // equal to this value are not reduced.
136 //
137 FunctionPass *createLoopStrengthReducePass(unsigned MaxTargetAMSize = 1);
138
139 //===----------------------------------------------------------------------===//
140 //
141 // LoopUnswitch - This pass is a simple loop unswitching pass.
142 //
143 FunctionPass *createLoopUnswitchPass();
144
145
146 //===----------------------------------------------------------------------===//
147 //
148 // LoopUnroll - This pass is a simple loop unrolling pass.
149 //
150 FunctionPass *createLoopUnrollPass();
151
152 //===----------------------------------------------------------------------===//
153 //
154 // This pass is used to promote memory references to be register references.  A
155 // simple example of the transformation performed by this pass is:
156 //
157 //        FROM CODE                           TO CODE
158 //   %X = alloca int, uint 1                 ret int 42
159 //   store int 42, int *%X
160 //   %Y = load int* %X
161 //   ret int %Y
162 //
163 FunctionPass *createPromoteMemoryToRegisterPass();
164
165
166 //===----------------------------------------------------------------------===//
167 //
168 // This pass reassociates commutative expressions in an order that is designed
169 // to promote better constant propagation, GCSE, LICM, PRE...
170 //
171 // For example:  4 + (x + 5)  ->  x + (4 + 5)
172 //
173 FunctionPass *createReassociatePass();
174
175 //===----------------------------------------------------------------------===//
176 //
177 // This pass eliminates correlated conditions, such as these:
178 //  if (X == 0)
179 //    if (X > 2) ;   // Known false
180 //    else
181 //      Y = X * Z;   // = 0
182 //
183 FunctionPass *createCorrelatedExpressionEliminationPass();
184
185
186 // createCondPropagationPass - This pass propagates information about
187 // conditional expressions through the program, allowing it to eliminate
188 // conditional branches in some cases.
189 //
190 FunctionPass *createCondPropagationPass();
191
192 //===----------------------------------------------------------------------===//
193 //
194 // TailDuplication - Eliminate unconditional branches through controlled code
195 // duplication, creating simpler CFG structures.
196 //
197 FunctionPass *createTailDuplicationPass();
198
199
200 //===----------------------------------------------------------------------===//
201 //
202 // CFG Simplification - Merge basic blocks, eliminate unreachable blocks,
203 // simplify terminator instructions, etc...
204 //
205 FunctionPass *createCFGSimplificationPass();
206
207
208 //===----------------------------------------------------------------------===//
209 //
210 // BreakCriticalEdges pass - Break all of the critical edges in the CFG by
211 // inserting a dummy basic block.  This pass may be "required" by passes that
212 // cannot deal with critical edges.  For this usage, a pass must call:
213 //
214 //   AU.addRequiredID(BreakCriticalEdgesID);
215 //
216 // This pass obviously invalidates the CFG, but can update forward dominator
217 // (set, immediate dominators, tree, and frontier) information.
218 //
219 FunctionPass *createBreakCriticalEdgesPass();
220 extern const PassInfo *BreakCriticalEdgesID;
221
222 //===----------------------------------------------------------------------===//
223 //
224 // LoopSimplify pass - Insert Pre-header blocks into the CFG for every function
225 // in the module.  This pass updates dominator information, loop information,
226 // and does not add critical edges to the CFG.
227 //
228 //   AU.addRequiredID(LoopSimplifyID);
229 //
230 FunctionPass *createLoopSimplifyPass();
231 extern const PassInfo *LoopSimplifyID;
232
233 //===----------------------------------------------------------------------===//
234 // 
235 // This pass eliminates call instructions to the current function which occur
236 // immediately before return instructions.
237 //
238 FunctionPass *createTailCallEliminationPass();
239
240
241 //===----------------------------------------------------------------------===//
242 // This pass convert malloc and free instructions to %malloc & %free function
243 // calls.
244 //
245 FunctionPass *createLowerAllocationsPass(bool LowerMallocArgToInteger = false);
246
247 //===----------------------------------------------------------------------===//
248 // This pass converts SwitchInst instructions into a sequence of chained binary
249 // branch instructions.
250 //
251 FunctionPass *createLowerSwitchPass();
252
253 //===----------------------------------------------------------------------===//
254 // This pass converts SelectInst instructions into conditional branch and PHI
255 // instructions.  If the OnlyFP flag is set to true, then only floating point
256 // select instructions are lowered.
257 //
258 FunctionPass *createLowerSelectPass(bool OnlyFP = false);
259
260 //===----------------------------------------------------------------------===//
261 // This pass converts PackedType operations into low-level scalar operations.
262 //
263 FunctionPass *createLowerPackedPass();
264
265 //===----------------------------------------------------------------------===//
266 // This pass converts invoke and unwind instructions to use sjlj exception
267 // handling mechanisms.  Note that after this pass runs the CFG is not entirely
268 // accurate (exceptional control flow edges are not correct anymore) so only
269 // very simple things should be done after the lowerinvoke pass has run (like
270 // generation of native code).  This should *NOT* be used as a general purpose
271 // "my LLVM-to-LLVM pass doesn't support the invoke instruction yet" lowering
272 // pass.
273 //
274 FunctionPass *createLowerInvokePass();
275 extern const PassInfo *LowerInvokePassID;
276
277   
278 //===----------------------------------------------------------------------===//
279 /// createLowerGCPass - This function returns an instance of the "lowergc"
280 /// pass, which lowers garbage collection intrinsics to normal LLVM code.
281 ///
282 FunctionPass *createLowerGCPass();
283
284 //===----------------------------------------------------------------------===//
285 // Returns a pass which converts all instances of ConstantExpression
286 // into regular LLVM instructions.
287 FunctionPass* createLowerConstantExpressionsPass();
288
289 //===----------------------------------------------------------------------===//
290 // This pass reorders basic blocks in order to increase the number of fall-
291 // through conditional branches.
292 FunctionPass *createBlockPlacementPass();
293
294 //===----------------------------------------------------------------------===//
295 // This pass does partial redundancy elimination.
296 FunctionPass *createPREPass();
297
298 } // End llvm namespace
299
300 #endif