]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/include/llvm/Transforms/Scalar.h
MFV: r313101
[FreeBSD/FreeBSD.git] / contrib / llvm / include / llvm / Transforms / Scalar.h
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
18 #include <functional>
19
20 namespace llvm {
21
22 class BasicBlockPass;
23 class Function;
24 class FunctionPass;
25 class ModulePass;
26 class Pass;
27 class GetElementPtrInst;
28 class PassInfo;
29 class TerminatorInst;
30 class TargetLowering;
31 class TargetMachine;
32
33 //===----------------------------------------------------------------------===//
34 //
35 // ConstantPropagation - A worklist driven constant propagation pass
36 //
37 FunctionPass *createConstantPropagationPass();
38
39 //===----------------------------------------------------------------------===//
40 //
41 // AlignmentFromAssumptions - Use assume intrinsics to set load/store
42 // alignments.
43 //
44 FunctionPass *createAlignmentFromAssumptionsPass();
45
46 //===----------------------------------------------------------------------===//
47 //
48 // SCCP - Sparse conditional constant propagation.
49 //
50 FunctionPass *createSCCPPass();
51
52 //===----------------------------------------------------------------------===//
53 //
54 // DeadInstElimination - This pass quickly removes trivially dead instructions
55 // without modifying the CFG of the function.  It is a BasicBlockPass, so it
56 // runs efficiently when queued next to other BasicBlockPass's.
57 //
58 Pass *createDeadInstEliminationPass();
59
60 //===----------------------------------------------------------------------===//
61 //
62 // DeadCodeElimination - This pass is more powerful than DeadInstElimination,
63 // because it is worklist driven that can potentially revisit instructions when
64 // their other instructions become dead, to eliminate chains of dead
65 // computations.
66 //
67 FunctionPass *createDeadCodeEliminationPass();
68
69 //===----------------------------------------------------------------------===//
70 //
71 // DeadStoreElimination - This pass deletes stores that are post-dominated by
72 // must-aliased stores and are not loaded used between the stores.
73 //
74 FunctionPass *createDeadStoreEliminationPass();
75
76 //===----------------------------------------------------------------------===//
77 //
78 // AggressiveDCE - This pass uses the SSA based Aggressive DCE algorithm.  This
79 // algorithm assumes instructions are dead until proven otherwise, which makes
80 // it more successful are removing non-obviously dead instructions.
81 //
82 FunctionPass *createAggressiveDCEPass();
83
84
85 //===----------------------------------------------------------------------===//
86 //
87 // GuardWidening - An optimization over the @llvm.experimental.guard intrinsic
88 // that (optimistically) combines multiple guards into one to have fewer checks
89 // at runtime.
90 //
91 FunctionPass *createGuardWideningPass();
92
93
94 //===----------------------------------------------------------------------===//
95 //
96 // BitTrackingDCE - This pass uses a bit-tracking DCE algorithm in order to
97 // remove computations of dead bits.
98 //
99 FunctionPass *createBitTrackingDCEPass();
100
101 //===----------------------------------------------------------------------===//
102 //
103 // SROA - Replace aggregates or pieces of aggregates with scalar SSA values.
104 //
105 FunctionPass *createSROAPass();
106
107 //===----------------------------------------------------------------------===//
108 //
109 // InductiveRangeCheckElimination - Transform loops to elide range checks on
110 // linear functions of the induction variable.
111 //
112 Pass *createInductiveRangeCheckEliminationPass();
113
114 //===----------------------------------------------------------------------===//
115 //
116 // InductionVariableSimplify - Transform induction variables in a program to all
117 // use a single canonical induction variable per loop.
118 //
119 Pass *createIndVarSimplifyPass();
120
121 //===----------------------------------------------------------------------===//
122 //
123 // InstructionCombining - Combine instructions to form fewer, simple
124 // instructions. This pass does not modify the CFG, and has a tendency to make
125 // instructions dead, so a subsequent DCE pass is useful.
126 //
127 // This pass combines things like:
128 //    %Y = add int 1, %X
129 //    %Z = add int 1, %Y
130 // into:
131 //    %Z = add int 2, %X
132 //
133 FunctionPass *createInstructionCombiningPass(bool ExpensiveCombines = true);
134
135 //===----------------------------------------------------------------------===//
136 //
137 // LICM - This pass is a loop invariant code motion and memory promotion pass.
138 //
139 Pass *createLICMPass();
140
141 //===----------------------------------------------------------------------===//
142 //
143 // LoopInterchange - This pass interchanges loops to provide a more
144 // cache-friendly memory access patterns.
145 //
146 Pass *createLoopInterchangePass();
147
148 //===----------------------------------------------------------------------===//
149 //
150 // LoopStrengthReduce - This pass is strength reduces GEP instructions that use
151 // a loop's canonical induction variable as one of their indices.
152 //
153 Pass *createLoopStrengthReducePass();
154
155 //===----------------------------------------------------------------------===//
156 //
157 // LoopUnswitch - This pass is a simple loop unswitching pass.
158 //
159 Pass *createLoopUnswitchPass(bool OptimizeForSize = false);
160
161 //===----------------------------------------------------------------------===//
162 //
163 // LoopInstSimplify - This pass simplifies instructions in a loop's body.
164 //
165 Pass *createLoopInstSimplifyPass();
166
167 //===----------------------------------------------------------------------===//
168 //
169 // LoopUnroll - This pass is a simple loop unrolling pass.
170 //
171 Pass *createLoopUnrollPass(int Threshold = -1, int Count = -1,
172                            int AllowPartial = -1, int Runtime = -1);
173 // Create an unrolling pass for full unrolling only.
174 Pass *createSimpleLoopUnrollPass();
175
176 //===----------------------------------------------------------------------===//
177 //
178 // LoopReroll - This pass is a simple loop rerolling pass.
179 //
180 Pass *createLoopRerollPass();
181
182 //===----------------------------------------------------------------------===//
183 //
184 // LoopRotate - This pass is a simple loop rotating pass.
185 //
186 Pass *createLoopRotatePass(int MaxHeaderSize = -1);
187
188 //===----------------------------------------------------------------------===//
189 //
190 // LoopIdiom - This pass recognizes and replaces idioms in loops.
191 //
192 Pass *createLoopIdiomPass();
193
194 //===----------------------------------------------------------------------===//
195 //
196 // LoopVersioningLICM - This pass is a loop versioning pass for LICM.
197 //
198 Pass *createLoopVersioningLICMPass();
199
200 //===----------------------------------------------------------------------===//
201 //
202 // PromoteMemoryToRegister - This pass is used to promote memory references to
203 // be register references. A simple example of the transformation performed by
204 // this pass is:
205 //
206 //        FROM CODE                           TO CODE
207 //   %X = alloca i32, i32 1                 ret i32 42
208 //   store i32 42, i32 *%X
209 //   %Y = load i32* %X
210 //   ret i32 %Y
211 //
212 FunctionPass *createPromoteMemoryToRegisterPass();
213
214 //===----------------------------------------------------------------------===//
215 //
216 // DemoteRegisterToMemoryPass - This pass is used to demote registers to memory
217 // references. In basically undoes the PromoteMemoryToRegister pass to make cfg
218 // hacking easier.
219 //
220 FunctionPass *createDemoteRegisterToMemoryPass();
221 extern char &DemoteRegisterToMemoryID;
222
223 //===----------------------------------------------------------------------===//
224 //
225 // Reassociate - This pass reassociates commutative expressions in an order that
226 // is designed to promote better constant propagation, GCSE, LICM, PRE...
227 //
228 // For example:  4 + (x + 5)  ->  x + (4 + 5)
229 //
230 FunctionPass *createReassociatePass();
231
232 //===----------------------------------------------------------------------===//
233 //
234 // JumpThreading - Thread control through mult-pred/multi-succ blocks where some
235 // preds always go to some succ. Thresholds other than minus one override the
236 // internal BB duplication default threshold.
237 //
238 FunctionPass *createJumpThreadingPass(int Threshold = -1);
239
240 //===----------------------------------------------------------------------===//
241 //
242 // CFGSimplification - Merge basic blocks, eliminate unreachable blocks,
243 // simplify terminator instructions, etc...
244 //
245 FunctionPass *createCFGSimplificationPass(
246     int Threshold = -1, std::function<bool(const Function &)> Ftor = nullptr);
247
248 //===----------------------------------------------------------------------===//
249 //
250 // FlattenCFG - flatten CFG, reduce number of conditional branches by using
251 // parallel-and and parallel-or mode, etc...
252 //
253 FunctionPass *createFlattenCFGPass();
254
255 //===----------------------------------------------------------------------===//
256 //
257 // CFG Structurization - Remove irreducible control flow
258 //
259 ///
260 /// When \p SkipUniformRegions is true the structizer will not structurize
261 /// regions that only contain uniform branches.
262 Pass *createStructurizeCFGPass(bool SkipUniformRegions = false);
263
264 //===----------------------------------------------------------------------===//
265 //
266 // BreakCriticalEdges - Break all of the critical edges in the CFG by inserting
267 // a dummy basic block. This pass may be "required" by passes that cannot deal
268 // with critical edges. For this usage, a pass must call:
269 //
270 //   AU.addRequiredID(BreakCriticalEdgesID);
271 //
272 // This pass obviously invalidates the CFG, but can update forward dominator
273 // (set, immediate dominators, tree, and frontier) information.
274 //
275 FunctionPass *createBreakCriticalEdgesPass();
276 extern char &BreakCriticalEdgesID;
277
278 //===----------------------------------------------------------------------===//
279 //
280 // LoopSimplify - Insert Pre-header blocks into the CFG for every function in
281 // the module.  This pass updates dominator information, loop information, and
282 // does not add critical edges to the CFG.
283 //
284 //   AU.addRequiredID(LoopSimplifyID);
285 //
286 Pass *createLoopSimplifyPass();
287 extern char &LoopSimplifyID;
288
289 //===----------------------------------------------------------------------===//
290 //
291 // TailCallElimination - This pass eliminates call instructions to the current
292 // function which occur immediately before return instructions.
293 //
294 FunctionPass *createTailCallEliminationPass();
295
296 //===----------------------------------------------------------------------===//
297 //
298 // LowerSwitch - This pass converts SwitchInst instructions into a sequence of
299 // chained binary branch instructions.
300 //
301 FunctionPass *createLowerSwitchPass();
302 extern char &LowerSwitchID;
303
304 //===----------------------------------------------------------------------===//
305 //
306 // LowerInvoke - This pass removes invoke instructions, converting them to call
307 // instructions.
308 //
309 FunctionPass *createLowerInvokePass();
310 extern char &LowerInvokePassID;
311
312 //===----------------------------------------------------------------------===//
313 //
314 // LCSSA - This pass inserts phi nodes at loop boundaries to simplify other loop
315 // optimizations.
316 //
317 Pass *createLCSSAPass();
318 extern char &LCSSAID;
319
320 //===----------------------------------------------------------------------===//
321 //
322 // EarlyCSE - This pass performs a simple and fast CSE pass over the dominator
323 // tree.
324 //
325 FunctionPass *createEarlyCSEPass();
326
327 //===----------------------------------------------------------------------===//
328 //
329 // GVNHoist - This pass performs a simple and fast GVN pass over the dominator
330 // tree to hoist common expressions from sibling branches.
331 //
332 FunctionPass *createGVNHoistPass();
333
334 //===----------------------------------------------------------------------===//
335 //
336 // MergedLoadStoreMotion - This pass merges loads and stores in diamonds. Loads
337 // are hoisted into the header, while stores sink into the footer.
338 //
339 FunctionPass *createMergedLoadStoreMotionPass();
340
341 //===----------------------------------------------------------------------===//
342 //
343 // MemCpyOpt - This pass performs optimizations related to eliminating memcpy
344 // calls and/or combining multiple stores into memset's.
345 //
346 FunctionPass *createMemCpyOptPass();
347
348 //===----------------------------------------------------------------------===//
349 //
350 // LoopDeletion - This pass performs DCE of non-infinite loops that it
351 // can prove are dead.
352 //
353 Pass *createLoopDeletionPass();
354
355 //===----------------------------------------------------------------------===//
356 //
357 // ConstantHoisting - This pass prepares a function for expensive constants.
358 //
359 FunctionPass *createConstantHoistingPass();
360
361 //===----------------------------------------------------------------------===//
362 //
363 // InstructionNamer - Give any unnamed non-void instructions "tmp" names.
364 //
365 FunctionPass *createInstructionNamerPass();
366 extern char &InstructionNamerID;
367
368 //===----------------------------------------------------------------------===//
369 //
370 // Sink - Code Sinking
371 //
372 FunctionPass *createSinkingPass();
373
374 //===----------------------------------------------------------------------===//
375 //
376 // LowerAtomic - Lower atomic intrinsics to non-atomic form
377 //
378 Pass *createLowerAtomicPass();
379
380 //===----------------------------------------------------------------------===//
381 //
382 // LowerGuardIntrinsic - Lower guard intrinsics to normal control flow.
383 //
384 Pass *createLowerGuardIntrinsicPass();
385
386 //===----------------------------------------------------------------------===//
387 //
388 // ValuePropagation - Propagate CFG-derived value information
389 //
390 Pass *createCorrelatedValuePropagationPass();
391
392 //===----------------------------------------------------------------------===//
393 //
394 // InstructionSimplifier - Remove redundant instructions.
395 //
396 FunctionPass *createInstructionSimplifierPass();
397 extern char &InstructionSimplifierID;
398
399 //===----------------------------------------------------------------------===//
400 //
401 // LowerExpectIntrinsics - Removes llvm.expect intrinsics and creates
402 // "block_weights" metadata.
403 FunctionPass *createLowerExpectIntrinsicPass();
404
405 //===----------------------------------------------------------------------===//
406 //
407 // PartiallyInlineLibCalls - Tries to inline the fast path of library
408 // calls such as sqrt.
409 //
410 FunctionPass *createPartiallyInlineLibCallsPass();
411
412 //===----------------------------------------------------------------------===//
413 //
414 // ScalarizerPass - Converts vector operations into scalar operations
415 //
416 FunctionPass *createScalarizerPass();
417
418 //===----------------------------------------------------------------------===//
419 //
420 // AddDiscriminators - Add DWARF path discriminators to the IR.
421 FunctionPass *createAddDiscriminatorsPass();
422
423 //===----------------------------------------------------------------------===//
424 //
425 // SeparateConstOffsetFromGEP - Split GEPs for better CSE
426 //
427 FunctionPass *
428 createSeparateConstOffsetFromGEPPass(const TargetMachine *TM = nullptr,
429                                      bool LowerGEP = false);
430
431 //===----------------------------------------------------------------------===//
432 //
433 // SpeculativeExecution - Aggressively hoist instructions to enable
434 // speculative execution on targets where branches are expensive.
435 //
436 FunctionPass *createSpeculativeExecutionPass();
437
438 // Same as createSpeculativeExecutionPass, but does nothing unless
439 // TargetTransformInfo::hasBranchDivergence() is true.
440 FunctionPass *createSpeculativeExecutionIfHasBranchDivergencePass();
441
442 //===----------------------------------------------------------------------===//
443 //
444 // LoadCombine - Combine loads into bigger loads.
445 //
446 BasicBlockPass *createLoadCombinePass();
447
448 //===----------------------------------------------------------------------===//
449 //
450 // StraightLineStrengthReduce - This pass strength-reduces some certain
451 // instruction patterns in straight-line code.
452 //
453 FunctionPass *createStraightLineStrengthReducePass();
454
455 //===----------------------------------------------------------------------===//
456 //
457 // PlaceSafepoints - Rewrite any IR calls to gc.statepoints and insert any
458 // safepoint polls (method entry, backedge) that might be required.  This pass
459 // does not generate explicit relocation sequences - that's handled by
460 // RewriteStatepointsForGC which can be run at an arbitrary point in the pass
461 // order following this pass.
462 //
463 FunctionPass *createPlaceSafepointsPass();
464
465 //===----------------------------------------------------------------------===//
466 //
467 // RewriteStatepointsForGC - Rewrite any gc.statepoints which do not yet have
468 // explicit relocations to include explicit relocations.
469 //
470 ModulePass *createRewriteStatepointsForGCPass();
471
472 //===----------------------------------------------------------------------===//
473 //
474 // Float2Int - Demote floats to ints where possible.
475 //
476 FunctionPass *createFloat2IntPass();
477
478 //===----------------------------------------------------------------------===//
479 //
480 // NaryReassociate - Simplify n-ary operations by reassociation.
481 //
482 FunctionPass *createNaryReassociatePass();
483
484 //===----------------------------------------------------------------------===//
485 //
486 // LoopDistribute - Distribute loops.
487 //
488 // ProcessAllLoopsByDefault instructs the pass to look for distribution
489 // opportunities in all loops unless -enable-loop-distribute or the
490 // llvm.loop.distribute.enable metadata data override this default.
491 FunctionPass *createLoopDistributePass(bool ProcessAllLoopsByDefault);
492
493 //===----------------------------------------------------------------------===//
494 //
495 // LoopLoadElimination - Perform loop-aware load elimination.
496 //
497 FunctionPass *createLoopLoadEliminationPass();
498
499 //===----------------------------------------------------------------------===//
500 //
501 // LoopSimplifyCFG - This pass performs basic CFG simplification on loops,
502 // primarily to help other loop passes.
503 //
504 Pass *createLoopSimplifyCFGPass();
505
506 //===----------------------------------------------------------------------===//
507 //
508 // LoopVersioning - Perform loop multi-versioning.
509 //
510 FunctionPass *createLoopVersioningPass();
511
512 //===----------------------------------------------------------------------===//
513 //
514 // LoopDataPrefetch - Perform data prefetching in loops.
515 //
516 FunctionPass *createLoopDataPrefetchPass();
517
518 ///===---------------------------------------------------------------------===//
519 ModulePass *createNameAnonFunctionPass();
520
521 } // End llvm namespace
522
523 #endif