LLVM API Documentation

Transforms/Scalar.h
Go to the documentation of this file.
00001 //===-- Scalar.h - Scalar Transformations -----------------------*- C++ -*-===//
00002 //
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file is distributed under the University of Illinois Open Source
00006 // License. See LICENSE.TXT for details.
00007 //
00008 //===----------------------------------------------------------------------===//
00009 //
00010 // This header file defines prototypes for accessor functions that expose passes
00011 // in the Scalar transformations library.
00012 //
00013 //===----------------------------------------------------------------------===//
00014 
00015 #ifndef LLVM_TRANSFORMS_SCALAR_H
00016 #define LLVM_TRANSFORMS_SCALAR_H
00017 
00018 #include "llvm/ADT/StringRef.h"
00019 
00020 namespace llvm {
00021 
00022 class BasicBlockPass;
00023 class FunctionPass;
00024 class Pass;
00025 class GetElementPtrInst;
00026 class PassInfo;
00027 class TerminatorInst;
00028 class TargetLowering;
00029 class TargetMachine;
00030 
00031 //===----------------------------------------------------------------------===//
00032 //
00033 // ConstantPropagation - A worklist driven constant propagation pass
00034 //
00035 FunctionPass *createConstantPropagationPass();
00036 
00037 //===----------------------------------------------------------------------===//
00038 //
00039 // AlignmentFromAssumptions - Use assume intrinsics to set load/store
00040 // alignments.
00041 //
00042 FunctionPass *createAlignmentFromAssumptionsPass();
00043 
00044 //===----------------------------------------------------------------------===//
00045 //
00046 // SCCP - Sparse conditional constant propagation.
00047 //
00048 FunctionPass *createSCCPPass();
00049 
00050 //===----------------------------------------------------------------------===//
00051 //
00052 // DeadInstElimination - This pass quickly removes trivially dead instructions
00053 // without modifying the CFG of the function.  It is a BasicBlockPass, so it
00054 // runs efficiently when queued next to other BasicBlockPass's.
00055 //
00056 Pass *createDeadInstEliminationPass();
00057 
00058 //===----------------------------------------------------------------------===//
00059 //
00060 // DeadCodeElimination - This pass is more powerful than DeadInstElimination,
00061 // because it is worklist driven that can potentially revisit instructions when
00062 // their other instructions become dead, to eliminate chains of dead
00063 // computations.
00064 //
00065 FunctionPass *createDeadCodeEliminationPass();
00066 
00067 //===----------------------------------------------------------------------===//
00068 //
00069 // DeadStoreElimination - This pass deletes stores that are post-dominated by
00070 // must-aliased stores and are not loaded used between the stores.
00071 //
00072 FunctionPass *createDeadStoreEliminationPass();
00073 
00074 //===----------------------------------------------------------------------===//
00075 //
00076 // AggressiveDCE - This pass uses the SSA based Aggressive DCE algorithm.  This
00077 // algorithm assumes instructions are dead until proven otherwise, which makes
00078 // it more successful are removing non-obviously dead instructions.
00079 //
00080 FunctionPass *createAggressiveDCEPass();
00081 
00082 //===----------------------------------------------------------------------===//
00083 //
00084 // SROA - Replace aggregates or pieces of aggregates with scalar SSA values.
00085 //
00086 FunctionPass *createSROAPass(bool RequiresDomTree = true);
00087 
00088 //===----------------------------------------------------------------------===//
00089 //
00090 // ScalarReplAggregates - Break up alloca's of aggregates into multiple allocas
00091 // if possible.
00092 //
00093 FunctionPass *createScalarReplAggregatesPass(signed Threshold = -1,
00094                                              bool UseDomTree = true,
00095                                              signed StructMemberThreshold = -1,
00096                                              signed ArrayElementThreshold = -1,
00097                                              signed ScalarLoadThreshold = -1);
00098 
00099 //===----------------------------------------------------------------------===//
00100 //
00101 // InductionVariableSimplify - Transform induction variables in a program to all
00102 // use a single canonical induction variable per loop.
00103 //
00104 Pass *createIndVarSimplifyPass();
00105 
00106 //===----------------------------------------------------------------------===//
00107 //
00108 // InstructionCombining - Combine instructions to form fewer, simple
00109 // instructions. This pass does not modify the CFG, and has a tendency to make
00110 // instructions dead, so a subsequent DCE pass is useful.
00111 //
00112 // This pass combines things like:
00113 //    %Y = add int 1, %X
00114 //    %Z = add int 1, %Y
00115 // into:
00116 //    %Z = add int 2, %X
00117 //
00118 FunctionPass *createInstructionCombiningPass();
00119 
00120 //===----------------------------------------------------------------------===//
00121 //
00122 // LICM - This pass is a loop invariant code motion and memory promotion pass.
00123 //
00124 Pass *createLICMPass();
00125 
00126 //===----------------------------------------------------------------------===//
00127 //
00128 // LoopStrengthReduce - This pass is strength reduces GEP instructions that use
00129 // a loop's canonical induction variable as one of their indices.
00130 //
00131 Pass *createLoopStrengthReducePass();
00132 
00133 Pass *createGlobalMergePass(const TargetMachine *TM = nullptr);
00134 
00135 //===----------------------------------------------------------------------===//
00136 //
00137 // LoopUnswitch - This pass is a simple loop unswitching pass.
00138 //
00139 Pass *createLoopUnswitchPass(bool OptimizeForSize = false);
00140 
00141 //===----------------------------------------------------------------------===//
00142 //
00143 // LoopInstSimplify - This pass simplifies instructions in a loop's body.
00144 //
00145 Pass *createLoopInstSimplifyPass();
00146 
00147 //===----------------------------------------------------------------------===//
00148 //
00149 // LoopUnroll - This pass is a simple loop unrolling pass.
00150 //
00151 Pass *createLoopUnrollPass(int Threshold = -1, int Count = -1,
00152                            int AllowPartial = -1, int Runtime = -1);
00153 // Create an unrolling pass for full unrolling only.
00154 Pass *createSimpleLoopUnrollPass();
00155 
00156 //===----------------------------------------------------------------------===//
00157 //
00158 // LoopReroll - This pass is a simple loop rerolling pass.
00159 //
00160 Pass *createLoopRerollPass();
00161 
00162 //===----------------------------------------------------------------------===//
00163 //
00164 // LoopRotate - This pass is a simple loop rotating pass.
00165 //
00166 Pass *createLoopRotatePass(int MaxHeaderSize = -1);
00167 
00168 //===----------------------------------------------------------------------===//
00169 //
00170 // LoopIdiom - This pass recognizes and replaces idioms in loops.
00171 //
00172 Pass *createLoopIdiomPass();
00173 
00174 //===----------------------------------------------------------------------===//
00175 //
00176 // PromoteMemoryToRegister - This pass is used to promote memory references to
00177 // be register references. A simple example of the transformation performed by
00178 // this pass is:
00179 //
00180 //        FROM CODE                           TO CODE
00181 //   %X = alloca i32, i32 1                 ret i32 42
00182 //   store i32 42, i32 *%X
00183 //   %Y = load i32* %X
00184 //   ret i32 %Y
00185 //
00186 FunctionPass *createPromoteMemoryToRegisterPass();
00187 
00188 //===----------------------------------------------------------------------===//
00189 //
00190 // DemoteRegisterToMemoryPass - This pass is used to demote registers to memory
00191 // references. In basically undoes the PromoteMemoryToRegister pass to make cfg
00192 // hacking easier.
00193 //
00194 FunctionPass *createDemoteRegisterToMemoryPass();
00195 extern char &DemoteRegisterToMemoryID;
00196 
00197 //===----------------------------------------------------------------------===//
00198 //
00199 // Reassociate - This pass reassociates commutative expressions in an order that
00200 // is designed to promote better constant propagation, GCSE, LICM, PRE...
00201 //
00202 // For example:  4 + (x + 5)  ->  x + (4 + 5)
00203 //
00204 FunctionPass *createReassociatePass();
00205 
00206 //===----------------------------------------------------------------------===//
00207 //
00208 // JumpThreading - Thread control through mult-pred/multi-succ blocks where some
00209 // preds always go to some succ.
00210 //
00211 FunctionPass *createJumpThreadingPass();
00212 
00213 //===----------------------------------------------------------------------===//
00214 //
00215 // CFGSimplification - Merge basic blocks, eliminate unreachable blocks,
00216 // simplify terminator instructions, etc...
00217 //
00218 FunctionPass *createCFGSimplificationPass();
00219 
00220 //===----------------------------------------------------------------------===//
00221 //
00222 // FlattenCFG - flatten CFG, reduce number of conditional branches by using
00223 // parallel-and and parallel-or mode, etc...
00224 //
00225 FunctionPass *createFlattenCFGPass();
00226 
00227 //===----------------------------------------------------------------------===//
00228 //
00229 // CFG Structurization - Remove irreducible control flow
00230 //
00231 Pass *createStructurizeCFGPass();
00232 
00233 //===----------------------------------------------------------------------===//
00234 //
00235 // BreakCriticalEdges - Break all of the critical edges in the CFG by inserting
00236 // a dummy basic block. This pass may be "required" by passes that cannot deal
00237 // with critical edges. For this usage, a pass must call:
00238 //
00239 //   AU.addRequiredID(BreakCriticalEdgesID);
00240 //
00241 // This pass obviously invalidates the CFG, but can update forward dominator
00242 // (set, immediate dominators, tree, and frontier) information.
00243 //
00244 FunctionPass *createBreakCriticalEdgesPass();
00245 extern char &BreakCriticalEdgesID;
00246 
00247 //===----------------------------------------------------------------------===//
00248 //
00249 // LoopSimplify - Insert Pre-header blocks into the CFG for every function in
00250 // the module.  This pass updates dominator information, loop information, and
00251 // does not add critical edges to the CFG.
00252 //
00253 //   AU.addRequiredID(LoopSimplifyID);
00254 //
00255 Pass *createLoopSimplifyPass();
00256 extern char &LoopSimplifyID;
00257 
00258 //===----------------------------------------------------------------------===//
00259 //
00260 // TailCallElimination - This pass eliminates call instructions to the current
00261 // function which occur immediately before return instructions.
00262 //
00263 FunctionPass *createTailCallEliminationPass();
00264 
00265 //===----------------------------------------------------------------------===//
00266 //
00267 // LowerSwitch - This pass converts SwitchInst instructions into a sequence of
00268 // chained binary branch instructions.
00269 //
00270 FunctionPass *createLowerSwitchPass();
00271 extern char &LowerSwitchID;
00272 
00273 //===----------------------------------------------------------------------===//
00274 //
00275 // LowerInvoke - This pass removes invoke instructions, converting them to call
00276 // instructions.
00277 //
00278 FunctionPass *createLowerInvokePass();
00279 extern char &LowerInvokePassID;
00280 
00281 //===----------------------------------------------------------------------===//
00282 //
00283 // LCSSA - This pass inserts phi nodes at loop boundaries to simplify other loop
00284 // optimizations.
00285 //
00286 Pass *createLCSSAPass();
00287 extern char &LCSSAID;
00288 
00289 //===----------------------------------------------------------------------===//
00290 //
00291 // EarlyCSE - This pass performs a simple and fast CSE pass over the dominator
00292 // tree.
00293 //
00294 FunctionPass *createEarlyCSEPass();
00295 
00296 //===----------------------------------------------------------------------===//
00297 //
00298 // MergedLoadStoreMotion - This pass merges loads and stores in diamonds. Loads
00299 // are hoisted into the header, while stores sink into the footer.
00300 //
00301 FunctionPass *createMergedLoadStoreMotionPass();
00302 
00303 //===----------------------------------------------------------------------===//
00304 //
00305 // GVN - This pass performs global value numbering and redundant load
00306 // elimination cotemporaneously.
00307 //
00308 FunctionPass *createGVNPass(bool NoLoads = false);
00309 
00310 //===----------------------------------------------------------------------===//
00311 //
00312 // MemCpyOpt - This pass performs optimizations related to eliminating memcpy
00313 // calls and/or combining multiple stores into memset's.
00314 //
00315 FunctionPass *createMemCpyOptPass();
00316 
00317 //===----------------------------------------------------------------------===//
00318 //
00319 // LoopDeletion - This pass performs DCE of non-infinite loops that it
00320 // can prove are dead.
00321 //
00322 Pass *createLoopDeletionPass();
00323 
00324 //===----------------------------------------------------------------------===//
00325 //
00326 // ConstantHoisting - This pass prepares a function for expensive constants.
00327 //
00328 FunctionPass *createConstantHoistingPass();
00329 
00330 //===----------------------------------------------------------------------===//
00331 //
00332 // InstructionNamer - Give any unnamed non-void instructions "tmp" names.
00333 //
00334 FunctionPass *createInstructionNamerPass();
00335 extern char &InstructionNamerID;
00336 
00337 //===----------------------------------------------------------------------===//
00338 //
00339 // Sink - Code Sinking
00340 //
00341 FunctionPass *createSinkingPass();
00342 
00343 //===----------------------------------------------------------------------===//
00344 //
00345 // LowerAtomic - Lower atomic intrinsics to non-atomic form
00346 //
00347 Pass *createLowerAtomicPass();
00348 
00349 //===----------------------------------------------------------------------===//
00350 //
00351 // ValuePropagation - Propagate CFG-derived value information
00352 //
00353 Pass *createCorrelatedValuePropagationPass();
00354 
00355 //===----------------------------------------------------------------------===//
00356 //
00357 // InstructionSimplifier - Remove redundant instructions.
00358 //
00359 FunctionPass *createInstructionSimplifierPass();
00360 extern char &InstructionSimplifierID;
00361 
00362 //===----------------------------------------------------------------------===//
00363 //
00364 // LowerExpectIntrinsics - Removes llvm.expect intrinsics and creates
00365 // "block_weights" metadata.
00366 FunctionPass *createLowerExpectIntrinsicPass();
00367 
00368 //===----------------------------------------------------------------------===//
00369 //
00370 // PartiallyInlineLibCalls - Tries to inline the fast path of library
00371 // calls such as sqrt.
00372 //
00373 FunctionPass *createPartiallyInlineLibCallsPass();
00374 
00375 //===----------------------------------------------------------------------===//
00376 //
00377 // SampleProfilePass - Loads sample profile data from disk and generates
00378 // IR metadata to reflect the profile.
00379 FunctionPass *createSampleProfileLoaderPass();
00380 FunctionPass *createSampleProfileLoaderPass(StringRef Name);
00381 
00382 //===----------------------------------------------------------------------===//
00383 //
00384 // ScalarizerPass - Converts vector operations into scalar operations
00385 //
00386 FunctionPass *createScalarizerPass();
00387 
00388 //===----------------------------------------------------------------------===//
00389 //
00390 // AddDiscriminators - Add DWARF path discriminators to the IR.
00391 FunctionPass *createAddDiscriminatorsPass();
00392 
00393 //===----------------------------------------------------------------------===//
00394 //
00395 // SeparateConstOffsetFromGEP - Split GEPs for better CSE
00396 //
00397 FunctionPass *createSeparateConstOffsetFromGEPPass();
00398 
00399 //===----------------------------------------------------------------------===//
00400 //
00401 // LoadCombine - Combine loads into bigger loads.
00402 //
00403 BasicBlockPass *createLoadCombinePass();
00404 
00405 } // End llvm namespace
00406 
00407 #endif