1 //===-- Passes.h - Target independent code generation passes ----*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file defines interfaces to access the target independent code generation
11 // passes provided by the LLVM backend.
13 //===----------------------------------------------------------------------===//
15 #ifndef LLVM_CODEGEN_PASSES_H
16 #define LLVM_CODEGEN_PASSES_H
18 #include "llvm/Target/TargetMachine.h"
24 class MachineFunctionPass;
27 class TargetRegisterClass;
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 run this pass as its
34 /// last LLVM modifying pass to clean up blocks that are not reachable from
36 FunctionPass *createUnreachableBlockEliminationPass();
38 /// MachineFunctionPrinter pass - This pass prints out the machine function to
39 /// the given stream as a debugging tool.
41 createMachineFunctionPrinterPass(raw_ostream &OS,
42 const std::string &Banner ="");
44 /// MachineLoopInfo pass - This pass is a loop analysis pass.
46 extern char &MachineLoopInfoID;
48 /// MachineLoopRanges pass - This pass is an on-demand loop coverage
51 extern char &MachineLoopRangesID;
53 /// MachineDominators pass - This pass is a machine dominators analysis pass.
55 extern char &MachineDominatorsID;
57 /// EdgeBundles analysis - Bundle machine CFG edges.
59 extern char &EdgeBundlesID;
61 /// PHIElimination pass - This pass eliminates machine instruction PHI nodes
62 /// by inserting copy instructions. This destroys SSA information, but is the
63 /// desired input for some register allocators. This pass is "required" by
64 /// these register allocator like this: AU.addRequiredID(PHIEliminationID);
66 extern char &PHIEliminationID;
68 /// StrongPHIElimination pass - This pass eliminates machine instruction PHI
69 /// nodes by inserting copy instructions. This destroys SSA information, but
70 /// is the desired input for some register allocators. This pass is
71 /// "required" by these register allocator like this:
72 /// AU.addRequiredID(PHIEliminationID);
73 /// This pass is still in development
74 extern char &StrongPHIEliminationID;
76 /// LiveStacks pass. An analysis keeping track of the liveness of stack slots.
77 extern char &LiveStacksID;
79 /// TwoAddressInstruction pass - This pass reduces two-address instructions to
80 /// use two operands. This destroys SSA information but it is desired by
81 /// register allocators.
82 extern char &TwoAddressInstructionPassID;
84 /// RegisteCoalescer pass - This pass merges live ranges to eliminate copies.
85 extern char &RegisterCoalescerPassID;
87 /// SpillPlacement analysis. Suggest optimal placement of spill code between
90 extern char &SpillPlacementID;
92 /// UnreachableMachineBlockElimination pass - This pass removes unreachable
93 /// machine basic blocks.
94 extern char &UnreachableMachineBlockElimID;
96 /// DeadMachineInstructionElim pass - This pass removes dead machine
99 FunctionPass *createDeadMachineInstructionElimPass();
101 /// Creates a register allocator as the user specified on the command line, or
102 /// picks one that matches OptLevel.
104 FunctionPass *createRegisterAllocator(CodeGenOpt::Level OptLevel);
106 /// FastRegisterAllocation Pass - This pass register allocates as fast as
107 /// possible. It is best suited for debug code where live ranges are short.
109 FunctionPass *createFastRegisterAllocator();
111 /// BasicRegisterAllocation Pass - This pass implements a degenerate global
112 /// register allocator using the basic regalloc framework.
114 FunctionPass *createBasicRegisterAllocator();
116 /// Greedy register allocation pass - This pass implements a global register
117 /// allocator for optimized builds.
119 FunctionPass *createGreedyRegisterAllocator();
121 /// PBQPRegisterAllocation Pass - This pass implements the Partitioned Boolean
122 /// Quadratic Prograaming (PBQP) based register allocator.
124 FunctionPass *createDefaultPBQPRegisterAllocator();
126 /// PrologEpilogCodeInserter Pass - This pass inserts prolog and epilog code,
127 /// and eliminates abstract frame references.
129 FunctionPass *createPrologEpilogCodeInserter();
131 /// ExpandPostRAPseudos Pass - This pass expands pseudo instructions after
132 /// register allocation.
134 FunctionPass *createExpandPostRAPseudosPass();
136 /// createPostRAScheduler - This pass performs post register allocation
138 FunctionPass *createPostRAScheduler(CodeGenOpt::Level OptLevel);
140 /// BranchFolding Pass - This pass performs machine code CFG based
141 /// optimizations to delete branches to branches, eliminate branches to
142 /// successor blocks (creating fall throughs), and eliminating branches over
144 FunctionPass *createBranchFoldingPass(bool DefaultEnableTailMerge);
146 /// TailDuplicate Pass - Duplicate blocks with unconditional branches
147 /// into tails of their predecessors.
148 FunctionPass *createTailDuplicatePass(bool PreRegAlloc = false);
150 /// IfConverter Pass - This pass performs machine code if conversion.
151 FunctionPass *createIfConverterPass();
153 /// MachineBlockPlacement Pass - This pass places basic blocks based on branch
155 FunctionPass *createMachineBlockPlacementPass();
157 /// MachineBlockPlacementStats Pass - This pass collects statistics about the
158 /// basic block placement using branch probabilities and block frequency
160 FunctionPass *createMachineBlockPlacementStatsPass();
162 /// Code Placement Pass - This pass optimize code placement and aligns loop
163 /// headers to target specific alignment boundary.
164 FunctionPass *createCodePlacementOptPass();
166 /// IntrinsicLowering Pass - Performs target-independent LLVM IR
167 /// transformations for highly portable strategies.
168 FunctionPass *createGCLoweringPass();
170 /// MachineCodeAnalysis Pass - Target-independent pass to mark safe points in
171 /// machine code. Must be added very late during code generation, just prior
172 /// to output, and importantly after all CFG transformations (such as branch
174 FunctionPass *createGCMachineCodeAnalysisPass();
176 /// Deleter Pass - Releases GC metadata.
178 FunctionPass *createGCInfoDeleter();
180 /// Creates a pass to print GC metadata.
182 FunctionPass *createGCInfoPrinter(raw_ostream &OS);
184 /// createMachineCSEPass - This pass performs global CSE on machine
186 FunctionPass *createMachineCSEPass();
188 /// createMachineLICMPass - This pass performs LICM on machine instructions.
190 FunctionPass *createMachineLICMPass(bool PreRegAlloc = true);
192 /// createMachineSinkingPass - This pass performs sinking on machine
194 FunctionPass *createMachineSinkingPass();
196 /// createMachineCopyPropagationPass - This pass performs copy propagation on
197 /// machine instructions.
198 FunctionPass *createMachineCopyPropagationPass();
200 /// createPeepholeOptimizerPass - This pass performs peephole optimizations -
201 /// like extension and comparison eliminations.
202 FunctionPass *createPeepholeOptimizerPass();
204 /// createOptimizePHIsPass - This pass optimizes machine instruction PHIs
205 /// to take advantage of opportunities created during DAG legalization.
206 FunctionPass *createOptimizePHIsPass();
208 /// createStackSlotColoringPass - This pass performs stack slot coloring.
209 FunctionPass *createStackSlotColoringPass(bool);
211 /// createStackProtectorPass - This pass adds stack protectors to functions.
212 FunctionPass *createStackProtectorPass(const TargetLowering *tli);
214 /// createMachineVerifierPass - This pass verifies cenerated machine code
215 /// instructions for correctness.
216 FunctionPass *createMachineVerifierPass(const char *Banner = 0);
218 /// createDwarfEHPass - This pass mulches exception handling code into a form
219 /// adapted to code generation. Required if using dwarf exception handling.
220 FunctionPass *createDwarfEHPass(const TargetMachine *tm);
222 /// createSjLjEHPass - This pass adapts exception handling code to use
223 /// the GCC-style builtin setjmp/longjmp (sjlj) to handling EH control flow.
224 FunctionPass *createSjLjEHPass(const TargetLowering *tli);
226 /// createLocalStackSlotAllocationPass - This pass assigns local frame
227 /// indices to stack slots relative to one another and allocates
228 /// base registers to access them when it is estimated by the target to
229 /// be out of range of normal frame pointer or stack pointer index
231 FunctionPass *createLocalStackSlotAllocationPass();
233 /// createExpandISelPseudosPass - This pass expands pseudo-instructions.
235 FunctionPass *createExpandISelPseudosPass();
237 /// createExecutionDependencyFixPass - This pass fixes execution time
238 /// problems with dependent instructions, such as switching execution
239 /// domains to match.
241 /// The pass will examine instructions using and defining registers in RC.
243 FunctionPass *createExecutionDependencyFixPass(const TargetRegisterClass *RC);
245 /// createUnpackMachineBundles - This pass unpack machine instruction bundles.
247 FunctionPass *createUnpackMachineBundlesPass();
249 } // End llvm namespace