| 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 | |
| Brian Gaeke | fc1f6e8 | 2004-02-04 21:41:10 +0000 | [diff] [blame] | 18 | #include <iosfwd> |
| 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; |
| 24 | class PassInfo; |
| 25 | class TargetMachine; |
| David Greene | 2c17c4d | 2007-09-06 16:18:45 +0000 | [diff] [blame] | 26 | class RegisterCoalescer; |
| Chris Lattner | 8b708e4 | 2004-07-02 05:44:13 +0000 | [diff] [blame] | 27 | |
| 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 |
| 33 | /// the entry block. |
| 34 | FunctionPass *createUnreachableBlockEliminationPass(); |
| Misha Brukman | ea61c35 | 2005-04-21 20:39:54 +0000 | [diff] [blame] | 35 | |
| Chris Lattner | 3e200e6 | 2003-12-20 10:18:58 +0000 | [diff] [blame] | 36 | /// MachineFunctionPrinter pass - This pass prints out the machine function to |
| 37 | /// standard error, as a debugging tool. |
| Brian Gaeke | fc1f6e8 | 2004-02-04 21:41:10 +0000 | [diff] [blame] | 38 | FunctionPass *createMachineFunctionPrinterPass(std::ostream *OS, |
| Brian Gaeke | 09caa37 | 2004-01-30 21:53:46 +0000 | [diff] [blame] | 39 | const std::string &Banner =""); |
| 40 | |
| Bill Wendling | 67d65bb | 2008-01-04 20:54:55 +0000 | [diff] [blame^] | 41 | /// MachineLoopInfo pass - This pass is a loop analysis pass. |
| 42 | /// |
| 43 | extern const PassInfo *MachineLoopInfoID; |
| 44 | |
| 45 | /// MachineDominators pass - This pass is a machine dominators analysis pass. |
| 46 | /// |
| 47 | extern const PassInfo *MachineDominatorsID; |
| 48 | |
| Chris Lattner | 3e200e6 | 2003-12-20 10:18:58 +0000 | [diff] [blame] | 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); |
| 53 | /// |
| 54 | extern const PassInfo *PHIEliminationID; |
| Owen Anderson | 0bda0e8 | 2007-10-31 03:37:57 +0000 | [diff] [blame] | 55 | |
| 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; |
| Chris Lattner | db00065 | 2003-01-13 01:01:31 +0000 | [diff] [blame] | 63 | |
| David Greene | 2513330 | 2007-06-08 17:18:56 +0000 | [diff] [blame] | 64 | /// SimpleRegisterCoalescing pass. Aggressively coalesces every register |
| 65 | /// copy it can. |
| 66 | /// |
| 67 | extern const PassInfo *SimpleRegisterCoalescingID; |
| 68 | |
| Chris Lattner | 3e200e6 | 2003-12-20 10:18:58 +0000 | [diff] [blame] | 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; |
| Chris Lattner | db00065 | 2003-01-13 01:01:31 +0000 | [diff] [blame] | 73 | |
| Chris Lattner | 3e200e6 | 2003-12-20 10:18:58 +0000 | [diff] [blame] | 74 | /// Creates a register allocator as the user specified on the command line. |
| 75 | /// |
| 76 | FunctionPass *createRegisterAllocator(); |
| Alkis Evlogimenos | 4c08086 | 2003-12-18 22:40:24 +0000 | [diff] [blame] | 77 | |
| Chris Lattner | 3e200e6 | 2003-12-20 10:18:58 +0000 | [diff] [blame] | 78 | /// SimpleRegisterAllocation Pass - This pass converts the input machine code |
| 79 | /// from SSA form to use explicit registers by spilling every register. Wow, |
| 80 | /// great policy huh? |
| 81 | /// |
| 82 | FunctionPass *createSimpleRegisterAllocator(); |
| Alkis Evlogimenos | eed462b | 2003-10-02 06:13:19 +0000 | [diff] [blame] | 83 | |
| Chris Lattner | 3e200e6 | 2003-12-20 10:18:58 +0000 | [diff] [blame] | 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. |
| Misha Brukman | ea61c35 | 2005-04-21 20:39:54 +0000 | [diff] [blame] | 87 | /// |
| Chris Lattner | 3e200e6 | 2003-12-20 10:18:58 +0000 | [diff] [blame] | 88 | FunctionPass *createLocalRegisterAllocator(); |
| Misha Brukman | ea61c35 | 2005-04-21 20:39:54 +0000 | [diff] [blame] | 89 | |
| Duraid Madina | a8c7682 | 2007-06-22 08:27:12 +0000 | [diff] [blame] | 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. |
| 96 | /// |
| 97 | FunctionPass *createBigBlockRegisterAllocator(); |
| 98 | |
| Chris Lattner | 3e200e6 | 2003-12-20 10:18:58 +0000 | [diff] [blame] | 99 | /// LinearScanRegisterAllocation Pass - This pass implements the linear scan |
| 100 | /// register allocation algorithm, a global register allocator. |
| 101 | /// |
| 102 | FunctionPass *createLinearScanRegisterAllocator(); |
| Chris Lattner | db00065 | 2003-01-13 01:01:31 +0000 | [diff] [blame] | 103 | |
| David Greene | 2c17c4d | 2007-09-06 16:18:45 +0000 | [diff] [blame] | 104 | /// SimpleRegisterCoalescing Pass - Coalesce all copies possible. Can run |
| 105 | /// independently of the register allocator. |
| 106 | /// |
| 107 | RegisterCoalescer *createSimpleRegisterCoalescer(); |
| 108 | |
| Chris Lattner | 3e200e6 | 2003-12-20 10:18:58 +0000 | [diff] [blame] | 109 | /// PrologEpilogCodeInserter Pass - This pass inserts prolog and epilog code, |
| 110 | /// and eliminates abstract frame references. |
| 111 | /// |
| 112 | FunctionPass *createPrologEpilogCodeInserter(); |
| Christopher Lamb | bab2474 | 2007-07-26 08:18:32 +0000 | [diff] [blame] | 113 | |
| 114 | /// LowerSubregs Pass - This pass lowers subregs to register-register copies |
| Christopher Lamb | 9836322 | 2007-08-06 16:33:56 +0000 | [diff] [blame] | 115 | /// which yields suboptimal, but correct code if the register allocator |
| Christopher Lamb | bab2474 | 2007-07-26 08:18:32 +0000 | [diff] [blame] | 116 | /// cannot coalesce all subreg operations during allocation. |
| 117 | /// |
| 118 | FunctionPass *createLowerSubregsPass(); |
| Chris Lattner | db00065 | 2003-01-13 01:01:31 +0000 | [diff] [blame] | 119 | |
| Dale Johannesen | e7e7d0d | 2007-07-13 17:13:54 +0000 | [diff] [blame] | 120 | /// createPostRAScheduler - under development. |
| 121 | FunctionPass *createPostRAScheduler(); |
| 122 | |
| Chris Lattner | 36c29db | 2004-07-31 09:59:14 +0000 | [diff] [blame] | 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 |
| 126 | /// branches. |
| Dale Johannesen | 81da02b | 2007-05-22 17:14:46 +0000 | [diff] [blame] | 127 | FunctionPass *createBranchFoldingPass(bool DefaultEnableTailMerge); |
| Chris Lattner | 36c29db | 2004-07-31 09:59:14 +0000 | [diff] [blame] | 128 | |
| Evan Cheng | 4e65485 | 2007-05-16 02:00:57 +0000 | [diff] [blame] | 129 | /// IfConverter Pass - This pass performs machine code if conversion. |
| 130 | FunctionPass *createIfConverterPass(); |
| 131 | |
| Jim Laskey | 9d4209f | 2006-11-07 19:33:46 +0000 | [diff] [blame] | 132 | /// DebugLabelFoldingPass - This pass prunes out redundant debug labels. This |
| 133 | /// allows a debug emitter to determine if the range of two labels is empty, |
| 134 | /// by seeing if the labels map to the same reduced label. |
| 135 | FunctionPass *createDebugLabelFoldingPass(); |
| 136 | |
| Chris Lattner | 3e200e6 | 2003-12-20 10:18:58 +0000 | [diff] [blame] | 137 | /// MachineCodeDeletion Pass - This pass deletes all of the machine code for |
| 138 | /// the current function, which should happen after the function has been |
| 139 | /// emitted to a .s file or to memory. |
| 140 | FunctionPass *createMachineCodeDeleter(); |
| Misha Brukman | ea61c35 | 2005-04-21 20:39:54 +0000 | [diff] [blame] | 141 | |
| Chris Lattner | 3e200e6 | 2003-12-20 10:18:58 +0000 | [diff] [blame] | 142 | /// getRegisterAllocator - This creates an instance of the register allocator |
| 143 | /// for the Sparc. |
| 144 | FunctionPass *getRegisterAllocator(TargetMachine &T); |
| Tanya Lattner | 5a75c91 | 2004-05-08 16:14:02 +0000 | [diff] [blame] | 145 | |
| Gordon Henriksen | ad93c4f | 2007-12-11 00:30:17 +0000 | [diff] [blame] | 146 | /// IntrinsicLowering Pass - Performs target-independent LLVM IR |
| 147 | /// transformations for highly portable collectors. |
| 148 | FunctionPass *createGCLoweringPass(); |
| 149 | |
| 150 | /// MachineCodeAnalysis Pass - Target-independent pass to mark safe points in |
| 151 | /// machine code. Must be added very late during code generation, just prior |
| 152 | /// to output, and importantly after all CFG transformations (such as branch |
| 153 | /// folding). |
| 154 | FunctionPass *createGCMachineCodeAnalysisPass(); |
| 155 | |
| 156 | /// Deleter Pass - Releases collector metadata. |
| 157 | /// |
| 158 | FunctionPass *createCollectorMetadataDeleter(); |
| 159 | |
| 160 | /// Creates a pass to print collector metadata. |
| 161 | /// |
| 162 | FunctionPass *createCollectorMetadataPrinter(std::ostream &OS); |
| 163 | |
| Bill Wendling | 0f940c9 | 2007-12-07 21:42:31 +0000 | [diff] [blame] | 164 | /// createMachineLICMPass - This pass performs LICM on machine instructions. |
| 165 | /// |
| 166 | FunctionPass *createMachineLICMPass(); |
| 167 | |
| Chris Lattner | c4ce73f | 2008-01-04 07:36:53 +0000 | [diff] [blame] | 168 | /// createMachineSinkingPass - This pass performs sinking on machine |
| 169 | /// instructions. |
| 170 | FunctionPass *createMachineSinkingPass(); |
| 171 | |
| Brian Gaeke | d0fde30 | 2003-11-11 22:41:34 +0000 | [diff] [blame] | 172 | } // End llvm namespace |
| 173 | |
| Chris Lattner | db00065 | 2003-01-13 01:01:31 +0000 | [diff] [blame] | 174 | #endif |