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