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 /// SimpleRegisterCoalescing pass. Aggressively coalesces every register
72 extern char &SimpleRegisterCoalescingID;
74 /// TwoAddressInstruction pass - This pass reduces two-address instructions to
75 /// use two operands. This destroys SSA information but it is desired by
76 /// register allocators.
77 extern char &TwoAddressInstructionPassID;
79 /// UnreachableMachineBlockElimination pass - This pass removes unreachable
80 /// machine basic blocks.
81 extern char &UnreachableMachineBlockElimID;
83 /// DeadMachineInstructionElim pass - This pass removes dead machine
86 FunctionPass *createDeadMachineInstructionElimPass();
88 /// Creates a register allocator as the user specified on the command line, or
89 /// picks one that matches OptLevel.
91 FunctionPass *createRegisterAllocator(CodeGenOpt::Level OptLevel);
93 /// FastRegisterAllocation Pass - This pass register allocates as fast as
94 /// possible. It is best suited for debug code where live ranges are short.
96 FunctionPass *createFastRegisterAllocator();
98 /// BasicRegisterAllocation Pass - This pass implements a degenerate global
99 /// register allocator using the basic regalloc framework.
101 FunctionPass *createBasicRegisterAllocator();
103 /// LinearScanRegisterAllocation Pass - This pass implements the linear scan
104 /// register allocation algorithm, a global register allocator.
106 FunctionPass *createLinearScanRegisterAllocator();
108 /// PBQPRegisterAllocation Pass - This pass implements the Partitioned Boolean
109 /// Quadratic Prograaming (PBQP) based register allocator.
111 FunctionPass *createDefaultPBQPRegisterAllocator();
113 /// SimpleRegisterCoalescing Pass - Coalesce all copies possible. Can run
114 /// independently of the register allocator.
116 RegisterCoalescer *createSimpleRegisterCoalescer();
118 /// PrologEpilogCodeInserter Pass - This pass inserts prolog and epilog code,
119 /// and eliminates abstract frame references.
121 FunctionPass *createPrologEpilogCodeInserter();
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.
127 FunctionPass *createLowerSubregsPass();
129 /// createPostRAScheduler - This pass performs post register allocation
131 FunctionPass *createPostRAScheduler(CodeGenOpt::Level OptLevel);
133 /// BranchFolding Pass - This pass performs machine code CFG based
134 /// optimizations to delete branches to branches, eliminate branches to
135 /// successor blocks (creating fall throughs), and eliminating branches over
137 FunctionPass *createBranchFoldingPass(bool DefaultEnableTailMerge);
139 /// TailDuplicate Pass - Duplicate blocks with unconditional branches
140 /// into tails of their predecessors.
141 FunctionPass *createTailDuplicatePass(bool PreRegAlloc = false);
143 /// IfConverter Pass - This pass performs machine code if conversion.
144 FunctionPass *createIfConverterPass();
146 /// Code Placement Pass - This pass optimize code placement and aligns loop
147 /// headers to target specific alignment boundary.
148 FunctionPass *createCodePlacementOptPass();
150 /// IntrinsicLowering Pass - Performs target-independent LLVM IR
151 /// transformations for highly portable strategies.
152 FunctionPass *createGCLoweringPass();
154 /// MachineCodeAnalysis Pass - Target-independent pass to mark safe points in
155 /// machine code. Must be added very late during code generation, just prior
156 /// to output, and importantly after all CFG transformations (such as branch
158 FunctionPass *createGCMachineCodeAnalysisPass();
160 /// Deleter Pass - Releases GC metadata.
162 FunctionPass *createGCInfoDeleter();
164 /// Creates a pass to print GC metadata.
166 FunctionPass *createGCInfoPrinter(raw_ostream &OS);
168 /// createMachineCSEPass - This pass performs global CSE on machine
170 FunctionPass *createMachineCSEPass();
172 /// createMachineLICMPass - This pass performs LICM on machine instructions.
174 FunctionPass *createMachineLICMPass(bool PreRegAlloc = true);
176 /// createMachineSinkingPass - This pass performs sinking on machine
178 FunctionPass *createMachineSinkingPass();
180 /// createPeepholeOptimizerPass - This pass performs peephole optimizations -
181 /// like extension and comparison eliminations.
182 FunctionPass *createPeepholeOptimizerPass();
184 /// createOptimizePHIsPass - This pass optimizes machine instruction PHIs
185 /// to take advantage of opportunities created during DAG legalization.
186 FunctionPass *createOptimizePHIsPass();
188 /// createStackSlotColoringPass - This pass performs stack slot coloring.
189 FunctionPass *createStackSlotColoringPass(bool);
191 /// createStackProtectorPass - This pass adds stack protectors to functions.
192 FunctionPass *createStackProtectorPass(const TargetLowering *tli);
194 /// createMachineVerifierPass - This pass verifies cenerated machine code
195 /// instructions for correctness.
196 FunctionPass *createMachineVerifierPass();
198 /// createDwarfEHPass - This pass mulches exception handling code into a form
199 /// adapted to code generation. Required if using dwarf exception handling.
200 FunctionPass *createDwarfEHPass(const TargetMachine *tm);
202 /// createSjLjEHPass - This pass adapts exception handling code to use
203 /// the GCC-style builtin setjmp/longjmp (sjlj) to handling EH control flow.
204 FunctionPass *createSjLjEHPass(const TargetLowering *tli);
206 /// createLocalStackSlotAllocationPass - This pass assigns local frame
207 /// indices to stack slots relative to one another and allocates
208 /// base registers to access them when it is estimated by the target to
209 /// be out of range of normal frame pointer or stack pointer index
211 FunctionPass *createLocalStackSlotAllocationPass();
213 } // End llvm namespace