1 //===-- Scalar.h - Scalar Transformations ------------------------*- C++ -*-==//
3 // This header file defines prototypes for accessor functions that expose passes
4 // in the Scalar transformations library.
6 //===----------------------------------------------------------------------===//
8 #ifndef LLVM_TRANSFORMS_SCALAR_H
9 #define LLVM_TRANSFORMS_SCALAR_H
14 //===----------------------------------------------------------------------===//
16 // Constant Propogation Pass - A worklist driven constant propogation pass
18 Pass *createConstantPropogationPass();
21 //===----------------------------------------------------------------------===//
23 // Sparse Conditional Constant Propogation Pass
25 Pass *createSCCPPass();
28 //===----------------------------------------------------------------------===//
30 // DeadInstElimination - This pass quickly removes trivially dead instructions
31 // without modifying the CFG of the function. It is a BasicBlockPass, so it
32 // runs efficiently when queued next to other BasicBlockPass's.
34 Pass *createDeadInstEliminationPass();
37 //===----------------------------------------------------------------------===//
39 // DeadCodeElimination - This pass is more powerful than DeadInstElimination,
40 // because it is worklist driven that can potentially revisit instructions when
41 // their other instructions become dead, to eliminate chains of dead
44 Pass *createDeadCodeEliminationPass();
47 //===----------------------------------------------------------------------===//
49 // AggressiveDCE - This pass uses the SSA based Aggressive DCE algorithm. This
50 // algorithm assumes instructions are dead until proven otherwise, which makes
51 // it more successful are removing non-obviously dead instructions.
53 Pass *createAggressiveDCEPass();
56 //===----------------------------------------------------------------------===//
58 // DecomposeMultiDimRefs - Convert multi-dimensional references consisting of
59 // any combination of 2 or more array and structure indices into a sequence of
60 // instructions (using getelementpr and cast) so that each instruction has at
61 // most one index (except structure references, which need an extra leading
64 Pass *createDecomposeMultiDimRefsPass();
67 //===----------------------------------------------------------------------===//
69 // GCSE - This pass is designed to be a very quick global transformation that
70 // eliminates global common subexpressions from a function. It does this by
71 // examining the SSA value graph of the function, instead of doing slow
72 // bit-vector computations.
74 Pass *createGCSEPass();
77 //===----------------------------------------------------------------------===//
79 // InductionVariableSimplify - Transform induction variables in a program to all
80 // use a single cannonical induction variable per loop.
82 Pass *createIndVarSimplifyPass();
85 //===----------------------------------------------------------------------===//
87 // InstructionCombining - Combine instructions to form fewer, simple
88 // instructions. This pass does not modify the CFG, and has a tendancy to
89 // make instructions dead, so a subsequent DCE pass is useful.
91 // This pass combines things like:
97 Pass *createInstructionCombiningPass();
100 //===----------------------------------------------------------------------===//
102 // LICM - This pass is a simple natural loop based loop invariant code motion
105 Pass *createLICMPass();
108 //===----------------------------------------------------------------------===//
110 // PiNodeInsertion - This pass inserts single entry Phi nodes into basic blocks
111 // that are preceeded by a conditional branch, where the branch gives
112 // information about the operands of the condition. For example, this C code:
113 // if (x == 0) { ... = x + 4;
116 // x2 = phi(x); // Node that can hold data flow information about X
119 // Since the direction of the condition branch gives information about X itself
120 // (whether or not it is zero), some passes (like value numbering or ABCD) can
121 // use the inserted Phi/Pi nodes as a place to attach information, in this case
122 // saying that X has a value of 0 in this scope. The power of this analysis
123 // information is that "in the scope" translates to "for all uses of x2".
125 // This special form of Phi node is refered to as a Pi node, following the
126 // terminology defined in the "Array Bounds Checks on Demand" paper.
128 Pass *createPiNodeInsertionPass();
131 //===----------------------------------------------------------------------===//
133 // This pass is used to promote memory references to be register references. A
134 // simple example of the transformation performed by this pass is:
137 // %X = alloca int, uint 1 ret int 42
138 // store int 42, int *%X
142 Pass *createPromoteMemoryToRegister();
145 //===----------------------------------------------------------------------===//
147 // This pass reassociates commutative expressions in an order that is designed
148 // to promote better constant propogation, GCSE, LICM, PRE...
150 // For example: 4 + (x + 5) -> x + (4 + 5)
152 Pass *createReassociatePass();
155 //===----------------------------------------------------------------------===//
157 // CFG Simplification - Merge basic blocks, eliminate unreachable blocks,
158 // simplify terminator instructions, etc...
160 Pass *createCFGSimplificationPass();
163 //===----------------------------------------------------------------------===//
164 // These two passes convert malloc and free instructions to and from %malloc &
165 // %free function calls. The LowerAllocations transformation is a target
166 // dependant tranformation because it depends on the size of data types and
167 // alignment constraints.
169 Pass *createLowerAllocationsPass(const TargetData &TD);
170 Pass *createRaiseAllocationsPass();
173 //===----------------------------------------------------------------------===//
175 // These functions removes symbols from functions and modules.
177 Pass *createSymbolStrippingPass();
178 Pass *createFullSymbolStrippingPass();