| 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 | |
| Andrew Trick | 7461334 | 2012-02-04 02:56:45 +0000 | [diff] [blame] | 18 | #include "llvm/Pass.h" |
| Evan Cheng | fa16354 | 2009-10-16 21:06:15 +0000 | [diff] [blame] | 19 | #include "llvm/Target/TargetMachine.h" |
| Brian Gaeke | fc1f6e8 | 2004-02-04 21:41:10 +0000 | [diff] [blame] | 20 | #include <string> |
| Brian Gaeke | 09caa37 | 2004-01-30 21:53:46 +0000 | [diff] [blame] | 21 | |
| Brian Gaeke | d0fde30 | 2003-11-11 22:41:34 +0000 | [diff] [blame] | 22 | namespace llvm { |
| 23 | |
| Chris Lattner | 3e200e6 | 2003-12-20 10:18:58 +0000 | [diff] [blame] | 24 | class FunctionPass; |
| David Greene | 5c8aa95 | 2010-04-02 23:17:14 +0000 | [diff] [blame] | 25 | class MachineFunctionPass; |
| Chris Lattner | 3e200e6 | 2003-12-20 10:18:58 +0000 | [diff] [blame] | 26 | class PassInfo; |
| Bill Wendling | 80a320d | 2008-11-04 21:53:09 +0000 | [diff] [blame] | 27 | class TargetLowering; |
| Jakob Stoklund Olesen | df4b35e | 2011-09-27 23:50:46 +0000 | [diff] [blame] | 28 | class TargetRegisterClass; |
| Chris Lattner | cf143a4 | 2009-08-23 03:13:20 +0000 | [diff] [blame] | 29 | class raw_ostream; |
| Andrew Trick | 843ee2e | 2012-02-03 05:12:41 +0000 | [diff] [blame] | 30 | } |
| Chris Lattner | 8b708e4 | 2004-07-02 05:44:13 +0000 | [diff] [blame] | 31 | |
| Andrew Trick | 843ee2e | 2012-02-03 05:12:41 +0000 | [diff] [blame] | 32 | namespace llvm { |
| 33 | |
| Andrew Trick | 746f24b | 2012-02-11 07:11:32 +0000 | [diff] [blame] | 34 | extern char &NoPassID; // Allow targets to choose not to run a pass. |
| 35 | |
| Andrew Trick | 5e108ee | 2012-02-15 03:21:47 +0000 | [diff] [blame] | 36 | class PassConfigImpl; |
| 37 | |
| Andrew Trick | 843ee2e | 2012-02-03 05:12:41 +0000 | [diff] [blame] | 38 | /// Target-Independent Code Generator Pass Configuration Options. |
| 39 | /// |
| Andrew Trick | 7461334 | 2012-02-04 02:56:45 +0000 | [diff] [blame] | 40 | /// This is an ImmutablePass solely for the purpose of exposing CodeGen options |
| 41 | /// to the internals of other CodeGen passes. |
| Andrew Trick | 7461334 | 2012-02-04 02:56:45 +0000 | [diff] [blame] | 42 | class TargetPassConfig : public ImmutablePass { |
| Andrew Trick | 79bf288 | 2012-02-15 03:21:51 +0000 | [diff] [blame] | 43 | public: |
| 44 | /// Pseudo Pass IDs. These are defined within TargetPassConfig because they |
| 45 | /// are unregistered pass IDs. They are only useful for use with |
| 46 | /// TargetPassConfig APIs to identify multiple occurrences of the same pass. |
| 47 | /// |
| 48 | |
| 49 | /// EarlyTailDuplicate - A clone of the TailDuplicate pass that runs early |
| 50 | /// during codegen, on SSA form. |
| 51 | static char EarlyTailDuplicateID; |
| 52 | |
| 53 | /// PostRAMachineLICM - A clone of the LICM pass that runs during late machine |
| 54 | /// optimization after regalloc. |
| 55 | static char PostRAMachineLICMID; |
| 56 | |
| Andrew Trick | 843ee2e | 2012-02-03 05:12:41 +0000 | [diff] [blame] | 57 | protected: |
| 58 | TargetMachine *TM; |
| Bill Wendling | 7c4ce30 | 2012-05-01 08:27:43 +0000 | [diff] [blame] | 59 | PassManagerBase *PM; |
| Andrew Trick | 5e108ee | 2012-02-15 03:21:47 +0000 | [diff] [blame] | 60 | PassConfigImpl *Impl; // Internal data structures |
| 61 | bool Initialized; // Flagged after all passes are configured. |
| Andrew Trick | 061efcf | 2012-02-04 02:56:59 +0000 | [diff] [blame] | 62 | |
| 63 | // Target Pass Options |
| Andrew Trick | 61f1e3d | 2012-02-08 21:22:48 +0000 | [diff] [blame] | 64 | // Targets provide a default setting, user flags override. |
| Andrew Trick | 061efcf | 2012-02-04 02:56:59 +0000 | [diff] [blame] | 65 | // |
| Andrew Trick | 843ee2e | 2012-02-03 05:12:41 +0000 | [diff] [blame] | 66 | bool DisableVerify; |
| 67 | |
| Andrew Trick | 61f1e3d | 2012-02-08 21:22:48 +0000 | [diff] [blame] | 68 | /// Default setting for -enable-tail-merge on this target. |
| 69 | bool EnableTailMerge; |
| 70 | |
| Andrew Trick | 843ee2e | 2012-02-03 05:12:41 +0000 | [diff] [blame] | 71 | public: |
| Andrew Trick | 061efcf | 2012-02-04 02:56:59 +0000 | [diff] [blame] | 72 | TargetPassConfig(TargetMachine *tm, PassManagerBase &pm); |
| Andrew Trick | 7461334 | 2012-02-04 02:56:45 +0000 | [diff] [blame] | 73 | // Dummy constructor. |
| 74 | TargetPassConfig(); |
| Andrew Trick | 843ee2e | 2012-02-03 05:12:41 +0000 | [diff] [blame] | 75 | |
| Andrew Trick | 7461334 | 2012-02-04 02:56:45 +0000 | [diff] [blame] | 76 | virtual ~TargetPassConfig(); |
| 77 | |
| 78 | static char ID; |
| Andrew Trick | 843ee2e | 2012-02-03 05:12:41 +0000 | [diff] [blame] | 79 | |
| 80 | /// Get the right type of TargetMachine for this target. |
| 81 | template<typename TMC> TMC &getTM() const { |
| 82 | return *static_cast<TMC*>(TM); |
| 83 | } |
| 84 | |
| Andrew Trick | 061efcf | 2012-02-04 02:56:59 +0000 | [diff] [blame] | 85 | const TargetLowering *getTargetLowering() const { |
| 86 | return TM->getTargetLowering(); |
| 87 | } |
| 88 | |
| Andrew Trick | 5e108ee | 2012-02-15 03:21:47 +0000 | [diff] [blame] | 89 | // |
| Andrew Trick | ffea03f | 2012-02-08 21:22:39 +0000 | [diff] [blame] | 90 | void setInitialized() { Initialized = true; } |
| 91 | |
| Andrew Trick | 843ee2e | 2012-02-03 05:12:41 +0000 | [diff] [blame] | 92 | CodeGenOpt::Level getOptLevel() const { return TM->getOptLevel(); } |
| 93 | |
| Andrew Trick | 61f1e3d | 2012-02-08 21:22:48 +0000 | [diff] [blame] | 94 | void setDisableVerify(bool Disable) { setOpt(DisableVerify, Disable); } |
| 95 | |
| 96 | bool getEnableTailMerge() const { return EnableTailMerge; } |
| 97 | void setEnableTailMerge(bool Enable) { setOpt(EnableTailMerge, Enable); } |
| Andrew Trick | 061efcf | 2012-02-04 02:56:59 +0000 | [diff] [blame] | 98 | |
| Andrew Trick | 5e108ee | 2012-02-15 03:21:47 +0000 | [diff] [blame] | 99 | /// Allow the target to override a specific pass without overriding the pass |
| 100 | /// pipeline. When passes are added to the standard pipeline at the |
| 101 | /// point where StadardID is expected, add TargetID in its place. |
| 102 | void substitutePass(char &StandardID, char &TargetID); |
| 103 | |
| Bob Wilson | 6e1b812 | 2012-05-30 00:17:12 +0000 | [diff] [blame^] | 104 | /// Insert InsertedPassID pass after TargetPassID pass. |
| 105 | void insertPass(const char &TargetPassID, const char &InsertedPassID); |
| 106 | |
| Andrew Trick | f91a330 | 2012-03-09 00:52:17 +0000 | [diff] [blame] | 107 | /// Allow the target to enable a specific standard pass by default. |
| 108 | void enablePass(char &ID) { substitutePass(ID, ID); } |
| 109 | |
| 110 | /// Allow the target to disable a specific standard pass by default. |
| Andrew Trick | 5e108ee | 2012-02-15 03:21:47 +0000 | [diff] [blame] | 111 | void disablePass(char &ID) { substitutePass(ID, NoPassID); } |
| 112 | |
| 113 | /// Return the pass ssubtituted for StandardID by the target. |
| 114 | /// If no substitution exists, return StandardID. |
| 115 | AnalysisID getPassSubstitution(AnalysisID StandardID) const; |
| 116 | |
| Andrew Trick | 5fd84a2 | 2012-02-15 03:21:43 +0000 | [diff] [blame] | 117 | /// Return true if the optimized regalloc pipeline is enabled. |
| Andrew Trick | 8dd2625 | 2012-02-10 04:10:36 +0000 | [diff] [blame] | 118 | bool getOptimizeRegAlloc() const; |
| 119 | |
| Andrew Trick | 061efcf | 2012-02-04 02:56:59 +0000 | [diff] [blame] | 120 | /// Add common target configurable passes that perform LLVM IR to IR |
| 121 | /// transforms following machine independent optimization. |
| 122 | virtual void addIRPasses(); |
| 123 | |
| 124 | /// Add common passes that perform LLVM IR to IR transforms in preparation for |
| 125 | /// instruction selection. |
| 126 | virtual void addISelPrepare(); |
| 127 | |
| 128 | /// addInstSelector - This method should install an instruction selector pass, |
| 129 | /// which converts from LLVM code to machine instructions. |
| 130 | virtual bool addInstSelector() { |
| 131 | return true; |
| 132 | } |
| Andrew Trick | 843ee2e | 2012-02-03 05:12:41 +0000 | [diff] [blame] | 133 | |
| 134 | /// Add the complete, standard set of LLVM CodeGen passes. |
| 135 | /// Fully developed targets will not generally override this. |
| Andrew Trick | 061efcf | 2012-02-04 02:56:59 +0000 | [diff] [blame] | 136 | virtual void addMachinePasses(); |
| Andrew Trick | 9d41bd5 | 2012-02-08 21:23:03 +0000 | [diff] [blame] | 137 | |
| Andrew Trick | 843ee2e | 2012-02-03 05:12:41 +0000 | [diff] [blame] | 138 | protected: |
| Andrew Trick | ffea03f | 2012-02-08 21:22:39 +0000 | [diff] [blame] | 139 | // Helper to verify the analysis is really immutable. |
| 140 | void setOpt(bool &Opt, bool Val); |
| 141 | |
| Andrew Trick | 061efcf | 2012-02-04 02:56:59 +0000 | [diff] [blame] | 142 | /// Methods with trivial inline returns are convenient points in the common |
| 143 | /// codegen pass pipeline where targets may insert passes. Methods with |
| 144 | /// out-of-line standard implementations are major CodeGen stages called by |
| 145 | /// addMachinePasses. Some targets may override major stages when inserting |
| 146 | /// passes is insufficient, but maintaining overriden stages is more work. |
| Andrew Trick | 843ee2e | 2012-02-03 05:12:41 +0000 | [diff] [blame] | 147 | /// |
| 148 | |
| 149 | /// addPreISelPasses - This method should add any "last minute" LLVM->LLVM |
| 150 | /// passes (which are run just before instruction selector). |
| 151 | virtual bool addPreISel() { |
| 152 | return true; |
| 153 | } |
| 154 | |
| Andrew Trick | f7b9631 | 2012-02-09 00:40:55 +0000 | [diff] [blame] | 155 | /// addMachineSSAOptimization - Add standard passes that optimize machine |
| 156 | /// instructions in SSA form. |
| 157 | virtual void addMachineSSAOptimization(); |
| 158 | |
| Andrew Trick | 843ee2e | 2012-02-03 05:12:41 +0000 | [diff] [blame] | 159 | /// addPreRegAlloc - This method may be implemented by targets that want to |
| 160 | /// run passes immediately before register allocation. This should return |
| 161 | /// true if -print-machineinstrs should print after these passes. |
| 162 | virtual bool addPreRegAlloc() { |
| 163 | return false; |
| 164 | } |
| 165 | |
| Andrew Trick | 8dd2625 | 2012-02-10 04:10:36 +0000 | [diff] [blame] | 166 | /// createTargetRegisterAllocator - Create the register allocator pass for |
| 167 | /// this target at the current optimization level. |
| 168 | virtual FunctionPass *createTargetRegisterAllocator(bool Optimized); |
| 169 | |
| 170 | /// addFastRegAlloc - Add the minimum set of target-independent passes that |
| 171 | /// are required for fast register allocation. |
| 172 | virtual void addFastRegAlloc(FunctionPass *RegAllocPass); |
| 173 | |
| Andrew Trick | fda655e | 2012-02-11 07:11:29 +0000 | [diff] [blame] | 174 | /// addOptimizedRegAlloc - Add passes related to register allocation. |
| 175 | /// LLVMTargetMachine provides standard regalloc passes for most targets. |
| Andrew Trick | 8dd2625 | 2012-02-10 04:10:36 +0000 | [diff] [blame] | 176 | virtual void addOptimizedRegAlloc(FunctionPass *RegAllocPass); |
| Andrew Trick | f7b9631 | 2012-02-09 00:40:55 +0000 | [diff] [blame] | 177 | |
| Andrew Trick | 746f24b | 2012-02-11 07:11:32 +0000 | [diff] [blame] | 178 | /// addFinalizeRegAlloc - This method may be implemented by targets that want |
| 179 | /// to run passes within the regalloc pipeline, immediately after the register |
| 180 | /// allocation pass itself. These passes run as soon as virtual regisiters |
| 181 | /// have been rewritten to physical registers but before and other postRA |
| 182 | /// optimization happens. Targets that have marked instructions for bundling |
| 183 | /// must have finalized those bundles by the time these passes have run, |
| 184 | /// because subsequent passes are not guaranteed to be bundle-aware. |
| 185 | virtual bool addFinalizeRegAlloc() { |
| 186 | return false; |
| 187 | } |
| 188 | |
| 189 | /// addPostRegAlloc - This method may be implemented by targets that want to |
| 190 | /// run passes after register allocation pass pipeline but before |
| 191 | /// prolog-epilog insertion. This should return true if -print-machineinstrs |
| 192 | /// should print after these passes. |
| Andrew Trick | 843ee2e | 2012-02-03 05:12:41 +0000 | [diff] [blame] | 193 | virtual bool addPostRegAlloc() { |
| 194 | return false; |
| 195 | } |
| 196 | |
| Andrew Trick | f7b9631 | 2012-02-09 00:40:55 +0000 | [diff] [blame] | 197 | /// Add passes that optimize machine instructions after register allocation. |
| 198 | virtual void addMachineLateOptimization(); |
| 199 | |
| Andrew Trick | 843ee2e | 2012-02-03 05:12:41 +0000 | [diff] [blame] | 200 | /// addPreSched2 - This method may be implemented by targets that want to |
| 201 | /// run passes after prolog-epilog insertion and before the second instruction |
| 202 | /// scheduling pass. This should return true if -print-machineinstrs should |
| 203 | /// print after these passes. |
| 204 | virtual bool addPreSched2() { |
| 205 | return false; |
| 206 | } |
| 207 | |
| Andrew Trick | f7b9631 | 2012-02-09 00:40:55 +0000 | [diff] [blame] | 208 | /// Add standard basic block placement passes. |
| 209 | virtual void addBlockPlacement(); |
| 210 | |
| Andrew Trick | 843ee2e | 2012-02-03 05:12:41 +0000 | [diff] [blame] | 211 | /// addPreEmitPass - This pass may be implemented by targets that want to run |
| 212 | /// passes immediately before machine code is emitted. This should return |
| 213 | /// true if -print-machineinstrs should print out the code after the passes. |
| 214 | virtual bool addPreEmitPass() { |
| 215 | return false; |
| 216 | } |
| 217 | |
| 218 | /// Utilities for targets to add passes to the pass manager. |
| 219 | /// |
| 220 | |
| Andrew Trick | 5e108ee | 2012-02-15 03:21:47 +0000 | [diff] [blame] | 221 | /// Add a CodeGen pass at this point in the pipeline after checking overrides. |
| 222 | /// Return the pass that was added, or NoPassID. |
| 223 | AnalysisID addPass(char &ID); |
| Andrew Trick | 843ee2e | 2012-02-03 05:12:41 +0000 | [diff] [blame] | 224 | |
| Andrew Trick | 8dd2625 | 2012-02-10 04:10:36 +0000 | [diff] [blame] | 225 | /// addMachinePasses helper to create the target-selected or overriden |
| 226 | /// regalloc pass. |
| 227 | FunctionPass *createRegAllocPass(bool Optimized); |
| 228 | |
| Andrew Trick | 843ee2e | 2012-02-03 05:12:41 +0000 | [diff] [blame] | 229 | /// printAndVerify - Add a pass to dump then verify the machine function, if |
| 230 | /// those steps are enabled. |
| 231 | /// |
| 232 | void printAndVerify(const char *Banner) const; |
| 233 | }; |
| 234 | } // namespace llvm |
| 235 | |
| 236 | /// List of target independent CodeGen pass IDs. |
| 237 | namespace llvm { |
| Chris Lattner | 8b708e4 | 2004-07-02 05:44:13 +0000 | [diff] [blame] | 238 | /// createUnreachableBlockEliminationPass - The LLVM code generator does not |
| 239 | /// work well with unreachable basic blocks (what live ranges make sense for a |
| 240 | /// block that cannot be reached?). As such, a code generator should either |
| Jim Grosbach | f691229 | 2010-08-06 21:31:35 +0000 | [diff] [blame] | 241 | /// not instruction select unreachable blocks, or run this pass as its |
| Chris Lattner | 8b708e4 | 2004-07-02 05:44:13 +0000 | [diff] [blame] | 242 | /// last LLVM modifying pass to clean up blocks that are not reachable from |
| 243 | /// the entry block. |
| 244 | FunctionPass *createUnreachableBlockEliminationPass(); |
| Misha Brukman | ea61c35 | 2005-04-21 20:39:54 +0000 | [diff] [blame] | 245 | |
| Chris Lattner | 3e200e6 | 2003-12-20 10:18:58 +0000 | [diff] [blame] | 246 | /// MachineFunctionPrinter pass - This pass prints out the machine function to |
| Jim Grosbach | f691229 | 2010-08-06 21:31:35 +0000 | [diff] [blame] | 247 | /// the given stream as a debugging tool. |
| David Greene | 5c8aa95 | 2010-04-02 23:17:14 +0000 | [diff] [blame] | 248 | MachineFunctionPass * |
| 249 | createMachineFunctionPrinterPass(raw_ostream &OS, |
| 250 | const std::string &Banner =""); |
| Brian Gaeke | 09caa37 | 2004-01-30 21:53:46 +0000 | [diff] [blame] | 251 | |
| Andrew Trick | 1dd8c85 | 2012-02-08 21:23:13 +0000 | [diff] [blame] | 252 | /// MachineLoopInfo - This pass is a loop analysis pass. |
| Owen Anderson | 90c579d | 2010-08-06 18:33:48 +0000 | [diff] [blame] | 253 | extern char &MachineLoopInfoID; |
| Bill Wendling | 67d65bb | 2008-01-04 20:54:55 +0000 | [diff] [blame] | 254 | |
| Andrew Trick | 1dd8c85 | 2012-02-08 21:23:13 +0000 | [diff] [blame] | 255 | /// MachineLoopRanges - This pass is an on-demand loop coverage analysis. |
| Jakob Stoklund Olesen | ceadc01 | 2010-12-15 23:41:23 +0000 | [diff] [blame] | 256 | extern char &MachineLoopRangesID; |
| 257 | |
| Andrew Trick | 1dd8c85 | 2012-02-08 21:23:13 +0000 | [diff] [blame] | 258 | /// MachineDominators - This pass is a machine dominators analysis pass. |
| Owen Anderson | 90c579d | 2010-08-06 18:33:48 +0000 | [diff] [blame] | 259 | extern char &MachineDominatorsID; |
| Bill Wendling | 67d65bb | 2008-01-04 20:54:55 +0000 | [diff] [blame] | 260 | |
| Jakob Stoklund Olesen | 8dd070e | 2011-01-04 21:10:05 +0000 | [diff] [blame] | 261 | /// EdgeBundles analysis - Bundle machine CFG edges. |
| Jakob Stoklund Olesen | 8dd070e | 2011-01-04 21:10:05 +0000 | [diff] [blame] | 262 | extern char &EdgeBundlesID; |
| 263 | |
| Andrew Trick | 8dd2625 | 2012-02-10 04:10:36 +0000 | [diff] [blame] | 264 | /// LiveVariables pass - This pass computes the set of blocks in which each |
| 265 | /// variable is life and sets machine operand kill flags. |
| 266 | extern char &LiveVariablesID; |
| 267 | |
| Andrew Trick | 1dd8c85 | 2012-02-08 21:23:13 +0000 | [diff] [blame] | 268 | /// PHIElimination - This pass eliminates machine instruction PHI nodes |
| Chris Lattner | 3e200e6 | 2003-12-20 10:18:58 +0000 | [diff] [blame] | 269 | /// by inserting copy instructions. This destroys SSA information, but is the |
| 270 | /// desired input for some register allocators. This pass is "required" by |
| 271 | /// these register allocator like this: AU.addRequiredID(PHIEliminationID); |
| Owen Anderson | 90c579d | 2010-08-06 18:33:48 +0000 | [diff] [blame] | 272 | extern char &PHIEliminationID; |
| Jim Grosbach | f691229 | 2010-08-06 21:31:35 +0000 | [diff] [blame] | 273 | |
| Andrew Trick | 1dd8c85 | 2012-02-08 21:23:13 +0000 | [diff] [blame] | 274 | /// StrongPHIElimination - This pass eliminates machine instruction PHI |
| Owen Anderson | 0bda0e8 | 2007-10-31 03:37:57 +0000 | [diff] [blame] | 275 | /// nodes by inserting copy instructions. This destroys SSA information, but |
| 276 | /// is the desired input for some register allocators. This pass is |
| 277 | /// "required" by these register allocator like this: |
| 278 | /// AU.addRequiredID(PHIEliminationID); |
| 279 | /// This pass is still in development |
| Owen Anderson | 90c579d | 2010-08-06 18:33:48 +0000 | [diff] [blame] | 280 | extern char &StrongPHIEliminationID; |
| Chris Lattner | db00065 | 2003-01-13 01:01:31 +0000 | [diff] [blame] | 281 | |
| Jakob Stoklund Olesen | 2d17293 | 2010-10-26 00:11:33 +0000 | [diff] [blame] | 282 | /// LiveStacks pass. An analysis keeping track of the liveness of stack slots. |
| 283 | extern char &LiveStacksID; |
| 284 | |
| Andrew Trick | 1dd8c85 | 2012-02-08 21:23:13 +0000 | [diff] [blame] | 285 | /// TwoAddressInstruction - This pass reduces two-address instructions to |
| Chris Lattner | 3e200e6 | 2003-12-20 10:18:58 +0000 | [diff] [blame] | 286 | /// use two operands. This destroys SSA information but it is desired by |
| 287 | /// register allocators. |
| Owen Anderson | 90c579d | 2010-08-06 18:33:48 +0000 | [diff] [blame] | 288 | extern char &TwoAddressInstructionPassID; |
| Chris Lattner | db00065 | 2003-01-13 01:01:31 +0000 | [diff] [blame] | 289 | |
| Andrew Trick | 8dd2625 | 2012-02-10 04:10:36 +0000 | [diff] [blame] | 290 | /// ProcessImpicitDefs pass - This pass removes IMPLICIT_DEFs. |
| 291 | extern char &ProcessImplicitDefsID; |
| 292 | |
| 293 | /// RegisterCoalescer - This pass merges live ranges to eliminate copies. |
| 294 | extern char &RegisterCoalescerID; |
| Jakob Stoklund Olesen | 2721567 | 2011-08-09 00:29:53 +0000 | [diff] [blame] | 295 | |
| Andrew Trick | 1dd8c85 | 2012-02-08 21:23:13 +0000 | [diff] [blame] | 296 | /// MachineScheduler - This pass schedules machine instructions. |
| Andrew Trick | 42b7a71 | 2012-01-17 06:55:03 +0000 | [diff] [blame] | 297 | extern char &MachineSchedulerID; |
| Andrew Trick | 96f678f | 2012-01-13 06:30:30 +0000 | [diff] [blame] | 298 | |
| Jakob Stoklund Olesen | 8bfe508 | 2011-01-06 01:21:53 +0000 | [diff] [blame] | 299 | /// SpillPlacement analysis. Suggest optimal placement of spill code between |
| 300 | /// basic blocks. |
| Jakob Stoklund Olesen | 8bfe508 | 2011-01-06 01:21:53 +0000 | [diff] [blame] | 301 | extern char &SpillPlacementID; |
| 302 | |
| Andrew Trick | 1dd8c85 | 2012-02-08 21:23:13 +0000 | [diff] [blame] | 303 | /// UnreachableMachineBlockElimination - This pass removes unreachable |
| Owen Anderson | bd3ba46 | 2008-08-04 23:54:43 +0000 | [diff] [blame] | 304 | /// machine basic blocks. |
| Owen Anderson | 90c579d | 2010-08-06 18:33:48 +0000 | [diff] [blame] | 305 | extern char &UnreachableMachineBlockElimID; |
| Owen Anderson | bd3ba46 | 2008-08-04 23:54:43 +0000 | [diff] [blame] | 306 | |
| Andrew Trick | 1dd8c85 | 2012-02-08 21:23:13 +0000 | [diff] [blame] | 307 | /// DeadMachineInstructionElim - This pass removes dead machine instructions. |
| 308 | extern char &DeadMachineInstructionElimID; |
| Dan Gohman | d3ead43 | 2008-09-17 00:43:24 +0000 | [diff] [blame] | 309 | |
| Jakob Stoklund Olesen | 0020723 | 2010-04-21 18:02:42 +0000 | [diff] [blame] | 310 | /// FastRegisterAllocation Pass - This pass register allocates as fast as |
| 311 | /// possible. It is best suited for debug code where live ranges are short. |
| 312 | /// |
| 313 | FunctionPass *createFastRegisterAllocator(); |
| 314 | |
| Andrew Trick | 14e8d71 | 2010-10-22 23:09:15 +0000 | [diff] [blame] | 315 | /// BasicRegisterAllocation Pass - This pass implements a degenerate global |
| 316 | /// register allocator using the basic regalloc framework. |
| 317 | /// |
| 318 | FunctionPass *createBasicRegisterAllocator(); |
| 319 | |
| Jakob Stoklund Olesen | cba2e06 | 2010-12-08 03:26:16 +0000 | [diff] [blame] | 320 | /// Greedy register allocation pass - This pass implements a global register |
| 321 | /// allocator for optimized builds. |
| 322 | /// |
| 323 | FunctionPass *createGreedyRegisterAllocator(); |
| 324 | |
| Evan Cheng | b1290a6 | 2008-10-02 18:29:27 +0000 | [diff] [blame] | 325 | /// PBQPRegisterAllocation Pass - This pass implements the Partitioned Boolean |
| 326 | /// Quadratic Prograaming (PBQP) based register allocator. |
| 327 | /// |
| Lang Hames | f70e7cc | 2010-09-23 04:28:54 +0000 | [diff] [blame] | 328 | FunctionPass *createDefaultPBQPRegisterAllocator(); |
| Evan Cheng | b1290a6 | 2008-10-02 18:29:27 +0000 | [diff] [blame] | 329 | |
| Andrew Trick | 1dd8c85 | 2012-02-08 21:23:13 +0000 | [diff] [blame] | 330 | /// PrologEpilogCodeInserter - This pass inserts prolog and epilog code, |
| Chris Lattner | 3e200e6 | 2003-12-20 10:18:58 +0000 | [diff] [blame] | 331 | /// and eliminates abstract frame references. |
| Andrew Trick | 1dd8c85 | 2012-02-08 21:23:13 +0000 | [diff] [blame] | 332 | extern char &PrologEpilogCodeInserterID; |
| Jim Grosbach | f691229 | 2010-08-06 21:31:35 +0000 | [diff] [blame] | 333 | |
| Andrew Trick | 1dd8c85 | 2012-02-08 21:23:13 +0000 | [diff] [blame] | 334 | /// ExpandPostRAPseudos - This pass expands pseudo instructions after |
| Jakob Stoklund Olesen | 74e2d6e | 2011-09-25 16:46:08 +0000 | [diff] [blame] | 335 | /// register allocation. |
| Andrew Trick | 1dd8c85 | 2012-02-08 21:23:13 +0000 | [diff] [blame] | 336 | extern char &ExpandPostRAPseudosID; |
| Chris Lattner | db00065 | 2003-01-13 01:01:31 +0000 | [diff] [blame] | 337 | |
| Evan Cheng | fa16354 | 2009-10-16 21:06:15 +0000 | [diff] [blame] | 338 | /// createPostRAScheduler - This pass performs post register allocation |
| 339 | /// scheduling. |
| Andrew Trick | 1dd8c85 | 2012-02-08 21:23:13 +0000 | [diff] [blame] | 340 | extern char &PostRASchedulerID; |
| Dale Johannesen | e7e7d0d | 2007-07-13 17:13:54 +0000 | [diff] [blame] | 341 | |
| Andrew Trick | 1dd8c85 | 2012-02-08 21:23:13 +0000 | [diff] [blame] | 342 | /// BranchFolding - This pass performs machine code CFG based |
| Chris Lattner | 36c29db | 2004-07-31 09:59:14 +0000 | [diff] [blame] | 343 | /// optimizations to delete branches to branches, eliminate branches to |
| 344 | /// successor blocks (creating fall throughs), and eliminating branches over |
| 345 | /// branches. |
| Andrew Trick | 61f1e3d | 2012-02-08 21:22:48 +0000 | [diff] [blame] | 346 | extern char &BranchFolderPassID; |
| Chris Lattner | 36c29db | 2004-07-31 09:59:14 +0000 | [diff] [blame] | 347 | |
| Bob Wilson | 6e1b812 | 2012-05-30 00:17:12 +0000 | [diff] [blame^] | 348 | /// MachineFunctionPrinterPass - This pass prints out MachineInstr's. |
| 349 | extern char &MachineFunctionPrinterPassID; |
| 350 | |
| Andrew Trick | 1dd8c85 | 2012-02-08 21:23:13 +0000 | [diff] [blame] | 351 | /// TailDuplicate - Duplicate blocks with unconditional branches |
| Bob Wilson | 15acadd | 2009-11-26 00:32:21 +0000 | [diff] [blame] | 352 | /// into tails of their predecessors. |
| Andrew Trick | 1dd8c85 | 2012-02-08 21:23:13 +0000 | [diff] [blame] | 353 | extern char &TailDuplicateID; |
| Bob Wilson | 15acadd | 2009-11-26 00:32:21 +0000 | [diff] [blame] | 354 | |
| Andrew Trick | 1dd8c85 | 2012-02-08 21:23:13 +0000 | [diff] [blame] | 355 | /// IfConverter - This pass performs machine code if conversion. |
| 356 | extern char &IfConverterID; |
| Evan Cheng | 4e65485 | 2007-05-16 02:00:57 +0000 | [diff] [blame] | 357 | |
| Andrew Trick | 1dd8c85 | 2012-02-08 21:23:13 +0000 | [diff] [blame] | 358 | /// MachineBlockPlacement - This pass places basic blocks based on branch |
| Chandler Carruth | db35087 | 2011-10-21 06:46:38 +0000 | [diff] [blame] | 359 | /// probabilities. |
| Andrew Trick | 1dd8c85 | 2012-02-08 21:23:13 +0000 | [diff] [blame] | 360 | extern char &MachineBlockPlacementID; |
| Chandler Carruth | db35087 | 2011-10-21 06:46:38 +0000 | [diff] [blame] | 361 | |
| Andrew Trick | 1dd8c85 | 2012-02-08 21:23:13 +0000 | [diff] [blame] | 362 | /// MachineBlockPlacementStats - This pass collects statistics about the |
| Chandler Carruth | 37efc9f | 2011-11-02 07:17:12 +0000 | [diff] [blame] | 363 | /// basic block placement using branch probabilities and block frequency |
| 364 | /// information. |
| Andrew Trick | 1dd8c85 | 2012-02-08 21:23:13 +0000 | [diff] [blame] | 365 | extern char &MachineBlockPlacementStatsID; |
| Chandler Carruth | 37efc9f | 2011-11-02 07:17:12 +0000 | [diff] [blame] | 366 | |
| Andrew Trick | 1dd8c85 | 2012-02-08 21:23:13 +0000 | [diff] [blame] | 367 | /// Code Placement - This pass optimize code placement and aligns loop |
| Evan Cheng | bbf1db7 | 2009-05-07 05:42:24 +0000 | [diff] [blame] | 368 | /// headers to target specific alignment boundary. |
| Andrew Trick | 1dd8c85 | 2012-02-08 21:23:13 +0000 | [diff] [blame] | 369 | extern char &CodePlacementOptID; |
| Evan Cheng | fb8075d | 2008-02-28 00:43:03 +0000 | [diff] [blame] | 370 | |
| Andrew Trick | 1dd8c85 | 2012-02-08 21:23:13 +0000 | [diff] [blame] | 371 | /// GCLowering Pass - Performs target-independent LLVM IR transformations for |
| 372 | /// highly portable strategies. |
| 373 | /// |
| Gordon Henriksen | ad93c4f | 2007-12-11 00:30:17 +0000 | [diff] [blame] | 374 | FunctionPass *createGCLoweringPass(); |
| Jim Grosbach | f691229 | 2010-08-06 21:31:35 +0000 | [diff] [blame] | 375 | |
| Andrew Trick | 1dd8c85 | 2012-02-08 21:23:13 +0000 | [diff] [blame] | 376 | /// GCMachineCodeAnalysis - Target-independent pass to mark safe points |
| 377 | /// in machine code. Must be added very late during code generation, just |
| 378 | /// prior to output, and importantly after all CFG transformations (such as |
| 379 | /// branch folding). |
| 380 | extern char &GCMachineCodeAnalysisID; |
| Jim Grosbach | f691229 | 2010-08-06 21:31:35 +0000 | [diff] [blame] | 381 | |
| Gordon Henriksen | 5eca075 | 2008-08-17 18:44:35 +0000 | [diff] [blame] | 382 | /// Deleter Pass - Releases GC metadata. |
| Jim Grosbach | f691229 | 2010-08-06 21:31:35 +0000 | [diff] [blame] | 383 | /// |
| Gordon Henriksen | 5eca075 | 2008-08-17 18:44:35 +0000 | [diff] [blame] | 384 | FunctionPass *createGCInfoDeleter(); |
| Jim Grosbach | f691229 | 2010-08-06 21:31:35 +0000 | [diff] [blame] | 385 | |
| Gordon Henriksen | 5eca075 | 2008-08-17 18:44:35 +0000 | [diff] [blame] | 386 | /// Creates a pass to print GC metadata. |
| Jim Grosbach | f691229 | 2010-08-06 21:31:35 +0000 | [diff] [blame] | 387 | /// |
| Chris Lattner | cf143a4 | 2009-08-23 03:13:20 +0000 | [diff] [blame] | 388 | FunctionPass *createGCInfoPrinter(raw_ostream &OS); |
| Jim Grosbach | f691229 | 2010-08-06 21:31:35 +0000 | [diff] [blame] | 389 | |
| Andrew Trick | 1dd8c85 | 2012-02-08 21:23:13 +0000 | [diff] [blame] | 390 | /// MachineCSE - This pass performs global CSE on machine instructions. |
| 391 | extern char &MachineCSEID; |
| Evan Cheng | c6fe333 | 2010-03-02 02:38:24 +0000 | [diff] [blame] | 392 | |
| Andrew Trick | 1dd8c85 | 2012-02-08 21:23:13 +0000 | [diff] [blame] | 393 | /// MachineLICM - This pass performs LICM on machine instructions. |
| 394 | extern char &MachineLICMID; |
| Bill Wendling | 0f940c9 | 2007-12-07 21:42:31 +0000 | [diff] [blame] | 395 | |
| Andrew Trick | 1dd8c85 | 2012-02-08 21:23:13 +0000 | [diff] [blame] | 396 | /// MachineSinking - This pass performs sinking on machine instructions. |
| 397 | extern char &MachineSinkingID; |
| Evan Cheng | 3f32d65 | 2008-06-04 09:18:41 +0000 | [diff] [blame] | 398 | |
| Andrew Trick | 1dd8c85 | 2012-02-08 21:23:13 +0000 | [diff] [blame] | 399 | /// MachineCopyPropagation - This pass performs copy propagation on |
| Evan Cheng | 977679d | 2012-01-07 03:02:36 +0000 | [diff] [blame] | 400 | /// machine instructions. |
| Andrew Trick | 1dd8c85 | 2012-02-08 21:23:13 +0000 | [diff] [blame] | 401 | extern char &MachineCopyPropagationID; |
| Evan Cheng | 977679d | 2012-01-07 03:02:36 +0000 | [diff] [blame] | 402 | |
| Andrew Trick | 1dd8c85 | 2012-02-08 21:23:13 +0000 | [diff] [blame] | 403 | /// PeepholeOptimizer - This pass performs peephole optimizations - |
| Bill Wendling | 6cdb1ab | 2010-08-09 23:59:04 +0000 | [diff] [blame] | 404 | /// like extension and comparison eliminations. |
| Andrew Trick | 1dd8c85 | 2012-02-08 21:23:13 +0000 | [diff] [blame] | 405 | extern char &PeepholeOptimizerID; |
| Evan Cheng | 7da9ecf | 2010-01-13 00:30:23 +0000 | [diff] [blame] | 406 | |
| Andrew Trick | 1dd8c85 | 2012-02-08 21:23:13 +0000 | [diff] [blame] | 407 | /// OptimizePHIs - This pass optimizes machine instruction PHIs |
| Bob Wilson | fe61fb1 | 2010-02-12 01:30:21 +0000 | [diff] [blame] | 408 | /// to take advantage of opportunities created during DAG legalization. |
| Andrew Trick | 1dd8c85 | 2012-02-08 21:23:13 +0000 | [diff] [blame] | 409 | extern char &OptimizePHIsID; |
| Bob Wilson | fe61fb1 | 2010-02-12 01:30:21 +0000 | [diff] [blame] | 410 | |
| Andrew Trick | 1dd8c85 | 2012-02-08 21:23:13 +0000 | [diff] [blame] | 411 | /// StackSlotColoring - This pass performs stack slot coloring. |
| 412 | extern char &StackSlotColoringID; |
| Bill Wendling | 2b58ce5 | 2008-11-04 02:10:20 +0000 | [diff] [blame] | 413 | |
| 414 | /// createStackProtectorPass - This pass adds stack protectors to functions. |
| Andrew Trick | 1dd8c85 | 2012-02-08 21:23:13 +0000 | [diff] [blame] | 415 | /// |
| Bill Wendling | e9e6bdf | 2008-11-13 01:02:14 +0000 | [diff] [blame] | 416 | FunctionPass *createStackProtectorPass(const TargetLowering *tli); |
| Bill Wendling | 2b58ce5 | 2008-11-04 02:10:20 +0000 | [diff] [blame] | 417 | |
| Jakob Stoklund Olesen | 48872e0 | 2009-05-16 00:33:53 +0000 | [diff] [blame] | 418 | /// createMachineVerifierPass - This pass verifies cenerated machine code |
| 419 | /// instructions for correctness. |
| Andrew Trick | 1dd8c85 | 2012-02-08 21:23:13 +0000 | [diff] [blame] | 420 | /// |
| Jakob Stoklund Olesen | 89cab93 | 2010-12-18 00:06:56 +0000 | [diff] [blame] | 421 | FunctionPass *createMachineVerifierPass(const char *Banner = 0); |
| Jakob Stoklund Olesen | 48872e0 | 2009-05-16 00:33:53 +0000 | [diff] [blame] | 422 | |
| Duncan Sands | b0f1e17 | 2009-05-22 20:36:31 +0000 | [diff] [blame] | 423 | /// createDwarfEHPass - This pass mulches exception handling code into a form |
| 424 | /// adapted to code generation. Required if using dwarf exception handling. |
| Duncan Sands | 22efc18 | 2010-08-31 09:05:06 +0000 | [diff] [blame] | 425 | FunctionPass *createDwarfEHPass(const TargetMachine *tm); |
| Duncan Sands | b0f1e17 | 2009-05-22 20:36:31 +0000 | [diff] [blame] | 426 | |
| Bill Wendling | eabae1d | 2012-03-13 20:04:21 +0000 | [diff] [blame] | 427 | /// createSjLjEHPreparePass - This pass adapts exception handling code to use |
| Jim Grosbach | 8b818d7 | 2009-08-17 16:41:22 +0000 | [diff] [blame] | 428 | /// the GCC-style builtin setjmp/longjmp (sjlj) to handling EH control flow. |
| Andrew Trick | 1dd8c85 | 2012-02-08 21:23:13 +0000 | [diff] [blame] | 429 | /// |
| Bill Wendling | eabae1d | 2012-03-13 20:04:21 +0000 | [diff] [blame] | 430 | FunctionPass *createSjLjEHPreparePass(const TargetLowering *tli); |
| Jim Grosbach | 8b818d7 | 2009-08-17 16:41:22 +0000 | [diff] [blame] | 431 | |
| Andrew Trick | 1dd8c85 | 2012-02-08 21:23:13 +0000 | [diff] [blame] | 432 | /// LocalStackSlotAllocation - This pass assigns local frame indices to stack |
| 433 | /// slots relative to one another and allocates base registers to access them |
| 434 | /// when it is estimated by the target to be out of range of normal frame |
| 435 | /// pointer or stack pointer index addressing. |
| 436 | extern char &LocalStackSlotAllocationID; |
| Jim Grosbach | 3d72367 | 2010-08-14 00:15:52 +0000 | [diff] [blame] | 437 | |
| Andrew Trick | 1dd8c85 | 2012-02-08 21:23:13 +0000 | [diff] [blame] | 438 | /// ExpandISelPseudos - This pass expands pseudo-instructions. |
| 439 | extern char &ExpandISelPseudosID; |
| Dan Gohman | 668ac2f | 2010-11-16 21:02:37 +0000 | [diff] [blame] | 440 | |
| Jakob Stoklund Olesen | df4b35e | 2011-09-27 23:50:46 +0000 | [diff] [blame] | 441 | /// createExecutionDependencyFixPass - This pass fixes execution time |
| 442 | /// problems with dependent instructions, such as switching execution |
| 443 | /// domains to match. |
| 444 | /// |
| 445 | /// The pass will examine instructions using and defining registers in RC. |
| 446 | /// |
| 447 | FunctionPass *createExecutionDependencyFixPass(const TargetRegisterClass *RC); |
| 448 | |
| Andrew Trick | 1dd8c85 | 2012-02-08 21:23:13 +0000 | [diff] [blame] | 449 | /// UnpackMachineBundles - This pass unpack machine instruction bundles. |
| 450 | extern char &UnpackMachineBundlesID; |
| Evan Cheng | ddfd137 | 2011-12-14 02:11:42 +0000 | [diff] [blame] | 451 | |
| Andrew Trick | 1dd8c85 | 2012-02-08 21:23:13 +0000 | [diff] [blame] | 452 | /// FinalizeMachineBundles - This pass finalize machine instruction |
| Evan Cheng | ef2887d | 2012-01-19 07:47:03 +0000 | [diff] [blame] | 453 | /// bundles (created earlier, e.g. during pre-RA scheduling). |
| Andrew Trick | 1dd8c85 | 2012-02-08 21:23:13 +0000 | [diff] [blame] | 454 | extern char &FinalizeMachineBundlesID; |
| Evan Cheng | ef2887d | 2012-01-19 07:47:03 +0000 | [diff] [blame] | 455 | |
| Brian Gaeke | d0fde30 | 2003-11-11 22:41:34 +0000 | [diff] [blame] | 456 | } // End llvm namespace |
| 457 | |
| Chris Lattner | db00065 | 2003-01-13 01:01:31 +0000 | [diff] [blame] | 458 | #endif |