Merge the contents of ChangeAllocations.h into Scalar.h
[oota-llvm.git] / include / llvm / Transforms / Scalar.h
1 //===-- Scalar.h - Scalar Transformations ------------------------*- C++ -*-==//
2 //
3 // This header file defines prototypes for accessor functions that expose passes
4 // in the Scalar transformations library.
5 //
6 //===----------------------------------------------------------------------===//
7
8 #ifndef LLVM_TRANSFORMS_SCALAR_H
9 #define LLVM_TRANSFORMS_SCALAR_H
10
11 class Pass;
12 class TargetData;
13
14 //===----------------------------------------------------------------------===//
15 //
16 // Constant Propogation Pass - A worklist driven constant propogation pass
17 //
18 Pass *createConstantPropogationPass();
19
20
21 //===----------------------------------------------------------------------===//
22 //
23 // Sparse Conditional Constant Propogation Pass
24 //
25 Pass *createSCCPPass();
26
27
28 //===----------------------------------------------------------------------===//
29 //
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.
33 //
34 Pass *createDeadInstEliminationPass();
35
36
37 //===----------------------------------------------------------------------===//
38 //
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
42 // computations.
43 //
44 Pass *createDeadCodeEliminationPass();
45
46
47 //===----------------------------------------------------------------------===//
48 //
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.
52 //
53 Pass *createAggressiveDCEPass();
54
55
56 //===----------------------------------------------------------------------===//
57 // 
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
62 // index of [0]).
63 //
64 Pass *createDecomposeMultiDimRefsPass();
65
66
67 //===----------------------------------------------------------------------===//
68 //
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.
73 //
74 Pass *createGCSEPass();
75
76
77 //===----------------------------------------------------------------------===//
78 //
79 // InductionVariableSimplify - Transform induction variables in a program to all
80 // use a single cannonical induction variable per loop.
81 //
82 Pass *createIndVarSimplifyPass();
83
84
85 //===----------------------------------------------------------------------===//
86 //
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.
90 //
91 // This pass combines things like:
92 //    %Y = add int 1, %X
93 //    %Z = add int 1, %Y
94 // into:
95 //    %Z = add int 2, %X
96 //
97 Pass *createInstructionCombiningPass();
98
99
100 //===----------------------------------------------------------------------===//
101 //
102 // LICM - This pass is a simple natural loop based loop invariant code motion
103 // pass.
104 //
105 Pass *createLICMPass();
106
107
108 //===----------------------------------------------------------------------===//
109 //
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;
114 // becomes:
115 //   if (x == 0) {
116 //     x2 = phi(x);    // Node that can hold data flow information about X
117 //     ... = x2 + 4;
118 //
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".
124 //
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.
127 //
128 Pass *createPiNodeInsertionPass();
129
130
131 //===----------------------------------------------------------------------===//
132 //
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:
135 //
136 //        FROM CODE                           TO CODE
137 //   %X = alloca int, uint 1                 ret int 42
138 //   store int 42, int *%X
139 //   %Y = load int* %X
140 //   ret int %Y
141 //
142 Pass *createPromoteMemoryToRegister();
143
144
145 //===----------------------------------------------------------------------===//
146 //
147 // This pass reassociates commutative expressions in an order that is designed
148 // to promote better constant propogation, GCSE, LICM, PRE...
149 //
150 // For example:  4 + (x + 5)  ->  x + (4 + 5)
151 //
152 Pass *createReassociatePass();
153
154
155 //===----------------------------------------------------------------------===//
156 //
157 // CFG Simplification - Merge basic blocks, eliminate unreachable blocks,
158 // simplify terminator instructions, etc...
159 //
160 Pass *createCFGSimplificationPass();
161
162
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.
168 //
169 Pass *createLowerAllocationsPass(const TargetData &TD);
170 Pass *createRaiseAllocationsPass();
171
172
173 //===----------------------------------------------------------------------===//
174 //
175 // These functions removes symbols from functions and modules.
176 //
177 Pass *createSymbolStrippingPass();
178 Pass *createFullSymbolStrippingPass();
179
180 #endif