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