Reformat linefeeds.
[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 #include "llvm/ADT/StringRef.h"
19
20 namespace llvm {
21
22 class FunctionPass;
23 class Pass;
24 class GetElementPtrInst;
25 class PassInfo;
26 class TerminatorInst;
27 class TargetLowering;
28 class TargetMachine;
29
30 //===----------------------------------------------------------------------===//
31 //
32 // ConstantPropagation - A worklist driven constant propagation pass
33 //
34 FunctionPass *createConstantPropagationPass();
35
36 //===----------------------------------------------------------------------===//
37 //
38 // SCCP - Sparse conditional constant propagation.
39 //
40 FunctionPass *createSCCPPass();
41
42 //===----------------------------------------------------------------------===//
43 //
44 // DeadInstElimination - This pass quickly removes trivially dead instructions
45 // without modifying the CFG of the function.  It is a BasicBlockPass, so it
46 // runs efficiently when queued next to other BasicBlockPass's.
47 //
48 Pass *createDeadInstEliminationPass();
49
50 //===----------------------------------------------------------------------===//
51 //
52 // DeadCodeElimination - This pass is more powerful than DeadInstElimination,
53 // because it is worklist driven that can potentially revisit instructions when
54 // their other instructions become dead, to eliminate chains of dead
55 // computations.
56 //
57 FunctionPass *createDeadCodeEliminationPass();
58
59 //===----------------------------------------------------------------------===//
60 //
61 // DeadStoreElimination - This pass deletes stores that are post-dominated by
62 // must-aliased stores and are not loaded used between the stores.
63 //
64 FunctionPass *createDeadStoreEliminationPass();
65
66 //===----------------------------------------------------------------------===//
67 //
68 // AggressiveDCE - This pass uses the SSA based Aggressive DCE algorithm.  This
69 // algorithm assumes instructions are dead until proven otherwise, which makes
70 // it more successful are removing non-obviously dead instructions.
71 //
72 FunctionPass *createAggressiveDCEPass();
73
74 //===----------------------------------------------------------------------===//
75 //
76 // SROA - Replace aggregates or pieces of aggregates with scalar SSA values.
77 //
78 FunctionPass *createSROAPass(bool RequiresDomTree = true);
79
80 //===----------------------------------------------------------------------===//
81 //
82 // ScalarReplAggregates - Break up alloca's of aggregates into multiple allocas
83 // if possible.
84 //
85 FunctionPass *createScalarReplAggregatesPass(signed Threshold = -1,
86                                              bool UseDomTree = true,
87                                              signed StructMemberThreshold = -1,
88                                              signed ArrayElementThreshold = -1,
89                                              signed ScalarLoadThreshold = -1);
90
91 //===----------------------------------------------------------------------===//
92 //
93 // InductionVariableSimplify - Transform induction variables in a program to all
94 // use a single canonical induction variable per loop.
95 //
96 Pass *createIndVarSimplifyPass();
97
98 //===----------------------------------------------------------------------===//
99 //
100 // InstructionCombining - Combine instructions to form fewer, simple
101 // instructions. This pass does not modify the CFG, and has a tendency to make
102 // instructions dead, so a subsequent DCE pass is useful.
103 //
104 // This pass combines things like:
105 //    %Y = add int 1, %X
106 //    %Z = add int 1, %Y
107 // into:
108 //    %Z = add int 2, %X
109 //
110 FunctionPass *createInstructionCombiningPass();
111
112 //===----------------------------------------------------------------------===//
113 //
114 // LICM - This pass is a loop invariant code motion and memory promotion pass.
115 //
116 Pass *createLICMPass();
117
118 //===----------------------------------------------------------------------===//
119 //
120 // LoopStrengthReduce - This pass is strength reduces GEP instructions that use
121 // a loop's canonical induction variable as one of their indices.
122 //
123 Pass *createLoopStrengthReducePass();
124
125 Pass *createGlobalMergePass(const TargetMachine *TM = nullptr);
126
127 //===----------------------------------------------------------------------===//
128 //
129 // LoopUnswitch - This pass is a simple loop unswitching pass.
130 //
131 Pass *createLoopUnswitchPass(bool OptimizeForSize = false);
132
133 //===----------------------------------------------------------------------===//
134 //
135 // LoopInstSimplify - This pass simplifies instructions in a loop's body.
136 //
137 Pass *createLoopInstSimplifyPass();
138
139 //===----------------------------------------------------------------------===//
140 //
141 // LoopUnroll - This pass is a simple loop unrolling pass.
142 //
143 Pass *createLoopUnrollPass(int Threshold = -1, int Count = -1,
144                            int AllowPartial = -1, int Runtime = -1);
145 // Create an unrolling pass for full unrolling only.
146 Pass *createSimpleLoopUnrollPass();
147
148 //===----------------------------------------------------------------------===//
149 //
150 // LoopReroll - This pass is a simple loop rerolling pass.
151 //
152 Pass *createLoopRerollPass();
153
154 //===----------------------------------------------------------------------===//
155 //
156 // LoopRotate - This pass is a simple loop rotating pass.
157 //
158 Pass *createLoopRotatePass();
159
160 //===----------------------------------------------------------------------===//
161 //
162 // LoopIdiom - This pass recognizes and replaces idioms in loops.
163 //
164 Pass *createLoopIdiomPass();
165
166 //===----------------------------------------------------------------------===//
167 //
168 // PromoteMemoryToRegister - This pass is used to promote memory references to
169 // be register references. A simple example of the transformation performed by
170 // this pass is:
171 //
172 //        FROM CODE                           TO CODE
173 //   %X = alloca i32, i32 1                 ret i32 42
174 //   store i32 42, i32 *%X
175 //   %Y = load i32* %X
176 //   ret i32 %Y
177 //
178 FunctionPass *createPromoteMemoryToRegisterPass();
179
180 //===----------------------------------------------------------------------===//
181 //
182 // DemoteRegisterToMemoryPass - This pass is used to demote registers to memory
183 // references. In basically undoes the PromoteMemoryToRegister pass to make cfg
184 // hacking easier.
185 //
186 FunctionPass *createDemoteRegisterToMemoryPass();
187 extern char &DemoteRegisterToMemoryID;
188
189 //===----------------------------------------------------------------------===//
190 //
191 // Reassociate - This pass reassociates commutative expressions in an order that
192 // is designed to promote better constant propagation, GCSE, LICM, PRE...
193 //
194 // For example:  4 + (x + 5)  ->  x + (4 + 5)
195 //
196 FunctionPass *createReassociatePass();
197
198 //===----------------------------------------------------------------------===//
199 //
200 // JumpThreading - Thread control through mult-pred/multi-succ blocks where some
201 // preds always go to some succ.
202 //
203 FunctionPass *createJumpThreadingPass();
204
205 //===----------------------------------------------------------------------===//
206 //
207 // CFGSimplification - Merge basic blocks, eliminate unreachable blocks,
208 // simplify terminator instructions, etc...
209 //
210 FunctionPass *createCFGSimplificationPass();
211
212 //===----------------------------------------------------------------------===//
213 //
214 // FlattenCFG - flatten CFG, reduce number of conditional branches by using
215 // parallel-and and parallel-or mode, etc...
216 //
217 FunctionPass *createFlattenCFGPass();
218
219 //===----------------------------------------------------------------------===//
220 //
221 // CFG Structurization - Remove irreducible control flow
222 //
223 Pass *createStructurizeCFGPass();
224
225 //===----------------------------------------------------------------------===//
226 //
227 // BreakCriticalEdges - Break all of the critical edges in the CFG by inserting
228 // a dummy basic block. This pass may be "required" by passes that cannot deal
229 // with critical edges. For this usage, a pass must call:
230 //
231 //   AU.addRequiredID(BreakCriticalEdgesID);
232 //
233 // This pass obviously invalidates the CFG, but can update forward dominator
234 // (set, immediate dominators, tree, and frontier) information.
235 //
236 FunctionPass *createBreakCriticalEdgesPass();
237 extern char &BreakCriticalEdgesID;
238
239 //===----------------------------------------------------------------------===//
240 //
241 // LoopSimplify - Insert Pre-header blocks into the CFG for every function in
242 // the module.  This pass updates dominator information, loop information, and
243 // does not add critical edges to the CFG.
244 //
245 //   AU.addRequiredID(LoopSimplifyID);
246 //
247 Pass *createLoopSimplifyPass();
248 extern char &LoopSimplifyID;
249
250 //===----------------------------------------------------------------------===//
251 //
252 // TailCallElimination - This pass eliminates call instructions to the current
253 // function which occur immediately before return instructions.
254 //
255 FunctionPass *createTailCallEliminationPass();
256
257 //===----------------------------------------------------------------------===//
258 //
259 // LowerSwitch - This pass converts SwitchInst instructions into a sequence of
260 // chained binary branch instructions.
261 //
262 FunctionPass *createLowerSwitchPass();
263 extern char &LowerSwitchID;
264
265 //===----------------------------------------------------------------------===//
266 //
267 // LowerInvoke - This pass removes invoke instructions, converting them to call
268 // instructions.
269 //
270 FunctionPass *createLowerInvokePass();
271 extern char &LowerInvokePassID;
272
273 //===----------------------------------------------------------------------===//
274 //
275 // LCSSA - This pass inserts phi nodes at loop boundaries to simplify other loop
276 // optimizations.
277 //
278 Pass *createLCSSAPass();
279 extern char &LCSSAID;
280
281 //===----------------------------------------------------------------------===//
282 //
283 // EarlyCSE - This pass performs a simple and fast CSE pass over the dominator
284 // tree.
285 //
286 FunctionPass *createEarlyCSEPass();
287
288 //===----------------------------------------------------------------------===//
289 //
290 // GVN - This pass performs global value numbering and redundant load
291 // elimination cotemporaneously.
292 //
293 FunctionPass *createGVNPass(bool NoLoads = false);
294
295 //===----------------------------------------------------------------------===//
296 //
297 // MemCpyOpt - This pass performs optimizations related to eliminating memcpy
298 // calls and/or combining multiple stores into memset's.
299 //
300 FunctionPass *createMemCpyOptPass();
301
302 //===----------------------------------------------------------------------===//
303 //
304 // LoopDeletion - This pass performs DCE of non-infinite loops that it
305 // can prove are dead.
306 //
307 Pass *createLoopDeletionPass();
308
309 //===----------------------------------------------------------------------===//
310 //
311 // ConstantHoisting - This pass prepares a function for expensive constants.
312 //
313 FunctionPass *createConstantHoistingPass();
314
315 //===----------------------------------------------------------------------===//
316 //
317 // InstructionNamer - Give any unnamed non-void instructions "tmp" names.
318 //
319 FunctionPass *createInstructionNamerPass();
320 extern char &InstructionNamerID;
321
322 //===----------------------------------------------------------------------===//
323 //
324 // Sink - Code Sinking
325 //
326 FunctionPass *createSinkingPass();
327
328 //===----------------------------------------------------------------------===//
329 //
330 // LowerAtomic - Lower atomic intrinsics to non-atomic form
331 //
332 Pass *createLowerAtomicPass();
333
334 //===----------------------------------------------------------------------===//
335 //
336 // ValuePropagation - Propagate CFG-derived value information
337 //
338 Pass *createCorrelatedValuePropagationPass();
339
340 //===----------------------------------------------------------------------===//
341 //
342 // InstructionSimplifier - Remove redundant instructions.
343 //
344 FunctionPass *createInstructionSimplifierPass();
345 extern char &InstructionSimplifierID;
346
347 //===----------------------------------------------------------------------===//
348 //
349 // LowerExpectIntrinsics - Removes llvm.expect intrinsics and creates
350 // "block_weights" metadata.
351 FunctionPass *createLowerExpectIntrinsicPass();
352
353 //===----------------------------------------------------------------------===//
354 //
355 // PartiallyInlineLibCalls - Tries to inline the fast path of library
356 // calls such as sqrt.
357 //
358 FunctionPass *createPartiallyInlineLibCallsPass();
359
360 //===----------------------------------------------------------------------===//
361 //
362 // SampleProfilePass - Loads sample profile data from disk and generates
363 // IR metadata to reflect the profile.
364 FunctionPass *createSampleProfileLoaderPass();
365 FunctionPass *createSampleProfileLoaderPass(StringRef Name);
366
367 //===----------------------------------------------------------------------===//
368 //
369 // ScalarizerPass - Converts vector operations into scalar operations
370 //
371 FunctionPass *createScalarizerPass();
372
373 //===----------------------------------------------------------------------===//
374 //
375 // AddDiscriminators - Add DWARF path discriminators to the IR.
376 FunctionPass *createAddDiscriminatorsPass();
377
378 //===----------------------------------------------------------------------===//
379 //
380 // SeparateConstOffsetFromGEP - Split GEPs for better CSE
381 //
382 FunctionPass *createSeparateConstOffsetFromGEPPass();
383
384 } // End llvm namespace
385
386 #endif