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