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