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 // LoopInstSimplify - This pass simplifies instructions in a loop's body.
124 Pass *createLoopInstSimplifyPass();
126 //===----------------------------------------------------------------------===//
128 // LoopUnroll - This pass is a simple loop unrolling pass.
130 Pass *createLoopUnrollPass();
132 //===----------------------------------------------------------------------===//
134 // LoopRotate - This pass is a simple loop rotating pass.
136 Pass *createLoopRotatePass();
138 //===----------------------------------------------------------------------===//
140 // LoopIdiom - This pass recognizes and replaces idioms in loops.
142 Pass *createLoopIdiomPass();
144 //===----------------------------------------------------------------------===//
146 // PromoteMemoryToRegister - This pass is used to promote memory references to
147 // be register references. A simple example of the transformation performed by
151 // %X = alloca i32, i32 1 ret i32 42
152 // store i32 42, i32 *%X
156 FunctionPass *createPromoteMemoryToRegisterPass();
158 //===----------------------------------------------------------------------===//
160 // DemoteRegisterToMemoryPass - This pass is used to demote registers to memory
161 // references. In basically undoes the PromoteMemoryToRegister pass to make cfg
164 FunctionPass *createDemoteRegisterToMemoryPass();
165 extern char &DemoteRegisterToMemoryID;
167 //===----------------------------------------------------------------------===//
169 // Reassociate - This pass reassociates commutative expressions in an order that
170 // is designed to promote better constant propagation, GCSE, LICM, PRE...
172 // For example: 4 + (x + 5) -> x + (4 + 5)
174 FunctionPass *createReassociatePass();
176 //===----------------------------------------------------------------------===//
178 // TailDuplication - Eliminate unconditional branches through controlled code
179 // duplication, creating simpler CFG structures.
181 FunctionPass *createTailDuplicationPass();
183 //===----------------------------------------------------------------------===//
185 // JumpThreading - Thread control through mult-pred/multi-succ blocks where some
186 // preds always go to some succ.
188 FunctionPass *createJumpThreadingPass();
190 //===----------------------------------------------------------------------===//
192 // CFGSimplification - Merge basic blocks, eliminate unreachable blocks,
193 // simplify terminator instructions, etc...
195 FunctionPass *createCFGSimplificationPass();
197 //===----------------------------------------------------------------------===//
199 // BreakCriticalEdges - Break all of the critical edges in the CFG by inserting
200 // a dummy basic block. This pass may be "required" by passes that cannot deal
201 // with critical edges. For this usage, a pass must call:
203 // AU.addRequiredID(BreakCriticalEdgesID);
205 // This pass obviously invalidates the CFG, but can update forward dominator
206 // (set, immediate dominators, tree, and frontier) information.
208 FunctionPass *createBreakCriticalEdgesPass();
209 extern char &BreakCriticalEdgesID;
211 //===----------------------------------------------------------------------===//
213 // LoopSimplify - Insert Pre-header blocks into the CFG for every function in
214 // the module. This pass updates dominator information, loop information, and
215 // does not add critical edges to the CFG.
217 // AU.addRequiredID(LoopSimplifyID);
219 Pass *createLoopSimplifyPass();
220 extern char &LoopSimplifyID;
222 //===----------------------------------------------------------------------===//
224 // TailCallElimination - This pass eliminates call instructions to the current
225 // function which occur immediately before return instructions.
227 FunctionPass *createTailCallEliminationPass();
229 //===----------------------------------------------------------------------===//
231 // LowerSwitch - This pass converts SwitchInst instructions into a sequence of
232 // chained binary branch instructions.
234 FunctionPass *createLowerSwitchPass();
235 extern char &LowerSwitchID;
237 //===----------------------------------------------------------------------===//
239 // LowerInvoke - This pass converts invoke and unwind instructions to use sjlj
240 // exception handling mechanisms. Note that after this pass runs the CFG is not
241 // entirely accurate (exceptional control flow edges are not correct anymore) so
242 // only very simple things should be done after the lowerinvoke pass has run
243 // (like generation of native code). This should *NOT* be used as a general
244 // purpose "my LLVM-to-LLVM pass doesn't support the invoke instruction yet"
247 FunctionPass *createLowerInvokePass(const TargetLowering *TLI = 0);
248 FunctionPass *createLowerInvokePass(const TargetLowering *TLI,
249 bool useExpensiveEHSupport);
250 extern char &LowerInvokePassID;
252 //===----------------------------------------------------------------------===//
254 // BlockPlacement - This pass reorders basic blocks in order to increase the
255 // number of fall-through conditional branches.
257 FunctionPass *createBlockPlacementPass();
259 //===----------------------------------------------------------------------===//
261 // LCSSA - This pass inserts phi nodes at loop boundaries to simplify other loop
264 Pass *createLCSSAPass();
265 extern char &LCSSAID;
267 //===----------------------------------------------------------------------===//
269 // EarlyCSE - This pass performs a simple and fast CSE pass over the dominator
272 FunctionPass *createEarlyCSEPass();
274 //===----------------------------------------------------------------------===//
276 // GVN - This pass performs global value numbering and redundant load
277 // elimination cotemporaneously.
279 FunctionPass *createGVNPass(bool NoLoads = false);
281 //===----------------------------------------------------------------------===//
283 // MemCpyOpt - This pass performs optimizations related to eliminating memcpy
284 // calls and/or combining multiple stores into memset's.
286 FunctionPass *createMemCpyOptPass();
288 //===----------------------------------------------------------------------===//
290 // LoopDeletion - This pass performs DCE of non-infinite loops that it
291 // can prove are dead.
293 Pass *createLoopDeletionPass();
295 //===----------------------------------------------------------------------===//
297 /// createSimplifyLibCallsPass - This pass optimizes specific calls to
298 /// specific well-known (library) functions.
299 FunctionPass *createSimplifyLibCallsPass();
301 //===----------------------------------------------------------------------===//
303 /// createSimplifyHalfPowrLibCallsPass - This is an experimental pass that
304 /// optimizes specific half_pow functions.
305 FunctionPass *createSimplifyHalfPowrLibCallsPass();
307 //===----------------------------------------------------------------------===//
309 // CodeGenPrepare - This pass prepares a function for instruction selection.
311 FunctionPass *createCodeGenPreparePass(const TargetLowering *TLI = 0);
313 //===----------------------------------------------------------------------===//
315 // InstructionNamer - Give any unnamed non-void instructions "tmp" names.
317 FunctionPass *createInstructionNamerPass();
318 extern char &InstructionNamerID;
320 //===----------------------------------------------------------------------===//
322 // GEPSplitter - Split complex GEPs into simple ones
324 FunctionPass *createGEPSplitterPass();
326 //===----------------------------------------------------------------------===//
328 // Sink - Code Sinking
330 FunctionPass *createSinkingPass();
332 //===----------------------------------------------------------------------===//
334 // LowerAtomic - Lower atomic intrinsics to non-atomic form
336 Pass *createLowerAtomicPass();
338 //===----------------------------------------------------------------------===//
340 // ValuePropagation - Propagate CFG-derived value information
342 Pass *createCorrelatedValuePropagationPass();
344 //===----------------------------------------------------------------------===//
346 // InstructionSimplifier - Remove redundant instructions.
348 FunctionPass *createInstructionSimplifierPass();
349 extern char &InstructionSimplifierID;
351 } // End llvm namespace