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