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