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