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 *MachineLoopInfoID;
45 /// MachineDominators pass - This pass is a machine dominators analysis pass.
47 extern const PassInfo *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 *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 *StrongPHIEliminationID;
64 /// SimpleRegisterCoalescing pass. Aggressively coalesces every register
67 extern const PassInfo *SimpleRegisterCoalescingID;
69 /// TwoAddressInstruction pass - This pass reduces two-address instructions to
70 /// use two operands. This destroys SSA information but it is desired by
71 /// register allocators.
72 extern const PassInfo *TwoAddressInstructionPassID;
74 /// Creates a register allocator as the user specified on the command line.
76 FunctionPass *createRegisterAllocator();
78 /// SimpleRegisterAllocation Pass - This pass converts the input machine code
79 /// from SSA form to use explicit registers by spilling every register. Wow,
82 FunctionPass *createSimpleRegisterAllocator();
84 /// LocalRegisterAllocation Pass - This pass register allocates the input code
85 /// a basic block at a time, yielding code better than the simple register
86 /// allocator, but not as good as a global allocator.
88 FunctionPass *createLocalRegisterAllocator();
90 /// BigBlockRegisterAllocation Pass - The BigBlock register allocator
91 /// munches single basic blocks at a time, like the local register
92 /// allocator. While the BigBlock allocator is a little slower, and uses
93 /// somewhat more memory than the local register allocator, it tends to
94 /// yield the best allocations (of any of the allocators) for blocks that
95 /// have hundreds or thousands of instructions in sequence.
97 FunctionPass *createBigBlockRegisterAllocator();
99 /// LinearScanRegisterAllocation Pass - This pass implements the linear scan
100 /// register allocation algorithm, a global register allocator.
102 FunctionPass *createLinearScanRegisterAllocator();
104 /// SimpleRegisterCoalescing Pass - Coalesce all copies possible. Can run
105 /// independently of the register allocator.
107 RegisterCoalescer *createSimpleRegisterCoalescer();
109 /// PrologEpilogCodeInserter Pass - This pass inserts prolog and epilog code,
110 /// and eliminates abstract frame references.
112 FunctionPass *createPrologEpilogCodeInserter();
114 /// LowerSubregs Pass - This pass lowers subregs to register-register copies
115 /// which yields suboptimal, but correct code if the register allocator
116 /// cannot coalesce all subreg operations during allocation.
118 FunctionPass *createLowerSubregsPass();
120 /// createPostRAScheduler - under development.
121 FunctionPass *createPostRAScheduler();
123 /// BranchFolding Pass - This pass performs machine code CFG based
124 /// optimizations to delete branches to branches, eliminate branches to
125 /// successor blocks (creating fall throughs), and eliminating branches over
127 FunctionPass *createBranchFoldingPass(bool DefaultEnableTailMerge);
129 /// IfConverter Pass - This pass performs machine code if conversion.
130 FunctionPass *createIfConverterPass();
132 /// LoopAligner Pass - This pass aligns loop headers to target specific
133 /// alignment boundary.
134 FunctionPass *createLoopAlignerPass();
136 /// DebugLabelFoldingPass - This pass prunes out redundant debug labels. This
137 /// allows a debug emitter to determine if the range of two labels is empty,
138 /// by seeing if the labels map to the same reduced label.
139 FunctionPass *createDebugLabelFoldingPass();
141 /// MachineCodeDeletion Pass - This pass deletes all of the machine code for
142 /// the current function, which should happen after the function has been
143 /// emitted to a .s file or to memory.
144 FunctionPass *createMachineCodeDeleter();
146 /// getRegisterAllocator - This creates an instance of the register allocator
148 FunctionPass *getRegisterAllocator(TargetMachine &T);
150 /// IntrinsicLowering Pass - Performs target-independent LLVM IR
151 /// transformations for highly portable collectors.
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 collector metadata.
162 FunctionPass *createCollectorMetadataDeleter();
164 /// Creates a pass to print collector metadata.
166 FunctionPass *createCollectorMetadataPrinter(std::ostream &OS);
168 /// createMachineLICMPass - This pass performs LICM on machine instructions.
170 FunctionPass *createMachineLICMPass();
172 /// createMachineSinkingPass - This pass performs sinking on machine
174 FunctionPass *createMachineSinkingPass();
176 } // End llvm namespace