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 it can run this pass as it's
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 const PassInfo *const MachineLoopInfoID;
48 /// MachineDominators pass - This pass is a machine dominators analysis pass.
50 extern const PassInfo *const 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 const PassInfo *const 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 const PassInfo *const StrongPHIEliminationID;
67 extern const PassInfo *const PreAllocSplittingID;
69 /// SimpleRegisterCoalescing pass. Aggressively coalesces every register
72 extern const PassInfo *const 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 const PassInfo *const TwoAddressInstructionPassID;
79 /// UnreachableMachineBlockElimination pass - This pass removes unreachable
80 /// machine basic blocks.
81 extern const PassInfo *const 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 /// LocalRegisterAllocation Pass - This pass register allocates the input code
94 /// a basic block at a time, yielding code better than the simple register
95 /// allocator, but not as good as a global allocator.
97 FunctionPass *createLocalRegisterAllocator();
99 /// FastRegisterAllocation Pass - This pass register allocates as fast as
100 /// possible. It is best suited for debug code where live ranges are short.
102 FunctionPass *createFastRegisterAllocator();
104 /// LinearScanRegisterAllocation Pass - This pass implements the linear scan
105 /// register allocation algorithm, a global register allocator.
107 FunctionPass *createLinearScanRegisterAllocator();
109 /// PBQPRegisterAllocation Pass - This pass implements the Partitioned Boolean
110 /// Quadratic Prograaming (PBQP) based register allocator.
112 FunctionPass *createPBQPRegisterAllocator();
114 /// SimpleRegisterCoalescing Pass - Coalesce all copies possible. Can run
115 /// independently of the register allocator.
117 RegisterCoalescer *createSimpleRegisterCoalescer();
119 /// PrologEpilogCodeInserter Pass - This pass inserts prolog and epilog code,
120 /// and eliminates abstract frame references.
122 FunctionPass *createPrologEpilogCodeInserter();
124 /// LowerSubregs Pass - This pass lowers subregs to register-register copies
125 /// which yields suboptimal, but correct code if the register allocator
126 /// cannot coalesce all subreg operations during allocation.
128 FunctionPass *createLowerSubregsPass();
130 /// createPostRAScheduler - This pass performs post register allocation
132 FunctionPass *createPostRAScheduler(CodeGenOpt::Level OptLevel);
134 /// BranchFolding Pass - This pass performs machine code CFG based
135 /// optimizations to delete branches to branches, eliminate branches to
136 /// successor blocks (creating fall throughs), and eliminating branches over
138 FunctionPass *createBranchFoldingPass(bool DefaultEnableTailMerge);
140 /// TailDuplicate Pass - Duplicate blocks with unconditional branches
141 /// into tails of their predecessors.
142 FunctionPass *createTailDuplicatePass(bool PreRegAlloc = false);
144 /// IfConverter Pass - This pass performs machine code if conversion.
145 FunctionPass *createIfConverterPass();
147 /// Code Placement Pass - This pass optimize code placement and aligns loop
148 /// headers to target specific alignment boundary.
149 FunctionPass *createCodePlacementOptPass();
151 /// IntrinsicLowering Pass - Performs target-independent LLVM IR
152 /// transformations for highly portable strategies.
153 FunctionPass *createGCLoweringPass();
155 /// MachineCodeAnalysis Pass - Target-independent pass to mark safe points in
156 /// machine code. Must be added very late during code generation, just prior
157 /// to output, and importantly after all CFG transformations (such as branch
159 FunctionPass *createGCMachineCodeAnalysisPass();
161 /// Deleter Pass - Releases GC metadata.
163 FunctionPass *createGCInfoDeleter();
165 /// Creates a pass to print GC metadata.
167 FunctionPass *createGCInfoPrinter(raw_ostream &OS);
169 /// createMachineCSEPass - This pass performs global CSE on machine
171 FunctionPass *createMachineCSEPass();
173 /// createMachineLICMPass - This pass performs LICM on machine instructions.
175 FunctionPass *createMachineLICMPass(bool PreRegAlloc = true);
177 /// createMachineSinkingPass - This pass performs sinking on machine
179 FunctionPass *createMachineSinkingPass();
181 /// createOptimizeExtsPass - This pass performs sign / zero extension
182 /// optimization by increasing uses of extended values.
183 FunctionPass *createOptimizeExtsPass();
185 /// createOptimizePHIsPass - This pass optimizes machine instruction PHIs
186 /// to take advantage of opportunities created during DAG legalization.
187 FunctionPass *createOptimizePHIsPass();
189 /// createStackSlotColoringPass - This pass performs stack slot coloring.
190 FunctionPass *createStackSlotColoringPass(bool);
192 /// createStackProtectorPass - This pass adds stack protectors to functions.
193 FunctionPass *createStackProtectorPass(const TargetLowering *tli);
195 /// createMachineVerifierPass - This pass verifies cenerated machine code
196 /// instructions for correctness.
198 /// @param allowDoubleDefs ignore double definitions of
199 /// registers. Useful before LiveVariables has run.
200 FunctionPass *createMachineVerifierPass(bool allowDoubleDefs);
202 /// createDwarfEHPass - This pass mulches exception handling code into a form
203 /// adapted to code generation. Required if using dwarf exception handling.
204 FunctionPass *createDwarfEHPass(const TargetMachine *tm, bool fast);
206 /// createSjLjEHPass - This pass adapts exception handling code to use
207 /// the GCC-style builtin setjmp/longjmp (sjlj) to handling EH control flow.
208 FunctionPass *createSjLjEHPass(const TargetLowering *tli);
210 } // End llvm namespace