- Fix SelectionDAG to generate correct CFGs.
[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   /// Creates a register allocator as the user specified on the command line.
79   ///
80   FunctionPass *createRegisterAllocator();
81
82   /// SimpleRegisterAllocation Pass - This pass converts the input machine code
83   /// from SSA form to use explicit registers by spilling every register.  Wow,
84   /// great policy huh?
85   ///
86   FunctionPass *createSimpleRegisterAllocator();
87
88   /// LocalRegisterAllocation Pass - This pass register allocates the input code
89   /// a basic block at a time, yielding code better than the simple register
90   /// allocator, but not as good as a global allocator.
91   ///
92   FunctionPass *createLocalRegisterAllocator();
93
94   /// BigBlockRegisterAllocation Pass - The BigBlock register allocator
95   /// munches single basic blocks at a time, like the local register
96   /// allocator.  While the BigBlock allocator is a little slower, and uses
97   /// somewhat more memory than the local register allocator, it tends to
98   /// yield the best allocations (of any of the allocators) for blocks that
99   /// have hundreds or thousands of instructions in sequence.
100   ///
101   FunctionPass *createBigBlockRegisterAllocator();
102
103   /// LinearScanRegisterAllocation Pass - This pass implements the linear scan
104   /// register allocation algorithm, a global register allocator.
105   ///
106   FunctionPass *createLinearScanRegisterAllocator();
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 - under development.
125   FunctionPass *createPostRAScheduler();
126
127   /// BranchFolding Pass - This pass performs machine code CFG based
128   /// optimizations to delete branches to branches, eliminate branches to
129   /// successor blocks (creating fall throughs), and eliminating branches over
130   /// branches.
131   FunctionPass *createBranchFoldingPass(bool DefaultEnableTailMerge);
132
133   /// IfConverter Pass - This pass performs machine code if conversion.
134   FunctionPass *createIfConverterPass();
135
136   /// LoopAligner Pass - This pass aligns loop headers to target specific
137   /// alignment boundary.
138   FunctionPass *createLoopAlignerPass();
139
140   /// DebugLabelFoldingPass - This pass prunes out redundant debug labels.  This
141   /// allows a debug emitter to determine if the range of two labels is empty,
142   /// by seeing if the labels map to the same reduced label.
143   FunctionPass *createDebugLabelFoldingPass();
144
145   /// MachineCodeDeletion Pass - This pass deletes all of the machine code for
146   /// the current function, which should happen after the function has been
147   /// emitted to a .s file or to memory.
148   FunctionPass *createMachineCodeDeleter();
149
150   /// getRegisterAllocator - This creates an instance of the register allocator
151   /// for the Sparc.
152   FunctionPass *getRegisterAllocator(TargetMachine &T);
153
154   /// IntrinsicLowering Pass - Performs target-independent LLVM IR
155   /// transformations for highly portable collectors.
156   FunctionPass *createGCLoweringPass();
157   
158   /// MachineCodeAnalysis Pass - Target-independent pass to mark safe points in
159   /// machine code. Must be added very late during code generation, just prior
160   /// to output, and importantly after all CFG transformations (such as branch
161   /// folding).
162   FunctionPass *createGCMachineCodeAnalysisPass();
163   
164   /// Deleter Pass - Releases collector metadata.
165   /// 
166   FunctionPass *createCollectorMetadataDeleter();
167   
168   /// Creates a pass to print collector metadata.
169   /// 
170   FunctionPass *createCollectorMetadataPrinter(std::ostream &OS);
171   
172   /// createMachineLICMPass - This pass performs LICM on machine instructions.
173   /// 
174   FunctionPass *createMachineLICMPass();
175
176   /// createMachineSinkingPass - This pass performs sinking on machine
177   /// instructions.
178   FunctionPass *createMachineSinkingPass();
179
180   /// createStackSlotColoringPass - This pass performs stack slot coloring.
181   FunctionPass *createStackSlotColoringPass();
182   
183 } // End llvm namespace
184
185 #endif