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