Remove GCSE, ValueNumbering, and LoadValueNumbering. These have been deprecated...
[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 LoopPass;
22 class Pass;
23 class GetElementPtrInst;
24 class PassInfo;
25 class TerminatorInst;
26 class TargetLowering;
27
28 //===----------------------------------------------------------------------===//
29 //
30 // ConstantPropagation - A worklist driven constant propagation pass
31 //
32 FunctionPass *createConstantPropagationPass();
33
34 //===----------------------------------------------------------------------===//
35 //
36 // SCCP - Sparse conditional constant propagation.
37 //
38 FunctionPass *createSCCPPass();
39
40 //===----------------------------------------------------------------------===//
41 //
42 // DeadInstElimination - This pass quickly removes trivially dead instructions
43 // without modifying the CFG of the function.  It is a BasicBlockPass, so it
44 // runs efficiently when queued next to other BasicBlockPass's.
45 //
46 Pass *createDeadInstEliminationPass();
47
48 //===----------------------------------------------------------------------===//
49 //
50 // DeadCodeElimination - This pass is more powerful than DeadInstElimination,
51 // because it is worklist driven that can potentially revisit instructions when
52 // their other instructions become dead, to eliminate chains of dead
53 // computations.
54 //
55 FunctionPass *createDeadCodeEliminationPass();
56
57 //===----------------------------------------------------------------------===//
58 //
59 // DeadStoreElimination - This pass deletes stores that are post-dominated by
60 // must-aliased stores and are not loaded used between the stores.
61 //
62 FunctionPass *createDeadStoreEliminationPass();
63
64 //===----------------------------------------------------------------------===//
65 //
66 // AggressiveDCE - This pass uses the SSA based Aggressive DCE algorithm.  This
67 // algorithm assumes instructions are dead until proven otherwise, which makes
68 // it more successful are removing non-obviously dead instructions.
69 //
70 FunctionPass *createAggressiveDCEPass();
71
72 //===----------------------------------------------------------------------===//
73 //
74 // ScalarReplAggregates - Break up alloca's of aggregates into multiple allocas
75 // if possible.
76 //
77 FunctionPass *createScalarReplAggregatesPass(signed Threshold = -1);
78
79 //===----------------------------------------------------------------------===//
80 //
81 // InductionVariableSimplify - Transform induction variables in a program to all
82 // use a single canonical induction variable per loop.
83 //
84 LoopPass *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 LoopPass *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 LoopPass *createLoopStrengthReducePass(const TargetLowering *TLI = 0);
114
115 //===----------------------------------------------------------------------===//
116 //
117 // LoopUnswitch - This pass is a simple loop unswitching pass.
118 //
119 LoopPass *createLoopUnswitchPass(bool OptimizeForSize = false);
120
121 //===----------------------------------------------------------------------===//
122 //
123 // LoopUnroll - This pass is a simple loop unrolling pass.
124 //
125 LoopPass *createLoopUnrollPass();
126
127 //===----------------------------------------------------------------------===//
128 //
129 // LoopRotate - This pass is a simple loop rotating pass.
130 //
131 LoopPass *createLoopRotatePass();
132
133 //===----------------------------------------------------------------------===//
134 //
135 // LoopIndexSplit - This pass divides loop's iteration range by spliting loop
136 // such that each individual loop is executed efficiently.
137 //
138 LoopPass *createLoopIndexSplitPass();
139
140
141 //===----------------------------------------------------------------------===//
142 //
143 // PromoteMemoryToRegister - This pass is used to promote memory references to
144 // be register references. A simple example of the transformation performed by
145 // this pass is:
146 //
147 //        FROM CODE                           TO CODE
148 //   %X = alloca int, uint 1                 ret int 42
149 //   store int 42, int *%X
150 //   %Y = load int* %X
151 //   ret int %Y
152 //
153 FunctionPass *createPromoteMemoryToRegisterPass();
154 extern const PassInfo *const PromoteMemoryToRegisterID;
155
156 //===----------------------------------------------------------------------===//
157 //
158 // DemoteRegisterToMemoryPass - This pass is used to demote registers to memory
159 // references. In basically undoes the PromoteMemoryToRegister pass to make cfg
160 // hacking easier.
161 //
162 FunctionPass *createDemoteRegisterToMemoryPass();
163 extern const PassInfo *const DemoteRegisterToMemoryID;
164
165 //===----------------------------------------------------------------------===//
166 //
167 // Reassociate - This pass reassociates commutative expressions in an order that
168 // is designed to promote better constant propagation, GCSE, LICM, PRE...
169 //
170 // For example:  4 + (x + 5)  ->  x + (4 + 5)
171 //
172 FunctionPass *createReassociatePass();
173
174 //===----------------------------------------------------------------------===//
175 //
176 // CondPropagationPass - This pass propagates information about conditional
177 // expressions through the program, allowing it to eliminate conditional
178 // branches in some cases.
179 //
180 FunctionPass *createCondPropagationPass();
181
182 //===----------------------------------------------------------------------===//
183 //
184 // TailDuplication - Eliminate unconditional branches through controlled code
185 // duplication, creating simpler CFG structures.
186 //
187 FunctionPass *createTailDuplicationPass();
188
189 //===----------------------------------------------------------------------===//
190 //
191 // JumpThreading - Thread control through mult-pred/multi-succ blocks where some
192 // preds always go to some succ.
193 //
194 FunctionPass *createJumpThreadingPass();
195   
196 //===----------------------------------------------------------------------===//
197 //
198 // CFGSimplification - Merge basic blocks, eliminate unreachable blocks,
199 // simplify terminator instructions, etc...
200 //
201 FunctionPass *createCFGSimplificationPass();
202
203 //===----------------------------------------------------------------------===//
204 //
205 // BreakCriticalEdges - Break all of the critical edges in the CFG by inserting
206 // a dummy basic block. This pass may be "required" by passes that cannot deal
207 // with critical edges. For this usage, a pass must call:
208 //
209 //   AU.addRequiredID(BreakCriticalEdgesID);
210 //
211 // This pass obviously invalidates the CFG, but can update forward dominator
212 // (set, immediate dominators, tree, and frontier) information.
213 //
214 FunctionPass *createBreakCriticalEdgesPass();
215 extern const PassInfo *const BreakCriticalEdgesID;
216
217 //===----------------------------------------------------------------------===//
218 //
219 // LoopSimplify - Insert Pre-header blocks into the CFG for every function in
220 // the module.  This pass updates dominator information, loop information, and
221 // does not add critical edges to the CFG.
222 //
223 //   AU.addRequiredID(LoopSimplifyID);
224 //
225 FunctionPass *createLoopSimplifyPass();
226 extern const PassInfo *const LoopSimplifyID;
227
228 //===----------------------------------------------------------------------===//
229 //
230 // LowerAllocations - Turn malloc and free instructions into %malloc and %free
231 // calls.
232 //
233 //   AU.addRequiredID(LowerAllocationsID);
234 //
235 Pass *createLowerAllocationsPass(bool LowerMallocArgToInteger = false);
236 extern const PassInfo *const LowerAllocationsID;
237
238 //===----------------------------------------------------------------------===//
239 //
240 // TailCallElimination - This pass eliminates call instructions to the current
241 // function which occur immediately before return instructions.
242 //
243 FunctionPass *createTailCallEliminationPass();
244
245 //===----------------------------------------------------------------------===//
246 //
247 // LowerSwitch - This pass converts SwitchInst instructions into a sequence of
248 // chained binary branch instructions.
249 //
250 FunctionPass *createLowerSwitchPass();
251 extern const PassInfo *const LowerSwitchID;
252
253 //===----------------------------------------------------------------------===//
254 //
255 // LowerInvoke - This pass converts invoke and unwind instructions to use sjlj
256 // exception handling mechanisms.  Note that after this pass runs the CFG is not
257 // entirely accurate (exceptional control flow edges are not correct anymore) so
258 // only very simple things should be done after the lowerinvoke pass has run
259 // (like generation of native code).  This should *NOT* be used as a general
260 // purpose "my LLVM-to-LLVM pass doesn't support the invoke instruction yet"
261 // lowering pass.
262 //
263 FunctionPass *createLowerInvokePass(const TargetLowering *TLI = 0);
264 extern const PassInfo *const LowerInvokePassID;
265
266 //===----------------------------------------------------------------------===//
267 //
268 // BlockPlacement - This pass reorders basic blocks in order to increase the
269 // number of fall-through conditional branches.
270 //
271 FunctionPass *createBlockPlacementPass();
272
273 //===----------------------------------------------------------------------===//
274 //
275 // LCSSA - This pass inserts phi nodes at loop boundaries to simplify other loop
276 // optimizations.
277 //
278 LoopPass *createLCSSAPass();
279 extern const PassInfo *const LCSSAID;
280
281 //===----------------------------------------------------------------------===//
282 //
283 // PredicateSimplifier - This pass collapses duplicate variables into one
284 // canonical form, and tries to simplify expressions along the way.
285 //
286 FunctionPass *createPredicateSimplifierPass();
287
288 //===----------------------------------------------------------------------===//
289 //
290 // GVN-PRE - This pass performs global value numbering and partial redundancy
291 // elimination.
292 //
293 FunctionPass *createGVNPREPass();
294
295 //===----------------------------------------------------------------------===//
296 //
297 // GVN - This pass performs global value numbering and redundant load 
298 // elimination cotemporaneously.
299 //
300 FunctionPass *createGVNPass();
301
302 //===----------------------------------------------------------------------===//
303 //
304 // MemCpyOpt - This pass performs optimizations related to eliminating memcpy
305 // calls and/or combining multiple stores into memset's.
306 //
307 FunctionPass *createMemCpyOptPass();
308
309 //===----------------------------------------------------------------------===//
310 //
311 // LoopDeletion - This pass performs DCE of non-infinite loops that it
312 // can prove are dead.
313 //
314 LoopPass *createLoopDeletionPass();
315   
316 //===----------------------------------------------------------------------===//
317 //
318 /// createSimplifyLibCallsPass - This pass optimizes specific calls to
319 /// specific well-known (library) functions.
320 FunctionPass *createSimplifyLibCallsPass();
321
322 //===----------------------------------------------------------------------===//
323 //
324 // CodeGenPrepare - This pass prepares a function for instruction selection.
325 //
326 FunctionPass *createCodeGenPreparePass(const TargetLowering *TLI = 0);
327
328 } // End llvm namespace
329
330 #endif