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 00167 //===----------------------------------------------------------------------===// 00168 // 00169 // This pass is used to demote registers to memory references . 00170 // In basically undoes the PromoteMemoryToRegister pass to 00171 // make cfg hacking easier. 00172 FunctionPass *createDemoteRegisterToMemoryPass(); 00173 extern const PassInfo *DemoteRegisterToMemoryID; 00174 00175 //===----------------------------------------------------------------------===// 00176 // 00177 // This pass reassociates commutative expressions in an order that is designed 00178 // to promote better constant propagation, GCSE, LICM, PRE... 00179 // 00180 // For example: 4 + (x + 5) -> x + (4 + 5) 00181 // 00182 FunctionPass *createReassociatePass(); 00183 00184 //===----------------------------------------------------------------------===// 00185 // 00186 // This pass eliminates correlated conditions, such as these: 00187 // if (X == 0) 00188 // if (X > 2) ; // Known false 00189 // else 00190 // Y = X * Z; // = 0 00191 // 00192 FunctionPass *createCorrelatedExpressionEliminationPass(); 00193 00194 00195 // createCondPropagationPass - This pass propagates information about 00196 // conditional expressions through the program, allowing it to eliminate 00197 // conditional branches in some cases. 00198 // 00199 FunctionPass *createCondPropagationPass(); 00200 00201 //===----------------------------------------------------------------------===// 00202 // 00203 // TailDuplication - Eliminate unconditional branches through controlled code 00204 // duplication, creating simpler CFG structures. 00205 // 00206 FunctionPass *createTailDuplicationPass(); 00207 00208 00209 //===----------------------------------------------------------------------===// 00210 // 00211 // CFG Simplification - Merge basic blocks, eliminate unreachable blocks, 00212 // simplify terminator instructions, etc... 00213 // 00214 FunctionPass *createCFGSimplificationPass(); 00215 00216 00217 //===----------------------------------------------------------------------===// 00218 // 00219 // BreakCriticalEdges pass - Break all of the critical edges in the CFG by 00220 // inserting a dummy basic block. This pass may be "required" by passes that 00221 // cannot deal with critical edges. For this usage, a pass must call: 00222 // 00223 // AU.addRequiredID(BreakCriticalEdgesID); 00224 // 00225 // This pass obviously invalidates the CFG, but can update forward dominator 00226 // (set, immediate dominators, tree, and frontier) information. 00227 // 00228 FunctionPass *createBreakCriticalEdgesPass(); 00229 extern const PassInfo *BreakCriticalEdgesID; 00230 00231 //===----------------------------------------------------------------------===// 00232 // 00233 // LoopSimplify pass - Insert Pre-header blocks into the CFG for every function 00234 // in the module. This pass updates dominator information, loop information, 00235 // and does not add critical edges to the CFG. 00236 // 00237 // AU.addRequiredID(LoopSimplifyID); 00238 // 00239 FunctionPass *createLoopSimplifyPass(); 00240 extern const PassInfo *LoopSimplifyID; 00241 00242 //===----------------------------------------------------------------------===// 00243 // 00244 // This pass eliminates call instructions to the current function which occur 00245 // immediately before return instructions. 00246 // 00247 FunctionPass *createTailCallEliminationPass(); 00248 00249 00250 //===----------------------------------------------------------------------===// 00251 // This pass convert malloc and free instructions to %malloc & %free function 00252 // calls. 00253 // 00254 FunctionPass *createLowerAllocationsPass(bool LowerMallocArgToInteger = false); 00255 00256 //===----------------------------------------------------------------------===// 00257 // This pass converts SwitchInst instructions into a sequence of chained binary 00258 // branch instructions. 00259 // 00260 FunctionPass *createLowerSwitchPass(); 00261 00262 //===----------------------------------------------------------------------===// 00263 // This pass converts SelectInst instructions into conditional branch and PHI 00264 // instructions. If the OnlyFP flag is set to true, then only floating point 00265 // select instructions are lowered. 00266 // 00267 FunctionPass *createLowerSelectPass(bool OnlyFP = false); 00268 00269 //===----------------------------------------------------------------------===// 00270 // This pass converts PackedType operations into low-level scalar operations. 00271 // 00272 FunctionPass *createLowerPackedPass(); 00273 00274 //===----------------------------------------------------------------------===// 00275 // This pass converts invoke and unwind instructions to use sjlj exception 00276 // handling mechanisms. Note that after this pass runs the CFG is not entirely 00277 // accurate (exceptional control flow edges are not correct anymore) so only 00278 // very simple things should be done after the lowerinvoke pass has run (like 00279 // generation of native code). This should *NOT* be used as a general purpose 00280 // "my LLVM-to-LLVM pass doesn't support the invoke instruction yet" lowering 00281 // pass. 00282 // 00283 FunctionPass *createLowerInvokePass(unsigned JumBufSize = 200, 00284 unsigned JumpBufAlign = 0); 00285 extern const PassInfo *LowerInvokePassID; 00286 00287 00288 //===----------------------------------------------------------------------===// 00289 /// createLowerGCPass - This function returns an instance of the "lowergc" 00290 /// pass, which lowers garbage collection intrinsics to normal LLVM code. 00291 /// 00292 FunctionPass *createLowerGCPass(); 00293 00294 //===----------------------------------------------------------------------===// 00295 // This pass reorders basic blocks in order to increase the number of fall- 00296 // through conditional branches. 00297 FunctionPass *createBlockPlacementPass(); 00298 00299 //===----------------------------------------------------------------------===// 00300 // This pass does partial redundancy elimination. 00301 FunctionPass *createPREPass(); 00302 00303 } // End llvm namespace 00304 00305 #endif