Reapply r110396, with fixes to appease the Linux buildbot gods.
[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 it can run this pass as it's
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   /// MachineDominators pass - This pass is a machine dominators analysis pass.
49   /// 
50   extern char &MachineDominatorsID;
51
52   /// PHIElimination pass - This pass eliminates machine instruction PHI nodes
53   /// by inserting copy instructions.  This destroys SSA information, but is the
54   /// desired input for some register allocators.  This pass is "required" by
55   /// these register allocator like this: AU.addRequiredID(PHIEliminationID);
56   ///
57   extern char &PHIEliminationID;
58   
59   /// StrongPHIElimination pass - This pass eliminates machine instruction PHI
60   /// nodes by inserting copy instructions.  This destroys SSA information, but
61   /// is the desired input for some register allocators.  This pass is
62   /// "required" by these register allocator like this:
63   ///    AU.addRequiredID(PHIEliminationID);
64   ///  This pass is still in development
65   extern char &StrongPHIEliminationID;
66
67   extern char &PreAllocSplittingID;
68
69   /// SimpleRegisterCoalescing pass.  Aggressively coalesces every register
70   /// copy it can.
71   ///
72   extern char &SimpleRegisterCoalescingID;
73
74   /// TwoAddressInstruction pass - This pass reduces two-address instructions to
75   /// use two operands. This destroys SSA information but it is desired by
76   /// register allocators.
77   extern char &TwoAddressInstructionPassID;
78
79   /// UnreachableMachineBlockElimination pass - This pass removes unreachable
80   /// machine basic blocks.
81   extern char &UnreachableMachineBlockElimID;
82
83   /// DeadMachineInstructionElim pass - This pass removes dead machine
84   /// instructions.
85   ///
86   FunctionPass *createDeadMachineInstructionElimPass();
87
88   /// Creates a register allocator as the user specified on the command line, or
89   /// picks one that matches OptLevel.
90   ///
91   FunctionPass *createRegisterAllocator(CodeGenOpt::Level OptLevel);
92
93   /// FastRegisterAllocation Pass - This pass register allocates as fast as
94   /// possible. It is best suited for debug code where live ranges are short.
95   ///
96   FunctionPass *createFastRegisterAllocator();
97
98   /// LinearScanRegisterAllocation Pass - This pass implements the linear scan
99   /// register allocation algorithm, a global register allocator.
100   ///
101   FunctionPass *createLinearScanRegisterAllocator();
102
103   /// PBQPRegisterAllocation Pass - This pass implements the Partitioned Boolean
104   /// Quadratic Prograaming (PBQP) based register allocator.
105   ///
106   FunctionPass *createPBQPRegisterAllocator();
107
108   /// SimpleRegisterCoalescing Pass - Coalesce all copies possible.  Can run
109   /// independently of the register allocator.
110   ///
111   RegisterCoalescer *createSimpleRegisterCoalescer();
112
113   /// PrologEpilogCodeInserter Pass - This pass inserts prolog and epilog code,
114   /// and eliminates abstract frame references.
115   ///
116   FunctionPass *createPrologEpilogCodeInserter();
117   
118   /// LowerSubregs Pass - This pass lowers subregs to register-register copies
119   /// which yields suboptimal, but correct code if the register allocator
120   /// cannot coalesce all subreg operations during allocation.
121   ///
122   FunctionPass *createLowerSubregsPass();
123
124   /// createPostRAScheduler - This pass performs post register allocation
125   /// scheduling.
126   FunctionPass *createPostRAScheduler(CodeGenOpt::Level OptLevel);
127
128   /// BranchFolding Pass - This pass performs machine code CFG based
129   /// optimizations to delete branches to branches, eliminate branches to
130   /// successor blocks (creating fall throughs), and eliminating branches over
131   /// branches.
132   FunctionPass *createBranchFoldingPass(bool DefaultEnableTailMerge);
133
134   /// TailDuplicate Pass - Duplicate blocks with unconditional branches
135   /// into tails of their predecessors.
136   FunctionPass *createTailDuplicatePass(bool PreRegAlloc = false);
137
138   /// IfConverter Pass - This pass performs machine code if conversion.
139   FunctionPass *createIfConverterPass();
140
141   /// Code Placement Pass - This pass optimize code placement and aligns loop
142   /// headers to target specific alignment boundary.
143   FunctionPass *createCodePlacementOptPass();
144
145   /// IntrinsicLowering Pass - Performs target-independent LLVM IR
146   /// transformations for highly portable strategies.
147   FunctionPass *createGCLoweringPass();
148   
149   /// MachineCodeAnalysis Pass - Target-independent pass to mark safe points in
150   /// machine code. Must be added very late during code generation, just prior
151   /// to output, and importantly after all CFG transformations (such as branch
152   /// folding).
153   FunctionPass *createGCMachineCodeAnalysisPass();
154   
155   /// Deleter Pass - Releases GC metadata.
156   /// 
157   FunctionPass *createGCInfoDeleter();
158   
159   /// Creates a pass to print GC metadata.
160   /// 
161   FunctionPass *createGCInfoPrinter(raw_ostream &OS);
162   
163   /// createMachineCSEPass - This pass performs global CSE on machine
164   /// instructions.
165   FunctionPass *createMachineCSEPass();
166
167   /// createMachineLICMPass - This pass performs LICM on machine instructions.
168   /// 
169   FunctionPass *createMachineLICMPass(bool PreRegAlloc = true);
170
171   /// createMachineSinkingPass - This pass performs sinking on machine
172   /// instructions.
173   FunctionPass *createMachineSinkingPass();
174
175   /// createOptimizeExtsPass - This pass performs sign / zero extension
176   /// optimization by increasing uses of extended values.
177   FunctionPass *createOptimizeExtsPass();
178
179   /// createOptimizePHIsPass - This pass optimizes machine instruction PHIs
180   /// to take advantage of opportunities created during DAG legalization.
181   FunctionPass *createOptimizePHIsPass();
182
183   /// createOptimizeCmpsPass - This pass performs redundant comparison removal
184   /// optimization.
185   FunctionPass *createOptimizeCmpsPass();
186
187   /// createStackSlotColoringPass - This pass performs stack slot coloring.
188   FunctionPass *createStackSlotColoringPass(bool);
189
190   /// createStackProtectorPass - This pass adds stack protectors to functions.
191   FunctionPass *createStackProtectorPass(const TargetLowering *tli);
192
193   /// createMachineVerifierPass - This pass verifies cenerated machine code
194   /// instructions for correctness.
195   FunctionPass *createMachineVerifierPass();
196
197   /// createDwarfEHPass - This pass mulches exception handling code into a form
198   /// adapted to code generation.  Required if using dwarf exception handling.
199   FunctionPass *createDwarfEHPass(const TargetMachine *tm, bool fast);
200
201   /// createSjLjEHPass - This pass adapts exception handling code to use
202   /// the GCC-style builtin setjmp/longjmp (sjlj) to handling EH control flow.
203   FunctionPass *createSjLjEHPass(const TargetLowering *tli);
204
205 } // End llvm namespace
206
207 #endif