Switch the SCEV expander and LoopStrengthReduce to use
[oota-llvm.git] / include / llvm / Transforms / Scalar.h
1 //===-- Scalar.h - Scalar Transformations -----------------------*- 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 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 FunctionPass;
21 class Pass;
22 class GetElementPtrInst;
23 class PassInfo;
24 class TerminatorInst;
25 class TargetLowering;
26
27 //===----------------------------------------------------------------------===//
28 //
29 // ConstantPropagation - A worklist driven constant propagation pass
30 //
31 FunctionPass *createConstantPropagationPass();
32
33 //===----------------------------------------------------------------------===//
34 //
35 // SCCP - Sparse conditional constant propagation.
36 //
37 FunctionPass *createSCCPPass();
38
39 //===----------------------------------------------------------------------===//
40 //
41 // DeadInstElimination - This pass quickly removes trivially dead instructions
42 // without modifying the CFG of the function.  It is a BasicBlockPass, so it
43 // runs efficiently when queued next to other BasicBlockPass's.
44 //
45 Pass *createDeadInstEliminationPass();
46
47 //===----------------------------------------------------------------------===//
48 //
49 // DeadCodeElimination - This pass is more powerful than DeadInstElimination,
50 // because it is worklist driven that can potentially revisit instructions when
51 // their other instructions become dead, to eliminate chains of dead
52 // computations.
53 //
54 FunctionPass *createDeadCodeEliminationPass();
55
56 //===----------------------------------------------------------------------===//
57 //
58 // DeadStoreElimination - This pass deletes stores that are post-dominated by
59 // must-aliased stores and are not loaded used between the stores.
60 //
61 FunctionPass *createDeadStoreEliminationPass();
62
63 //===----------------------------------------------------------------------===//
64 //
65 // AggressiveDCE - This pass uses the SSA based Aggressive DCE algorithm.  This
66 // algorithm assumes instructions are dead until proven otherwise, which makes
67 // it more successful are removing non-obviously dead instructions.
68 //
69 FunctionPass *createAggressiveDCEPass();
70
71 //===----------------------------------------------------------------------===//
72 //
73 // SROA - Replace aggregates or pieces of aggregates with scalar SSA values.
74 //
75 FunctionPass *createSROAPass(bool RequiresDomTree = true);
76
77 //===----------------------------------------------------------------------===//
78 //
79 // ScalarReplAggregates - Break up alloca's of aggregates into multiple allocas
80 // if possible.
81 //
82 FunctionPass *createScalarReplAggregatesPass(signed Threshold = -1,
83                                              bool UseDomTree = true,
84                                              signed StructMemberThreshold = -1,
85                                              signed ArrayElementThreshold = -1,
86                                              signed ScalarLoadThreshold = -1);
87
88 //===----------------------------------------------------------------------===//
89 //
90 // InductionVariableSimplify - Transform induction variables in a program to all
91 // use a single canonical induction variable per loop.
92 //
93 Pass *createIndVarSimplifyPass();
94
95 //===----------------------------------------------------------------------===//
96 //
97 // InstructionCombining - Combine instructions to form fewer, simple
98 // instructions. This pass does not modify the CFG, and has a tendency to make
99 // instructions dead, so a subsequent DCE pass is useful.
100 //
101 // This pass combines things like:
102 //    %Y = add int 1, %X
103 //    %Z = add int 1, %Y
104 // into:
105 //    %Z = add int 2, %X
106 //
107 FunctionPass *createInstructionCombiningPass();
108
109 //===----------------------------------------------------------------------===//
110 //
111 // LICM - This pass is a loop invariant code motion and memory promotion pass.
112 //
113 Pass *createLICMPass();
114
115 //===----------------------------------------------------------------------===//
116 //
117 // LoopStrengthReduce - This pass is strength reduces GEP instructions that use
118 // a loop's canonical induction variable as one of their indices.
119 //
120 Pass *createLoopStrengthReducePass();
121
122 Pass *createGlobalMergePass(const TargetLowering *TLI = 0);
123
124 //===----------------------------------------------------------------------===//
125 //
126 // LoopUnswitch - This pass is a simple loop unswitching pass.
127 //
128 Pass *createLoopUnswitchPass(bool OptimizeForSize = false);
129
130 //===----------------------------------------------------------------------===//
131 //
132 // LoopInstSimplify - This pass simplifies instructions in a loop's body.
133 //
134 Pass *createLoopInstSimplifyPass();
135
136 //===----------------------------------------------------------------------===//
137 //
138 // LoopUnroll - This pass is a simple loop unrolling pass.
139 //
140 Pass *createLoopUnrollPass(int Threshold = -1, int Count = -1, int AllowPartial = -1);
141
142 //===----------------------------------------------------------------------===//
143 //
144 // LoopRotate - This pass is a simple loop rotating pass.
145 //
146 Pass *createLoopRotatePass();
147
148 //===----------------------------------------------------------------------===//
149 //
150 // LoopIdiom - This pass recognizes and replaces idioms in loops.
151 //
152 Pass *createLoopIdiomPass();
153   
154 //===----------------------------------------------------------------------===//
155 //
156 // PromoteMemoryToRegister - This pass is used to promote memory references to
157 // be register references. A simple example of the transformation performed by
158 // this pass is:
159 //
160 //        FROM CODE                           TO CODE
161 //   %X = alloca i32, i32 1                 ret i32 42
162 //   store i32 42, i32 *%X
163 //   %Y = load i32* %X
164 //   ret i32 %Y
165 //
166 FunctionPass *createPromoteMemoryToRegisterPass();
167
168 //===----------------------------------------------------------------------===//
169 //
170 // DemoteRegisterToMemoryPass - This pass is used to demote registers to memory
171 // references. In basically undoes the PromoteMemoryToRegister pass to make cfg
172 // hacking easier.
173 //
174 FunctionPass *createDemoteRegisterToMemoryPass();
175 extern char &DemoteRegisterToMemoryID;
176
177 //===----------------------------------------------------------------------===//
178 //
179 // Reassociate - This pass reassociates commutative expressions in an order that
180 // is designed to promote better constant propagation, GCSE, LICM, PRE...
181 //
182 // For example:  4 + (x + 5)  ->  x + (4 + 5)
183 //
184 FunctionPass *createReassociatePass();
185
186 //===----------------------------------------------------------------------===//
187 //
188 // JumpThreading - Thread control through mult-pred/multi-succ blocks where some
189 // preds always go to some succ.
190 //
191 FunctionPass *createJumpThreadingPass();
192   
193 //===----------------------------------------------------------------------===//
194 //
195 // CFGSimplification - Merge basic blocks, eliminate unreachable blocks,
196 // simplify terminator instructions, etc...
197 //
198 FunctionPass *createCFGSimplificationPass();
199
200 //===----------------------------------------------------------------------===//
201 //
202 // BreakCriticalEdges - Break all of the critical edges in the CFG by inserting
203 // a dummy basic block. This pass may be "required" by passes that cannot deal
204 // with critical edges. For this usage, a pass must call:
205 //
206 //   AU.addRequiredID(BreakCriticalEdgesID);
207 //
208 // This pass obviously invalidates the CFG, but can update forward dominator
209 // (set, immediate dominators, tree, and frontier) information.
210 //
211 FunctionPass *createBreakCriticalEdgesPass();
212 extern char &BreakCriticalEdgesID;
213
214 //===----------------------------------------------------------------------===//
215 //
216 // LoopSimplify - Insert Pre-header blocks into the CFG for every function in
217 // the module.  This pass updates dominator information, loop information, and
218 // does not add critical edges to the CFG.
219 //
220 //   AU.addRequiredID(LoopSimplifyID);
221 //
222 Pass *createLoopSimplifyPass();
223 extern char &LoopSimplifyID;
224
225 //===----------------------------------------------------------------------===//
226 //
227 // TailCallElimination - This pass eliminates call instructions to the current
228 // function which occur immediately before return instructions.
229 //
230 FunctionPass *createTailCallEliminationPass();
231
232 //===----------------------------------------------------------------------===//
233 //
234 // LowerSwitch - This pass converts SwitchInst instructions into a sequence of
235 // chained binary branch instructions.
236 //
237 FunctionPass *createLowerSwitchPass();
238 extern char &LowerSwitchID;
239
240 //===----------------------------------------------------------------------===//
241 //
242 // LowerInvoke - This pass converts invoke and unwind instructions to use sjlj
243 // exception handling mechanisms.  Note that after this pass runs the CFG is not
244 // entirely accurate (exceptional control flow edges are not correct anymore) so
245 // only very simple things should be done after the lowerinvoke pass has run
246 // (like generation of native code).  This should *NOT* be used as a general
247 // purpose "my LLVM-to-LLVM pass doesn't support the invoke instruction yet"
248 // lowering pass.
249 //
250 FunctionPass *createLowerInvokePass(const TargetLowering *TLI = 0);
251 FunctionPass *createLowerInvokePass(const TargetLowering *TLI,
252                                     bool useExpensiveEHSupport);
253 extern char &LowerInvokePassID;
254
255 //===----------------------------------------------------------------------===//
256 //
257 // BlockPlacement - This pass reorders basic blocks in order to increase the
258 // number of fall-through conditional branches.
259 //
260 FunctionPass *createBlockPlacementPass();
261
262 //===----------------------------------------------------------------------===//
263 //
264 // LCSSA - This pass inserts phi nodes at loop boundaries to simplify other loop
265 // optimizations.
266 //
267 Pass *createLCSSAPass();
268 extern char &LCSSAID;
269
270 //===----------------------------------------------------------------------===//
271 //
272 // EarlyCSE - This pass performs a simple and fast CSE pass over the dominator
273 // tree.
274 //
275 FunctionPass *createEarlyCSEPass();
276   
277 //===----------------------------------------------------------------------===//
278 //
279 // GVN - This pass performs global value numbering and redundant load 
280 // elimination cotemporaneously.
281 //
282 FunctionPass *createGVNPass(bool NoLoads = false);
283
284 //===----------------------------------------------------------------------===//
285 //
286 // MemCpyOpt - This pass performs optimizations related to eliminating memcpy
287 // calls and/or combining multiple stores into memset's.
288 //
289 FunctionPass *createMemCpyOptPass();
290
291 //===----------------------------------------------------------------------===//
292 //
293 // LoopDeletion - This pass performs DCE of non-infinite loops that it
294 // can prove are dead.
295 //
296 Pass *createLoopDeletionPass();
297   
298 //===----------------------------------------------------------------------===//
299 //
300 /// createSimplifyLibCallsPass - This pass optimizes specific calls to
301 /// specific well-known (library) functions.
302 FunctionPass *createSimplifyLibCallsPass();
303
304 //===----------------------------------------------------------------------===//
305 //
306 // CodeGenPrepare - This pass prepares a function for instruction selection.
307 //
308 FunctionPass *createCodeGenPreparePass(const TargetLowering *TLI = 0);
309
310 //===----------------------------------------------------------------------===//
311 //
312 // InstructionNamer - Give any unnamed non-void instructions "tmp" names.
313 //
314 FunctionPass *createInstructionNamerPass();
315 extern char &InstructionNamerID;
316   
317 //===----------------------------------------------------------------------===//
318 //
319 // Sink - Code Sinking
320 //
321 FunctionPass *createSinkingPass();
322
323 //===----------------------------------------------------------------------===//
324 //
325 // LowerAtomic - Lower atomic intrinsics to non-atomic form
326 //
327 Pass *createLowerAtomicPass();
328
329 //===----------------------------------------------------------------------===//
330 //
331 // ValuePropagation - Propagate CFG-derived value information
332 //
333 Pass *createCorrelatedValuePropagationPass();
334
335 //===----------------------------------------------------------------------===//
336 //
337 // ObjCARCAPElim - ObjC ARC autorelease pool elimination.
338 //
339 Pass *createObjCARCAPElimPass();
340
341 //===----------------------------------------------------------------------===//
342 //
343 // ObjCARCExpand - ObjC ARC preliminary simplifications.
344 //
345 Pass *createObjCARCExpandPass();
346
347 //===----------------------------------------------------------------------===//
348 //
349 // ObjCARCContract - Late ObjC ARC cleanups.
350 //
351 Pass *createObjCARCContractPass();
352
353 //===----------------------------------------------------------------------===//
354 //
355 // ObjCARCOpt - ObjC ARC optimization.
356 //
357 Pass *createObjCARCOptPass();
358
359 //===----------------------------------------------------------------------===//
360 //
361 // InstructionSimplifier - Remove redundant instructions.
362 //
363 FunctionPass *createInstructionSimplifierPass();
364 extern char &InstructionSimplifierID;
365
366
367 //===----------------------------------------------------------------------===//
368 //
369 // LowerExpectIntriniscs - Removes llvm.expect intrinsics and creates
370 // "block_weights" metadata.
371 FunctionPass *createLowerExpectIntrinsicPass();
372
373
374 } // End llvm namespace
375
376 #endif