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 RegisterCoalescer;
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 /// MachineDominators pass - This pass is a machine dominators analysis pass.
50 extern char &MachineDominatorsID;
52 /// PHIElimination pass - This pass eliminates machine instruction PHI nodes
53 /// by inserting copy instructions. This destroys SSA information, but is the
54 /// desired input for some register allocators. This pass is "required" by
55 /// these register allocator like this: AU.addRequiredID(PHIEliminationID);
57 extern char &PHIEliminationID;
59 /// StrongPHIElimination pass - This pass eliminates machine instruction PHI
60 /// nodes by inserting copy instructions. This destroys SSA information, but
61 /// is the desired input for some register allocators. This pass is
62 /// "required" by these register allocator like this:
63 /// AU.addRequiredID(PHIEliminationID);
64 /// This pass is still in development
65 extern char &StrongPHIEliminationID;
67 extern char &PreAllocSplittingID;
69 /// LiveStacks pass. An analysis keeping track of the liveness of stack slots.
70 extern char &LiveStacksID;
72 /// SimpleRegisterCoalescing pass. Aggressively coalesces every register
75 extern char &SimpleRegisterCoalescingID;
77 /// TwoAddressInstruction pass - This pass reduces two-address instructions to
78 /// use two operands. This destroys SSA information but it is desired by
79 /// register allocators.
80 extern char &TwoAddressInstructionPassID;
82 /// UnreachableMachineBlockElimination pass - This pass removes unreachable
83 /// machine basic blocks.
84 extern char &UnreachableMachineBlockElimID;
86 /// DeadMachineInstructionElim pass - This pass removes dead machine
89 FunctionPass *createDeadMachineInstructionElimPass();
91 /// Creates a register allocator as the user specified on the command line, or
92 /// picks one that matches OptLevel.
94 FunctionPass *createRegisterAllocator(CodeGenOpt::Level OptLevel);
96 /// FastRegisterAllocation Pass - This pass register allocates as fast as
97 /// possible. It is best suited for debug code where live ranges are short.
99 FunctionPass *createFastRegisterAllocator();
101 /// BasicRegisterAllocation Pass - This pass implements a degenerate global
102 /// register allocator using the basic regalloc framework.
104 FunctionPass *createBasicRegisterAllocator();
106 /// Greedy register allocation pass - This pass implements a global register
107 /// allocator for optimized builds.
109 FunctionPass *createGreedyRegisterAllocator();
111 /// LinearScanRegisterAllocation Pass - This pass implements the linear scan
112 /// register allocation algorithm, a global register allocator.
114 FunctionPass *createLinearScanRegisterAllocator();
116 /// PBQPRegisterAllocation Pass - This pass implements the Partitioned Boolean
117 /// Quadratic Prograaming (PBQP) based register allocator.
119 FunctionPass *createDefaultPBQPRegisterAllocator();
121 /// SimpleRegisterCoalescing Pass - Coalesce all copies possible. Can run
122 /// independently of the register allocator.
124 RegisterCoalescer *createSimpleRegisterCoalescer();
126 /// PrologEpilogCodeInserter Pass - This pass inserts prolog and epilog code,
127 /// and eliminates abstract frame references.
129 FunctionPass *createPrologEpilogCodeInserter();
131 /// LowerSubregs Pass - This pass lowers subregs to register-register copies
132 /// which yields suboptimal, but correct code if the register allocator
133 /// cannot coalesce all subreg operations during allocation.
135 FunctionPass *createLowerSubregsPass();
137 /// createPostRAScheduler - This pass performs post register allocation
139 FunctionPass *createPostRAScheduler(CodeGenOpt::Level OptLevel);
141 /// BranchFolding Pass - This pass performs machine code CFG based
142 /// optimizations to delete branches to branches, eliminate branches to
143 /// successor blocks (creating fall throughs), and eliminating branches over
145 FunctionPass *createBranchFoldingPass(bool DefaultEnableTailMerge);
147 /// TailDuplicate Pass - Duplicate blocks with unconditional branches
148 /// into tails of their predecessors.
149 FunctionPass *createTailDuplicatePass(bool PreRegAlloc = false);
151 /// IfConverter Pass - This pass performs machine code if conversion.
152 FunctionPass *createIfConverterPass();
154 /// Code Placement Pass - This pass optimize code placement and aligns loop
155 /// headers to target specific alignment boundary.
156 FunctionPass *createCodePlacementOptPass();
158 /// IntrinsicLowering Pass - Performs target-independent LLVM IR
159 /// transformations for highly portable strategies.
160 FunctionPass *createGCLoweringPass();
162 /// MachineCodeAnalysis Pass - Target-independent pass to mark safe points in
163 /// machine code. Must be added very late during code generation, just prior
164 /// to output, and importantly after all CFG transformations (such as branch
166 FunctionPass *createGCMachineCodeAnalysisPass();
168 /// Deleter Pass - Releases GC metadata.
170 FunctionPass *createGCInfoDeleter();
172 /// Creates a pass to print GC metadata.
174 FunctionPass *createGCInfoPrinter(raw_ostream &OS);
176 /// createMachineCSEPass - This pass performs global CSE on machine
178 FunctionPass *createMachineCSEPass();
180 /// createMachineLICMPass - This pass performs LICM on machine instructions.
182 FunctionPass *createMachineLICMPass(bool PreRegAlloc = true);
184 /// createMachineSinkingPass - This pass performs sinking on machine
186 FunctionPass *createMachineSinkingPass();
188 /// createPeepholeOptimizerPass - This pass performs peephole optimizations -
189 /// like extension and comparison eliminations.
190 FunctionPass *createPeepholeOptimizerPass();
192 /// createOptimizePHIsPass - This pass optimizes machine instruction PHIs
193 /// to take advantage of opportunities created during DAG legalization.
194 FunctionPass *createOptimizePHIsPass();
196 /// createStackSlotColoringPass - This pass performs stack slot coloring.
197 FunctionPass *createStackSlotColoringPass(bool);
199 /// createStackProtectorPass - This pass adds stack protectors to functions.
200 FunctionPass *createStackProtectorPass(const TargetLowering *tli);
202 /// createMachineVerifierPass - This pass verifies cenerated machine code
203 /// instructions for correctness.
204 FunctionPass *createMachineVerifierPass();
206 /// createDwarfEHPass - This pass mulches exception handling code into a form
207 /// adapted to code generation. Required if using dwarf exception handling.
208 FunctionPass *createDwarfEHPass(const TargetMachine *tm);
210 /// createSjLjEHPass - This pass adapts exception handling code to use
211 /// the GCC-style builtin setjmp/longjmp (sjlj) to handling EH control flow.
212 FunctionPass *createSjLjEHPass(const TargetLowering *tli);
214 /// createLocalStackSlotAllocationPass - This pass assigns local frame
215 /// indices to stack slots relative to one another and allocates
216 /// base registers to access them when it is estimated by the target to
217 /// be out of range of normal frame pointer or stack pointer index
219 FunctionPass *createLocalStackSlotAllocationPass();
221 /// createExpandISelPseudosPass - This pass expands pseudo-instructions.
223 FunctionPass *createExpandISelPseudosPass();
225 } // End llvm namespace