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