LLVM API Documentation
00001 //===-- Scalar.h - Scalar Transformations -----------------------*- C++ -*-===// 00002 // 00003 // The LLVM Compiler Infrastructure 00004 // 00005 // This file was developed by the LLVM research group and is distributed under 00006 // the University of Illinois Open Source 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 <cstdlib> 00019 00020 namespace llvm { 00021 00022 class ModulePass; 00023 class FunctionPass; 00024 class GetElementPtrInst; 00025 class PassInfo; 00026 class TerminatorInst; 00027 class TargetLowering; 00028 00029 //===----------------------------------------------------------------------===// 00030 // 00031 // RaisePointerReferences - Try to eliminate as many pointer arithmetic 00032 // expressions as possible, by converting expressions to use getelementptr and 00033 // friends. 00034 // 00035 FunctionPass *createRaisePointerReferencesPass(); 00036 00037 //===----------------------------------------------------------------------===// 00038 // 00039 // Constant Propagation Pass - A worklist driven constant propagation pass 00040 // 00041 FunctionPass *createConstantPropagationPass(); 00042 00043 00044 //===----------------------------------------------------------------------===// 00045 // 00046 // Sparse Conditional Constant Propagation Pass 00047 // 00048 FunctionPass *createSCCPPass(); 00049 00050 00051 //===----------------------------------------------------------------------===// 00052 // 00053 // DeadInstElimination - This pass quickly removes trivially dead instructions 00054 // without modifying the CFG of the function. It is a BasicBlockPass, so it 00055 // runs efficiently when queued next to other BasicBlockPass's. 00056 // 00057 FunctionPass *createDeadInstEliminationPass(); 00058 00059 00060 //===----------------------------------------------------------------------===// 00061 // 00062 // DeadCodeElimination - This pass is more powerful than DeadInstElimination, 00063 // because it is worklist driven that can potentially revisit instructions when 00064 // their other instructions become dead, to eliminate chains of dead 00065 // computations. 00066 // 00067 FunctionPass *createDeadCodeEliminationPass(); 00068 00069 //===----------------------------------------------------------------------===// 00070 // 00071 // DeadStoreElimination - This pass deletes stores that are post-dominated by 00072 // must-aliased stores and are not loaded used between the stores. 00073 // 00074 FunctionPass *createDeadStoreEliminationPass(); 00075 00076 //===----------------------------------------------------------------------===// 00077 // 00078 // AggressiveDCE - This pass uses the SSA based Aggressive DCE algorithm. This 00079 // algorithm assumes instructions are dead until proven otherwise, which makes 00080 // it more successful are removing non-obviously dead instructions. 00081 // 00082 FunctionPass *createAggressiveDCEPass(); 00083 00084 00085 //===----------------------------------------------------------------------===// 00086 // 00087 // Scalar Replacement of Aggregates - Break up alloca's of aggregates into 00088 // multiple allocas if possible. 00089 // 00090 FunctionPass *createScalarReplAggregatesPass(); 00091 00092 00093 //===----------------------------------------------------------------------===// 00094 // 00095 // GCSE - This pass is designed to be a very quick global transformation that 00096 // eliminates global common subexpressions from a function. It does this by 00097 // examining the SSA value graph of the function, instead of doing slow 00098 // bit-vector computations. 00099 // 00100 FunctionPass *createGCSEPass(); 00101 00102 00103 //===----------------------------------------------------------------------===// 00104 // 00105 // InductionVariableSimplify - Transform induction variables in a program to all 00106 // use a single canonical induction variable per loop. 00107 // 00108 FunctionPass *createIndVarSimplifyPass(); 00109 00110 00111 //===----------------------------------------------------------------------===// 00112 // 00113 // InstructionCombining - Combine instructions to form fewer, simple 00114 // instructions. This pass does not modify the CFG, and has a tendency to 00115 // make instructions dead, so a subsequent DCE pass is useful. 00116 // 00117 // This pass combines things like: 00118 // %Y = add int 1, %X 00119 // %Z = add int 1, %Y 00120 // into: 00121 // %Z = add int 2, %X 00122 // 00123 FunctionPass *createInstructionCombiningPass(); 00124 00125 00126 //===----------------------------------------------------------------------===// 00127 // 00128 // LICM - This pass is a loop invariant code motion and memory promotion pass. 00129 // 00130 FunctionPass *createLICMPass(); 00131 00132 //===----------------------------------------------------------------------===// 00133 // 00134 // LoopStrengthReduce - This pass is strength reduces GEP instructions that use 00135 // a loop's canonical induction variable as one of their indices. It takes an 00136 // optional parameter used to consult the target machine whether certain 00137 // transformations are profitable. 00138 // 00139 FunctionPass *createLoopStrengthReducePass(const TargetLowering *TLI = NULL); 00140 00141 //===----------------------------------------------------------------------===// 00142 // 00143 // LoopUnswitch - This pass is a simple loop unswitching pass. 00144 // 00145 FunctionPass *createLoopUnswitchPass(); 00146 00147 00148 //===----------------------------------------------------------------------===// 00149 // 00150 // LoopUnroll - This pass is a simple loop unrolling pass. 00151 // 00152 FunctionPass *createLoopUnrollPass(); 00153 00154 //===----------------------------------------------------------------------===// 00155 // 00156 // This pass is used to promote memory references to be register references. A 00157 // simple example of the transformation performed by this pass is: 00158 // 00159 // FROM CODE TO CODE 00160 // %X = alloca int, uint 1 ret int 42 00161 // store int 42, int *%X 00162 // %Y = load int* %X 00163 // ret int %Y 00164 // 00165 FunctionPass *createPromoteMemoryToRegisterPass(); 00166 extern const PassInfo *PromoteMemoryToRegisterID; 00167 00168 //===----------------------------------------------------------------------===// 00169 // 00170 // This pass is used to demote registers to memory references . 00171 // In basically undoes the PromoteMemoryToRegister pass to 00172 // make cfg hacking easier. 00173 FunctionPass *createDemoteRegisterToMemoryPass(); 00174 extern const PassInfo *DemoteRegisterToMemoryID; 00175 00176 //===----------------------------------------------------------------------===// 00177 // 00178 // This pass reassociates commutative expressions in an order that is designed 00179 // to promote better constant propagation, GCSE, LICM, PRE... 00180 // 00181 // For example: 4 + (x + 5) -> x + (4 + 5) 00182 // 00183 FunctionPass *createReassociatePass(); 00184 00185 //===----------------------------------------------------------------------===// 00186 // 00187 // This pass eliminates correlated conditions, such as these: 00188 // if (X == 0) 00189 // if (X > 2) ; // Known false 00190 // else 00191 // Y = X * Z; // = 0 00192 // 00193 FunctionPass *createCorrelatedExpressionEliminationPass(); 00194 00195 00196 // createCondPropagationPass - This pass propagates information about 00197 // conditional expressions through the program, allowing it to eliminate 00198 // conditional branches in some cases. 00199 // 00200 FunctionPass *createCondPropagationPass(); 00201 00202 //===----------------------------------------------------------------------===// 00203 // 00204 // TailDuplication - Eliminate unconditional branches through controlled code 00205 // duplication, creating simpler CFG structures. 00206 // 00207 FunctionPass *createTailDuplicationPass(); 00208 00209 00210 //===----------------------------------------------------------------------===// 00211 // 00212 // CFG Simplification - Merge basic blocks, eliminate unreachable blocks, 00213 // simplify terminator instructions, etc... 00214 // 00215 FunctionPass *createCFGSimplificationPass(); 00216 00217 00218 //===----------------------------------------------------------------------===// 00219 // 00220 // BreakCriticalEdges pass - Break all of the critical edges in the CFG by 00221 // inserting a dummy basic block. This pass may be "required" by passes that 00222 // cannot deal with critical edges. For this usage, a pass must call: 00223 // 00224 // AU.addRequiredID(BreakCriticalEdgesID); 00225 // 00226 // This pass obviously invalidates the CFG, but can update forward dominator 00227 // (set, immediate dominators, tree, and frontier) information. 00228 // 00229 FunctionPass *createBreakCriticalEdgesPass(); 00230 extern const PassInfo *BreakCriticalEdgesID; 00231 00232 //===----------------------------------------------------------------------===// 00233 // 00234 // LoopSimplify pass - Insert Pre-header blocks into the CFG for every function 00235 // in the module. This pass updates dominator information, loop information, 00236 // and does not add critical edges to the CFG. 00237 // 00238 // AU.addRequiredID(LoopSimplifyID); 00239 // 00240 FunctionPass *createLoopSimplifyPass(); 00241 extern const PassInfo *LoopSimplifyID; 00242 00243 //===----------------------------------------------------------------------===// 00244 // This pass converts SelectInst instructions into conditional branch and PHI 00245 // instructions. If the OnlyFP flag is set to true, then only floating point 00246 // select instructions are lowered. 00247 // 00248 FunctionPass *createLowerSelectPass(bool OnlyFP = false); 00249 extern const PassInfo *LowerSelectID; 00250 00251 //===----------------------------------------------------------------------===// 00252 // 00253 // LowerAllocations Pass - Turn malloc and free instructions into %malloc and 00254 // %free calls. 00255 // 00256 // AU.addRequiredID(LowerAllocationsID); 00257 // 00258 FunctionPass *createLowerAllocationsPass(bool LowerMallocArgToInteger = false); 00259 extern const PassInfo *LowerAllocationsID; 00260 00261 //===----------------------------------------------------------------------===// 00262 // 00263 // This pass eliminates call instructions to the current function which occur 00264 // immediately before return instructions. 00265 // 00266 FunctionPass *createTailCallEliminationPass(); 00267 00268 //===----------------------------------------------------------------------===// 00269 // This pass converts SwitchInst instructions into a sequence of chained binary 00270 // branch instructions. 00271 // 00272 FunctionPass *createLowerSwitchPass(); 00273 extern const PassInfo *LowerSwitchID; 00274 00275 //===----------------------------------------------------------------------===// 00276 // This pass converts PackedType operations into low-level scalar operations. 00277 // 00278 FunctionPass *createLowerPackedPass(); 00279 00280 //===----------------------------------------------------------------------===// 00281 // This pass converts invoke and unwind instructions to use sjlj exception 00282 // handling mechanisms. Note that after this pass runs the CFG is not entirely 00283 // accurate (exceptional control flow edges are not correct anymore) so only 00284 // very simple things should be done after the lowerinvoke pass has run (like 00285 // generation of native code). This should *NOT* be used as a general purpose 00286 // "my LLVM-to-LLVM pass doesn't support the invoke instruction yet" lowering 00287 // pass. 00288 // 00289 FunctionPass *createLowerInvokePass(unsigned JumBufSize = 200, 00290 unsigned JumpBufAlign = 0); 00291 extern const PassInfo *LowerInvokePassID; 00292 00293 00294 //===----------------------------------------------------------------------===// 00295 /// createLowerGCPass - This function returns an instance of the "lowergc" 00296 /// pass, which lowers garbage collection intrinsics to normal LLVM code. 00297 /// 00298 FunctionPass *createLowerGCPass(); 00299 00300 //===----------------------------------------------------------------------===// 00301 // This pass reorders basic blocks in order to increase the number of fall- 00302 // through conditional branches. 00303 FunctionPass *createBlockPlacementPass(); 00304 00305 //===----------------------------------------------------------------------===// 00306 // This pass inserts phi nodes at loop boundaries to simplify other loop 00307 // optimizations. 00308 FunctionPass *createLCSSAPass(); 00309 extern const PassInfo *LCSSAID; 00310 00311 } // End llvm namespace 00312 00313 #endif