blob: 1ccf29d844b3864cbd303edfedf716e7490088bd [file] [log] [blame]
Misha Brukmanef6a6a62003-08-21 22:14:26 +00001//===-- Passes.h - Target independent code generation passes ----*- C++ -*-===//
Misha Brukmanea61c352005-04-21 20:39:54 +00002//
John Criswell6fbcc262003-10-20 20:19:47 +00003// The LLVM Compiler Infrastructure
4//
Chris Lattner7ed47a12007-12-29 19:59:42 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Misha Brukmanea61c352005-04-21 20:39:54 +00007//
John Criswell6fbcc262003-10-20 20:19:47 +00008//===----------------------------------------------------------------------===//
Chris Lattnerdb000652003-01-13 01:01:31 +00009//
Misha Brukmanef6a6a62003-08-21 22:14:26 +000010// This file defines interfaces to access the target independent code generation
Chris Lattnerdb000652003-01-13 01:01:31 +000011// passes provided by the LLVM backend.
12//
13//===----------------------------------------------------------------------===//
14
15#ifndef LLVM_CODEGEN_PASSES_H
16#define LLVM_CODEGEN_PASSES_H
17
Andrew Trick74613342012-02-04 02:56:45 +000018#include "llvm/Pass.h"
Evan Chengfa163542009-10-16 21:06:15 +000019#include "llvm/Target/TargetMachine.h"
Brian Gaekefc1f6e82004-02-04 21:41:10 +000020#include <string>
Brian Gaeke09caa372004-01-30 21:53:46 +000021
Brian Gaeked0fde302003-11-11 22:41:34 +000022namespace llvm {
23
Chris Lattner3e200e62003-12-20 10:18:58 +000024 class FunctionPass;
David Greene5c8aa952010-04-02 23:17:14 +000025 class MachineFunctionPass;
Chris Lattner3e200e62003-12-20 10:18:58 +000026 class PassInfo;
Bob Wilson8add7b42012-07-02 19:48:18 +000027 class PassManagerBase;
Bill Wendling80a320d2008-11-04 21:53:09 +000028 class TargetLowering;
Jakob Stoklund Olesendf4b35e2011-09-27 23:50:46 +000029 class TargetRegisterClass;
Chris Lattnercf143a42009-08-23 03:13:20 +000030 class raw_ostream;
Andrew Trick843ee2e2012-02-03 05:12:41 +000031}
Chris Lattner8b708e42004-07-02 05:44:13 +000032
Andrew Trick843ee2e2012-02-03 05:12:41 +000033namespace llvm {
34
Andrew Trick746f24b2012-02-11 07:11:32 +000035extern char &NoPassID; // Allow targets to choose not to run a pass.
36
Andrew Trick5e108ee2012-02-15 03:21:47 +000037class PassConfigImpl;
38
Andrew Trick843ee2e2012-02-03 05:12:41 +000039/// Target-Independent Code Generator Pass Configuration Options.
40///
Andrew Trick74613342012-02-04 02:56:45 +000041/// This is an ImmutablePass solely for the purpose of exposing CodeGen options
42/// to the internals of other CodeGen passes.
Andrew Trick74613342012-02-04 02:56:45 +000043class TargetPassConfig : public ImmutablePass {
Andrew Trick79bf2882012-02-15 03:21:51 +000044public:
45 /// Pseudo Pass IDs. These are defined within TargetPassConfig because they
46 /// are unregistered pass IDs. They are only useful for use with
47 /// TargetPassConfig APIs to identify multiple occurrences of the same pass.
48 ///
49
50 /// EarlyTailDuplicate - A clone of the TailDuplicate pass that runs early
51 /// during codegen, on SSA form.
52 static char EarlyTailDuplicateID;
53
54 /// PostRAMachineLICM - A clone of the LICM pass that runs during late machine
55 /// optimization after regalloc.
56 static char PostRAMachineLICMID;
57
Bob Wilson564fbf62012-07-02 19:48:31 +000058private:
59 PassManagerBase *PM;
60
Andrew Trick843ee2e2012-02-03 05:12:41 +000061protected:
62 TargetMachine *TM;
Andrew Trick5e108ee2012-02-15 03:21:47 +000063 PassConfigImpl *Impl; // Internal data structures
64 bool Initialized; // Flagged after all passes are configured.
Andrew Trick061efcf2012-02-04 02:56:59 +000065
66 // Target Pass Options
Andrew Trick61f1e3d2012-02-08 21:22:48 +000067 // Targets provide a default setting, user flags override.
Andrew Trick061efcf2012-02-04 02:56:59 +000068 //
Andrew Trick843ee2e2012-02-03 05:12:41 +000069 bool DisableVerify;
70
Andrew Trick61f1e3d2012-02-08 21:22:48 +000071 /// Default setting for -enable-tail-merge on this target.
72 bool EnableTailMerge;
73
Andrew Trick843ee2e2012-02-03 05:12:41 +000074public:
Andrew Trick061efcf2012-02-04 02:56:59 +000075 TargetPassConfig(TargetMachine *tm, PassManagerBase &pm);
Andrew Trick74613342012-02-04 02:56:45 +000076 // Dummy constructor.
77 TargetPassConfig();
Andrew Trick843ee2e2012-02-03 05:12:41 +000078
Andrew Trick74613342012-02-04 02:56:45 +000079 virtual ~TargetPassConfig();
80
81 static char ID;
Andrew Trick843ee2e2012-02-03 05:12:41 +000082
83 /// Get the right type of TargetMachine for this target.
84 template<typename TMC> TMC &getTM() const {
85 return *static_cast<TMC*>(TM);
86 }
87
Andrew Trick061efcf2012-02-04 02:56:59 +000088 const TargetLowering *getTargetLowering() const {
89 return TM->getTargetLowering();
90 }
91
Andrew Trick5e108ee2012-02-15 03:21:47 +000092 //
Andrew Trickffea03f2012-02-08 21:22:39 +000093 void setInitialized() { Initialized = true; }
94
Andrew Trick843ee2e2012-02-03 05:12:41 +000095 CodeGenOpt::Level getOptLevel() const { return TM->getOptLevel(); }
96
Andrew Trick61f1e3d2012-02-08 21:22:48 +000097 void setDisableVerify(bool Disable) { setOpt(DisableVerify, Disable); }
98
99 bool getEnableTailMerge() const { return EnableTailMerge; }
100 void setEnableTailMerge(bool Enable) { setOpt(EnableTailMerge, Enable); }
Andrew Trick061efcf2012-02-04 02:56:59 +0000101
Andrew Trick5e108ee2012-02-15 03:21:47 +0000102 /// Allow the target to override a specific pass without overriding the pass
103 /// pipeline. When passes are added to the standard pipeline at the
104 /// point where StadardID is expected, add TargetID in its place.
105 void substitutePass(char &StandardID, char &TargetID);
106
Bob Wilson6e1b8122012-05-30 00:17:12 +0000107 /// Insert InsertedPassID pass after TargetPassID pass.
108 void insertPass(const char &TargetPassID, const char &InsertedPassID);
109
Andrew Trickf91a3302012-03-09 00:52:17 +0000110 /// Allow the target to enable a specific standard pass by default.
111 void enablePass(char &ID) { substitutePass(ID, ID); }
112
113 /// Allow the target to disable a specific standard pass by default.
Andrew Trick5e108ee2012-02-15 03:21:47 +0000114 void disablePass(char &ID) { substitutePass(ID, NoPassID); }
115
116 /// Return the pass ssubtituted for StandardID by the target.
117 /// If no substitution exists, return StandardID.
118 AnalysisID getPassSubstitution(AnalysisID StandardID) const;
119
Andrew Trick5fd84a22012-02-15 03:21:43 +0000120 /// Return true if the optimized regalloc pipeline is enabled.
Andrew Trick8dd26252012-02-10 04:10:36 +0000121 bool getOptimizeRegAlloc() const;
122
Andrew Trick061efcf2012-02-04 02:56:59 +0000123 /// Add common target configurable passes that perform LLVM IR to IR
124 /// transforms following machine independent optimization.
125 virtual void addIRPasses();
126
Bob Wilson564fbf62012-07-02 19:48:31 +0000127 /// Add passes to lower exception handling for the code generator.
128 void addPassesToHandleExceptions();
129
Andrew Trick061efcf2012-02-04 02:56:59 +0000130 /// Add common passes that perform LLVM IR to IR transforms in preparation for
131 /// instruction selection.
132 virtual void addISelPrepare();
133
134 /// addInstSelector - This method should install an instruction selector pass,
135 /// which converts from LLVM code to machine instructions.
136 virtual bool addInstSelector() {
137 return true;
138 }
Andrew Trick843ee2e2012-02-03 05:12:41 +0000139
140 /// Add the complete, standard set of LLVM CodeGen passes.
141 /// Fully developed targets will not generally override this.
Andrew Trick061efcf2012-02-04 02:56:59 +0000142 virtual void addMachinePasses();
Andrew Trick9d41bd52012-02-08 21:23:03 +0000143
Andrew Trick843ee2e2012-02-03 05:12:41 +0000144protected:
Andrew Trickffea03f2012-02-08 21:22:39 +0000145 // Helper to verify the analysis is really immutable.
146 void setOpt(bool &Opt, bool Val);
147
Andrew Trick061efcf2012-02-04 02:56:59 +0000148 /// Methods with trivial inline returns are convenient points in the common
149 /// codegen pass pipeline where targets may insert passes. Methods with
150 /// out-of-line standard implementations are major CodeGen stages called by
151 /// addMachinePasses. Some targets may override major stages when inserting
152 /// passes is insufficient, but maintaining overriden stages is more work.
Andrew Trick843ee2e2012-02-03 05:12:41 +0000153 ///
154
155 /// addPreISelPasses - This method should add any "last minute" LLVM->LLVM
156 /// passes (which are run just before instruction selector).
157 virtual bool addPreISel() {
158 return true;
159 }
160
Andrew Trickf7b96312012-02-09 00:40:55 +0000161 /// addMachineSSAOptimization - Add standard passes that optimize machine
162 /// instructions in SSA form.
163 virtual void addMachineSSAOptimization();
164
Andrew Trick843ee2e2012-02-03 05:12:41 +0000165 /// addPreRegAlloc - This method may be implemented by targets that want to
166 /// run passes immediately before register allocation. This should return
167 /// true if -print-machineinstrs should print after these passes.
168 virtual bool addPreRegAlloc() {
169 return false;
170 }
171
Andrew Trick8dd26252012-02-10 04:10:36 +0000172 /// createTargetRegisterAllocator - Create the register allocator pass for
173 /// this target at the current optimization level.
174 virtual FunctionPass *createTargetRegisterAllocator(bool Optimized);
175
176 /// addFastRegAlloc - Add the minimum set of target-independent passes that
177 /// are required for fast register allocation.
178 virtual void addFastRegAlloc(FunctionPass *RegAllocPass);
179
Andrew Trickfda655e2012-02-11 07:11:29 +0000180 /// addOptimizedRegAlloc - Add passes related to register allocation.
181 /// LLVMTargetMachine provides standard regalloc passes for most targets.
Andrew Trick8dd26252012-02-10 04:10:36 +0000182 virtual void addOptimizedRegAlloc(FunctionPass *RegAllocPass);
Andrew Trickf7b96312012-02-09 00:40:55 +0000183
Jakob Stoklund Olesen34f5a2b2012-06-26 17:09:29 +0000184 /// addPreRewrite - Add passes to the optimized register allocation pipeline
185 /// after register allocation is complete, but before virtual registers are
186 /// rewritten to physical registers.
187 ///
188 /// These passes must preserve VirtRegMap and LiveIntervals, and when running
189 /// after RABasic or RAGreedy, they should take advantage of LiveRegMatrix.
190 /// When these passes run, VirtRegMap contains legal physreg assignments for
191 /// all virtual registers.
192 virtual bool addPreRewrite() {
193 return false;
194 }
195
Andrew Trick746f24b2012-02-11 07:11:32 +0000196 /// addFinalizeRegAlloc - This method may be implemented by targets that want
197 /// to run passes within the regalloc pipeline, immediately after the register
198 /// allocation pass itself. These passes run as soon as virtual regisiters
199 /// have been rewritten to physical registers but before and other postRA
200 /// optimization happens. Targets that have marked instructions for bundling
201 /// must have finalized those bundles by the time these passes have run,
202 /// because subsequent passes are not guaranteed to be bundle-aware.
203 virtual bool addFinalizeRegAlloc() {
204 return false;
205 }
206
207 /// addPostRegAlloc - This method may be implemented by targets that want to
208 /// run passes after register allocation pass pipeline but before
209 /// prolog-epilog insertion. This should return true if -print-machineinstrs
210 /// should print after these passes.
Andrew Trick843ee2e2012-02-03 05:12:41 +0000211 virtual bool addPostRegAlloc() {
212 return false;
213 }
214
Andrew Trickf7b96312012-02-09 00:40:55 +0000215 /// Add passes that optimize machine instructions after register allocation.
216 virtual void addMachineLateOptimization();
217
Andrew Trick843ee2e2012-02-03 05:12:41 +0000218 /// addPreSched2 - This method may be implemented by targets that want to
219 /// run passes after prolog-epilog insertion and before the second instruction
220 /// scheduling pass. This should return true if -print-machineinstrs should
221 /// print after these passes.
222 virtual bool addPreSched2() {
223 return false;
224 }
225
Andrew Trickf7b96312012-02-09 00:40:55 +0000226 /// Add standard basic block placement passes.
227 virtual void addBlockPlacement();
228
Andrew Trick843ee2e2012-02-03 05:12:41 +0000229 /// addPreEmitPass - This pass may be implemented by targets that want to run
230 /// passes immediately before machine code is emitted. This should return
231 /// true if -print-machineinstrs should print out the code after the passes.
232 virtual bool addPreEmitPass() {
233 return false;
234 }
235
236 /// Utilities for targets to add passes to the pass manager.
237 ///
238
Andrew Trick5e108ee2012-02-15 03:21:47 +0000239 /// Add a CodeGen pass at this point in the pipeline after checking overrides.
240 /// Return the pass that was added, or NoPassID.
241 AnalysisID addPass(char &ID);
Andrew Trick843ee2e2012-02-03 05:12:41 +0000242
Bob Wilson564fbf62012-07-02 19:48:31 +0000243 /// Add a pass to the PassManager.
244 void addPass(Pass *P);
245
Andrew Trick8dd26252012-02-10 04:10:36 +0000246 /// addMachinePasses helper to create the target-selected or overriden
247 /// regalloc pass.
248 FunctionPass *createRegAllocPass(bool Optimized);
249
Andrew Trick843ee2e2012-02-03 05:12:41 +0000250 /// printAndVerify - Add a pass to dump then verify the machine function, if
251 /// those steps are enabled.
252 ///
Bob Wilson564fbf62012-07-02 19:48:31 +0000253 void printAndVerify(const char *Banner);
Andrew Trick843ee2e2012-02-03 05:12:41 +0000254};
255} // namespace llvm
256
257/// List of target independent CodeGen pass IDs.
258namespace llvm {
Chris Lattner8b708e42004-07-02 05:44:13 +0000259 /// createUnreachableBlockEliminationPass - The LLVM code generator does not
260 /// work well with unreachable basic blocks (what live ranges make sense for a
261 /// block that cannot be reached?). As such, a code generator should either
Jim Grosbachf6912292010-08-06 21:31:35 +0000262 /// not instruction select unreachable blocks, or run this pass as its
Chris Lattner8b708e42004-07-02 05:44:13 +0000263 /// last LLVM modifying pass to clean up blocks that are not reachable from
264 /// the entry block.
265 FunctionPass *createUnreachableBlockEliminationPass();
Misha Brukmanea61c352005-04-21 20:39:54 +0000266
Chris Lattner3e200e62003-12-20 10:18:58 +0000267 /// MachineFunctionPrinter pass - This pass prints out the machine function to
Jim Grosbachf6912292010-08-06 21:31:35 +0000268 /// the given stream as a debugging tool.
David Greene5c8aa952010-04-02 23:17:14 +0000269 MachineFunctionPass *
270 createMachineFunctionPrinterPass(raw_ostream &OS,
271 const std::string &Banner ="");
Brian Gaeke09caa372004-01-30 21:53:46 +0000272
Andrew Trick1dd8c852012-02-08 21:23:13 +0000273 /// MachineLoopInfo - This pass is a loop analysis pass.
Owen Anderson90c579d2010-08-06 18:33:48 +0000274 extern char &MachineLoopInfoID;
Bill Wendling67d65bb2008-01-04 20:54:55 +0000275
Andrew Trick1dd8c852012-02-08 21:23:13 +0000276 /// MachineLoopRanges - This pass is an on-demand loop coverage analysis.
Jakob Stoklund Olesenceadc012010-12-15 23:41:23 +0000277 extern char &MachineLoopRangesID;
278
Andrew Trick1dd8c852012-02-08 21:23:13 +0000279 /// MachineDominators - This pass is a machine dominators analysis pass.
Owen Anderson90c579d2010-08-06 18:33:48 +0000280 extern char &MachineDominatorsID;
Bill Wendling67d65bb2008-01-04 20:54:55 +0000281
Jakob Stoklund Olesen8dd070e2011-01-04 21:10:05 +0000282 /// EdgeBundles analysis - Bundle machine CFG edges.
Jakob Stoklund Olesen8dd070e2011-01-04 21:10:05 +0000283 extern char &EdgeBundlesID;
284
Andrew Trick8dd26252012-02-10 04:10:36 +0000285 /// LiveVariables pass - This pass computes the set of blocks in which each
286 /// variable is life and sets machine operand kill flags.
287 extern char &LiveVariablesID;
288
Andrew Trick1dd8c852012-02-08 21:23:13 +0000289 /// PHIElimination - This pass eliminates machine instruction PHI nodes
Chris Lattner3e200e62003-12-20 10:18:58 +0000290 /// by inserting copy instructions. This destroys SSA information, but is the
291 /// desired input for some register allocators. This pass is "required" by
292 /// these register allocator like this: AU.addRequiredID(PHIEliminationID);
Owen Anderson90c579d2010-08-06 18:33:48 +0000293 extern char &PHIEliminationID;
Jim Grosbachf6912292010-08-06 21:31:35 +0000294
Andrew Trick1dd8c852012-02-08 21:23:13 +0000295 /// StrongPHIElimination - This pass eliminates machine instruction PHI
Owen Anderson0bda0e82007-10-31 03:37:57 +0000296 /// nodes by inserting copy instructions. This destroys SSA information, but
297 /// is the desired input for some register allocators. This pass is
298 /// "required" by these register allocator like this:
299 /// AU.addRequiredID(PHIEliminationID);
300 /// This pass is still in development
Owen Anderson90c579d2010-08-06 18:33:48 +0000301 extern char &StrongPHIEliminationID;
Chris Lattnerdb000652003-01-13 01:01:31 +0000302
Jakob Stoklund Olesen2d172932010-10-26 00:11:33 +0000303 /// LiveStacks pass. An analysis keeping track of the liveness of stack slots.
304 extern char &LiveStacksID;
305
Andrew Trick1dd8c852012-02-08 21:23:13 +0000306 /// TwoAddressInstruction - This pass reduces two-address instructions to
Chris Lattner3e200e62003-12-20 10:18:58 +0000307 /// use two operands. This destroys SSA information but it is desired by
308 /// register allocators.
Owen Anderson90c579d2010-08-06 18:33:48 +0000309 extern char &TwoAddressInstructionPassID;
Chris Lattnerdb000652003-01-13 01:01:31 +0000310
Andrew Trick8dd26252012-02-10 04:10:36 +0000311 /// ProcessImpicitDefs pass - This pass removes IMPLICIT_DEFs.
312 extern char &ProcessImplicitDefsID;
313
314 /// RegisterCoalescer - This pass merges live ranges to eliminate copies.
315 extern char &RegisterCoalescerID;
Jakob Stoklund Olesen27215672011-08-09 00:29:53 +0000316
Andrew Trick1dd8c852012-02-08 21:23:13 +0000317 /// MachineScheduler - This pass schedules machine instructions.
Andrew Trick42b7a712012-01-17 06:55:03 +0000318 extern char &MachineSchedulerID;
Andrew Trick96f678f2012-01-13 06:30:30 +0000319
Jakob Stoklund Olesen8bfe5082011-01-06 01:21:53 +0000320 /// SpillPlacement analysis. Suggest optimal placement of spill code between
321 /// basic blocks.
Jakob Stoklund Olesen8bfe5082011-01-06 01:21:53 +0000322 extern char &SpillPlacementID;
323
Jakob Stoklund Olesen05ec7122012-06-08 23:44:45 +0000324 /// VirtRegRewriter pass. Rewrite virtual registers to physical registers as
325 /// assigned in VirtRegMap.
326 extern char &VirtRegRewriterID;
327
Andrew Trick1dd8c852012-02-08 21:23:13 +0000328 /// UnreachableMachineBlockElimination - This pass removes unreachable
Owen Andersonbd3ba462008-08-04 23:54:43 +0000329 /// machine basic blocks.
Owen Anderson90c579d2010-08-06 18:33:48 +0000330 extern char &UnreachableMachineBlockElimID;
Owen Andersonbd3ba462008-08-04 23:54:43 +0000331
Andrew Trick1dd8c852012-02-08 21:23:13 +0000332 /// DeadMachineInstructionElim - This pass removes dead machine instructions.
333 extern char &DeadMachineInstructionElimID;
Dan Gohmand3ead432008-09-17 00:43:24 +0000334
Jakob Stoklund Olesen00207232010-04-21 18:02:42 +0000335 /// FastRegisterAllocation Pass - This pass register allocates as fast as
336 /// possible. It is best suited for debug code where live ranges are short.
337 ///
338 FunctionPass *createFastRegisterAllocator();
339
Andrew Trick14e8d712010-10-22 23:09:15 +0000340 /// BasicRegisterAllocation Pass - This pass implements a degenerate global
341 /// register allocator using the basic regalloc framework.
342 ///
343 FunctionPass *createBasicRegisterAllocator();
344
Jakob Stoklund Olesencba2e062010-12-08 03:26:16 +0000345 /// Greedy register allocation pass - This pass implements a global register
346 /// allocator for optimized builds.
347 ///
348 FunctionPass *createGreedyRegisterAllocator();
349
Evan Chengb1290a62008-10-02 18:29:27 +0000350 /// PBQPRegisterAllocation Pass - This pass implements the Partitioned Boolean
351 /// Quadratic Prograaming (PBQP) based register allocator.
352 ///
Lang Hamesf70e7cc2010-09-23 04:28:54 +0000353 FunctionPass *createDefaultPBQPRegisterAllocator();
Evan Chengb1290a62008-10-02 18:29:27 +0000354
Andrew Trick1dd8c852012-02-08 21:23:13 +0000355 /// PrologEpilogCodeInserter - This pass inserts prolog and epilog code,
Chris Lattner3e200e62003-12-20 10:18:58 +0000356 /// and eliminates abstract frame references.
Andrew Trick1dd8c852012-02-08 21:23:13 +0000357 extern char &PrologEpilogCodeInserterID;
Jim Grosbachf6912292010-08-06 21:31:35 +0000358
Andrew Trick1dd8c852012-02-08 21:23:13 +0000359 /// ExpandPostRAPseudos - This pass expands pseudo instructions after
Jakob Stoklund Olesen74e2d6e2011-09-25 16:46:08 +0000360 /// register allocation.
Andrew Trick1dd8c852012-02-08 21:23:13 +0000361 extern char &ExpandPostRAPseudosID;
Chris Lattnerdb000652003-01-13 01:01:31 +0000362
Evan Chengfa163542009-10-16 21:06:15 +0000363 /// createPostRAScheduler - This pass performs post register allocation
364 /// scheduling.
Andrew Trick1dd8c852012-02-08 21:23:13 +0000365 extern char &PostRASchedulerID;
Dale Johannesene7e7d0d2007-07-13 17:13:54 +0000366
Andrew Trick1dd8c852012-02-08 21:23:13 +0000367 /// BranchFolding - This pass performs machine code CFG based
Chris Lattner36c29db2004-07-31 09:59:14 +0000368 /// optimizations to delete branches to branches, eliminate branches to
369 /// successor blocks (creating fall throughs), and eliminating branches over
370 /// branches.
Andrew Trick61f1e3d2012-02-08 21:22:48 +0000371 extern char &BranchFolderPassID;
Chris Lattner36c29db2004-07-31 09:59:14 +0000372
Bob Wilson6e1b8122012-05-30 00:17:12 +0000373 /// MachineFunctionPrinterPass - This pass prints out MachineInstr's.
374 extern char &MachineFunctionPrinterPassID;
375
Andrew Trick1dd8c852012-02-08 21:23:13 +0000376 /// TailDuplicate - Duplicate blocks with unconditional branches
Bob Wilson15acadd2009-11-26 00:32:21 +0000377 /// into tails of their predecessors.
Andrew Trick1dd8c852012-02-08 21:23:13 +0000378 extern char &TailDuplicateID;
Bob Wilson15acadd2009-11-26 00:32:21 +0000379
Andrew Trick1dd8c852012-02-08 21:23:13 +0000380 /// IfConverter - This pass performs machine code if conversion.
381 extern char &IfConverterID;
Evan Cheng4e654852007-05-16 02:00:57 +0000382
Andrew Trick1dd8c852012-02-08 21:23:13 +0000383 /// MachineBlockPlacement - This pass places basic blocks based on branch
Chandler Carruthdb350872011-10-21 06:46:38 +0000384 /// probabilities.
Andrew Trick1dd8c852012-02-08 21:23:13 +0000385 extern char &MachineBlockPlacementID;
Chandler Carruthdb350872011-10-21 06:46:38 +0000386
Andrew Trick1dd8c852012-02-08 21:23:13 +0000387 /// MachineBlockPlacementStats - This pass collects statistics about the
Chandler Carruth37efc9f2011-11-02 07:17:12 +0000388 /// basic block placement using branch probabilities and block frequency
389 /// information.
Andrew Trick1dd8c852012-02-08 21:23:13 +0000390 extern char &MachineBlockPlacementStatsID;
Chandler Carruth37efc9f2011-11-02 07:17:12 +0000391
Andrew Trick1dd8c852012-02-08 21:23:13 +0000392 /// Code Placement - This pass optimize code placement and aligns loop
Evan Chengbbf1db72009-05-07 05:42:24 +0000393 /// headers to target specific alignment boundary.
Andrew Trick1dd8c852012-02-08 21:23:13 +0000394 extern char &CodePlacementOptID;
Evan Chengfb8075d2008-02-28 00:43:03 +0000395
Andrew Trick1dd8c852012-02-08 21:23:13 +0000396 /// GCLowering Pass - Performs target-independent LLVM IR transformations for
397 /// highly portable strategies.
398 ///
Gordon Henriksenad93c4f2007-12-11 00:30:17 +0000399 FunctionPass *createGCLoweringPass();
Jim Grosbachf6912292010-08-06 21:31:35 +0000400
Andrew Trick1dd8c852012-02-08 21:23:13 +0000401 /// GCMachineCodeAnalysis - Target-independent pass to mark safe points
402 /// in machine code. Must be added very late during code generation, just
403 /// prior to output, and importantly after all CFG transformations (such as
404 /// branch folding).
405 extern char &GCMachineCodeAnalysisID;
Jim Grosbachf6912292010-08-06 21:31:35 +0000406
Gordon Henriksen5eca0752008-08-17 18:44:35 +0000407 /// Deleter Pass - Releases GC metadata.
Jim Grosbachf6912292010-08-06 21:31:35 +0000408 ///
Gordon Henriksen5eca0752008-08-17 18:44:35 +0000409 FunctionPass *createGCInfoDeleter();
Jim Grosbachf6912292010-08-06 21:31:35 +0000410
Gordon Henriksen5eca0752008-08-17 18:44:35 +0000411 /// Creates a pass to print GC metadata.
Jim Grosbachf6912292010-08-06 21:31:35 +0000412 ///
Chris Lattnercf143a42009-08-23 03:13:20 +0000413 FunctionPass *createGCInfoPrinter(raw_ostream &OS);
Jim Grosbachf6912292010-08-06 21:31:35 +0000414
Andrew Trick1dd8c852012-02-08 21:23:13 +0000415 /// MachineCSE - This pass performs global CSE on machine instructions.
416 extern char &MachineCSEID;
Evan Chengc6fe3332010-03-02 02:38:24 +0000417
Andrew Trick1dd8c852012-02-08 21:23:13 +0000418 /// MachineLICM - This pass performs LICM on machine instructions.
419 extern char &MachineLICMID;
Bill Wendling0f940c92007-12-07 21:42:31 +0000420
Andrew Trick1dd8c852012-02-08 21:23:13 +0000421 /// MachineSinking - This pass performs sinking on machine instructions.
422 extern char &MachineSinkingID;
Evan Cheng3f32d652008-06-04 09:18:41 +0000423
Andrew Trick1dd8c852012-02-08 21:23:13 +0000424 /// MachineCopyPropagation - This pass performs copy propagation on
Evan Cheng977679d2012-01-07 03:02:36 +0000425 /// machine instructions.
Andrew Trick1dd8c852012-02-08 21:23:13 +0000426 extern char &MachineCopyPropagationID;
Evan Cheng977679d2012-01-07 03:02:36 +0000427
Andrew Trick1dd8c852012-02-08 21:23:13 +0000428 /// PeepholeOptimizer - This pass performs peephole optimizations -
Bill Wendling6cdb1ab2010-08-09 23:59:04 +0000429 /// like extension and comparison eliminations.
Andrew Trick1dd8c852012-02-08 21:23:13 +0000430 extern char &PeepholeOptimizerID;
Evan Cheng7da9ecf2010-01-13 00:30:23 +0000431
Andrew Trick1dd8c852012-02-08 21:23:13 +0000432 /// OptimizePHIs - This pass optimizes machine instruction PHIs
Bob Wilsonfe61fb12010-02-12 01:30:21 +0000433 /// to take advantage of opportunities created during DAG legalization.
Andrew Trick1dd8c852012-02-08 21:23:13 +0000434 extern char &OptimizePHIsID;
Bob Wilsonfe61fb12010-02-12 01:30:21 +0000435
Andrew Trick1dd8c852012-02-08 21:23:13 +0000436 /// StackSlotColoring - This pass performs stack slot coloring.
437 extern char &StackSlotColoringID;
Bill Wendling2b58ce52008-11-04 02:10:20 +0000438
439 /// createStackProtectorPass - This pass adds stack protectors to functions.
Andrew Trick1dd8c852012-02-08 21:23:13 +0000440 ///
Bill Wendlinge9e6bdf2008-11-13 01:02:14 +0000441 FunctionPass *createStackProtectorPass(const TargetLowering *tli);
Bill Wendling2b58ce52008-11-04 02:10:20 +0000442
Jakob Stoklund Olesen48872e02009-05-16 00:33:53 +0000443 /// createMachineVerifierPass - This pass verifies cenerated machine code
444 /// instructions for correctness.
Andrew Trick1dd8c852012-02-08 21:23:13 +0000445 ///
Jakob Stoklund Olesen89cab932010-12-18 00:06:56 +0000446 FunctionPass *createMachineVerifierPass(const char *Banner = 0);
Jakob Stoklund Olesen48872e02009-05-16 00:33:53 +0000447
Duncan Sandsb0f1e172009-05-22 20:36:31 +0000448 /// createDwarfEHPass - This pass mulches exception handling code into a form
449 /// adapted to code generation. Required if using dwarf exception handling.
Duncan Sands22efc182010-08-31 09:05:06 +0000450 FunctionPass *createDwarfEHPass(const TargetMachine *tm);
Duncan Sandsb0f1e172009-05-22 20:36:31 +0000451
Bill Wendlingeabae1d2012-03-13 20:04:21 +0000452 /// createSjLjEHPreparePass - This pass adapts exception handling code to use
Jim Grosbach8b818d72009-08-17 16:41:22 +0000453 /// the GCC-style builtin setjmp/longjmp (sjlj) to handling EH control flow.
Andrew Trick1dd8c852012-02-08 21:23:13 +0000454 ///
Bill Wendlingeabae1d2012-03-13 20:04:21 +0000455 FunctionPass *createSjLjEHPreparePass(const TargetLowering *tli);
Jim Grosbach8b818d72009-08-17 16:41:22 +0000456
Andrew Trick1dd8c852012-02-08 21:23:13 +0000457 /// LocalStackSlotAllocation - This pass assigns local frame indices to stack
458 /// slots relative to one another and allocates base registers to access them
459 /// when it is estimated by the target to be out of range of normal frame
460 /// pointer or stack pointer index addressing.
461 extern char &LocalStackSlotAllocationID;
Jim Grosbach3d723672010-08-14 00:15:52 +0000462
Andrew Trick1dd8c852012-02-08 21:23:13 +0000463 /// ExpandISelPseudos - This pass expands pseudo-instructions.
464 extern char &ExpandISelPseudosID;
Dan Gohman668ac2f2010-11-16 21:02:37 +0000465
Jakob Stoklund Olesendf4b35e2011-09-27 23:50:46 +0000466 /// createExecutionDependencyFixPass - This pass fixes execution time
467 /// problems with dependent instructions, such as switching execution
468 /// domains to match.
469 ///
470 /// The pass will examine instructions using and defining registers in RC.
471 ///
472 FunctionPass *createExecutionDependencyFixPass(const TargetRegisterClass *RC);
473
Andrew Trick1dd8c852012-02-08 21:23:13 +0000474 /// UnpackMachineBundles - This pass unpack machine instruction bundles.
475 extern char &UnpackMachineBundlesID;
Evan Chengddfd1372011-12-14 02:11:42 +0000476
Andrew Trick1dd8c852012-02-08 21:23:13 +0000477 /// FinalizeMachineBundles - This pass finalize machine instruction
Evan Chengef2887d2012-01-19 07:47:03 +0000478 /// bundles (created earlier, e.g. during pre-RA scheduling).
Andrew Trick1dd8c852012-02-08 21:23:13 +0000479 extern char &FinalizeMachineBundlesID;
Evan Chengef2887d2012-01-19 07:47:03 +0000480
Brian Gaeked0fde302003-11-11 22:41:34 +0000481} // End llvm namespace
482
Chris Lattnerdb000652003-01-13 01:01:31 +0000483#endif