d8ec67f91632834879f94543c0c8561e5c4328cd
[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 <iosfwd>
19 #include <string>
20
21 namespace llvm {
22
23   class FunctionPass;
24   class PassInfo;
25   class TargetMachine;
26   class TargetLowering;
27   class RegisterCoalescer;
28
29   /// createUnreachableBlockEliminationPass - The LLVM code generator does not
30   /// work well with unreachable basic blocks (what live ranges make sense for a
31   /// block that cannot be reached?).  As such, a code generator should either
32   /// not instruction select unreachable blocks, or it can run this pass as it's
33   /// last LLVM modifying pass to clean up blocks that are not reachable from
34   /// the entry block.
35   FunctionPass *createUnreachableBlockEliminationPass();
36
37   /// MachineFunctionPrinter pass - This pass prints out the machine function to
38   /// the given stream, as a debugging tool.
39   FunctionPass *createMachineFunctionPrinterPass(std::ostream *OS,
40                                                  const std::string &Banner ="");
41
42   /// MachineLoopInfo pass - This pass is a loop analysis pass.
43   /// 
44   extern const PassInfo *const MachineLoopInfoID;
45
46   /// MachineDominators pass - This pass is a machine dominators analysis pass.
47   /// 
48   extern const PassInfo *const MachineDominatorsID;
49
50   /// PHIElimination pass - This pass eliminates machine instruction PHI nodes
51   /// by inserting copy instructions.  This destroys SSA information, but is the
52   /// desired input for some register allocators.  This pass is "required" by
53   /// these register allocator like this: AU.addRequiredID(PHIEliminationID);
54   ///
55   extern const PassInfo *const PHIEliminationID;
56   
57   /// StrongPHIElimination pass - This pass eliminates machine instruction PHI
58   /// nodes by inserting copy instructions.  This destroys SSA information, but
59   /// is the desired input for some register allocators.  This pass is
60   /// "required" by these register allocator like this:
61   ///    AU.addRequiredID(PHIEliminationID);
62   ///  This pass is still in development
63   extern const PassInfo *const StrongPHIEliminationID;
64
65   extern const PassInfo *const PreAllocSplittingID;
66
67   /// SimpleRegisterCoalescing pass.  Aggressively coalesces every register
68   /// copy it can.
69   ///
70   extern const PassInfo *const SimpleRegisterCoalescingID;
71
72   /// TwoAddressInstruction pass - This pass reduces two-address instructions to
73   /// use two operands. This destroys SSA information but it is desired by
74   /// register allocators.
75   extern const PassInfo *const TwoAddressInstructionPassID;
76
77   /// UnreachableMachineBlockElimination pass - This pass removes unreachable
78   /// machine basic blocks.
79   extern const PassInfo *const UnreachableMachineBlockElimID;
80
81   /// DeadMachineInstructionElim pass - This pass removes dead machine
82   /// instructions.
83   ///
84   FunctionPass *createDeadMachineInstructionElimPass();
85
86   /// Creates a register allocator as the user specified on the command line.
87   ///
88   FunctionPass *createRegisterAllocator();
89
90   /// SimpleRegisterAllocation Pass - This pass converts the input machine code
91   /// from SSA form to use explicit registers by spilling every register.  Wow,
92   /// great policy huh?
93   ///
94   FunctionPass *createSimpleRegisterAllocator();
95
96   /// LocalRegisterAllocation Pass - This pass register allocates the input code
97   /// a basic block at a time, yielding code better than the simple register
98   /// allocator, but not as good as a global allocator.
99   ///
100   FunctionPass *createLocalRegisterAllocator();
101
102   /// LinearScanRegisterAllocation Pass - This pass implements the linear scan
103   /// register allocation algorithm, a global register allocator.
104   ///
105   FunctionPass *createLinearScanRegisterAllocator();
106
107   /// PBQPRegisterAllocation Pass - This pass implements the Partitioned Boolean
108   /// Quadratic Prograaming (PBQP) based register allocator.
109   ///
110   FunctionPass *createPBQPRegisterAllocator();
111
112   /// SimpleRegisterCoalescing Pass - Coalesce all copies possible.  Can run
113   /// independently of the register allocator.
114   ///
115   RegisterCoalescer *createSimpleRegisterCoalescer();
116
117   /// PrologEpilogCodeInserter Pass - This pass inserts prolog and epilog code,
118   /// and eliminates abstract frame references.
119   ///
120   FunctionPass *createPrologEpilogCodeInserter();
121   
122   /// LowerSubregs Pass - This pass lowers subregs to register-register copies
123   /// which yields suboptimal, but correct code if the register allocator
124   /// cannot coalesce all subreg operations during allocation.
125   ///
126   FunctionPass *createLowerSubregsPass();
127
128   /// createPostRAScheduler - under development.
129   FunctionPass *createPostRAScheduler();
130
131   /// BranchFolding Pass - This pass performs machine code CFG based
132   /// optimizations to delete branches to branches, eliminate branches to
133   /// successor blocks (creating fall throughs), and eliminating branches over
134   /// branches.
135   FunctionPass *createBranchFoldingPass(bool DefaultEnableTailMerge);
136
137   /// IfConverter Pass - This pass performs machine code if conversion.
138   FunctionPass *createIfConverterPass();
139
140   /// Code Placement Pass - This pass optimize code placement and aligns loop
141   /// headers to target specific alignment boundary.
142   FunctionPass *createCodePlacementOptPass();
143
144   /// DebugLabelFoldingPass - This pass prunes out redundant debug labels.  This
145   /// allows a debug emitter to determine if the range of two labels is empty,
146   /// by seeing if the labels map to the same reduced label.
147   FunctionPass *createDebugLabelFoldingPass();
148
149   /// getRegisterAllocator - This creates an instance of the register allocator
150   /// for the Sparc.
151   FunctionPass *getRegisterAllocator(TargetMachine &T);
152
153   /// IntrinsicLowering Pass - Performs target-independent LLVM IR
154   /// transformations for highly portable strategies.
155   FunctionPass *createGCLoweringPass();
156   
157   /// MachineCodeAnalysis Pass - Target-independent pass to mark safe points in
158   /// machine code. Must be added very late during code generation, just prior
159   /// to output, and importantly after all CFG transformations (such as branch
160   /// folding).
161   FunctionPass *createGCMachineCodeAnalysisPass();
162   
163   /// Deleter Pass - Releases GC metadata.
164   /// 
165   FunctionPass *createGCInfoDeleter();
166   
167   /// Creates a pass to print GC metadata.
168   /// 
169   FunctionPass *createGCInfoPrinter(std::ostream &OS);
170   
171   /// createMachineLICMPass - This pass performs LICM on machine instructions.
172   /// 
173   FunctionPass *createMachineLICMPass();
174
175   /// createMachineSinkingPass - This pass performs sinking on machine
176   /// instructions.
177   FunctionPass *createMachineSinkingPass();
178
179   /// createStackSlotColoringPass - This pass performs stack slot coloring.
180   FunctionPass *createStackSlotColoringPass(bool);
181
182   /// createStackProtectorPass - This pass adds stack protectors to functions.
183   FunctionPass *createStackProtectorPass(const TargetLowering *tli);
184
185   /// createMachineVerifierPass - This pass verifies cenerated machine code
186   /// instructions for correctness.
187   ///
188   /// @param allowPhysDoubleDefs ignore double definitions of
189   ///        registers. Useful before LiveVariables has run.
190   FunctionPass *createMachineVerifierPass(bool allowDoubleDefs);
191
192   /// createDwarfEHPass - This pass mulches exception handling code into a form
193   /// adapted to code generation.  Required if using dwarf exception handling.
194   FunctionPass *createDwarfEHPass(const TargetLowering *tli, bool fast);
195
196   /// createSjLjEHPass - This pass adapts exception handling code to use
197   /// the GCC-style builtin setjmp/longjmp (sjlj) to handling EH control flow.
198   FunctionPass *createSjLjEHPass(const TargetLowering *tli);
199
200 } // End llvm namespace
201
202 #endif