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 namespace llvm {
00019 
00020 class FunctionPass;
00021 class Pass;
00022 class GetElementPtrInst;
00023 class PassInfo;
00024 class TerminatorInst;
00025 class TargetLowering;
00026 
00027 //===----------------------------------------------------------------------===//
00028 //
00029 // ConstantPropagation - A worklist driven constant propagation pass
00030 //
00031 FunctionPass *createConstantPropagationPass();
00032 
00033 //===----------------------------------------------------------------------===//
00034 //
00035 // SCCP - Sparse conditional constant propagation.
00036 //
00037 FunctionPass *createSCCPPass();
00038 
00039 //===----------------------------------------------------------------------===//
00040 //
00041 // DeadInstElimination - This pass quickly removes trivially dead instructions
00042 // without modifying the CFG of the function.  It is a BasicBlockPass, so it
00043 // runs efficiently when queued next to other BasicBlockPass's.
00044 //
00045 Pass *createDeadInstEliminationPass();
00046 
00047 //===----------------------------------------------------------------------===//
00048 //
00049 // DeadCodeElimination - This pass is more powerful than DeadInstElimination,
00050 // because it is worklist driven that can potentially revisit instructions when
00051 // their other instructions become dead, to eliminate chains of dead
00052 // computations.
00053 //
00054 FunctionPass *createDeadCodeEliminationPass();
00055 
00056 //===----------------------------------------------------------------------===//
00057 //
00058 // DeadStoreElimination - This pass deletes stores that are post-dominated by
00059 // must-aliased stores and are not loaded used between the stores.
00060 //
00061 FunctionPass *createDeadStoreEliminationPass();
00062 
00063 //===----------------------------------------------------------------------===//
00064 //
00065 // AggressiveDCE - This pass uses the SSA based Aggressive DCE algorithm.  This
00066 // algorithm assumes instructions are dead until proven otherwise, which makes
00067 // it more successful are removing non-obviously dead instructions.
00068 //
00069 FunctionPass *createAggressiveDCEPass();
00070 
00071 //===----------------------------------------------------------------------===//
00072 //
00073 // SROA - Replace aggregates or pieces of aggregates with scalar SSA values.
00074 //
00075 FunctionPass *createSROAPass(bool RequiresDomTree = true);
00076 
00077 //===----------------------------------------------------------------------===//
00078 //
00079 // ScalarReplAggregates - Break up alloca's of aggregates into multiple allocas
00080 // if possible.
00081 //
00082 FunctionPass *createScalarReplAggregatesPass(signed Threshold = -1,
00083                                              bool UseDomTree = true,
00084                                              signed StructMemberThreshold = -1,
00085                                              signed ArrayElementThreshold = -1,
00086                                              signed ScalarLoadThreshold = -1);
00087 
00088 //===----------------------------------------------------------------------===//
00089 //
00090 // InductionVariableSimplify - Transform induction variables in a program to all
00091 // use a single canonical induction variable per loop.
00092 //
00093 Pass *createIndVarSimplifyPass();
00094 
00095 //===----------------------------------------------------------------------===//
00096 //
00097 // InstructionCombining - Combine instructions to form fewer, simple
00098 // instructions. This pass does not modify the CFG, and has a tendency to make
00099 // instructions dead, so a subsequent DCE pass is useful.
00100 //
00101 // This pass combines things like:
00102 //    %Y = add int 1, %X
00103 //    %Z = add int 1, %Y
00104 // into:
00105 //    %Z = add int 2, %X
00106 //
00107 FunctionPass *createInstructionCombiningPass();
00108 
00109 //===----------------------------------------------------------------------===//
00110 //
00111 // LICM - This pass is a loop invariant code motion and memory promotion pass.
00112 //
00113 Pass *createLICMPass();
00114 
00115 //===----------------------------------------------------------------------===//
00116 //
00117 // LoopStrengthReduce - This pass is strength reduces GEP instructions that use
00118 // a loop's canonical induction variable as one of their indices.
00119 //
00120 Pass *createLoopStrengthReducePass();
00121 
00122 Pass *createGlobalMergePass(const TargetLowering *TLI = 0);
00123 
00124 //===----------------------------------------------------------------------===//
00125 //
00126 // LoopUnswitch - This pass is a simple loop unswitching pass.
00127 //
00128 Pass *createLoopUnswitchPass(bool OptimizeForSize = false);
00129 
00130 //===----------------------------------------------------------------------===//
00131 //
00132 // LoopInstSimplify - This pass simplifies instructions in a loop's body.
00133 //
00134 Pass *createLoopInstSimplifyPass();
00135 
00136 //===----------------------------------------------------------------------===//
00137 //
00138 // LoopUnroll - This pass is a simple loop unrolling pass.
00139 //
00140 Pass *createLoopUnrollPass(int Threshold = -1, int Count = -1, int AllowPartial = -1);
00141 
00142 //===----------------------------------------------------------------------===//
00143 //
00144 // LoopRotate - This pass is a simple loop rotating pass.
00145 //
00146 Pass *createLoopRotatePass();
00147 
00148 //===----------------------------------------------------------------------===//
00149 //
00150 // LoopIdiom - This pass recognizes and replaces idioms in loops.
00151 //
00152 Pass *createLoopIdiomPass();
00153   
00154 //===----------------------------------------------------------------------===//
00155 //
00156 // PromoteMemoryToRegister - This pass is used to promote memory references to
00157 // be register references. A simple example of the transformation performed by
00158 // this pass is:
00159 //
00160 //        FROM CODE                           TO CODE
00161 //   %X = alloca i32, i32 1                 ret i32 42
00162 //   store i32 42, i32 *%X
00163 //   %Y = load i32* %X
00164 //   ret i32 %Y
00165 //
00166 FunctionPass *createPromoteMemoryToRegisterPass();
00167 
00168 //===----------------------------------------------------------------------===//
00169 //
00170 // DemoteRegisterToMemoryPass - This pass is used to demote registers to memory
00171 // references. In basically undoes the PromoteMemoryToRegister pass to make cfg
00172 // hacking easier.
00173 //
00174 FunctionPass *createDemoteRegisterToMemoryPass();
00175 extern char &DemoteRegisterToMemoryID;
00176 
00177 //===----------------------------------------------------------------------===//
00178 //
00179 // Reassociate - This pass reassociates commutative expressions in an order that
00180 // is designed to promote better constant propagation, GCSE, LICM, PRE...
00181 //
00182 // For example:  4 + (x + 5)  ->  x + (4 + 5)
00183 //
00184 FunctionPass *createReassociatePass();
00185 
00186 //===----------------------------------------------------------------------===//
00187 //
00188 // JumpThreading - Thread control through mult-pred/multi-succ blocks where some
00189 // preds always go to some succ.
00190 //
00191 FunctionPass *createJumpThreadingPass();
00192   
00193 //===----------------------------------------------------------------------===//
00194 //
00195 // CFGSimplification - Merge basic blocks, eliminate unreachable blocks,
00196 // simplify terminator instructions, etc...
00197 //
00198 FunctionPass *createCFGSimplificationPass();
00199 
00200 //===----------------------------------------------------------------------===//
00201 //
00202 // BreakCriticalEdges - Break all of the critical edges in the CFG by inserting
00203 // a dummy basic block. This pass may be "required" by passes that cannot deal
00204 // with critical edges. For this usage, a pass must call:
00205 //
00206 //   AU.addRequiredID(BreakCriticalEdgesID);
00207 //
00208 // This pass obviously invalidates the CFG, but can update forward dominator
00209 // (set, immediate dominators, tree, and frontier) information.
00210 //
00211 FunctionPass *createBreakCriticalEdgesPass();
00212 extern char &BreakCriticalEdgesID;
00213 
00214 //===----------------------------------------------------------------------===//
00215 //
00216 // LoopSimplify - Insert Pre-header blocks into the CFG for every function in
00217 // the module.  This pass updates dominator information, loop information, and
00218 // does not add critical edges to the CFG.
00219 //
00220 //   AU.addRequiredID(LoopSimplifyID);
00221 //
00222 Pass *createLoopSimplifyPass();
00223 extern char &LoopSimplifyID;
00224 
00225 //===----------------------------------------------------------------------===//
00226 //
00227 // TailCallElimination - This pass eliminates call instructions to the current
00228 // function which occur immediately before return instructions.
00229 //
00230 FunctionPass *createTailCallEliminationPass();
00231 
00232 //===----------------------------------------------------------------------===//
00233 //
00234 // LowerSwitch - This pass converts SwitchInst instructions into a sequence of
00235 // chained binary branch instructions.
00236 //
00237 FunctionPass *createLowerSwitchPass();
00238 extern char &LowerSwitchID;
00239 
00240 //===----------------------------------------------------------------------===//
00241 //
00242 // LowerInvoke - This pass converts invoke and unwind instructions to use sjlj
00243 // exception handling mechanisms.  Note that after this pass runs the CFG is not
00244 // entirely accurate (exceptional control flow edges are not correct anymore) so
00245 // only very simple things should be done after the lowerinvoke pass has run
00246 // (like generation of native code).  This should *NOT* be used as a general
00247 // purpose "my LLVM-to-LLVM pass doesn't support the invoke instruction yet"
00248 // lowering pass.
00249 //
00250 FunctionPass *createLowerInvokePass(const TargetLowering *TLI = 0);
00251 FunctionPass *createLowerInvokePass(const TargetLowering *TLI,
00252                                     bool useExpensiveEHSupport);
00253 extern char &LowerInvokePassID;
00254 
00255 //===----------------------------------------------------------------------===//
00256 //
00257 // BlockPlacement - This pass reorders basic blocks in order to increase the
00258 // number of fall-through conditional branches.
00259 //
00260 FunctionPass *createBlockPlacementPass();
00261 
00262 //===----------------------------------------------------------------------===//
00263 //
00264 // LCSSA - This pass inserts phi nodes at loop boundaries to simplify other loop
00265 // optimizations.
00266 //
00267 Pass *createLCSSAPass();
00268 extern char &LCSSAID;
00269 
00270 //===----------------------------------------------------------------------===//
00271 //
00272 // EarlyCSE - This pass performs a simple and fast CSE pass over the dominator
00273 // tree.
00274 //
00275 FunctionPass *createEarlyCSEPass();
00276   
00277 //===----------------------------------------------------------------------===//
00278 //
00279 // GVN - This pass performs global value numbering and redundant load 
00280 // elimination cotemporaneously.
00281 //
00282 FunctionPass *createGVNPass(bool NoLoads = false);
00283 
00284 //===----------------------------------------------------------------------===//
00285 //
00286 // MemCpyOpt - This pass performs optimizations related to eliminating memcpy
00287 // calls and/or combining multiple stores into memset's.
00288 //
00289 FunctionPass *createMemCpyOptPass();
00290 
00291 //===----------------------------------------------------------------------===//
00292 //
00293 // LoopDeletion - This pass performs DCE of non-infinite loops that it
00294 // can prove are dead.
00295 //
00296 Pass *createLoopDeletionPass();
00297   
00298 //===----------------------------------------------------------------------===//
00299 //
00300 /// createSimplifyLibCallsPass - This pass optimizes specific calls to
00301 /// specific well-known (library) functions.
00302 FunctionPass *createSimplifyLibCallsPass();
00303 
00304 //===----------------------------------------------------------------------===//
00305 //
00306 // CodeGenPrepare - This pass prepares a function for instruction selection.
00307 //
00308 FunctionPass *createCodeGenPreparePass(const TargetLowering *TLI = 0);
00309 
00310 //===----------------------------------------------------------------------===//
00311 //
00312 // InstructionNamer - Give any unnamed non-void instructions "tmp" names.
00313 //
00314 FunctionPass *createInstructionNamerPass();
00315 extern char &InstructionNamerID;
00316   
00317 //===----------------------------------------------------------------------===//
00318 //
00319 // Sink - Code Sinking
00320 //
00321 FunctionPass *createSinkingPass();
00322 
00323 //===----------------------------------------------------------------------===//
00324 //
00325 // LowerAtomic - Lower atomic intrinsics to non-atomic form
00326 //
00327 Pass *createLowerAtomicPass();
00328 
00329 //===----------------------------------------------------------------------===//
00330 //
00331 // ValuePropagation - Propagate CFG-derived value information
00332 //
00333 Pass *createCorrelatedValuePropagationPass();
00334 
00335 //===----------------------------------------------------------------------===//
00336 //
00337 // InstructionSimplifier - Remove redundant instructions.
00338 //
00339 FunctionPass *createInstructionSimplifierPass();
00340 extern char &InstructionSimplifierID;
00341 
00342 
00343 //===----------------------------------------------------------------------===//
00344 //
00345 // LowerExpectIntrinsics - Removes llvm.expect intrinsics and creates
00346 // "block_weights" metadata.
00347 FunctionPass *createLowerExpectIntrinsicPass();
00348 
00349 
00350 } // End llvm namespace
00351 
00352 #endif