Add the SpillPlacement analysis pass.
[oota-llvm.git] / include / llvm / CodeGen / Passes.h
1 //===-- Passes.h - Target independent code generation passes ----*- 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 file defines interfaces to access the target independent code generation
11 // passes provided by the LLVM backend.
12 //
13 //===----------------------------------------------------------------------===//
14
15 #ifndef LLVM_CODEGEN_PASSES_H
16 #define LLVM_CODEGEN_PASSES_H
17
18 #include "llvm/Target/TargetMachine.h"
19 #include <string>
20
21 namespace llvm {
22
23   class FunctionPass;
24   class MachineFunctionPass;
25   class PassInfo;
26   class TargetLowering;
27   class RegisterCoalescer;
28   class raw_ostream;
29
30   /// createUnreachableBlockEliminationPass - The LLVM code generator does not
31   /// work well with unreachable basic blocks (what live ranges make sense for a
32   /// block that cannot be reached?).  As such, a code generator should either
33   /// not instruction select unreachable blocks, or run this pass as its
34   /// last LLVM modifying pass to clean up blocks that are not reachable from
35   /// the entry block.
36   FunctionPass *createUnreachableBlockEliminationPass();
37
38   /// MachineFunctionPrinter pass - This pass prints out the machine function to
39   /// the given stream as a debugging tool.
40   MachineFunctionPass *
41   createMachineFunctionPrinterPass(raw_ostream &OS,
42                                    const std::string &Banner ="");
43
44   /// MachineLoopInfo pass - This pass is a loop analysis pass.
45   ///
46   extern char &MachineLoopInfoID;
47
48   /// MachineLoopRanges pass - This pass is an on-demand loop coverage
49   /// analysis pass.
50   ///
51   extern char &MachineLoopRangesID;
52
53   /// MachineDominators pass - This pass is a machine dominators analysis pass.
54   ///
55   extern char &MachineDominatorsID;
56
57   /// EdgeBundles analysis - Bundle machine CFG edges.
58   ///
59   extern char &EdgeBundlesID;
60
61   /// PHIElimination pass - This pass eliminates machine instruction PHI nodes
62   /// by inserting copy instructions.  This destroys SSA information, but is the
63   /// desired input for some register allocators.  This pass is "required" by
64   /// these register allocator like this: AU.addRequiredID(PHIEliminationID);
65   ///
66   extern char &PHIEliminationID;
67
68   /// StrongPHIElimination pass - This pass eliminates machine instruction PHI
69   /// nodes by inserting copy instructions.  This destroys SSA information, but
70   /// is the desired input for some register allocators.  This pass is
71   /// "required" by these register allocator like this:
72   ///    AU.addRequiredID(PHIEliminationID);
73   ///  This pass is still in development
74   extern char &StrongPHIEliminationID;
75
76   extern char &PreAllocSplittingID;
77
78   /// LiveStacks pass. An analysis keeping track of the liveness of stack slots.
79   extern char &LiveStacksID;
80
81   /// SimpleRegisterCoalescing pass.  Aggressively coalesces every register
82   /// copy it can.
83   ///
84   extern char &SimpleRegisterCoalescingID;
85
86   /// TwoAddressInstruction pass - This pass reduces two-address instructions to
87   /// use two operands. This destroys SSA information but it is desired by
88   /// register allocators.
89   extern char &TwoAddressInstructionPassID;
90
91   /// SpillPlacement analysis. Suggest optimal placement of spill code between
92   /// basic blocks.
93   ///
94   extern char &SpillPlacementID;
95
96   /// UnreachableMachineBlockElimination pass - This pass removes unreachable
97   /// machine basic blocks.
98   extern char &UnreachableMachineBlockElimID;
99
100   /// DeadMachineInstructionElim pass - This pass removes dead machine
101   /// instructions.
102   ///
103   FunctionPass *createDeadMachineInstructionElimPass();
104
105   /// Creates a register allocator as the user specified on the command line, or
106   /// picks one that matches OptLevel.
107   ///
108   FunctionPass *createRegisterAllocator(CodeGenOpt::Level OptLevel);
109
110   /// FastRegisterAllocation Pass - This pass register allocates as fast as
111   /// possible. It is best suited for debug code where live ranges are short.
112   ///
113   FunctionPass *createFastRegisterAllocator();
114
115   /// BasicRegisterAllocation Pass - This pass implements a degenerate global
116   /// register allocator using the basic regalloc framework.
117   ///
118   FunctionPass *createBasicRegisterAllocator();
119
120   /// Greedy register allocation pass - This pass implements a global register
121   /// allocator for optimized builds.
122   ///
123   FunctionPass *createGreedyRegisterAllocator();
124
125   /// LinearScanRegisterAllocation Pass - This pass implements the linear scan
126   /// register allocation algorithm, a global register allocator.
127   ///
128   FunctionPass *createLinearScanRegisterAllocator();
129
130   /// PBQPRegisterAllocation Pass - This pass implements the Partitioned Boolean
131   /// Quadratic Prograaming (PBQP) based register allocator.
132   ///
133   FunctionPass *createDefaultPBQPRegisterAllocator();
134
135   /// SimpleRegisterCoalescing Pass - Coalesce all copies possible.  Can run
136   /// independently of the register allocator.
137   ///
138   RegisterCoalescer *createSimpleRegisterCoalescer();
139
140   /// PrologEpilogCodeInserter Pass - This pass inserts prolog and epilog code,
141   /// and eliminates abstract frame references.
142   ///
143   FunctionPass *createPrologEpilogCodeInserter();
144
145   /// LowerSubregs Pass - This pass lowers subregs to register-register copies
146   /// which yields suboptimal, but correct code if the register allocator
147   /// cannot coalesce all subreg operations during allocation.
148   ///
149   FunctionPass *createLowerSubregsPass();
150
151   /// createPostRAScheduler - This pass performs post register allocation
152   /// scheduling.
153   FunctionPass *createPostRAScheduler(CodeGenOpt::Level OptLevel);
154
155   /// BranchFolding Pass - This pass performs machine code CFG based
156   /// optimizations to delete branches to branches, eliminate branches to
157   /// successor blocks (creating fall throughs), and eliminating branches over
158   /// branches.
159   FunctionPass *createBranchFoldingPass(bool DefaultEnableTailMerge);
160
161   /// TailDuplicate Pass - Duplicate blocks with unconditional branches
162   /// into tails of their predecessors.
163   FunctionPass *createTailDuplicatePass(bool PreRegAlloc = false);
164
165   /// IfConverter Pass - This pass performs machine code if conversion.
166   FunctionPass *createIfConverterPass();
167
168   /// Code Placement Pass - This pass optimize code placement and aligns loop
169   /// headers to target specific alignment boundary.
170   FunctionPass *createCodePlacementOptPass();
171
172   /// IntrinsicLowering Pass - Performs target-independent LLVM IR
173   /// transformations for highly portable strategies.
174   FunctionPass *createGCLoweringPass();
175
176   /// MachineCodeAnalysis Pass - Target-independent pass to mark safe points in
177   /// machine code. Must be added very late during code generation, just prior
178   /// to output, and importantly after all CFG transformations (such as branch
179   /// folding).
180   FunctionPass *createGCMachineCodeAnalysisPass();
181
182   /// Deleter Pass - Releases GC metadata.
183   ///
184   FunctionPass *createGCInfoDeleter();
185
186   /// Creates a pass to print GC metadata.
187   ///
188   FunctionPass *createGCInfoPrinter(raw_ostream &OS);
189
190   /// createMachineCSEPass - This pass performs global CSE on machine
191   /// instructions.
192   FunctionPass *createMachineCSEPass();
193
194   /// createMachineLICMPass - This pass performs LICM on machine instructions.
195   ///
196   FunctionPass *createMachineLICMPass(bool PreRegAlloc = true);
197
198   /// createMachineSinkingPass - This pass performs sinking on machine
199   /// instructions.
200   FunctionPass *createMachineSinkingPass();
201
202   /// createPeepholeOptimizerPass - This pass performs peephole optimizations -
203   /// like extension and comparison eliminations.
204   FunctionPass *createPeepholeOptimizerPass();
205
206   /// createOptimizePHIsPass - This pass optimizes machine instruction PHIs
207   /// to take advantage of opportunities created during DAG legalization.
208   FunctionPass *createOptimizePHIsPass();
209
210   /// createStackSlotColoringPass - This pass performs stack slot coloring.
211   FunctionPass *createStackSlotColoringPass(bool);
212
213   /// createStackProtectorPass - This pass adds stack protectors to functions.
214   FunctionPass *createStackProtectorPass(const TargetLowering *tli);
215
216   /// createMachineVerifierPass - This pass verifies cenerated machine code
217   /// instructions for correctness.
218   FunctionPass *createMachineVerifierPass(const char *Banner = 0);
219
220   /// createDwarfEHPass - This pass mulches exception handling code into a form
221   /// adapted to code generation.  Required if using dwarf exception handling.
222   FunctionPass *createDwarfEHPass(const TargetMachine *tm);
223
224   /// createSjLjEHPass - This pass adapts exception handling code to use
225   /// the GCC-style builtin setjmp/longjmp (sjlj) to handling EH control flow.
226   FunctionPass *createSjLjEHPass(const TargetLowering *tli);
227
228   /// createLocalStackSlotAllocationPass - This pass assigns local frame
229   /// indices to stack slots relative to one another and allocates
230   /// base registers to access them when it is estimated by the target to
231   /// be out of range of normal frame pointer or stack pointer index
232   /// addressing.
233   FunctionPass *createLocalStackSlotAllocationPass();
234
235   /// createExpandISelPseudosPass - This pass expands pseudo-instructions.
236   ///
237   FunctionPass *createExpandISelPseudosPass();
238
239 } // End llvm namespace
240
241 #endif