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
27 class RegisterCoalescer;
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
35 FunctionPass *createUnreachableBlockEliminationPass();
37 /// MachineFunctionPrinter pass - This pass prints out the machine function to
38 /// standard error, as a debugging tool.
39 FunctionPass *createMachineFunctionPrinterPass(std::ostream *OS,
40 const std::string &Banner ="");
42 /// MachineLoopInfo pass - This pass is a loop analysis pass.
44 extern const PassInfo *const MachineLoopInfoID;
46 /// MachineDominators pass - This pass is a machine dominators analysis pass.
48 extern const PassInfo *const MachineDominatorsID;
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);
55 extern const PassInfo *const PHIEliminationID;
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;
65 extern const PassInfo *const PreAllocSplittingID;
67 /// SimpleRegisterCoalescing pass. Aggressively coalesces every register
70 extern const PassInfo *const SimpleRegisterCoalescingID;
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;
77 /// UnreachableMachineBlockElimination pass - This pass removes unreachable
78 /// machine basic blocks.
79 extern const PassInfo *const UnreachableMachineBlockElimID;
81 /// DeadMachineInstructionElim pass - This pass removes dead machine
84 FunctionPass *createDeadMachineInstructionElimPass();
86 /// Creates a register allocator as the user specified on the command line.
88 FunctionPass *createRegisterAllocator();
90 /// SimpleRegisterAllocation Pass - This pass converts the input machine code
91 /// from SSA form to use explicit registers by spilling every register. Wow,
94 FunctionPass *createSimpleRegisterAllocator();
96 /// LocalRegisterAllocation Pass - This pass register allocates the input code
97 /// a basic block at a time, yielding code better than the simple register
98 /// allocator, but not as good as a global allocator.
100 FunctionPass *createLocalRegisterAllocator();
102 /// BigBlockRegisterAllocation Pass - The BigBlock register allocator
103 /// munches single basic blocks at a time, like the local register
104 /// allocator. While the BigBlock allocator is a little slower, and uses
105 /// somewhat more memory than the local register allocator, it tends to
106 /// yield the best allocations (of any of the allocators) for blocks that
107 /// have hundreds or thousands of instructions in sequence.
109 FunctionPass *createBigBlockRegisterAllocator();
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 *createPBQPRegisterAllocator();
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 - under development.
138 FunctionPass *createPostRAScheduler();
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 /// IfConverter Pass - This pass performs machine code if conversion.
147 FunctionPass *createIfConverterPass();
149 /// Code Placement Pass - This pass optimize code placement and aligns loop
150 /// headers to target specific alignment boundary.
151 FunctionPass *createCodePlacementOptPass();
153 /// DebugLabelFoldingPass - This pass prunes out redundant debug labels. This
154 /// allows a debug emitter to determine if the range of two labels is empty,
155 /// by seeing if the labels map to the same reduced label.
156 FunctionPass *createDebugLabelFoldingPass();
158 /// MachineCodeDeletion Pass - This pass deletes all of the machine code for
159 /// the current function, which should happen after the function has been
160 /// emitted to a .s file or to memory.
161 FunctionPass *createMachineCodeDeleter();
163 /// getRegisterAllocator - This creates an instance of the register allocator
165 FunctionPass *getRegisterAllocator(TargetMachine &T);
167 /// IntrinsicLowering Pass - Performs target-independent LLVM IR
168 /// transformations for highly portable strategies.
169 FunctionPass *createGCLoweringPass();
171 /// MachineCodeAnalysis Pass - Target-independent pass to mark safe points in
172 /// machine code. Must be added very late during code generation, just prior
173 /// to output, and importantly after all CFG transformations (such as branch
175 FunctionPass *createGCMachineCodeAnalysisPass();
177 /// Deleter Pass - Releases GC metadata.
179 FunctionPass *createGCInfoDeleter();
181 /// Creates a pass to print GC metadata.
183 FunctionPass *createGCInfoPrinter(std::ostream &OS);
185 /// createMachineLICMPass - This pass performs LICM on machine instructions.
187 FunctionPass *createMachineLICMPass();
189 /// createMachineSinkingPass - This pass performs sinking on machine
191 FunctionPass *createMachineSinkingPass();
193 /// createStackSlotColoringPass - This pass performs stack slot coloring.
194 FunctionPass *createStackSlotColoringPass(bool);
196 /// createStackProtectorPass - This pass adds stack protectors to functions.
197 FunctionPass *createStackProtectorPass(const TargetLowering *tli);
199 /// createMachineVerifierPass - This pass verifies cenerated machine code
200 /// instructions for correctness.
202 /// @param allowPhysDoubleDefs ignore double definitions of
203 /// registers. Useful before LiveVariables has run.
204 FunctionPass *createMachineVerifierPass(bool allowDoubleDefs);
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 TargetLowering *tli, bool fast);
210 } // End llvm namespace