Remove the MarkModRef pass (use AddReadAttrs instead).
[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 // PromoteMemoryToRegister - This pass is used to promote memory references to
143 // be register references. A simple example of the transformation performed by
144 // this pass is:
145 //
146 //        FROM CODE                           TO CODE
147 //   %X = alloca int, uint 1                 ret int 42
148 //   store int 42, int *%X
149 //   %Y = load int* %X
150 //   ret int %Y
151 //
152 FunctionPass *createPromoteMemoryToRegisterPass();
153 extern const PassInfo *const PromoteMemoryToRegisterID;
154
155 //===----------------------------------------------------------------------===//
156 //
157 // DemoteRegisterToMemoryPass - This pass is used to demote registers to memory
158 // references. In basically undoes the PromoteMemoryToRegister pass to make cfg
159 // hacking easier.
160 //
161 FunctionPass *createDemoteRegisterToMemoryPass();
162 extern const PassInfo *const DemoteRegisterToMemoryID;
163
164 //===----------------------------------------------------------------------===//
165 //
166 // Reassociate - This pass reassociates commutative expressions in an order that
167 // is designed to promote better constant propagation, GCSE, LICM, PRE...
168 //
169 // For example:  4 + (x + 5)  ->  x + (4 + 5)
170 //
171 FunctionPass *createReassociatePass();
172
173 //===----------------------------------------------------------------------===//
174 //
175 // CondPropagationPass - This pass propagates information about conditional
176 // expressions through the program, allowing it to eliminate conditional
177 // branches in some cases.
178 //
179 FunctionPass *createCondPropagationPass();
180
181 //===----------------------------------------------------------------------===//
182 //
183 // TailDuplication - Eliminate unconditional branches through controlled code
184 // duplication, creating simpler CFG structures.
185 //
186 FunctionPass *createTailDuplicationPass();
187
188 //===----------------------------------------------------------------------===//
189 //
190 // JumpThreading - Thread control through mult-pred/multi-succ blocks where some
191 // preds always go to some succ.
192 //
193 FunctionPass *createJumpThreadingPass();
194   
195 //===----------------------------------------------------------------------===//
196 //
197 // CFGSimplification - Merge basic blocks, eliminate unreachable blocks,
198 // simplify terminator instructions, etc...
199 //
200 FunctionPass *createCFGSimplificationPass();
201
202 //===----------------------------------------------------------------------===//
203 //
204 // BreakCriticalEdges - Break all of the critical edges in the CFG by inserting
205 // a dummy basic block. This pass may be "required" by passes that cannot deal
206 // with critical edges. For this usage, a pass must call:
207 //
208 //   AU.addRequiredID(BreakCriticalEdgesID);
209 //
210 // This pass obviously invalidates the CFG, but can update forward dominator
211 // (set, immediate dominators, tree, and frontier) information.
212 //
213 FunctionPass *createBreakCriticalEdgesPass();
214 extern const PassInfo *const BreakCriticalEdgesID;
215
216 //===----------------------------------------------------------------------===//
217 //
218 // LoopSimplify - Insert Pre-header blocks into the CFG for every function in
219 // the module.  This pass updates dominator information, loop information, and
220 // does not add critical edges to the CFG.
221 //
222 //   AU.addRequiredID(LoopSimplifyID);
223 //
224 FunctionPass *createLoopSimplifyPass();
225 extern const PassInfo *const LoopSimplifyID;
226
227 //===----------------------------------------------------------------------===//
228 //
229 // LowerAllocations - Turn malloc and free instructions into %malloc and %free
230 // calls.
231 //
232 //   AU.addRequiredID(LowerAllocationsID);
233 //
234 Pass *createLowerAllocationsPass(bool LowerMallocArgToInteger = false);
235 extern const PassInfo *const LowerAllocationsID;
236
237 //===----------------------------------------------------------------------===//
238 //
239 // TailCallElimination - This pass eliminates call instructions to the current
240 // function which occur immediately before return instructions.
241 //
242 FunctionPass *createTailCallEliminationPass();
243
244 //===----------------------------------------------------------------------===//
245 //
246 // LowerSwitch - This pass converts SwitchInst instructions into a sequence of
247 // chained binary branch instructions.
248 //
249 FunctionPass *createLowerSwitchPass();
250 extern const PassInfo *const LowerSwitchID;
251
252 //===----------------------------------------------------------------------===//
253 //
254 // LowerInvoke - This pass converts invoke and unwind instructions to use sjlj
255 // exception handling mechanisms.  Note that after this pass runs the CFG is not
256 // entirely accurate (exceptional control flow edges are not correct anymore) so
257 // only very simple things should be done after the lowerinvoke pass has run
258 // (like generation of native code).  This should *NOT* be used as a general
259 // purpose "my LLVM-to-LLVM pass doesn't support the invoke instruction yet"
260 // lowering pass.
261 //
262 FunctionPass *createLowerInvokePass(const TargetLowering *TLI = 0);
263 extern const PassInfo *const LowerInvokePassID;
264
265 //===----------------------------------------------------------------------===//
266 //
267 // BlockPlacement - This pass reorders basic blocks in order to increase the
268 // number of fall-through conditional branches.
269 //
270 FunctionPass *createBlockPlacementPass();
271
272 //===----------------------------------------------------------------------===//
273 //
274 // LCSSA - This pass inserts phi nodes at loop boundaries to simplify other loop
275 // optimizations.
276 //
277 LoopPass *createLCSSAPass();
278 extern const PassInfo *const LCSSAID;
279
280 //===----------------------------------------------------------------------===//
281 //
282 // PredicateSimplifier - This pass collapses duplicate variables into one
283 // canonical form, and tries to simplify expressions along the way.
284 //
285 FunctionPass *createPredicateSimplifierPass();
286
287 //===----------------------------------------------------------------------===//
288 //
289 // GVN-PRE - This pass performs global value numbering and partial redundancy
290 // elimination.
291 //
292 FunctionPass *createGVNPREPass();
293
294 //===----------------------------------------------------------------------===//
295 //
296 // GVN - This pass performs global value numbering and redundant load 
297 // elimination cotemporaneously.
298 //
299 FunctionPass *createGVNPass();
300
301 //===----------------------------------------------------------------------===//
302 //
303 // MemCpyOpt - This pass performs optimizations related to eliminating memcpy
304 // calls and/or combining multiple stores into memset's.
305 //
306 FunctionPass *createMemCpyOptPass();
307
308 //===----------------------------------------------------------------------===//
309 //
310 // LoopDeletion - This pass performs DCE of non-infinite loops that it
311 // can prove are dead.
312 //
313 LoopPass *createLoopDeletionPass();
314   
315 //===----------------------------------------------------------------------===//
316 //
317 /// createSimplifyLibCallsPass - This pass optimizes specific calls to
318 /// specific well-known (library) functions.
319 FunctionPass *createSimplifyLibCallsPass();
320
321 //===----------------------------------------------------------------------===//
322 //
323 // CodeGenPrepare - This pass prepares a function for instruction selection.
324 //
325 FunctionPass *createCodeGenPreparePass(const TargetLowering *TLI = 0);
326
327   
328 //===----------------------------------------------------------------------===//
329 //
330 // InstructionNamer - Give any unnamed non-void instructions "tmp" names.
331 //
332 FunctionPass *createInstructionNamerPass();
333   
334 } // End llvm namespace
335
336 #endif