Scalar.h revision 234353
1//===-- Scalar.h - Scalar Transformations -----------------------*- C++ -*-===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// 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 FunctionPass; 21class Pass; 22class GetElementPtrInst; 23class PassInfo; 24class TerminatorInst; 25class TargetLowering; 26 27//===----------------------------------------------------------------------===// 28// 29// ConstantPropagation - A worklist driven constant propagation pass 30// 31FunctionPass *createConstantPropagationPass(); 32 33//===----------------------------------------------------------------------===// 34// 35// SCCP - Sparse conditional constant propagation. 36// 37FunctionPass *createSCCPPass(); 38 39//===----------------------------------------------------------------------===// 40// 41// DeadInstElimination - This pass quickly removes trivially dead instructions 42// without modifying the CFG of the function. It is a BasicBlockPass, so it 43// runs efficiently when queued next to other BasicBlockPass's. 44// 45Pass *createDeadInstEliminationPass(); 46 47//===----------------------------------------------------------------------===// 48// 49// DeadCodeElimination - This pass is more powerful than DeadInstElimination, 50// because it is worklist driven that can potentially revisit instructions when 51// their other instructions become dead, to eliminate chains of dead 52// computations. 53// 54FunctionPass *createDeadCodeEliminationPass(); 55 56//===----------------------------------------------------------------------===// 57// 58// DeadStoreElimination - This pass deletes stores that are post-dominated by 59// must-aliased stores and are not loaded used between the stores. 60// 61FunctionPass *createDeadStoreEliminationPass(); 62 63//===----------------------------------------------------------------------===// 64// 65// AggressiveDCE - This pass uses the SSA based Aggressive DCE algorithm. This 66// algorithm assumes instructions are dead until proven otherwise, which makes 67// it more successful are removing non-obviously dead instructions. 68// 69FunctionPass *createAggressiveDCEPass(); 70 71//===----------------------------------------------------------------------===// 72// 73// ScalarReplAggregates - Break up alloca's of aggregates into multiple allocas 74// if possible. 75// 76FunctionPass *createScalarReplAggregatesPass(signed Threshold = -1, 77 bool UseDomTree = true); 78 79//===----------------------------------------------------------------------===// 80// 81// InductionVariableSimplify - Transform induction variables in a program to all 82// use a single canonical induction variable per loop. 83// 84Pass *createIndVarSimplifyPass(); 85 86//===----------------------------------------------------------------------===// 87// 88// InstructionCombining - Combine instructions to form fewer, simple 89// instructions. This pass does not modify the CFG, and has a tendency to make 90// instructions dead, so a subsequent DCE pass is useful. 91// 92// This pass combines things like: 93// %Y = add int 1, %X 94// %Z = add int 1, %Y 95// into: 96// %Z = add int 2, %X 97// 98FunctionPass *createInstructionCombiningPass(); 99 100//===----------------------------------------------------------------------===// 101// 102// LICM - This pass is a loop invariant code motion and memory promotion pass. 103// 104Pass *createLICMPass(); 105 106//===----------------------------------------------------------------------===// 107// 108// LoopStrengthReduce - This pass is strength reduces GEP instructions that use 109// a loop's canonical induction variable as one of their indices. It takes an 110// optional parameter used to consult the target machine whether certain 111// transformations are profitable. 112// 113Pass *createLoopStrengthReducePass(const TargetLowering *TLI = 0); 114 115Pass *createGlobalMergePass(const TargetLowering *TLI = 0); 116 117//===----------------------------------------------------------------------===// 118// 119// LoopUnswitch - This pass is a simple loop unswitching pass. 120// 121Pass *createLoopUnswitchPass(bool OptimizeForSize = false); 122 123//===----------------------------------------------------------------------===// 124// 125// LoopInstSimplify - This pass simplifies instructions in a loop's body. 126// 127Pass *createLoopInstSimplifyPass(); 128 129//===----------------------------------------------------------------------===// 130// 131// LoopUnroll - This pass is a simple loop unrolling pass. 132// 133Pass *createLoopUnrollPass(int Threshold = -1, int Count = -1, int AllowPartial = -1); 134 135//===----------------------------------------------------------------------===// 136// 137// LoopRotate - This pass is a simple loop rotating pass. 138// 139Pass *createLoopRotatePass(); 140 141//===----------------------------------------------------------------------===// 142// 143// LoopIdiom - This pass recognizes and replaces idioms in loops. 144// 145Pass *createLoopIdiomPass(); 146 147//===----------------------------------------------------------------------===// 148// 149// PromoteMemoryToRegister - This pass is used to promote memory references to 150// be register references. A simple example of the transformation performed by 151// this pass is: 152// 153// FROM CODE TO CODE 154// %X = alloca i32, i32 1 ret i32 42 155// store i32 42, i32 *%X 156// %Y = load i32* %X 157// ret i32 %Y 158// 159FunctionPass *createPromoteMemoryToRegisterPass(); 160 161//===----------------------------------------------------------------------===// 162// 163// DemoteRegisterToMemoryPass - This pass is used to demote registers to memory 164// references. In basically undoes the PromoteMemoryToRegister pass to make cfg 165// hacking easier. 166// 167FunctionPass *createDemoteRegisterToMemoryPass(); 168extern char &DemoteRegisterToMemoryID; 169 170//===----------------------------------------------------------------------===// 171// 172// Reassociate - This pass reassociates commutative expressions in an order that 173// is designed to promote better constant propagation, GCSE, LICM, PRE... 174// 175// For example: 4 + (x + 5) -> x + (4 + 5) 176// 177FunctionPass *createReassociatePass(); 178 179//===----------------------------------------------------------------------===// 180// 181// JumpThreading - Thread control through mult-pred/multi-succ blocks where some 182// preds always go to some succ. 183// 184FunctionPass *createJumpThreadingPass(); 185 186//===----------------------------------------------------------------------===// 187// 188// CFGSimplification - Merge basic blocks, eliminate unreachable blocks, 189// simplify terminator instructions, etc... 190// 191FunctionPass *createCFGSimplificationPass(); 192 193//===----------------------------------------------------------------------===// 194// 195// BreakCriticalEdges - Break all of the critical edges in the CFG by inserting 196// a dummy basic block. This pass may be "required" by passes that cannot deal 197// with critical edges. For this usage, a pass must call: 198// 199// AU.addRequiredID(BreakCriticalEdgesID); 200// 201// This pass obviously invalidates the CFG, but can update forward dominator 202// (set, immediate dominators, tree, and frontier) information. 203// 204FunctionPass *createBreakCriticalEdgesPass(); 205extern char &BreakCriticalEdgesID; 206 207//===----------------------------------------------------------------------===// 208// 209// LoopSimplify - Insert Pre-header blocks into the CFG for every function in 210// the module. This pass updates dominator information, loop information, and 211// does not add critical edges to the CFG. 212// 213// AU.addRequiredID(LoopSimplifyID); 214// 215Pass *createLoopSimplifyPass(); 216extern char &LoopSimplifyID; 217 218//===----------------------------------------------------------------------===// 219// 220// TailCallElimination - This pass eliminates call instructions to the current 221// function which occur immediately before return instructions. 222// 223FunctionPass *createTailCallEliminationPass(); 224 225//===----------------------------------------------------------------------===// 226// 227// LowerSwitch - This pass converts SwitchInst instructions into a sequence of 228// chained binary branch instructions. 229// 230FunctionPass *createLowerSwitchPass(); 231extern char &LowerSwitchID; 232 233//===----------------------------------------------------------------------===// 234// 235// LowerInvoke - This pass converts invoke and unwind instructions to use sjlj 236// exception handling mechanisms. Note that after this pass runs the CFG is not 237// entirely accurate (exceptional control flow edges are not correct anymore) so 238// only very simple things should be done after the lowerinvoke pass has run 239// (like generation of native code). This should *NOT* be used as a general 240// purpose "my LLVM-to-LLVM pass doesn't support the invoke instruction yet" 241// lowering pass. 242// 243FunctionPass *createLowerInvokePass(const TargetLowering *TLI = 0); 244FunctionPass *createLowerInvokePass(const TargetLowering *TLI, 245 bool useExpensiveEHSupport); 246extern char &LowerInvokePassID; 247 248//===----------------------------------------------------------------------===// 249// 250// BlockPlacement - This pass reorders basic blocks in order to increase the 251// number of fall-through conditional branches. 252// 253FunctionPass *createBlockPlacementPass(); 254 255//===----------------------------------------------------------------------===// 256// 257// LCSSA - This pass inserts phi nodes at loop boundaries to simplify other loop 258// optimizations. 259// 260Pass *createLCSSAPass(); 261extern char &LCSSAID; 262 263//===----------------------------------------------------------------------===// 264// 265// EarlyCSE - This pass performs a simple and fast CSE pass over the dominator 266// tree. 267// 268FunctionPass *createEarlyCSEPass(); 269 270//===----------------------------------------------------------------------===// 271// 272// GVN - This pass performs global value numbering and redundant load 273// elimination cotemporaneously. 274// 275FunctionPass *createGVNPass(bool NoLoads = false); 276 277//===----------------------------------------------------------------------===// 278// 279// MemCpyOpt - This pass performs optimizations related to eliminating memcpy 280// calls and/or combining multiple stores into memset's. 281// 282FunctionPass *createMemCpyOptPass(); 283 284//===----------------------------------------------------------------------===// 285// 286// LoopDeletion - This pass performs DCE of non-infinite loops that it 287// can prove are dead. 288// 289Pass *createLoopDeletionPass(); 290 291//===----------------------------------------------------------------------===// 292// 293/// createSimplifyLibCallsPass - This pass optimizes specific calls to 294/// specific well-known (library) functions. 295FunctionPass *createSimplifyLibCallsPass(); 296 297//===----------------------------------------------------------------------===// 298// 299// CodeGenPrepare - This pass prepares a function for instruction selection. 300// 301FunctionPass *createCodeGenPreparePass(const TargetLowering *TLI = 0); 302 303//===----------------------------------------------------------------------===// 304// 305// InstructionNamer - Give any unnamed non-void instructions "tmp" names. 306// 307FunctionPass *createInstructionNamerPass(); 308extern char &InstructionNamerID; 309 310//===----------------------------------------------------------------------===// 311// 312// Sink - Code Sinking 313// 314FunctionPass *createSinkingPass(); 315 316//===----------------------------------------------------------------------===// 317// 318// LowerAtomic - Lower atomic intrinsics to non-atomic form 319// 320Pass *createLowerAtomicPass(); 321 322//===----------------------------------------------------------------------===// 323// 324// ValuePropagation - Propagate CFG-derived value information 325// 326Pass *createCorrelatedValuePropagationPass(); 327 328//===----------------------------------------------------------------------===// 329// 330// ObjCARCAPElim - ObjC ARC autorelease pool elimination. 331// 332Pass *createObjCARCAPElimPass(); 333 334//===----------------------------------------------------------------------===// 335// 336// ObjCARCExpand - ObjC ARC preliminary simplifications. 337// 338Pass *createObjCARCExpandPass(); 339 340//===----------------------------------------------------------------------===// 341// 342// ObjCARCContract - Late ObjC ARC cleanups. 343// 344Pass *createObjCARCContractPass(); 345 346//===----------------------------------------------------------------------===// 347// 348// ObjCARCOpt - ObjC ARC optimization. 349// 350Pass *createObjCARCOptPass(); 351 352//===----------------------------------------------------------------------===// 353// 354// InstructionSimplifier - Remove redundant instructions. 355// 356FunctionPass *createInstructionSimplifierPass(); 357extern char &InstructionSimplifierID; 358 359 360//===----------------------------------------------------------------------===// 361// 362// LowerExpectIntriniscs - Removes llvm.expect intrinsics and creates 363// "block_weights" metadata. 364FunctionPass *createLowerExpectIntrinsicPass(); 365 366 367} // End llvm namespace 368 369#endif 370