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