Scalar.h revision b8bcb086f7d4a74c40661c5c18134533a3f69fc9
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
11class Pass;
12
13//===----------------------------------------------------------------------===//
14//
15// Constant Propogation Pass - A worklist driven constant propogation pass
16//
17Pass *createConstantPropogationPass();
18
19
20//===----------------------------------------------------------------------===//
21//
22// Sparse Conditional Constant Propogation Pass
23//
24Pass *createSCCPPass();
25
26
27//===----------------------------------------------------------------------===//
28//
29// DeadInstElimination - This pass quickly removes trivially dead instructions
30// without modifying the CFG of the function.  It is a BasicBlockPass, so it
31// runs efficiently when queued next to other BasicBlockPass's.
32//
33Pass *createDeadInstEliminationPass();
34
35
36//===----------------------------------------------------------------------===//
37//
38// DeadCodeElimination - This pass is more powerful than DeadInstElimination,
39// because it is worklist driven that can potentially revisit instructions when
40// their other instructions become dead, to eliminate chains of dead
41// computations.
42//
43Pass *createDeadCodeEliminationPass();
44
45
46//===----------------------------------------------------------------------===//
47//
48// AggressiveDCE - This pass uses the SSA based Aggressive DCE algorithm.  This
49// algorithm assumes instructions are dead until proven otherwise, which makes
50// it more successful are removing non-obviously dead instructions.
51//
52Pass *createAggressiveDCEPass();
53
54
55//===----------------------------------------------------------------------===//
56//
57// DecomposeMultiDimRefs - Convert multi-dimensional references consisting of
58// any combination of 2 or more array and structure indices into a sequence of
59// instructions (using getelementpr and cast) so that each instruction has at
60// most one index (except structure references, which need an extra leading
61// index of [0]).
62//
63Pass *createDecomposeMultiDimRefsPass();
64
65
66//===----------------------------------------------------------------------===//
67//
68// GCSE - This pass is designed to be a very quick global transformation that
69// eliminates global common subexpressions from a function.  It does this by
70// examining the SSA value graph of the function, instead of doing slow
71// bit-vector computations.
72//
73Pass *createGCSEPass();
74
75
76//===----------------------------------------------------------------------===//
77//
78// InductionVariableSimplify - Transform induction variables in a program to all
79// use a single cannonical induction variable per loop.
80//
81Pass *createIndVarSimplifyPass();
82
83
84//===----------------------------------------------------------------------===//
85//
86// InstructionCombining - Combine instructions to form fewer, simple
87//   instructions.  This pass does not modify the CFG, and has a tendancy to
88//   make instructions dead, so a subsequent DCE pass is useful.
89//
90// This pass combines things like:
91//    %Y = add int 1, %X
92//    %Z = add int 1, %Y
93// into:
94//    %Z = add int 2, %X
95//
96Pass *createInstructionCombiningPass();
97
98
99//===----------------------------------------------------------------------===//
100//
101// LICM - This pass is a simple natural loop based loop invariant code motion
102// pass.
103//
104Pass *createLICMPass();
105
106
107//===----------------------------------------------------------------------===//
108//
109// PiNodeInsertion - This pass inserts single entry Phi nodes into basic blocks
110// that are preceeded by a conditional branch, where the branch gives
111// information about the operands of the condition.  For example, this C code:
112//   if (x == 0) { ... = x + 4;
113// becomes:
114//   if (x == 0) {
115//     x2 = phi(x);    // Node that can hold data flow information about X
116//     ... = x2 + 4;
117//
118// Since the direction of the condition branch gives information about X itself
119// (whether or not it is zero), some passes (like value numbering or ABCD) can
120// use the inserted Phi/Pi nodes as a place to attach information, in this case
121// saying that X has a value of 0 in this scope.  The power of this analysis
122// information is that "in the scope" translates to "for all uses of x2".
123//
124// This special form of Phi node is refered to as a Pi node, following the
125// terminology defined in the "Array Bounds Checks on Demand" paper.
126//
127Pass *createPiNodeInsertionPass();
128
129
130//===----------------------------------------------------------------------===//
131//
132// This pass is used to promote memory references to be register references.  A
133// simple example of the transformation performed by this pass is:
134//
135//        FROM CODE                           TO CODE
136//   %X = alloca int, uint 1                 ret int 42
137//   store int 42, int *%X
138//   %Y = load int* %X
139//   ret int %Y
140//
141Pass *createPromoteMemoryToRegister();
142
143
144//===----------------------------------------------------------------------===//
145//
146// This pass reassociates commutative expressions in an order that is designed
147// to promote better constant propogation, GCSE, LICM, PRE...
148//
149// For example:  4 + (x + 5)  ->  x + (4 + 5)
150//
151Pass *createReassociatePass();
152
153
154//===----------------------------------------------------------------------===//
155//
156// CFG Simplification - Merge basic blocks, eliminate unreachable blocks,
157// simplify terminator instructions, etc...
158//
159Pass *createCFGSimplificationPass();
160
161
162//===----------------------------------------------------------------------===//
163//
164// These functions removes symbols from functions and modules.
165//
166Pass *createSymbolStrippingPass();
167Pass *createFullSymbolStrippingPass();
168
169#endif
170