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
26 class RegisterCoalescer;
28 /// createUnreachableBlockEliminationPass - The LLVM code generator does not
29 /// work well with unreachable basic blocks (what live ranges make sense for a
30 /// block that cannot be reached?). As such, a code generator should either
31 /// not instruction select unreachable blocks, or it can run this pass as it's
32 /// last LLVM modifying pass to clean up blocks that are not reachable from
34 FunctionPass *createUnreachableBlockEliminationPass();
36 /// MachineFunctionPrinter pass - This pass prints out the machine function to
37 /// standard error, as a debugging tool.
38 FunctionPass *createMachineFunctionPrinterPass(std::ostream *OS,
39 const std::string &Banner ="");
41 /// MachineLoopInfo pass - This pass is a loop analysis pass.
43 extern const PassInfo *const MachineLoopInfoID;
45 /// MachineDominators pass - This pass is a machine dominators analysis pass.
47 extern const PassInfo *const MachineDominatorsID;
49 /// PHIElimination pass - This pass eliminates machine instruction PHI nodes
50 /// by inserting copy instructions. This destroys SSA information, but is the
51 /// desired input for some register allocators. This pass is "required" by
52 /// these register allocator like this: AU.addRequiredID(PHIEliminationID);
54 extern const PassInfo *const PHIEliminationID;
56 /// StrongPHIElimination pass - This pass eliminates machine instruction PHI
57 /// nodes by inserting copy instructions. This destroys SSA information, but
58 /// is the desired input for some register allocators. This pass is
59 /// "required" by these register allocator like this:
60 /// AU.addRequiredID(PHIEliminationID);
61 /// This pass is still in development
62 extern const PassInfo *const StrongPHIEliminationID;
64 extern const PassInfo *const PreAllocSplittingID;
66 /// SimpleRegisterCoalescing pass. Aggressively coalesces every register
69 extern const PassInfo *const SimpleRegisterCoalescingID;
71 /// TwoAddressInstruction pass - This pass reduces two-address instructions to
72 /// use two operands. This destroys SSA information but it is desired by
73 /// register allocators.
74 extern const PassInfo *const TwoAddressInstructionPassID;
76 /// UnreachableMachineBlockElimination pass - This pass removes unreachable
77 /// machine basic blocks.
78 extern const PassInfo *const UnreachableMachineBlockElimID;
80 /// DeadMachineInstructionElim pass - This pass removes dead machine
83 FunctionPass *createDeadMachineInstructionElimPass();
85 /// Creates a register allocator as the user specified on the command line.
87 FunctionPass *createRegisterAllocator();
89 /// SimpleRegisterAllocation Pass - This pass converts the input machine code
90 /// from SSA form to use explicit registers by spilling every register. Wow,
93 FunctionPass *createSimpleRegisterAllocator();
95 /// LocalRegisterAllocation Pass - This pass register allocates the input code
96 /// a basic block at a time, yielding code better than the simple register
97 /// allocator, but not as good as a global allocator.
99 FunctionPass *createLocalRegisterAllocator();
101 /// BigBlockRegisterAllocation Pass - The BigBlock register allocator
102 /// munches single basic blocks at a time, like the local register
103 /// allocator. While the BigBlock allocator is a little slower, and uses
104 /// somewhat more memory than the local register allocator, it tends to
105 /// yield the best allocations (of any of the allocators) for blocks that
106 /// have hundreds or thousands of instructions in sequence.
108 FunctionPass *createBigBlockRegisterAllocator();
110 /// LinearScanRegisterAllocation Pass - This pass implements the linear scan
111 /// register allocation algorithm, a global register allocator.
113 FunctionPass *createLinearScanRegisterAllocator();
115 /// PBQPRegisterAllocation Pass - This pass implements the Partitioned Boolean
116 /// Quadratic Prograaming (PBQP) based register allocator.
118 FunctionPass *createPBQPRegisterAllocator();
120 /// SimpleRegisterCoalescing Pass - Coalesce all copies possible. Can run
121 /// independently of the register allocator.
123 RegisterCoalescer *createSimpleRegisterCoalescer();
125 /// PrologEpilogCodeInserter Pass - This pass inserts prolog and epilog code,
126 /// and eliminates abstract frame references.
128 FunctionPass *createPrologEpilogCodeInserter();
130 /// LowerSubregs Pass - This pass lowers subregs to register-register copies
131 /// which yields suboptimal, but correct code if the register allocator
132 /// cannot coalesce all subreg operations during allocation.
134 FunctionPass *createLowerSubregsPass();
136 /// createPostRAScheduler - under development.
137 FunctionPass *createPostRAScheduler();
139 /// BranchFolding Pass - This pass performs machine code CFG based
140 /// optimizations to delete branches to branches, eliminate branches to
141 /// successor blocks (creating fall throughs), and eliminating branches over
143 FunctionPass *createBranchFoldingPass(bool DefaultEnableTailMerge);
145 /// IfConverter Pass - This pass performs machine code if conversion.
146 FunctionPass *createIfConverterPass();
148 /// LoopAligner Pass - This pass aligns loop headers to target specific
149 /// alignment boundary.
150 FunctionPass *createLoopAlignerPass();
152 /// DebugLabelFoldingPass - This pass prunes out redundant debug labels. This
153 /// allows a debug emitter to determine if the range of two labels is empty,
154 /// by seeing if the labels map to the same reduced label.
155 FunctionPass *createDebugLabelFoldingPass();
157 /// MachineCodeDeletion Pass - This pass deletes all of the machine code for
158 /// the current function, which should happen after the function has been
159 /// emitted to a .s file or to memory.
160 FunctionPass *createMachineCodeDeleter();
162 /// getRegisterAllocator - This creates an instance of the register allocator
164 FunctionPass *getRegisterAllocator(TargetMachine &T);
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(std::ostream &OS);
184 /// createMachineLICMPass - This pass performs LICM on machine instructions.
186 FunctionPass *createMachineLICMPass();
188 /// createMachineSinkingPass - This pass performs sinking on machine
190 FunctionPass *createMachineSinkingPass();
192 /// createStackSlotColoringPass - This pass performs stack slot coloring.
193 FunctionPass *createStackSlotColoringPass();
195 } // End llvm namespace