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