Revert r85346 change to control tail merging by CodeGenOpt::Level.
[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 PassInfo;
25   class TargetLowering;
26   class RegisterCoalescer;
27   class raw_ostream;
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(raw_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   /// LocalRegisterAllocation Pass - This pass register allocates the input code
91   /// a basic block at a time, yielding code better than the simple register
92   /// allocator, but not as good as a global allocator.
93   ///
94   FunctionPass *createLocalRegisterAllocator();
95
96   /// LinearScanRegisterAllocation Pass - This pass implements the linear scan
97   /// register allocation algorithm, a global register allocator.
98   ///
99   FunctionPass *createLinearScanRegisterAllocator();
100
101   /// PBQPRegisterAllocation Pass - This pass implements the Partitioned Boolean
102   /// Quadratic Prograaming (PBQP) based register allocator.
103   ///
104   FunctionPass *createPBQPRegisterAllocator();
105
106   /// SimpleRegisterCoalescing Pass - Coalesce all copies possible.  Can run
107   /// independently of the register allocator.
108   ///
109   RegisterCoalescer *createSimpleRegisterCoalescer();
110
111   /// PrologEpilogCodeInserter Pass - This pass inserts prolog and epilog code,
112   /// and eliminates abstract frame references.
113   ///
114   FunctionPass *createPrologEpilogCodeInserter();
115   
116   /// LowerSubregs Pass - This pass lowers subregs to register-register copies
117   /// which yields suboptimal, but correct code if the register allocator
118   /// cannot coalesce all subreg operations during allocation.
119   ///
120   FunctionPass *createLowerSubregsPass();
121
122   /// createPostRAScheduler - This pass performs post register allocation
123   /// scheduling.
124   FunctionPass *createPostRAScheduler(CodeGenOpt::Level OptLevel);
125
126   /// BranchFolding Pass - This pass performs machine code CFG based
127   /// optimizations to delete branches to branches, eliminate branches to
128   /// successor blocks (creating fall throughs), and eliminating branches over
129   /// branches.
130   FunctionPass *createBranchFoldingPass(bool DefaultEnableTailMerge);
131
132   /// IfConverter Pass - This pass performs machine code if conversion.
133   FunctionPass *createIfConverterPass();
134
135   /// Code Placement Pass - This pass optimize code placement and aligns loop
136   /// headers to target specific alignment boundary.
137   FunctionPass *createCodePlacementOptPass();
138
139   /// DebugLabelFoldingPass - This pass prunes out redundant debug labels.  This
140   /// allows a debug emitter to determine if the range of two labels is empty,
141   /// by seeing if the labels map to the same reduced label.
142   FunctionPass *createDebugLabelFoldingPass();
143
144   /// getRegisterAllocator - This creates an instance of the register allocator
145   /// for the Sparc.
146   FunctionPass *getRegisterAllocator(TargetMachine &T);
147
148   /// IntrinsicLowering Pass - Performs target-independent LLVM IR
149   /// transformations for highly portable strategies.
150   FunctionPass *createGCLoweringPass();
151   
152   /// MachineCodeAnalysis Pass - Target-independent pass to mark safe points in
153   /// machine code. Must be added very late during code generation, just prior
154   /// to output, and importantly after all CFG transformations (such as branch
155   /// folding).
156   FunctionPass *createGCMachineCodeAnalysisPass();
157   
158   /// Deleter Pass - Releases GC metadata.
159   /// 
160   FunctionPass *createGCInfoDeleter();
161   
162   /// Creates a pass to print GC metadata.
163   /// 
164   FunctionPass *createGCInfoPrinter(raw_ostream &OS);
165   
166   /// createMachineLICMPass - This pass performs LICM on machine instructions.
167   /// 
168   FunctionPass *createMachineLICMPass();
169
170   /// createMachineSinkingPass - This pass performs sinking on machine
171   /// instructions.
172   FunctionPass *createMachineSinkingPass();
173
174   /// createStackSlotColoringPass - This pass performs stack slot coloring.
175   FunctionPass *createStackSlotColoringPass(bool);
176
177   /// createStackProtectorPass - This pass adds stack protectors to functions.
178   FunctionPass *createStackProtectorPass(const TargetLowering *tli);
179
180   /// createMachineVerifierPass - This pass verifies cenerated machine code
181   /// instructions for correctness.
182   ///
183   /// @param allowPhysDoubleDefs ignore double definitions of
184   ///        registers. Useful before LiveVariables has run.
185   FunctionPass *createMachineVerifierPass(bool allowDoubleDefs);
186
187   /// createDwarfEHPass - This pass mulches exception handling code into a form
188   /// adapted to code generation.  Required if using dwarf exception handling.
189   FunctionPass *createDwarfEHPass(const TargetLowering *tli, bool fast);
190
191   /// createSjLjEHPass - This pass adapts exception handling code to use
192   /// the GCC-style builtin setjmp/longjmp (sjlj) to handling EH control flow.
193   FunctionPass *createSjLjEHPass(const TargetLowering *tli);
194
195 } // End llvm namespace
196
197 #endif