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                                             bool UseDomTree = true,
78                                             signed StructMemberThreshold = -1,
79                                             signed ArrayElementThreshold = -1,
80                                             signed ScalarLoadThreshold = -1);
81
82//===----------------------------------------------------------------------===//
83//
84// InductionVariableSimplify - Transform induction variables in a program to all
85// use a single canonical induction variable per loop.
86//
87Pass *createIndVarSimplifyPass();
88
89//===----------------------------------------------------------------------===//
90//
91// InstructionCombining - Combine instructions to form fewer, simple
92// instructions. This pass does not modify the CFG, and has a tendency to make
93// instructions dead, so a subsequent DCE pass is useful.
94//
95// This pass combines things like:
96//    %Y = add int 1, %X
97//    %Z = add int 1, %Y
98// into:
99//    %Z = add int 2, %X
100//
101FunctionPass *createInstructionCombiningPass();
102
103//===----------------------------------------------------------------------===//
104//
105// LICM - This pass is a loop invariant code motion and memory promotion pass.
106//
107Pass *createLICMPass();
108
109//===----------------------------------------------------------------------===//
110//
111// LoopStrengthReduce - This pass is strength reduces GEP instructions that use
112// a loop's canonical induction variable as one of their indices.  It takes an
113// optional parameter used to consult the target machine whether certain
114// transformations are profitable.
115//
116Pass *createLoopStrengthReducePass(const TargetLowering *TLI = 0);
117
118Pass *createGlobalMergePass(const TargetLowering *TLI = 0);
119
120//===----------------------------------------------------------------------===//
121//
122// LoopUnswitch - This pass is a simple loop unswitching pass.
123//
124Pass *createLoopUnswitchPass(bool OptimizeForSize = false);
125
126//===----------------------------------------------------------------------===//
127//
128// LoopInstSimplify - This pass simplifies instructions in a loop's body.
129//
130Pass *createLoopInstSimplifyPass();
131
132//===----------------------------------------------------------------------===//
133//
134// LoopUnroll - This pass is a simple loop unrolling pass.
135//
136Pass *createLoopUnrollPass(int Threshold = -1, int Count = -1, int AllowPartial = -1);
137
138//===----------------------------------------------------------------------===//
139//
140// LoopRotate - This pass is a simple loop rotating pass.
141//
142Pass *createLoopRotatePass();
143
144//===----------------------------------------------------------------------===//
145//
146// LoopIdiom - This pass recognizes and replaces idioms in loops.
147//
148Pass *createLoopIdiomPass();
149
150//===----------------------------------------------------------------------===//
151//
152// PromoteMemoryToRegister - This pass is used to promote memory references to
153// be register references. A simple example of the transformation performed by
154// this pass is:
155//
156//        FROM CODE                           TO CODE
157//   %X = alloca i32, i32 1                 ret i32 42
158//   store i32 42, i32 *%X
159//   %Y = load i32* %X
160//   ret i32 %Y
161//
162FunctionPass *createPromoteMemoryToRegisterPass();
163
164//===----------------------------------------------------------------------===//
165//
166// DemoteRegisterToMemoryPass - This pass is used to demote registers to memory
167// references. In basically undoes the PromoteMemoryToRegister pass to make cfg
168// hacking easier.
169//
170FunctionPass *createDemoteRegisterToMemoryPass();
171extern char &DemoteRegisterToMemoryID;
172
173//===----------------------------------------------------------------------===//
174//
175// Reassociate - This pass reassociates commutative expressions in an order that
176// is designed to promote better constant propagation, GCSE, LICM, PRE...
177//
178// For example:  4 + (x + 5)  ->  x + (4 + 5)
179//
180FunctionPass *createReassociatePass();
181
182//===----------------------------------------------------------------------===//
183//
184// JumpThreading - Thread control through mult-pred/multi-succ blocks where some
185// preds always go to some succ.
186//
187FunctionPass *createJumpThreadingPass();
188
189//===----------------------------------------------------------------------===//
190//
191// CFGSimplification - Merge basic blocks, eliminate unreachable blocks,
192// simplify terminator instructions, etc...
193//
194FunctionPass *createCFGSimplificationPass();
195
196//===----------------------------------------------------------------------===//
197//
198// BreakCriticalEdges - Break all of the critical edges in the CFG by inserting
199// a dummy basic block. This pass may be "required" by passes that cannot deal
200// with critical edges. For this usage, a pass must call:
201//
202//   AU.addRequiredID(BreakCriticalEdgesID);
203//
204// This pass obviously invalidates the CFG, but can update forward dominator
205// (set, immediate dominators, tree, and frontier) information.
206//
207FunctionPass *createBreakCriticalEdgesPass();
208extern char &BreakCriticalEdgesID;
209
210//===----------------------------------------------------------------------===//
211//
212// LoopSimplify - Insert Pre-header blocks into the CFG for every function in
213// the module.  This pass updates dominator information, loop information, and
214// does not add critical edges to the CFG.
215//
216//   AU.addRequiredID(LoopSimplifyID);
217//
218Pass *createLoopSimplifyPass();
219extern char &LoopSimplifyID;
220
221//===----------------------------------------------------------------------===//
222//
223// TailCallElimination - This pass eliminates call instructions to the current
224// function which occur immediately before return instructions.
225//
226FunctionPass *createTailCallEliminationPass();
227
228//===----------------------------------------------------------------------===//
229//
230// LowerSwitch - This pass converts SwitchInst instructions into a sequence of
231// chained binary branch instructions.
232//
233FunctionPass *createLowerSwitchPass();
234extern char &LowerSwitchID;
235
236//===----------------------------------------------------------------------===//
237//
238// LowerInvoke - This pass converts invoke and unwind instructions to use sjlj
239// exception handling mechanisms.  Note that after this pass runs the CFG is not
240// entirely accurate (exceptional control flow edges are not correct anymore) so
241// only very simple things should be done after the lowerinvoke pass has run
242// (like generation of native code).  This should *NOT* be used as a general
243// purpose "my LLVM-to-LLVM pass doesn't support the invoke instruction yet"
244// lowering pass.
245//
246FunctionPass *createLowerInvokePass(const TargetLowering *TLI = 0);
247FunctionPass *createLowerInvokePass(const TargetLowering *TLI,
248                                    bool useExpensiveEHSupport);
249extern char &LowerInvokePassID;
250
251//===----------------------------------------------------------------------===//
252//
253// BlockPlacement - This pass reorders basic blocks in order to increase the
254// number of fall-through conditional branches.
255//
256FunctionPass *createBlockPlacementPass();
257
258//===----------------------------------------------------------------------===//
259//
260// LCSSA - This pass inserts phi nodes at loop boundaries to simplify other loop
261// optimizations.
262//
263Pass *createLCSSAPass();
264extern char &LCSSAID;
265
266//===----------------------------------------------------------------------===//
267//
268// EarlyCSE - This pass performs a simple and fast CSE pass over the dominator
269// tree.
270//
271FunctionPass *createEarlyCSEPass();
272
273//===----------------------------------------------------------------------===//
274//
275// GVN - This pass performs global value numbering and redundant load
276// elimination cotemporaneously.
277//
278FunctionPass *createGVNPass(bool NoLoads = false);
279
280//===----------------------------------------------------------------------===//
281//
282// MemCpyOpt - This pass performs optimizations related to eliminating memcpy
283// calls and/or combining multiple stores into memset's.
284//
285FunctionPass *createMemCpyOptPass();
286
287//===----------------------------------------------------------------------===//
288//
289// LoopDeletion - This pass performs DCE of non-infinite loops that it
290// can prove are dead.
291//
292Pass *createLoopDeletionPass();
293
294//===----------------------------------------------------------------------===//
295//
296/// createSimplifyLibCallsPass - This pass optimizes specific calls to
297/// specific well-known (library) functions.
298FunctionPass *createSimplifyLibCallsPass();
299
300//===----------------------------------------------------------------------===//
301//
302// CodeGenPrepare - This pass prepares a function for instruction selection.
303//
304FunctionPass *createCodeGenPreparePass(const TargetLowering *TLI = 0);
305
306//===----------------------------------------------------------------------===//
307//
308// InstructionNamer - Give any unnamed non-void instructions "tmp" names.
309//
310FunctionPass *createInstructionNamerPass();
311extern char &InstructionNamerID;
312
313//===----------------------------------------------------------------------===//
314//
315// Sink - Code Sinking
316//
317FunctionPass *createSinkingPass();
318
319//===----------------------------------------------------------------------===//
320//
321// LowerAtomic - Lower atomic intrinsics to non-atomic form
322//
323Pass *createLowerAtomicPass();
324
325//===----------------------------------------------------------------------===//
326//
327// ValuePropagation - Propagate CFG-derived value information
328//
329Pass *createCorrelatedValuePropagationPass();
330
331//===----------------------------------------------------------------------===//
332//
333// ObjCARCAPElim - ObjC ARC autorelease pool elimination.
334//
335Pass *createObjCARCAPElimPass();
336
337//===----------------------------------------------------------------------===//
338//
339// ObjCARCExpand - ObjC ARC preliminary simplifications.
340//
341Pass *createObjCARCExpandPass();
342
343//===----------------------------------------------------------------------===//
344//
345// ObjCARCContract - Late ObjC ARC cleanups.
346//
347Pass *createObjCARCContractPass();
348
349//===----------------------------------------------------------------------===//
350//
351// ObjCARCOpt - ObjC ARC optimization.
352//
353Pass *createObjCARCOptPass();
354
355//===----------------------------------------------------------------------===//
356//
357// InstructionSimplifier - Remove redundant instructions.
358//
359FunctionPass *createInstructionSimplifierPass();
360extern char &InstructionSimplifierID;
361
362
363//===----------------------------------------------------------------------===//
364//
365// LowerExpectIntriniscs - Removes llvm.expect intrinsics and creates
366// "block_weights" metadata.
367FunctionPass *createLowerExpectIntrinsicPass();
368
369
370} // End llvm namespace
371
372#endif
373