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"
26 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 /// the given stream, as a debugging tool.
39 FunctionPass *createMachineFunctionPrinterPass(raw_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 /// LocalRegisterAllocation Pass - This pass register allocates the input code
91 /// a basic block at a time, yielding code better than the simple register
92 /// allocator, but not as good as a global allocator.
94 FunctionPass *createLocalRegisterAllocator();
96 /// LinearScanRegisterAllocation Pass - This pass implements the linear scan
97 /// register allocation algorithm, a global register allocator.
99 FunctionPass *createLinearScanRegisterAllocator();
101 /// PBQPRegisterAllocation Pass - This pass implements the Partitioned Boolean
102 /// Quadratic Prograaming (PBQP) based register allocator.
104 FunctionPass *createPBQPRegisterAllocator();
106 /// SimpleRegisterCoalescing Pass - Coalesce all copies possible. Can run
107 /// independently of the register allocator.
109 RegisterCoalescer *createSimpleRegisterCoalescer();
111 /// PrologEpilogCodeInserter Pass - This pass inserts prolog and epilog code,
112 /// and eliminates abstract frame references.
114 FunctionPass *createPrologEpilogCodeInserter();
116 /// LowerSubregs Pass - This pass lowers subregs to register-register copies
117 /// which yields suboptimal, but correct code if the register allocator
118 /// cannot coalesce all subreg operations during allocation.
120 FunctionPass *createLowerSubregsPass();
122 /// createPostRAScheduler - This pass performs post register allocation
124 FunctionPass *createPostRAScheduler(CodeGenOpt::Level OptLevel);
126 /// BranchFolding Pass - This pass performs machine code CFG based
127 /// optimizations to delete branches to branches, eliminate branches to
128 /// successor blocks (creating fall throughs), and eliminating branches over
130 FunctionPass *createBranchFoldingPass(bool DefaultEnableTailMerge);
132 /// TailDuplicate Pass - Duplicate blocks with unconditional branches
133 /// into tails of their predecessors.
134 FunctionPass *createTailDuplicatePass();
136 /// IfConverter Pass - This pass performs machine code if conversion.
137 FunctionPass *createIfConverterPass();
139 /// Code Placement Pass - This pass optimize code placement and aligns loop
140 /// headers to target specific alignment boundary.
141 FunctionPass *createCodePlacementOptPass();
143 /// getRegisterAllocator - This creates an instance of the register allocator
145 FunctionPass *getRegisterAllocator(TargetMachine &T);
147 /// IntrinsicLowering Pass - Performs target-independent LLVM IR
148 /// transformations for highly portable strategies.
149 FunctionPass *createGCLoweringPass();
151 /// MachineCodeAnalysis Pass - Target-independent pass to mark safe points in
152 /// machine code. Must be added very late during code generation, just prior
153 /// to output, and importantly after all CFG transformations (such as branch
155 FunctionPass *createGCMachineCodeAnalysisPass();
157 /// Deleter Pass - Releases GC metadata.
159 FunctionPass *createGCInfoDeleter();
161 /// Creates a pass to print GC metadata.
163 FunctionPass *createGCInfoPrinter(raw_ostream &OS);
165 /// createMachineLICMPass - This pass performs LICM on machine instructions.
167 FunctionPass *createMachineLICMPass();
169 /// createMachineSinkingPass - This pass performs sinking on machine
171 FunctionPass *createMachineSinkingPass();
173 /// createStackSlotColoringPass - This pass performs stack slot coloring.
174 FunctionPass *createStackSlotColoringPass(bool);
176 /// createStackProtectorPass - This pass adds stack protectors to functions.
177 FunctionPass *createStackProtectorPass(const TargetLowering *tli);
179 /// createMachineVerifierPass - This pass verifies cenerated machine code
180 /// instructions for correctness.
182 /// @param allowPhysDoubleDefs ignore double definitions of
183 /// registers. Useful before LiveVariables has run.
184 FunctionPass *createMachineVerifierPass(bool allowDoubleDefs);
186 /// createDwarfEHPass - This pass mulches exception handling code into a form
187 /// adapted to code generation. Required if using dwarf exception handling.
188 FunctionPass *createDwarfEHPass(const TargetLowering *tli, bool fast);
190 /// createSjLjEHPass - This pass adapts exception handling code to use
191 /// the GCC-style builtin setjmp/longjmp (sjlj) to handling EH control flow.
192 FunctionPass *createSjLjEHPass(const TargetLowering *tli);
194 /// createMaxStackAlignmentCalculatorPass() - Determine the maximum required
195 /// alignment for a function.
196 FunctionPass* createMaxStackAlignmentCalculatorPass();
198 } // End llvm namespace