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