Scalar.h revision eaa13851a7fe604363577350c5cf65c257c4d41a
1//===-- Scalar.h - Scalar Transformations -----------------------*- C++ -*-===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file was developed by the LLVM research group and is distributed under 6// the University of Illinois Open Source License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9// 10// This header file defines prototypes for accessor functions that expose passes 11// in the Scalar transformations library. 12// 13//===----------------------------------------------------------------------===// 14 15#ifndef LLVM_TRANSFORMS_SCALAR_H 16#define LLVM_TRANSFORMS_SCALAR_H 17 18namespace llvm { 19 20class ModulePass; 21class FunctionPass; 22class GetElementPtrInst; 23class PassInfo; 24class TerminatorInst; 25 26//===----------------------------------------------------------------------===// 27// 28// RaisePointerReferences - Try to eliminate as many pointer arithmetic 29// expressions as possible, by converting expressions to use getelementptr and 30// friends. 31// 32FunctionPass *createRaisePointerReferencesPass(); 33 34//===----------------------------------------------------------------------===// 35// 36// Constant Propagation Pass - A worklist driven constant propagation pass 37// 38FunctionPass *createConstantPropagationPass(); 39 40 41//===----------------------------------------------------------------------===// 42// 43// Sparse Conditional Constant Propagation Pass 44// 45FunctionPass *createSCCPPass(); 46 47 48//===----------------------------------------------------------------------===// 49// 50// DeadInstElimination - This pass quickly removes trivially dead instructions 51// without modifying the CFG of the function. It is a BasicBlockPass, so it 52// runs efficiently when queued next to other BasicBlockPass's. 53// 54FunctionPass *createDeadInstEliminationPass(); 55 56 57//===----------------------------------------------------------------------===// 58// 59// DeadCodeElimination - This pass is more powerful than DeadInstElimination, 60// because it is worklist driven that can potentially revisit instructions when 61// their other instructions become dead, to eliminate chains of dead 62// computations. 63// 64FunctionPass *createDeadCodeEliminationPass(); 65 66//===----------------------------------------------------------------------===// 67// 68// DeadStoreElimination - This pass deletes stores that are post-dominated by 69// must-aliased stores and are not loaded used between the stores. 70// 71FunctionPass *createDeadStoreEliminationPass(); 72 73//===----------------------------------------------------------------------===// 74// 75// AggressiveDCE - This pass uses the SSA based Aggressive DCE algorithm. This 76// algorithm assumes instructions are dead until proven otherwise, which makes 77// it more successful are removing non-obviously dead instructions. 78// 79FunctionPass *createAggressiveDCEPass(); 80 81 82//===----------------------------------------------------------------------===// 83// 84// Scalar Replacement of Aggregates - Break up alloca's of aggregates into 85// multiple allocas if possible. 86// 87FunctionPass *createScalarReplAggregatesPass(); 88 89//===----------------------------------------------------------------------===// 90// 91// DecomposeMultiDimRefs - Convert multi-dimensional references consisting of 92// any combination of 2 or more array and structure indices into a sequence of 93// instructions (using getelementpr and cast) so that each instruction has at 94// most one index (except structure references, which need an extra leading 95// index of [0]). 96 97// This pass decomposes all multi-dimensional references in a function. 98FunctionPass *createDecomposeMultiDimRefsPass(); 99 100// This function decomposes a single instance of such a reference. 101// Return value: true if the instruction was replaced; false otherwise. 102// 103bool DecomposeArrayRef(GetElementPtrInst* GEP); 104 105//===----------------------------------------------------------------------===// 106// 107// GCSE - This pass is designed to be a very quick global transformation that 108// eliminates global common subexpressions from a function. It does this by 109// examining the SSA value graph of the function, instead of doing slow 110// bit-vector computations. 111// 112FunctionPass *createGCSEPass(); 113 114 115//===----------------------------------------------------------------------===// 116// 117// InductionVariableSimplify - Transform induction variables in a program to all 118// use a single canonical induction variable per loop. 119// 120FunctionPass *createIndVarSimplifyPass(); 121 122 123//===----------------------------------------------------------------------===// 124// 125// InstructionCombining - Combine instructions to form fewer, simple 126// instructions. This pass does not modify the CFG, and has a tendency to 127// make instructions dead, so a subsequent DCE pass is useful. 128// 129// This pass combines things like: 130// %Y = add int 1, %X 131// %Z = add int 1, %Y 132// into: 133// %Z = add int 2, %X 134// 135FunctionPass *createInstructionCombiningPass(); 136 137 138//===----------------------------------------------------------------------===// 139// 140// LICM - This pass is a loop invariant code motion and memory promotion pass. 141// 142FunctionPass *createLICMPass(); 143 144//===----------------------------------------------------------------------===// 145// 146// LoopStrengthReduce - This pass is strength reduces GEP instructions that use 147// a loop's canonical induction variable as one of their indices. 148// 149FunctionPass *createLoopStrengthReducePass(); 150 151//===----------------------------------------------------------------------===// 152// 153// LoopUnswitch - This pass is a simple loop unswitching pass. 154// 155FunctionPass *createLoopUnswitchPass(); 156 157 158//===----------------------------------------------------------------------===// 159// 160// LoopUnroll - This pass is a simple loop unrolling pass. 161// 162FunctionPass *createLoopUnrollPass(); 163 164//===----------------------------------------------------------------------===// 165// 166// This pass is used to promote memory references to be register references. A 167// simple example of the transformation performed by this pass is: 168// 169// FROM CODE TO CODE 170// %X = alloca int, uint 1 ret int 42 171// store int 42, int *%X 172// %Y = load int* %X 173// ret int %Y 174// 175FunctionPass *createPromoteMemoryToRegister(); 176 177 178//===----------------------------------------------------------------------===// 179// 180// This pass reassociates commutative expressions in an order that is designed 181// to promote better constant propagation, GCSE, LICM, PRE... 182// 183// For example: 4 + (x + 5) -> x + (4 + 5) 184// 185FunctionPass *createReassociatePass(); 186 187//===----------------------------------------------------------------------===// 188// 189// This pass eliminates correlated conditions, such as these: 190// if (X == 0) 191// if (X > 2) ; // Known false 192// else 193// Y = X * Z; // = 0 194// 195FunctionPass *createCorrelatedExpressionEliminationPass(); 196 197//===----------------------------------------------------------------------===// 198// 199// TailDuplication - Eliminate unconditional branches through controlled code 200// duplication, creating simpler CFG structures. 201// 202FunctionPass *createTailDuplicationPass(); 203 204 205//===----------------------------------------------------------------------===// 206// 207// CFG Simplification - Merge basic blocks, eliminate unreachable blocks, 208// simplify terminator instructions, etc... 209// 210FunctionPass *createCFGSimplificationPass(); 211 212 213//===----------------------------------------------------------------------===// 214// 215// BreakCriticalEdges pass - Break all of the critical edges in the CFG by 216// inserting a dummy basic block. This pass may be "required" by passes that 217// cannot deal with critical edges. For this usage, a pass must call: 218// 219// AU.addRequiredID(BreakCriticalEdgesID); 220// 221// This pass obviously invalidates the CFG, but can update forward dominator 222// (set, immediate dominators, tree, and frontier) information. 223// 224FunctionPass *createBreakCriticalEdgesPass(); 225extern const PassInfo *BreakCriticalEdgesID; 226 227//===----------------------------------------------------------------------===// 228// 229// LoopSimplify pass - Insert Pre-header blocks into the CFG for every function 230// in the module. This pass updates dominator information, loop information, 231// and does not add critical edges to the CFG. 232// 233// AU.addRequiredID(LoopSimplifyID); 234// 235FunctionPass *createLoopSimplifyPass(); 236extern const PassInfo *LoopSimplifyID; 237 238//===----------------------------------------------------------------------===// 239// 240// This pass eliminates call instructions to the current function which occur 241// immediately before return instructions. 242// 243FunctionPass *createTailCallEliminationPass(); 244 245 246//===----------------------------------------------------------------------===// 247// This pass convert malloc and free instructions to %malloc & %free function 248// calls. 249// 250FunctionPass *createLowerAllocationsPass(); 251 252//===----------------------------------------------------------------------===// 253// This pass converts SwitchInst instructions into a sequence of chained binary 254// branch instructions. 255// 256FunctionPass *createLowerSwitchPass(); 257 258//===----------------------------------------------------------------------===// 259// This pass converts SelectInst instructions into conditional branch and PHI 260// instructions. If the OnlyFP flag is set to true, then only floating point 261// select instructions are lowered. 262// 263FunctionPass *createLowerSelectPass(bool OnlyFP = false); 264 265//===----------------------------------------------------------------------===// 266// This pass converts invoke and unwind instructions to use sjlj exception 267// handling mechanisms. Note that after this pass runs the CFG is not entirely 268// accurate (exceptional control flow edges are not correct anymore) so only 269// very simple things should be done after the lowerinvoke pass has run (like 270// generation of native code). This should *NOT* be used as a general purpose 271// "my LLVM-to-LLVM pass doesn't support the invoke instruction yet" lowering 272// pass. 273// 274FunctionPass *createLowerInvokePass(); 275extern const PassInfo *LowerInvokePassID; 276 277 278//===----------------------------------------------------------------------===// 279/// createLowerGCPass - This function returns an instance of the "lowergc" 280/// pass, which lowers garbage collection intrinsics to normal LLVM code. 281/// 282FunctionPass *createLowerGCPass(); 283 284//===----------------------------------------------------------------------===// 285// Returns a pass which converts all instances of ConstantExpression 286// into regular LLVM instructions. 287FunctionPass* createLowerConstantExpressionsPass(); 288 289 290//===----------------------------------------------------------------------===// 291// 292// These functions removes symbols from functions and modules. 293// 294FunctionPass *createSymbolStrippingPass(); 295FunctionPass *createFullSymbolStrippingPass(); 296 297} // End llvm namespace 298 299#endif 300