1 //===-- Scalar.h - Scalar Transformations -----------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This header file defines prototypes for accessor functions that expose passes
11 // in the Scalar transformations library.
13 //===----------------------------------------------------------------------===//
15 #ifndef LLVM_TRANSFORMS_SCALAR_H
16 #define LLVM_TRANSFORMS_SCALAR_H
22 class GetElementPtrInst;
27 //===----------------------------------------------------------------------===//
29 // ConstantPropagation - A worklist driven constant propagation pass
31 FunctionPass *createConstantPropagationPass();
33 //===----------------------------------------------------------------------===//
35 // SCCP - Sparse conditional constant propagation.
37 FunctionPass *createSCCPPass();
39 //===----------------------------------------------------------------------===//
41 // DeadInstElimination - This pass quickly removes trivially dead instructions
42 // without modifying the CFG of the function. It is a BasicBlockPass, so it
43 // runs efficiently when queued next to other BasicBlockPass's.
45 Pass *createDeadInstEliminationPass();
47 //===----------------------------------------------------------------------===//
49 // DeadCodeElimination - This pass is more powerful than DeadInstElimination,
50 // because it is worklist driven that can potentially revisit instructions when
51 // their other instructions become dead, to eliminate chains of dead
54 FunctionPass *createDeadCodeEliminationPass();
56 //===----------------------------------------------------------------------===//
58 // DeadStoreElimination - This pass deletes stores that are post-dominated by
59 // must-aliased stores and are not loaded used between the stores.
61 FunctionPass *createDeadStoreEliminationPass();
63 //===----------------------------------------------------------------------===//
65 // AggressiveDCE - This pass uses the SSA based Aggressive DCE algorithm. This
66 // algorithm assumes instructions are dead until proven otherwise, which makes
67 // it more successful are removing non-obviously dead instructions.
69 FunctionPass *createAggressiveDCEPass();
71 //===----------------------------------------------------------------------===//
73 // ScalarReplAggregates - Break up alloca's of aggregates into multiple allocas
76 FunctionPass *createScalarReplAggregatesPass(signed Threshold = -1);
78 //===----------------------------------------------------------------------===//
80 // InductionVariableSimplify - Transform induction variables in a program to all
81 // use a single canonical induction variable per loop.
83 Pass *createIndVarSimplifyPass();
85 //===----------------------------------------------------------------------===//
87 // InstructionCombining - Combine instructions to form fewer, simple
88 // instructions. This pass does not modify the CFG, and has a tendency to make
89 // instructions dead, so a subsequent DCE pass is useful.
91 // This pass combines things like:
97 FunctionPass *createInstructionCombiningPass();
99 //===----------------------------------------------------------------------===//
101 // LICM - This pass is a loop invariant code motion and memory promotion pass.
103 Pass *createLICMPass();
105 //===----------------------------------------------------------------------===//
107 // LoopStrengthReduce - This pass is strength reduces GEP instructions that use
108 // a loop's canonical induction variable as one of their indices. It takes an
109 // optional parameter used to consult the target machine whether certain
110 // transformations are profitable.
112 Pass *createLoopStrengthReducePass(const TargetLowering *TLI = 0);
114 //===----------------------------------------------------------------------===//
116 // LoopUnswitch - This pass is a simple loop unswitching pass.
118 Pass *createLoopUnswitchPass(bool OptimizeForSize = false);
120 //===----------------------------------------------------------------------===//
122 // LoopUnroll - This pass is a simple loop unrolling pass.
124 Pass *createLoopUnrollPass();
126 //===----------------------------------------------------------------------===//
128 // LoopRotate - This pass is a simple loop rotating pass.
130 Pass *createLoopRotatePass();
132 //===----------------------------------------------------------------------===//
134 // LoopIndexSplit - This pass divides loop's iteration range by spliting loop
135 // such that each individual loop is executed efficiently.
137 Pass *createLoopIndexSplitPass();
139 //===----------------------------------------------------------------------===//
141 // PromoteMemoryToRegister - This pass is used to promote memory references to
142 // be register references. A simple example of the transformation performed by
146 // %X = alloca i32, i32 1 ret i32 42
147 // store i32 42, i32 *%X
151 FunctionPass *createPromoteMemoryToRegisterPass();
153 //===----------------------------------------------------------------------===//
155 // DemoteRegisterToMemoryPass - This pass is used to demote registers to memory
156 // references. In basically undoes the PromoteMemoryToRegister pass to make cfg
159 FunctionPass *createDemoteRegisterToMemoryPass();
160 extern char &DemoteRegisterToMemoryID;
162 //===----------------------------------------------------------------------===//
164 // Reassociate - This pass reassociates commutative expressions in an order that
165 // is designed to promote better constant propagation, GCSE, LICM, PRE...
167 // For example: 4 + (x + 5) -> x + (4 + 5)
169 FunctionPass *createReassociatePass();
171 //===----------------------------------------------------------------------===//
173 // TailDuplication - Eliminate unconditional branches through controlled code
174 // duplication, creating simpler CFG structures.
176 FunctionPass *createTailDuplicationPass();
178 //===----------------------------------------------------------------------===//
180 // JumpThreading - Thread control through mult-pred/multi-succ blocks where some
181 // preds always go to some succ.
183 FunctionPass *createJumpThreadingPass();
185 //===----------------------------------------------------------------------===//
187 // CFGSimplification - Merge basic blocks, eliminate unreachable blocks,
188 // simplify terminator instructions, etc...
190 FunctionPass *createCFGSimplificationPass();
192 //===----------------------------------------------------------------------===//
194 // BreakCriticalEdges - Break all of the critical edges in the CFG by inserting
195 // a dummy basic block. This pass may be "required" by passes that cannot deal
196 // with critical edges. For this usage, a pass must call:
198 // AU.addRequiredID(BreakCriticalEdgesID);
200 // This pass obviously invalidates the CFG, but can update forward dominator
201 // (set, immediate dominators, tree, and frontier) information.
203 FunctionPass *createBreakCriticalEdgesPass();
204 extern char &BreakCriticalEdgesID;
206 //===----------------------------------------------------------------------===//
208 // LoopSimplify - Insert Pre-header blocks into the CFG for every function in
209 // the module. This pass updates dominator information, loop information, and
210 // does not add critical edges to the CFG.
212 // AU.addRequiredID(LoopSimplifyID);
214 Pass *createLoopSimplifyPass();
215 extern char &LoopSimplifyID;
217 //===----------------------------------------------------------------------===//
219 // TailCallElimination - This pass eliminates call instructions to the current
220 // function which occur immediately before return instructions.
222 FunctionPass *createTailCallEliminationPass();
224 //===----------------------------------------------------------------------===//
226 // LowerSwitch - This pass converts SwitchInst instructions into a sequence of
227 // chained binary branch instructions.
229 FunctionPass *createLowerSwitchPass();
230 extern char &LowerSwitchID;
232 //===----------------------------------------------------------------------===//
234 // LowerInvoke - This pass converts invoke and unwind instructions to use sjlj
235 // exception handling mechanisms. Note that after this pass runs the CFG is not
236 // entirely accurate (exceptional control flow edges are not correct anymore) so
237 // only very simple things should be done after the lowerinvoke pass has run
238 // (like generation of native code). This should *NOT* be used as a general
239 // purpose "my LLVM-to-LLVM pass doesn't support the invoke instruction yet"
242 FunctionPass *createLowerInvokePass(const TargetLowering *TLI = 0);
243 FunctionPass *createLowerInvokePass(const TargetLowering *TLI,
244 bool useExpensiveEHSupport);
245 extern char &LowerInvokePassID;
247 //===----------------------------------------------------------------------===//
249 // BlockPlacement - This pass reorders basic blocks in order to increase the
250 // number of fall-through conditional branches.
252 FunctionPass *createBlockPlacementPass();
254 //===----------------------------------------------------------------------===//
256 // LCSSA - This pass inserts phi nodes at loop boundaries to simplify other loop
259 Pass *createLCSSAPass();
260 extern char &LCSSAID;
262 //===----------------------------------------------------------------------===//
264 // GVN - This pass performs global value numbering and redundant load
265 // elimination cotemporaneously.
267 FunctionPass *createGVNPass(bool NoLoads = false);
269 //===----------------------------------------------------------------------===//
271 // MemCpyOpt - This pass performs optimizations related to eliminating memcpy
272 // calls and/or combining multiple stores into memset's.
274 FunctionPass *createMemCpyOptPass();
276 //===----------------------------------------------------------------------===//
278 // LoopDeletion - This pass performs DCE of non-infinite loops that it
279 // can prove are dead.
281 Pass *createLoopDeletionPass();
283 //===----------------------------------------------------------------------===//
285 /// createSimplifyLibCallsPass - This pass optimizes specific calls to
286 /// specific well-known (library) functions.
287 FunctionPass *createSimplifyLibCallsPass();
289 //===----------------------------------------------------------------------===//
291 /// createSimplifyHalfPowrLibCallsPass - This is an experimental pass that
292 /// optimizes specific half_pow functions.
293 FunctionPass *createSimplifyHalfPowrLibCallsPass();
295 //===----------------------------------------------------------------------===//
297 // CodeGenPrepare - This pass prepares a function for instruction selection.
299 FunctionPass *createCodeGenPreparePass(const TargetLowering *TLI = 0);
301 //===----------------------------------------------------------------------===//
303 // InstructionNamer - Give any unnamed non-void instructions "tmp" names.
305 FunctionPass *createInstructionNamerPass();
306 extern char &InstructionNamerID;
308 //===----------------------------------------------------------------------===//
310 // SSI - This pass converts instructions to Static Single Information form
313 FunctionPass *createSSIPass();
315 //===----------------------------------------------------------------------===//
317 // SSI - This pass converts every non-void instuction to Static Single
320 FunctionPass *createSSIEverythingPass();
322 //===----------------------------------------------------------------------===//
324 // GEPSplitter - Split complex GEPs into simple ones
326 FunctionPass *createGEPSplitterPass();
328 //===----------------------------------------------------------------------===//
330 // ABCD - Elimination of Array Bounds Checks on Demand
332 FunctionPass *createABCDPass();
334 //===----------------------------------------------------------------------===//
336 // Sink - Code Sinking
338 FunctionPass *createSinkingPass();
340 //===----------------------------------------------------------------------===//
342 // LowerAtomic - Lower atomic intrinsics to non-atomic form
344 Pass *createLowerAtomicPass();
346 } // End llvm namespace