Scalar.h revision 198396
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
18namespace llvm {
19
20class FunctionPass;
21class Pass;
22class GetElementPtrInst;
23class PassInfo;
24class TerminatorInst;
25class TargetLowering;
26
27//===----------------------------------------------------------------------===//
28//
29// ConstantPropagation - A worklist driven constant propagation pass
30//
31FunctionPass *createConstantPropagationPass();
32
33//===----------------------------------------------------------------------===//
34//
35// SCCP - Sparse conditional constant propagation.
36//
37FunctionPass *createSCCPPass();
38
39//===----------------------------------------------------------------------===//
40//
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.
44//
45Pass *createDeadInstEliminationPass();
46
47//===----------------------------------------------------------------------===//
48//
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
52// computations.
53//
54FunctionPass *createDeadCodeEliminationPass();
55
56//===----------------------------------------------------------------------===//
57//
58// DeadStoreElimination - This pass deletes stores that are post-dominated by
59// must-aliased stores and are not loaded used between the stores.
60//
61FunctionPass *createDeadStoreEliminationPass();
62
63//===----------------------------------------------------------------------===//
64//
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.
68//
69FunctionPass *createAggressiveDCEPass();
70
71//===----------------------------------------------------------------------===//
72//
73// ScalarReplAggregates - Break up alloca's of aggregates into multiple allocas
74// if possible.
75//
76FunctionPass *createScalarReplAggregatesPass(signed Threshold = -1);
77
78//===----------------------------------------------------------------------===//
79//
80// InductionVariableSimplify - Transform induction variables in a program to all
81// use a single canonical induction variable per loop.
82//
83Pass *createIndVarSimplifyPass();
84
85//===----------------------------------------------------------------------===//
86//
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.
90//
91// This pass combines things like:
92//    %Y = add int 1, %X
93//    %Z = add int 1, %Y
94// into:
95//    %Z = add int 2, %X
96//
97FunctionPass *createInstructionCombiningPass();
98
99//===----------------------------------------------------------------------===//
100//
101// LICM - This pass is a loop invariant code motion and memory promotion pass.
102//
103Pass *createLICMPass();
104
105//===----------------------------------------------------------------------===//
106//
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.
111//
112Pass *createLoopStrengthReducePass(const TargetLowering *TLI = 0);
113
114//===----------------------------------------------------------------------===//
115//
116// LoopUnswitch - This pass is a simple loop unswitching pass.
117//
118Pass *createLoopUnswitchPass(bool OptimizeForSize = false);
119
120//===----------------------------------------------------------------------===//
121//
122// LoopUnroll - This pass is a simple loop unrolling pass.
123//
124Pass *createLoopUnrollPass();
125
126//===----------------------------------------------------------------------===//
127//
128// LoopRotate - This pass is a simple loop rotating pass.
129//
130Pass *createLoopRotatePass();
131
132//===----------------------------------------------------------------------===//
133//
134// LoopIndexSplit - This pass divides loop's iteration range by spliting loop
135// such that each individual loop is executed efficiently.
136//
137Pass *createLoopIndexSplitPass();
138
139//===----------------------------------------------------------------------===//
140//
141// PromoteMemoryToRegister - This pass is used to promote memory references to
142// be register references. A simple example of the transformation performed by
143// this pass is:
144//
145//        FROM CODE                           TO CODE
146//   %X = alloca i32, i32 1                 ret i32 42
147//   store i32 42, i32 *%X
148//   %Y = load i32* %X
149//   ret i32 %Y
150//
151FunctionPass *createPromoteMemoryToRegisterPass();
152extern const PassInfo *const PromoteMemoryToRegisterID;
153
154//===----------------------------------------------------------------------===//
155//
156// DemoteRegisterToMemoryPass - This pass is used to demote registers to memory
157// references. In basically undoes the PromoteMemoryToRegister pass to make cfg
158// hacking easier.
159//
160FunctionPass *createDemoteRegisterToMemoryPass();
161extern const PassInfo *const DemoteRegisterToMemoryID;
162
163//===----------------------------------------------------------------------===//
164//
165// Reassociate - This pass reassociates commutative expressions in an order that
166// is designed to promote better constant propagation, GCSE, LICM, PRE...
167//
168// For example:  4 + (x + 5)  ->  x + (4 + 5)
169//
170FunctionPass *createReassociatePass();
171
172//===----------------------------------------------------------------------===//
173//
174// CondPropagationPass - This pass propagates information about conditional
175// expressions through the program, allowing it to eliminate conditional
176// branches in some cases.
177//
178FunctionPass *createCondPropagationPass();
179
180//===----------------------------------------------------------------------===//
181//
182// TailDuplication - Eliminate unconditional branches through controlled code
183// duplication, creating simpler CFG structures.
184//
185FunctionPass *createTailDuplicationPass();
186
187//===----------------------------------------------------------------------===//
188//
189// JumpThreading - Thread control through mult-pred/multi-succ blocks where some
190// preds always go to some succ.
191//
192FunctionPass *createJumpThreadingPass();
193
194//===----------------------------------------------------------------------===//
195//
196// CFGSimplification - Merge basic blocks, eliminate unreachable blocks,
197// simplify terminator instructions, etc...
198//
199FunctionPass *createCFGSimplificationPass();
200
201//===----------------------------------------------------------------------===//
202//
203// BreakCriticalEdges - Break all of the critical edges in the CFG by inserting
204// a dummy basic block. This pass may be "required" by passes that cannot deal
205// with critical edges. For this usage, a pass must call:
206//
207//   AU.addRequiredID(BreakCriticalEdgesID);
208//
209// This pass obviously invalidates the CFG, but can update forward dominator
210// (set, immediate dominators, tree, and frontier) information.
211//
212FunctionPass *createBreakCriticalEdgesPass();
213extern const PassInfo *const BreakCriticalEdgesID;
214
215//===----------------------------------------------------------------------===//
216//
217// LoopSimplify - Insert Pre-header blocks into the CFG for every function in
218// the module.  This pass updates dominator information, loop information, and
219// does not add critical edges to the CFG.
220//
221//   AU.addRequiredID(LoopSimplifyID);
222//
223Pass *createLoopSimplifyPass();
224extern const PassInfo *const LoopSimplifyID;
225
226//===----------------------------------------------------------------------===//
227//
228// LowerAllocations - Turn free instructions into @free calls.
229//
230//   AU.addRequiredID(LowerAllocationsID);
231//
232Pass *createLowerAllocationsPass();
233extern const PassInfo *const LowerAllocationsID;
234
235//===----------------------------------------------------------------------===//
236//
237// TailCallElimination - This pass eliminates call instructions to the current
238// function which occur immediately before return instructions.
239//
240FunctionPass *createTailCallEliminationPass();
241
242//===----------------------------------------------------------------------===//
243//
244// LowerSwitch - This pass converts SwitchInst instructions into a sequence of
245// chained binary branch instructions.
246//
247FunctionPass *createLowerSwitchPass();
248extern const PassInfo *const LowerSwitchID;
249
250//===----------------------------------------------------------------------===//
251//
252// LowerInvoke - This pass converts invoke and unwind instructions to use sjlj
253// exception handling mechanisms.  Note that after this pass runs the CFG is not
254// entirely accurate (exceptional control flow edges are not correct anymore) so
255// only very simple things should be done after the lowerinvoke pass has run
256// (like generation of native code).  This should *NOT* be used as a general
257// purpose "my LLVM-to-LLVM pass doesn't support the invoke instruction yet"
258// lowering pass.
259//
260FunctionPass *createLowerInvokePass(const TargetLowering *TLI = 0);
261extern const PassInfo *const LowerInvokePassID;
262
263//===----------------------------------------------------------------------===//
264//
265// BlockPlacement - This pass reorders basic blocks in order to increase the
266// number of fall-through conditional branches.
267//
268FunctionPass *createBlockPlacementPass();
269
270//===----------------------------------------------------------------------===//
271//
272// LCSSA - This pass inserts phi nodes at loop boundaries to simplify other loop
273// optimizations.
274//
275Pass *createLCSSAPass();
276extern const PassInfo *const LCSSAID;
277
278//===----------------------------------------------------------------------===//
279//
280// GVN - This pass performs global value numbering and redundant load
281// elimination cotemporaneously.
282//
283FunctionPass *createGVNPass();
284
285//===----------------------------------------------------------------------===//
286//
287// MemCpyOpt - This pass performs optimizations related to eliminating memcpy
288// calls and/or combining multiple stores into memset's.
289//
290FunctionPass *createMemCpyOptPass();
291
292//===----------------------------------------------------------------------===//
293//
294// LoopDeletion - This pass performs DCE of non-infinite loops that it
295// can prove are dead.
296//
297Pass *createLoopDeletionPass();
298
299//===----------------------------------------------------------------------===//
300//
301/// createSimplifyLibCallsPass - This pass optimizes specific calls to
302/// specific well-known (library) functions.
303FunctionPass *createSimplifyLibCallsPass();
304
305//===----------------------------------------------------------------------===//
306//
307/// createSimplifyHalfPowrLibCallsPass - This is an experimental pass that
308/// optimizes specific half_pow functions.
309FunctionPass *createSimplifyHalfPowrLibCallsPass();
310
311//===----------------------------------------------------------------------===//
312//
313// CodeGenPrepare - This pass prepares a function for instruction selection.
314//
315FunctionPass *createCodeGenPreparePass(const TargetLowering *TLI = 0);
316
317//===----------------------------------------------------------------------===//
318//
319// CodeGenLICM - This pass performs late LICM; hoisting constants out of loops.
320//
321Pass *createCodeGenLICMPass();
322
323//===----------------------------------------------------------------------===//
324//
325// InstructionNamer - Give any unnamed non-void instructions "tmp" names.
326//
327FunctionPass *createInstructionNamerPass();
328extern const PassInfo *const InstructionNamerID;
329
330//===----------------------------------------------------------------------===//
331//
332// SSI - This pass converts instructions to Static Single Information form
333// on demand.
334//
335FunctionPass *createSSIPass();
336
337//===----------------------------------------------------------------------===//
338//
339// SSI - This pass converts every non-void instuction to Static Single
340// Information form.
341//
342FunctionPass *createSSIEverythingPass();
343
344} // End llvm namespace
345
346#endif
347