Turn the EdgeBundles class into a stand-alone machine CFG 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   /// UnreachableMachineBlockElimination pass - This pass removes unreachable
92   /// machine basic blocks.
93   extern char &UnreachableMachineBlockElimID;
94
95   /// DeadMachineInstructionElim pass - This pass removes dead machine
96   /// instructions.
97   ///
98   FunctionPass *createDeadMachineInstructionElimPass();
99
100   /// Creates a register allocator as the user specified on the command line, or
101   /// picks one that matches OptLevel.
102   ///
103   FunctionPass *createRegisterAllocator(CodeGenOpt::Level OptLevel);
104
105   /// FastRegisterAllocation Pass - This pass register allocates as fast as
106   /// possible. It is best suited for debug code where live ranges are short.
107   ///
108   FunctionPass *createFastRegisterAllocator();
109
110   /// BasicRegisterAllocation Pass - This pass implements a degenerate global
111   /// register allocator using the basic regalloc framework.
112   ///
113   FunctionPass *createBasicRegisterAllocator();
114
115   /// Greedy register allocation pass - This pass implements a global register
116   /// allocator for optimized builds.
117   ///
118   FunctionPass *createGreedyRegisterAllocator();
119
120   /// LinearScanRegisterAllocation Pass - This pass implements the linear scan
121   /// register allocation algorithm, a global register allocator.
122   ///
123   FunctionPass *createLinearScanRegisterAllocator();
124
125   /// PBQPRegisterAllocation Pass - This pass implements the Partitioned Boolean
126   /// Quadratic Prograaming (PBQP) based register allocator.
127   ///
128   FunctionPass *createDefaultPBQPRegisterAllocator();
129
130   /// SimpleRegisterCoalescing Pass - Coalesce all copies possible.  Can run
131   /// independently of the register allocator.
132   ///
133   RegisterCoalescer *createSimpleRegisterCoalescer();
134
135   /// PrologEpilogCodeInserter Pass - This pass inserts prolog and epilog code,
136   /// and eliminates abstract frame references.
137   ///
138   FunctionPass *createPrologEpilogCodeInserter();
139
140   /// LowerSubregs Pass - This pass lowers subregs to register-register copies
141   /// which yields suboptimal, but correct code if the register allocator
142   /// cannot coalesce all subreg operations during allocation.
143   ///
144   FunctionPass *createLowerSubregsPass();
145
146   /// createPostRAScheduler - This pass performs post register allocation
147   /// scheduling.
148   FunctionPass *createPostRAScheduler(CodeGenOpt::Level OptLevel);
149
150   /// BranchFolding Pass - This pass performs machine code CFG based
151   /// optimizations to delete branches to branches, eliminate branches to
152   /// successor blocks (creating fall throughs), and eliminating branches over
153   /// branches.
154   FunctionPass *createBranchFoldingPass(bool DefaultEnableTailMerge);
155
156   /// TailDuplicate Pass - Duplicate blocks with unconditional branches
157   /// into tails of their predecessors.
158   FunctionPass *createTailDuplicatePass(bool PreRegAlloc = false);
159
160   /// IfConverter Pass - This pass performs machine code if conversion.
161   FunctionPass *createIfConverterPass();
162
163   /// Code Placement Pass - This pass optimize code placement and aligns loop
164   /// headers to target specific alignment boundary.
165   FunctionPass *createCodePlacementOptPass();
166
167   /// IntrinsicLowering Pass - Performs target-independent LLVM IR
168   /// transformations for highly portable strategies.
169   FunctionPass *createGCLoweringPass();
170
171   /// MachineCodeAnalysis Pass - Target-independent pass to mark safe points in
172   /// machine code. Must be added very late during code generation, just prior
173   /// to output, and importantly after all CFG transformations (such as branch
174   /// folding).
175   FunctionPass *createGCMachineCodeAnalysisPass();
176
177   /// Deleter Pass - Releases GC metadata.
178   ///
179   FunctionPass *createGCInfoDeleter();
180
181   /// Creates a pass to print GC metadata.
182   ///
183   FunctionPass *createGCInfoPrinter(raw_ostream &OS);
184
185   /// createMachineCSEPass - This pass performs global CSE on machine
186   /// instructions.
187   FunctionPass *createMachineCSEPass();
188
189   /// createMachineLICMPass - This pass performs LICM on machine instructions.
190   ///
191   FunctionPass *createMachineLICMPass(bool PreRegAlloc = true);
192
193   /// createMachineSinkingPass - This pass performs sinking on machine
194   /// instructions.
195   FunctionPass *createMachineSinkingPass();
196
197   /// createPeepholeOptimizerPass - This pass performs peephole optimizations -
198   /// like extension and comparison eliminations.
199   FunctionPass *createPeepholeOptimizerPass();
200
201   /// createOptimizePHIsPass - This pass optimizes machine instruction PHIs
202   /// to take advantage of opportunities created during DAG legalization.
203   FunctionPass *createOptimizePHIsPass();
204
205   /// createStackSlotColoringPass - This pass performs stack slot coloring.
206   FunctionPass *createStackSlotColoringPass(bool);
207
208   /// createStackProtectorPass - This pass adds stack protectors to functions.
209   FunctionPass *createStackProtectorPass(const TargetLowering *tli);
210
211   /// createMachineVerifierPass - This pass verifies cenerated machine code
212   /// instructions for correctness.
213   FunctionPass *createMachineVerifierPass(const char *Banner = 0);
214
215   /// createDwarfEHPass - This pass mulches exception handling code into a form
216   /// adapted to code generation.  Required if using dwarf exception handling.
217   FunctionPass *createDwarfEHPass(const TargetMachine *tm);
218
219   /// createSjLjEHPass - This pass adapts exception handling code to use
220   /// the GCC-style builtin setjmp/longjmp (sjlj) to handling EH control flow.
221   FunctionPass *createSjLjEHPass(const TargetLowering *tli);
222
223   /// createLocalStackSlotAllocationPass - This pass assigns local frame
224   /// indices to stack slots relative to one another and allocates
225   /// base registers to access them when it is estimated by the target to
226   /// be out of range of normal frame pointer or stack pointer index
227   /// addressing.
228   FunctionPass *createLocalStackSlotAllocationPass();
229
230   /// createExpandISelPseudosPass - This pass expands pseudo-instructions.
231   ///
232   FunctionPass *createExpandISelPseudosPass();
233
234 } // End llvm namespace
235
236 #endif