More bundle related API additions.
[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 TargetRegisterClass;
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   /// LiveStacks pass. An analysis keeping track of the liveness of stack slots.
77   extern char &LiveStacksID;
78
79   /// TwoAddressInstruction pass - This pass reduces two-address instructions to
80   /// use two operands. This destroys SSA information but it is desired by
81   /// register allocators.
82   extern char &TwoAddressInstructionPassID;
83
84   /// RegisteCoalescer pass - This pass merges live ranges to eliminate copies.
85   extern char &RegisterCoalescerPassID;
86
87   /// MachineScheduler pass - This pass schedules machine instructions.
88   extern char &MachineSchedulerID;
89
90   /// SpillPlacement analysis. Suggest optimal placement of spill code between
91   /// basic blocks.
92   ///
93   extern char &SpillPlacementID;
94
95   /// UnreachableMachineBlockElimination pass - This pass removes unreachable
96   /// machine basic blocks.
97   extern char &UnreachableMachineBlockElimID;
98
99   /// DeadMachineInstructionElim pass - This pass removes dead machine
100   /// instructions.
101   ///
102   FunctionPass *createDeadMachineInstructionElimPass();
103
104   /// Creates a register allocator as the user specified on the command line, or
105   /// picks one that matches OptLevel.
106   ///
107   FunctionPass *createRegisterAllocator(CodeGenOpt::Level OptLevel);
108
109   /// FastRegisterAllocation Pass - This pass register allocates as fast as
110   /// possible. It is best suited for debug code where live ranges are short.
111   ///
112   FunctionPass *createFastRegisterAllocator();
113
114   /// BasicRegisterAllocation Pass - This pass implements a degenerate global
115   /// register allocator using the basic regalloc framework.
116   ///
117   FunctionPass *createBasicRegisterAllocator();
118
119   /// Greedy register allocation pass - This pass implements a global register
120   /// allocator for optimized builds.
121   ///
122   FunctionPass *createGreedyRegisterAllocator();
123
124   /// PBQPRegisterAllocation Pass - This pass implements the Partitioned Boolean
125   /// Quadratic Prograaming (PBQP) based register allocator.
126   ///
127   FunctionPass *createDefaultPBQPRegisterAllocator();
128
129   /// PrologEpilogCodeInserter Pass - This pass inserts prolog and epilog code,
130   /// and eliminates abstract frame references.
131   ///
132   FunctionPass *createPrologEpilogCodeInserter();
133
134   /// ExpandPostRAPseudos Pass - This pass expands pseudo instructions after
135   /// register allocation.
136   ///
137   FunctionPass *createExpandPostRAPseudosPass();
138
139   /// createPostRAScheduler - This pass performs post register allocation
140   /// scheduling.
141   FunctionPass *createPostRAScheduler(CodeGenOpt::Level OptLevel);
142
143   /// BranchFolding Pass - This pass performs machine code CFG based
144   /// optimizations to delete branches to branches, eliminate branches to
145   /// successor blocks (creating fall throughs), and eliminating branches over
146   /// branches.
147   FunctionPass *createBranchFoldingPass(bool DefaultEnableTailMerge);
148
149   /// TailDuplicate Pass - Duplicate blocks with unconditional branches
150   /// into tails of their predecessors.
151   FunctionPass *createTailDuplicatePass(bool PreRegAlloc = false);
152
153   /// IfConverter Pass - This pass performs machine code if conversion.
154   FunctionPass *createIfConverterPass();
155
156   /// MachineBlockPlacement Pass - This pass places basic blocks based on branch
157   /// probabilities.
158   FunctionPass *createMachineBlockPlacementPass();
159
160   /// MachineBlockPlacementStats Pass - This pass collects statistics about the
161   /// basic block placement using branch probabilities and block frequency
162   /// information.
163   FunctionPass *createMachineBlockPlacementStatsPass();
164
165   /// Code Placement Pass - This pass optimize code placement and aligns loop
166   /// headers to target specific alignment boundary.
167   FunctionPass *createCodePlacementOptPass();
168
169   /// IntrinsicLowering Pass - Performs target-independent LLVM IR
170   /// transformations for highly portable strategies.
171   FunctionPass *createGCLoweringPass();
172
173   /// MachineCodeAnalysis Pass - Target-independent pass to mark safe points in
174   /// machine code. Must be added very late during code generation, just prior
175   /// to output, and importantly after all CFG transformations (such as branch
176   /// folding).
177   FunctionPass *createGCMachineCodeAnalysisPass();
178
179   /// Deleter Pass - Releases GC metadata.
180   ///
181   FunctionPass *createGCInfoDeleter();
182
183   /// Creates a pass to print GC metadata.
184   ///
185   FunctionPass *createGCInfoPrinter(raw_ostream &OS);
186
187   /// createMachineCSEPass - This pass performs global CSE on machine
188   /// instructions.
189   FunctionPass *createMachineCSEPass();
190
191   /// createMachineLICMPass - This pass performs LICM on machine instructions.
192   ///
193   FunctionPass *createMachineLICMPass(bool PreRegAlloc = true);
194
195   /// createMachineSinkingPass - This pass performs sinking on machine
196   /// instructions.
197   FunctionPass *createMachineSinkingPass();
198
199   /// createMachineCopyPropagationPass - This pass performs copy propagation on
200   /// machine instructions.
201   FunctionPass *createMachineCopyPropagationPass();
202
203   /// createPeepholeOptimizerPass - This pass performs peephole optimizations -
204   /// like extension and comparison eliminations.
205   FunctionPass *createPeepholeOptimizerPass();
206
207   /// createOptimizePHIsPass - This pass optimizes machine instruction PHIs
208   /// to take advantage of opportunities created during DAG legalization.
209   FunctionPass *createOptimizePHIsPass();
210
211   /// createStackSlotColoringPass - This pass performs stack slot coloring.
212   FunctionPass *createStackSlotColoringPass(bool);
213
214   /// createStackProtectorPass - This pass adds stack protectors to functions.
215   FunctionPass *createStackProtectorPass(const TargetLowering *tli);
216
217   /// createMachineVerifierPass - This pass verifies cenerated machine code
218   /// instructions for correctness.
219   FunctionPass *createMachineVerifierPass(const char *Banner = 0);
220
221   /// createDwarfEHPass - This pass mulches exception handling code into a form
222   /// adapted to code generation.  Required if using dwarf exception handling.
223   FunctionPass *createDwarfEHPass(const TargetMachine *tm);
224
225   /// createSjLjEHPass - This pass adapts exception handling code to use
226   /// the GCC-style builtin setjmp/longjmp (sjlj) to handling EH control flow.
227   FunctionPass *createSjLjEHPass(const TargetLowering *tli);
228
229   /// createLocalStackSlotAllocationPass - This pass assigns local frame
230   /// indices to stack slots relative to one another and allocates
231   /// base registers to access them when it is estimated by the target to
232   /// be out of range of normal frame pointer or stack pointer index
233   /// addressing.
234   FunctionPass *createLocalStackSlotAllocationPass();
235
236   /// createExpandISelPseudosPass - This pass expands pseudo-instructions.
237   ///
238   FunctionPass *createExpandISelPseudosPass();
239
240   /// createExecutionDependencyFixPass - This pass fixes execution time
241   /// problems with dependent instructions, such as switching execution
242   /// domains to match.
243   ///
244   /// The pass will examine instructions using and defining registers in RC.
245   ///
246   FunctionPass *createExecutionDependencyFixPass(const TargetRegisterClass *RC);
247
248   /// createUnpackMachineBundles - This pass unpack machine instruction bundles.
249   ///
250   FunctionPass *createUnpackMachineBundlesPass();
251
252   /// createFinalizeMachineBundles - This pass finalize machine instruction
253   /// bundles (created earlier, e.g. during pre-RA scheduling).
254   ///
255   FunctionPass *createFinalizeMachineBundlesPass();
256
257 } // End llvm namespace
258
259 #endif