| Misha Brukman | ef6a6a6 | 2003-08-21 22:14:26 +0000 | [diff] [blame] | 1 | //===-- Passes.h - Target independent code generation passes ----*- C++ -*-===// |
| Misha Brukman | ea61c35 | 2005-04-21 20:39:54 +0000 | [diff] [blame] | 2 | // |
| John Criswell | 6fbcc26 | 2003-10-20 20:19:47 +0000 | [diff] [blame] | 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| Chris Lattner | 7ed47a1 | 2007-12-29 19:59:42 +0000 | [diff] [blame] | 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| Misha Brukman | ea61c35 | 2005-04-21 20:39:54 +0000 | [diff] [blame] | 7 | // |
| John Criswell | 6fbcc26 | 2003-10-20 20:19:47 +0000 | [diff] [blame] | 8 | //===----------------------------------------------------------------------===// |
| Chris Lattner | db00065 | 2003-01-13 01:01:31 +0000 | [diff] [blame] | 9 | // |
| Misha Brukman | ef6a6a6 | 2003-08-21 22:14:26 +0000 | [diff] [blame] | 10 | // This file defines interfaces to access the target independent code generation |
| Chris Lattner | db00065 | 2003-01-13 01:01:31 +0000 | [diff] [blame] | 11 | // passes provided by the LLVM backend. |
| 12 | // |
| 13 | //===----------------------------------------------------------------------===// |
| 14 | |
| 15 | #ifndef LLVM_CODEGEN_PASSES_H |
| 16 | #define LLVM_CODEGEN_PASSES_H |
| 17 | |
| Evan Cheng | fa16354 | 2009-10-16 21:06:15 +0000 | [diff] [blame] | 18 | #include "llvm/Target/TargetMachine.h" |
| Brian Gaeke | fc1f6e8 | 2004-02-04 21:41:10 +0000 | [diff] [blame] | 19 | #include <string> |
| Brian Gaeke | 09caa37 | 2004-01-30 21:53:46 +0000 | [diff] [blame] | 20 | |
| Brian Gaeke | d0fde30 | 2003-11-11 22:41:34 +0000 | [diff] [blame] | 21 | namespace llvm { |
| 22 | |
| Chris Lattner | 3e200e6 | 2003-12-20 10:18:58 +0000 | [diff] [blame] | 23 | class FunctionPass; |
| David Greene | 5c8aa95 | 2010-04-02 23:17:14 +0000 | [diff] [blame] | 24 | class MachineFunctionPass; |
| Chris Lattner | 3e200e6 | 2003-12-20 10:18:58 +0000 | [diff] [blame] | 25 | class PassInfo; |
| Bill Wendling | 80a320d | 2008-11-04 21:53:09 +0000 | [diff] [blame] | 26 | class TargetLowering; |
| David Greene | 2c17c4d | 2007-09-06 16:18:45 +0000 | [diff] [blame] | 27 | class RegisterCoalescer; |
| Chris Lattner | cf143a4 | 2009-08-23 03:13:20 +0000 | [diff] [blame] | 28 | class raw_ostream; |
| Chris Lattner | 8b708e4 | 2004-07-02 05:44:13 +0000 | [diff] [blame] | 29 | |
| 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 |
| 35 | /// the entry block. |
| 36 | FunctionPass *createUnreachableBlockEliminationPass(); |
| Misha Brukman | ea61c35 | 2005-04-21 20:39:54 +0000 | [diff] [blame] | 37 | |
| Chris Lattner | 3e200e6 | 2003-12-20 10:18:58 +0000 | [diff] [blame] | 38 | /// MachineFunctionPrinter pass - This pass prints out the machine function to |
| Daniel Dunbar | 275872e | 2009-08-03 01:02:24 +0000 | [diff] [blame] | 39 | /// the given stream, as a debugging tool. |
| David Greene | 5c8aa95 | 2010-04-02 23:17:14 +0000 | [diff] [blame] | 40 | MachineFunctionPass * |
| 41 | createMachineFunctionPrinterPass(raw_ostream &OS, |
| 42 | const std::string &Banner =""); |
| Brian Gaeke | 09caa37 | 2004-01-30 21:53:46 +0000 | [diff] [blame] | 43 | |
| Bill Wendling | 67d65bb | 2008-01-04 20:54:55 +0000 | [diff] [blame] | 44 | /// MachineLoopInfo pass - This pass is a loop analysis pass. |
| 45 | /// |
| Dan Gohman | 6ddba2b | 2008-05-13 02:05:11 +0000 | [diff] [blame] | 46 | extern const PassInfo *const MachineLoopInfoID; |
| Bill Wendling | 67d65bb | 2008-01-04 20:54:55 +0000 | [diff] [blame] | 47 | |
| 48 | /// MachineDominators pass - This pass is a machine dominators analysis pass. |
| 49 | /// |
| Dan Gohman | 6ddba2b | 2008-05-13 02:05:11 +0000 | [diff] [blame] | 50 | extern const PassInfo *const MachineDominatorsID; |
| Bill Wendling | 67d65bb | 2008-01-04 20:54:55 +0000 | [diff] [blame] | 51 | |
| Chris Lattner | 3e200e6 | 2003-12-20 10:18:58 +0000 | [diff] [blame] | 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); |
| 56 | /// |
| Dan Gohman | 6ddba2b | 2008-05-13 02:05:11 +0000 | [diff] [blame] | 57 | extern const PassInfo *const PHIEliminationID; |
| Owen Anderson | 0bda0e8 | 2007-10-31 03:37:57 +0000 | [diff] [blame] | 58 | |
| 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 |
| Dan Gohman | 6ddba2b | 2008-05-13 02:05:11 +0000 | [diff] [blame] | 65 | extern const PassInfo *const StrongPHIEliminationID; |
| Chris Lattner | db00065 | 2003-01-13 01:01:31 +0000 | [diff] [blame] | 66 | |
| Evan Cheng | 09e8ca8 | 2008-10-20 21:44:59 +0000 | [diff] [blame] | 67 | extern const PassInfo *const PreAllocSplittingID; |
| 68 | |
| David Greene | 2513330 | 2007-06-08 17:18:56 +0000 | [diff] [blame] | 69 | /// SimpleRegisterCoalescing pass. Aggressively coalesces every register |
| 70 | /// copy it can. |
| 71 | /// |
| Dan Gohman | 6ddba2b | 2008-05-13 02:05:11 +0000 | [diff] [blame] | 72 | extern const PassInfo *const SimpleRegisterCoalescingID; |
| David Greene | 2513330 | 2007-06-08 17:18:56 +0000 | [diff] [blame] | 73 | |
| Chris Lattner | 3e200e6 | 2003-12-20 10:18:58 +0000 | [diff] [blame] | 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. |
| Dan Gohman | 6ddba2b | 2008-05-13 02:05:11 +0000 | [diff] [blame] | 77 | extern const PassInfo *const TwoAddressInstructionPassID; |
| Chris Lattner | db00065 | 2003-01-13 01:01:31 +0000 | [diff] [blame] | 78 | |
| Owen Anderson | bd3ba46 | 2008-08-04 23:54:43 +0000 | [diff] [blame] | 79 | /// UnreachableMachineBlockElimination pass - This pass removes unreachable |
| 80 | /// machine basic blocks. |
| 81 | extern const PassInfo *const UnreachableMachineBlockElimID; |
| 82 | |
| Dan Gohman | d3ead43 | 2008-09-17 00:43:24 +0000 | [diff] [blame] | 83 | /// DeadMachineInstructionElim pass - This pass removes dead machine |
| 84 | /// instructions. |
| 85 | /// |
| 86 | FunctionPass *createDeadMachineInstructionElimPass(); |
| 87 | |
| Chris Lattner | 3e200e6 | 2003-12-20 10:18:58 +0000 | [diff] [blame] | 88 | /// Creates a register allocator as the user specified on the command line. |
| 89 | /// |
| 90 | FunctionPass *createRegisterAllocator(); |
| Alkis Evlogimenos | 4c08086 | 2003-12-18 22:40:24 +0000 | [diff] [blame] | 91 | |
| Chris Lattner | 3e200e6 | 2003-12-20 10:18:58 +0000 | [diff] [blame] | 92 | /// LocalRegisterAllocation Pass - This pass register allocates the input code |
| 93 | /// a basic block at a time, yielding code better than the simple register |
| 94 | /// allocator, but not as good as a global allocator. |
| Misha Brukman | ea61c35 | 2005-04-21 20:39:54 +0000 | [diff] [blame] | 95 | /// |
| Chris Lattner | 3e200e6 | 2003-12-20 10:18:58 +0000 | [diff] [blame] | 96 | FunctionPass *createLocalRegisterAllocator(); |
| Misha Brukman | ea61c35 | 2005-04-21 20:39:54 +0000 | [diff] [blame] | 97 | |
| Chris Lattner | 3e200e6 | 2003-12-20 10:18:58 +0000 | [diff] [blame] | 98 | /// LinearScanRegisterAllocation Pass - This pass implements the linear scan |
| 99 | /// register allocation algorithm, a global register allocator. |
| 100 | /// |
| 101 | FunctionPass *createLinearScanRegisterAllocator(); |
| Chris Lattner | db00065 | 2003-01-13 01:01:31 +0000 | [diff] [blame] | 102 | |
| Evan Cheng | b1290a6 | 2008-10-02 18:29:27 +0000 | [diff] [blame] | 103 | /// PBQPRegisterAllocation Pass - This pass implements the Partitioned Boolean |
| 104 | /// Quadratic Prograaming (PBQP) based register allocator. |
| 105 | /// |
| 106 | FunctionPass *createPBQPRegisterAllocator(); |
| 107 | |
| David Greene | 2c17c4d | 2007-09-06 16:18:45 +0000 | [diff] [blame] | 108 | /// SimpleRegisterCoalescing Pass - Coalesce all copies possible. Can run |
| 109 | /// independently of the register allocator. |
| 110 | /// |
| 111 | RegisterCoalescer *createSimpleRegisterCoalescer(); |
| 112 | |
| Chris Lattner | 3e200e6 | 2003-12-20 10:18:58 +0000 | [diff] [blame] | 113 | /// PrologEpilogCodeInserter Pass - This pass inserts prolog and epilog code, |
| 114 | /// and eliminates abstract frame references. |
| 115 | /// |
| 116 | FunctionPass *createPrologEpilogCodeInserter(); |
| Christopher Lamb | bab2474 | 2007-07-26 08:18:32 +0000 | [diff] [blame] | 117 | |
| 118 | /// LowerSubregs Pass - This pass lowers subregs to register-register copies |
| Christopher Lamb | 9836322 | 2007-08-06 16:33:56 +0000 | [diff] [blame] | 119 | /// which yields suboptimal, but correct code if the register allocator |
| Christopher Lamb | bab2474 | 2007-07-26 08:18:32 +0000 | [diff] [blame] | 120 | /// cannot coalesce all subreg operations during allocation. |
| 121 | /// |
| 122 | FunctionPass *createLowerSubregsPass(); |
| Chris Lattner | db00065 | 2003-01-13 01:01:31 +0000 | [diff] [blame] | 123 | |
| Evan Cheng | fa16354 | 2009-10-16 21:06:15 +0000 | [diff] [blame] | 124 | /// createPostRAScheduler - This pass performs post register allocation |
| 125 | /// scheduling. |
| 126 | FunctionPass *createPostRAScheduler(CodeGenOpt::Level OptLevel); |
| Dale Johannesen | e7e7d0d | 2007-07-13 17:13:54 +0000 | [diff] [blame] | 127 | |
| Chris Lattner | 36c29db | 2004-07-31 09:59:14 +0000 | [diff] [blame] | 128 | /// BranchFolding Pass - This pass performs machine code CFG based |
| 129 | /// optimizations to delete branches to branches, eliminate branches to |
| 130 | /// successor blocks (creating fall throughs), and eliminating branches over |
| 131 | /// branches. |
| Bob Wilson | a597103 | 2009-10-28 20:46:46 +0000 | [diff] [blame] | 132 | FunctionPass *createBranchFoldingPass(bool DefaultEnableTailMerge); |
| Chris Lattner | 36c29db | 2004-07-31 09:59:14 +0000 | [diff] [blame] | 133 | |
| Bob Wilson | 2d521e5 | 2009-11-26 21:38:41 +0000 | [diff] [blame] | 134 | /// TailDuplicate Pass - Duplicate blocks with unconditional branches |
| Bob Wilson | 15acadd | 2009-11-26 00:32:21 +0000 | [diff] [blame] | 135 | /// into tails of their predecessors. |
| Evan Cheng | 79fc6f4 | 2009-12-04 09:42:45 +0000 | [diff] [blame] | 136 | FunctionPass *createTailDuplicatePass(bool PreRegAlloc = false); |
| Bob Wilson | 15acadd | 2009-11-26 00:32:21 +0000 | [diff] [blame] | 137 | |
| Bob Wilson | a597103 | 2009-10-28 20:46:46 +0000 | [diff] [blame] | 138 | /// IfConverter Pass - This pass performs machine code if conversion. |
| 139 | FunctionPass *createIfConverterPass(); |
| Evan Cheng | 4e65485 | 2007-05-16 02:00:57 +0000 | [diff] [blame] | 140 | |
| Evan Cheng | bbf1db7 | 2009-05-07 05:42:24 +0000 | [diff] [blame] | 141 | /// Code Placement Pass - This pass optimize code placement and aligns loop |
| 142 | /// headers to target specific alignment boundary. |
| 143 | FunctionPass *createCodePlacementOptPass(); |
| Evan Cheng | fb8075d | 2008-02-28 00:43:03 +0000 | [diff] [blame] | 144 | |
| Chris Lattner | 3e200e6 | 2003-12-20 10:18:58 +0000 | [diff] [blame] | 145 | /// getRegisterAllocator - This creates an instance of the register allocator |
| 146 | /// for the Sparc. |
| 147 | FunctionPass *getRegisterAllocator(TargetMachine &T); |
| Tanya Lattner | 5a75c91 | 2004-05-08 16:14:02 +0000 | [diff] [blame] | 148 | |
| Gordon Henriksen | ad93c4f | 2007-12-11 00:30:17 +0000 | [diff] [blame] | 149 | /// IntrinsicLowering Pass - Performs target-independent LLVM IR |
| Gordon Henriksen | 5eca075 | 2008-08-17 18:44:35 +0000 | [diff] [blame] | 150 | /// transformations for highly portable strategies. |
| Gordon Henriksen | ad93c4f | 2007-12-11 00:30:17 +0000 | [diff] [blame] | 151 | FunctionPass *createGCLoweringPass(); |
| 152 | |
| 153 | /// MachineCodeAnalysis Pass - Target-independent pass to mark safe points in |
| 154 | /// machine code. Must be added very late during code generation, just prior |
| 155 | /// to output, and importantly after all CFG transformations (such as branch |
| 156 | /// folding). |
| 157 | FunctionPass *createGCMachineCodeAnalysisPass(); |
| 158 | |
| Gordon Henriksen | 5eca075 | 2008-08-17 18:44:35 +0000 | [diff] [blame] | 159 | /// Deleter Pass - Releases GC metadata. |
| Gordon Henriksen | ad93c4f | 2007-12-11 00:30:17 +0000 | [diff] [blame] | 160 | /// |
| Gordon Henriksen | 5eca075 | 2008-08-17 18:44:35 +0000 | [diff] [blame] | 161 | FunctionPass *createGCInfoDeleter(); |
| Gordon Henriksen | ad93c4f | 2007-12-11 00:30:17 +0000 | [diff] [blame] | 162 | |
| Gordon Henriksen | 5eca075 | 2008-08-17 18:44:35 +0000 | [diff] [blame] | 163 | /// Creates a pass to print GC metadata. |
| Gordon Henriksen | ad93c4f | 2007-12-11 00:30:17 +0000 | [diff] [blame] | 164 | /// |
| Chris Lattner | cf143a4 | 2009-08-23 03:13:20 +0000 | [diff] [blame] | 165 | FunctionPass *createGCInfoPrinter(raw_ostream &OS); |
| Gordon Henriksen | ad93c4f | 2007-12-11 00:30:17 +0000 | [diff] [blame] | 166 | |
| Evan Cheng | c6fe333 | 2010-03-02 02:38:24 +0000 | [diff] [blame] | 167 | /// createMachineCSEPass - This pass performs global CSE on machine |
| 168 | /// instructions. |
| 169 | FunctionPass *createMachineCSEPass(); |
| 170 | |
| Bill Wendling | 0f940c9 | 2007-12-07 21:42:31 +0000 | [diff] [blame] | 171 | /// createMachineLICMPass - This pass performs LICM on machine instructions. |
| 172 | /// |
| Evan Cheng | d94671a | 2010-04-07 00:41:17 +0000 | [diff] [blame] | 173 | FunctionPass *createMachineLICMPass(bool PreRegAlloc = true); |
| Bill Wendling | 0f940c9 | 2007-12-07 21:42:31 +0000 | [diff] [blame] | 174 | |
| Chris Lattner | c4ce73f | 2008-01-04 07:36:53 +0000 | [diff] [blame] | 175 | /// createMachineSinkingPass - This pass performs sinking on machine |
| 176 | /// instructions. |
| 177 | FunctionPass *createMachineSinkingPass(); |
| Evan Cheng | 3f32d65 | 2008-06-04 09:18:41 +0000 | [diff] [blame] | 178 | |
| Evan Cheng | 7da9ecf | 2010-01-13 00:30:23 +0000 | [diff] [blame] | 179 | /// createOptimizeExtsPass - This pass performs sign / zero extension |
| 180 | /// optimization by increasing uses of extended values. |
| 181 | FunctionPass *createOptimizeExtsPass(); |
| 182 | |
| Bob Wilson | fe61fb1 | 2010-02-12 01:30:21 +0000 | [diff] [blame] | 183 | /// createOptimizePHIsPass - This pass optimizes machine instruction PHIs |
| 184 | /// to take advantage of opportunities created during DAG legalization. |
| 185 | FunctionPass *createOptimizePHIsPass(); |
| 186 | |
| Evan Cheng | 3f32d65 | 2008-06-04 09:18:41 +0000 | [diff] [blame] | 187 | /// createStackSlotColoringPass - This pass performs stack slot coloring. |
| Bill Wendling | 2c1d772 | 2009-05-07 01:33:38 +0000 | [diff] [blame] | 188 | FunctionPass *createStackSlotColoringPass(bool); |
| Bill Wendling | 2b58ce5 | 2008-11-04 02:10:20 +0000 | [diff] [blame] | 189 | |
| 190 | /// createStackProtectorPass - This pass adds stack protectors to functions. |
| Bill Wendling | e9e6bdf | 2008-11-13 01:02:14 +0000 | [diff] [blame] | 191 | FunctionPass *createStackProtectorPass(const TargetLowering *tli); |
| Bill Wendling | 2b58ce5 | 2008-11-04 02:10:20 +0000 | [diff] [blame] | 192 | |
| Jakob Stoklund Olesen | 48872e0 | 2009-05-16 00:33:53 +0000 | [diff] [blame] | 193 | /// createMachineVerifierPass - This pass verifies cenerated machine code |
| 194 | /// instructions for correctness. |
| 195 | /// |
| Dan Gohman | fb76fe0 | 2010-02-22 04:10:52 +0000 | [diff] [blame] | 196 | /// @param allowDoubleDefs ignore double definitions of |
| Jakob Stoklund Olesen | 48872e0 | 2009-05-16 00:33:53 +0000 | [diff] [blame] | 197 | /// registers. Useful before LiveVariables has run. |
| 198 | FunctionPass *createMachineVerifierPass(bool allowDoubleDefs); |
| 199 | |
| Duncan Sands | b0f1e17 | 2009-05-22 20:36:31 +0000 | [diff] [blame] | 200 | /// createDwarfEHPass - This pass mulches exception handling code into a form |
| 201 | /// adapted to code generation. Required if using dwarf exception handling. |
| Dan Gohman | 55e59c1 | 2010-04-19 19:05:59 +0000 | [diff] [blame^] | 202 | FunctionPass *createDwarfEHPass(const TargetMachine *tm, bool fast); |
| Duncan Sands | b0f1e17 | 2009-05-22 20:36:31 +0000 | [diff] [blame] | 203 | |
| Jim Grosbach | 8b818d7 | 2009-08-17 16:41:22 +0000 | [diff] [blame] | 204 | /// createSjLjEHPass - This pass adapts exception handling code to use |
| 205 | /// the GCC-style builtin setjmp/longjmp (sjlj) to handling EH control flow. |
| 206 | FunctionPass *createSjLjEHPass(const TargetLowering *tli); |
| 207 | |
| Brian Gaeke | d0fde30 | 2003-11-11 22:41:34 +0000 | [diff] [blame] | 208 | } // End llvm namespace |
| 209 | |
| Chris Lattner | db00065 | 2003-01-13 01:01:31 +0000 | [diff] [blame] | 210 | #endif |