blob: ae4a2fa0bf83e417f5fe3a238f1d27f215f38c1b [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
Chandler Carruthcc3d76d2013-10-15 02:03:44 +000024class FunctionPass;
25class MachineFunctionPass;
Andrew Trick5e108ee2012-02-15 03:21:47 +000026class PassConfigImpl;
Chandler Carruthcc3d76d2013-10-15 02:03:44 +000027class PassInfo;
Chandler Carruthcc3d76d2013-10-15 02:03:44 +000028class ScheduleDAGInstrs;
29class TargetLowering;
30class TargetLoweringBase;
31class TargetRegisterClass;
32class raw_ostream;
33struct MachineSchedContext;
Andrew Trick5e108ee2012-02-15 03:21:47 +000034
Chandler Carruth49837ef2013-11-09 12:26:54 +000035// The old pass manager infrastructure is hidden in a legacy namespace now.
36namespace legacy {
37class PassManagerBase;
38}
39using legacy::PassManagerBase;
40
Andrew Trick5ed02832013-04-10 01:06:56 +000041/// Discriminated union of Pass ID types.
42///
43/// The PassConfig API prefers dealing with IDs because they are safer and more
44/// efficient. IDs decouple configuration from instantiation. This way, when a
45/// pass is overriden, it isn't unnecessarily instantiated. It is also unsafe to
46/// refer to a Pass pointer after adding it to a pass manager, which deletes
47/// redundant pass instances.
48///
49/// However, it is convient to directly instantiate target passes with
50/// non-default ctors. These often don't have a registered PassInfo. Rather than
51/// force all target passes to implement the pass registry boilerplate, allow
52/// the PassConfig API to handle either type.
53///
54/// AnalysisID is sadly char*, so PointerIntPair won't work.
55class IdentifyingPassPtr {
Benjamin Kramer8f583652013-04-10 20:50:44 +000056 union {
57 AnalysisID ID;
58 Pass *P;
59 };
Andrew Trick5ed02832013-04-10 01:06:56 +000060 bool IsInstance;
61public:
Benjamin Kramer8f583652013-04-10 20:50:44 +000062 IdentifyingPassPtr() : P(0), IsInstance(false) {}
63 IdentifyingPassPtr(AnalysisID IDPtr) : ID(IDPtr), IsInstance(false) {}
64 IdentifyingPassPtr(Pass *InstancePtr) : P(InstancePtr), IsInstance(true) {}
Andrew Trick5ed02832013-04-10 01:06:56 +000065
66 bool isValid() const { return P; }
67 bool isInstance() const { return IsInstance; }
68
69 AnalysisID getID() const {
70 assert(!IsInstance && "Not a Pass ID");
Benjamin Kramer8f583652013-04-10 20:50:44 +000071 return ID;
Andrew Trick5ed02832013-04-10 01:06:56 +000072 }
73 Pass *getInstance() const {
74 assert(IsInstance && "Not a Pass Instance");
Benjamin Kramer8f583652013-04-10 20:50:44 +000075 return P;
Andrew Trick5ed02832013-04-10 01:06:56 +000076 }
77};
78
79template <> struct isPodLike<IdentifyingPassPtr> {
80 static const bool value = true;
81};
82
Andrew Trick843ee2e2012-02-03 05:12:41 +000083/// Target-Independent Code Generator Pass Configuration Options.
84///
Andrew Trick74613342012-02-04 02:56:45 +000085/// This is an ImmutablePass solely for the purpose of exposing CodeGen options
86/// to the internals of other CodeGen passes.
Andrew Trick74613342012-02-04 02:56:45 +000087class TargetPassConfig : public ImmutablePass {
Andrew Trick79bf2882012-02-15 03:21:51 +000088public:
89 /// Pseudo Pass IDs. These are defined within TargetPassConfig because they
90 /// are unregistered pass IDs. They are only useful for use with
91 /// TargetPassConfig APIs to identify multiple occurrences of the same pass.
92 ///
93
94 /// EarlyTailDuplicate - A clone of the TailDuplicate pass that runs early
95 /// during codegen, on SSA form.
96 static char EarlyTailDuplicateID;
97
98 /// PostRAMachineLICM - A clone of the LICM pass that runs during late machine
99 /// optimization after regalloc.
100 static char PostRAMachineLICMID;
101
Bob Wilson564fbf62012-07-02 19:48:31 +0000102private:
103 PassManagerBase *PM;
Bob Wilson30a507a2012-07-02 19:48:45 +0000104 AnalysisID StartAfter;
105 AnalysisID StopAfter;
106 bool Started;
107 bool Stopped;
Bob Wilson564fbf62012-07-02 19:48:31 +0000108
Andrew Trick843ee2e2012-02-03 05:12:41 +0000109protected:
110 TargetMachine *TM;
Andrew Trick5e108ee2012-02-15 03:21:47 +0000111 PassConfigImpl *Impl; // Internal data structures
112 bool Initialized; // Flagged after all passes are configured.
Andrew Trick061efcf2012-02-04 02:56:59 +0000113
114 // Target Pass Options
Andrew Trick61f1e3d2012-02-08 21:22:48 +0000115 // Targets provide a default setting, user flags override.
Andrew Trick061efcf2012-02-04 02:56:59 +0000116 //
Andrew Trick843ee2e2012-02-03 05:12:41 +0000117 bool DisableVerify;
118
Andrew Trick61f1e3d2012-02-08 21:22:48 +0000119 /// Default setting for -enable-tail-merge on this target.
120 bool EnableTailMerge;
121
Andrew Trick843ee2e2012-02-03 05:12:41 +0000122public:
Andrew Trick061efcf2012-02-04 02:56:59 +0000123 TargetPassConfig(TargetMachine *tm, PassManagerBase &pm);
Andrew Trick74613342012-02-04 02:56:45 +0000124 // Dummy constructor.
125 TargetPassConfig();
Andrew Trick843ee2e2012-02-03 05:12:41 +0000126
Andrew Trick74613342012-02-04 02:56:45 +0000127 virtual ~TargetPassConfig();
128
129 static char ID;
Andrew Trick843ee2e2012-02-03 05:12:41 +0000130
131 /// Get the right type of TargetMachine for this target.
132 template<typename TMC> TMC &getTM() const {
133 return *static_cast<TMC*>(TM);
134 }
135
Andrew Trick061efcf2012-02-04 02:56:59 +0000136 const TargetLowering *getTargetLowering() const {
137 return TM->getTargetLowering();
138 }
139
Andrew Trick5e108ee2012-02-15 03:21:47 +0000140 //
Andrew Trickffea03f2012-02-08 21:22:39 +0000141 void setInitialized() { Initialized = true; }
142
Andrew Trick843ee2e2012-02-03 05:12:41 +0000143 CodeGenOpt::Level getOptLevel() const { return TM->getOptLevel(); }
144
Bob Wilson30a507a2012-07-02 19:48:45 +0000145 /// setStartStopPasses - Set the StartAfter and StopAfter passes to allow
146 /// running only a portion of the normal code-gen pass sequence. If the
147 /// Start pass ID is zero, then compilation will begin at the normal point;
148 /// otherwise, clear the Started flag to indicate that passes should not be
149 /// added until the starting pass is seen. If the Stop pass ID is zero,
150 /// then compilation will continue to the end.
151 void setStartStopPasses(AnalysisID Start, AnalysisID Stop) {
152 StartAfter = Start;
153 StopAfter = Stop;
154 Started = (StartAfter == 0);
155 }
156
Andrew Trick61f1e3d2012-02-08 21:22:48 +0000157 void setDisableVerify(bool Disable) { setOpt(DisableVerify, Disable); }
158
159 bool getEnableTailMerge() const { return EnableTailMerge; }
160 void setEnableTailMerge(bool Enable) { setOpt(EnableTailMerge, Enable); }
Andrew Trick061efcf2012-02-04 02:56:59 +0000161
Andrew Trick5e108ee2012-02-15 03:21:47 +0000162 /// Allow the target to override a specific pass without overriding the pass
163 /// pipeline. When passes are added to the standard pipeline at the
Bob Wilson3fb99a72012-07-02 19:48:37 +0000164 /// point where StandardID is expected, add TargetID in its place.
Andrew Trick5ed02832013-04-10 01:06:56 +0000165 void substitutePass(AnalysisID StandardID, IdentifyingPassPtr TargetID);
Andrew Trick5e108ee2012-02-15 03:21:47 +0000166
Bob Wilson6e1b8122012-05-30 00:17:12 +0000167 /// Insert InsertedPassID pass after TargetPassID pass.
Andrew Trick5ed02832013-04-10 01:06:56 +0000168 void insertPass(AnalysisID TargetPassID, IdentifyingPassPtr InsertedPassID);
Bob Wilson6e1b8122012-05-30 00:17:12 +0000169
Andrew Trickf91a3302012-03-09 00:52:17 +0000170 /// Allow the target to enable a specific standard pass by default.
Bob Wilson3fb99a72012-07-02 19:48:37 +0000171 void enablePass(AnalysisID PassID) { substitutePass(PassID, PassID); }
Andrew Trickf91a3302012-03-09 00:52:17 +0000172
173 /// Allow the target to disable a specific standard pass by default.
Andrew Trick5ed02832013-04-10 01:06:56 +0000174 void disablePass(AnalysisID PassID) {
175 substitutePass(PassID, IdentifyingPassPtr());
176 }
Andrew Trick5e108ee2012-02-15 03:21:47 +0000177
Bob Wilson3fb99a72012-07-02 19:48:37 +0000178 /// Return the pass substituted for StandardID by the target.
Andrew Trick5e108ee2012-02-15 03:21:47 +0000179 /// If no substitution exists, return StandardID.
Andrew Trick5ed02832013-04-10 01:06:56 +0000180 IdentifyingPassPtr getPassSubstitution(AnalysisID StandardID) const;
Andrew Trick5e108ee2012-02-15 03:21:47 +0000181
Andrew Trick5fd84a22012-02-15 03:21:43 +0000182 /// Return true if the optimized regalloc pipeline is enabled.
Andrew Trick8dd26252012-02-10 04:10:36 +0000183 bool getOptimizeRegAlloc() const;
184
Andrew Trick061efcf2012-02-04 02:56:59 +0000185 /// Add common target configurable passes that perform LLVM IR to IR
186 /// transforms following machine independent optimization.
187 virtual void addIRPasses();
188
Bob Wilson564fbf62012-07-02 19:48:31 +0000189 /// Add passes to lower exception handling for the code generator.
190 void addPassesToHandleExceptions();
191
Bill Wendling08510b12012-11-30 22:08:55 +0000192 /// Add pass to prepare the LLVM IR for code generation. This should be done
193 /// before exception handling preparation passes.
194 virtual void addCodeGenPrepare();
195
Andrew Trick061efcf2012-02-04 02:56:59 +0000196 /// Add common passes that perform LLVM IR to IR transforms in preparation for
197 /// instruction selection.
198 virtual void addISelPrepare();
199
200 /// addInstSelector - This method should install an instruction selector pass,
201 /// which converts from LLVM code to machine instructions.
202 virtual bool addInstSelector() {
203 return true;
204 }
Andrew Trick843ee2e2012-02-03 05:12:41 +0000205
206 /// Add the complete, standard set of LLVM CodeGen passes.
207 /// Fully developed targets will not generally override this.
Andrew Trick061efcf2012-02-04 02:56:59 +0000208 virtual void addMachinePasses();
Andrew Trick9d41bd52012-02-08 21:23:03 +0000209
Andrew Trickf45edcc2013-09-20 05:14:41 +0000210 /// createTargetScheduler - Create an instance of ScheduleDAGInstrs to be run
211 /// within the standard MachineScheduler pass for this function and target at
212 /// the current optimization level.
213 ///
214 /// This can also be used to plug a new MachineSchedStrategy into an instance
215 /// of the standard ScheduleDAGMI:
216 /// return new ScheduleDAGMI(C, new MyStrategy(C))
217 ///
218 /// Return NULL to select the default (generic) machine scheduler.
219 virtual ScheduleDAGInstrs *
220 createMachineScheduler(MachineSchedContext *C) const {
221 return 0;
222 }
223
Andrew Trick843ee2e2012-02-03 05:12:41 +0000224protected:
Andrew Trickffea03f2012-02-08 21:22:39 +0000225 // Helper to verify the analysis is really immutable.
226 void setOpt(bool &Opt, bool Val);
227
Andrew Trick061efcf2012-02-04 02:56:59 +0000228 /// Methods with trivial inline returns are convenient points in the common
229 /// codegen pass pipeline where targets may insert passes. Methods with
230 /// out-of-line standard implementations are major CodeGen stages called by
231 /// addMachinePasses. Some targets may override major stages when inserting
232 /// passes is insufficient, but maintaining overriden stages is more work.
Andrew Trick843ee2e2012-02-03 05:12:41 +0000233 ///
234
235 /// addPreISelPasses - This method should add any "last minute" LLVM->LLVM
236 /// passes (which are run just before instruction selector).
237 virtual bool addPreISel() {
238 return true;
239 }
240
Andrew Trickf7b96312012-02-09 00:40:55 +0000241 /// addMachineSSAOptimization - Add standard passes that optimize machine
242 /// instructions in SSA form.
243 virtual void addMachineSSAOptimization();
244
Jakob Stoklund Olesen02c63252013-01-17 00:58:38 +0000245 /// Add passes that optimize instruction level parallelism for out-of-order
246 /// targets. These passes are run while the machine code is still in SSA
247 /// form, so they can use MachineTraceMetrics to control their heuristics.
248 ///
249 /// All passes added here should preserve the MachineDominatorTree,
250 /// MachineLoopInfo, and MachineTraceMetrics analyses.
251 virtual bool addILPOpts() {
252 return false;
253 }
254
Andrew Trick843ee2e2012-02-03 05:12:41 +0000255 /// addPreRegAlloc - This method may be implemented by targets that want to
256 /// run passes immediately before register allocation. This should return
257 /// true if -print-machineinstrs should print after these passes.
258 virtual bool addPreRegAlloc() {
259 return false;
260 }
261
Andrew Trick8dd26252012-02-10 04:10:36 +0000262 /// createTargetRegisterAllocator - Create the register allocator pass for
263 /// this target at the current optimization level.
264 virtual FunctionPass *createTargetRegisterAllocator(bool Optimized);
265
266 /// addFastRegAlloc - Add the minimum set of target-independent passes that
267 /// are required for fast register allocation.
268 virtual void addFastRegAlloc(FunctionPass *RegAllocPass);
269
Andrew Trickfda655e2012-02-11 07:11:29 +0000270 /// addOptimizedRegAlloc - Add passes related to register allocation.
271 /// LLVMTargetMachine provides standard regalloc passes for most targets.
Andrew Trick8dd26252012-02-10 04:10:36 +0000272 virtual void addOptimizedRegAlloc(FunctionPass *RegAllocPass);
Andrew Trickf7b96312012-02-09 00:40:55 +0000273
Jakob Stoklund Olesen34f5a2b2012-06-26 17:09:29 +0000274 /// addPreRewrite - Add passes to the optimized register allocation pipeline
275 /// after register allocation is complete, but before virtual registers are
276 /// rewritten to physical registers.
277 ///
278 /// These passes must preserve VirtRegMap and LiveIntervals, and when running
279 /// after RABasic or RAGreedy, they should take advantage of LiveRegMatrix.
280 /// When these passes run, VirtRegMap contains legal physreg assignments for
281 /// all virtual registers.
282 virtual bool addPreRewrite() {
283 return false;
284 }
285
Andrew Trick746f24b2012-02-11 07:11:32 +0000286 /// addPostRegAlloc - This method may be implemented by targets that want to
287 /// run passes after register allocation pass pipeline but before
288 /// prolog-epilog insertion. This should return true if -print-machineinstrs
289 /// should print after these passes.
Andrew Trick843ee2e2012-02-03 05:12:41 +0000290 virtual bool addPostRegAlloc() {
291 return false;
292 }
293
Andrew Trickf7b96312012-02-09 00:40:55 +0000294 /// Add passes that optimize machine instructions after register allocation.
295 virtual void addMachineLateOptimization();
296
Andrew Trick843ee2e2012-02-03 05:12:41 +0000297 /// addPreSched2 - This method may be implemented by targets that want to
298 /// run passes after prolog-epilog insertion and before the second instruction
299 /// scheduling pass. This should return true if -print-machineinstrs should
300 /// print after these passes.
301 virtual bool addPreSched2() {
302 return false;
303 }
304
Evan Chengab37b2c2012-12-21 02:57:04 +0000305 /// addGCPasses - Add late codegen passes that analyze code for garbage
306 /// collection. This should return true if GC info should be printed after
307 /// these passes.
308 virtual bool addGCPasses();
309
Andrew Trickf7b96312012-02-09 00:40:55 +0000310 /// Add standard basic block placement passes.
311 virtual void addBlockPlacement();
312
Andrew Trick843ee2e2012-02-03 05:12:41 +0000313 /// addPreEmitPass - This pass may be implemented by targets that want to run
314 /// passes immediately before machine code is emitted. This should return
315 /// true if -print-machineinstrs should print out the code after the passes.
316 virtual bool addPreEmitPass() {
317 return false;
318 }
319
320 /// Utilities for targets to add passes to the pass manager.
321 ///
322
Andrew Trick5e108ee2012-02-15 03:21:47 +0000323 /// Add a CodeGen pass at this point in the pipeline after checking overrides.
Bob Wilson3fb99a72012-07-02 19:48:37 +0000324 /// Return the pass that was added, or zero if no pass was added.
325 AnalysisID addPass(AnalysisID PassID);
Andrew Trick843ee2e2012-02-03 05:12:41 +0000326
Bob Wilson30a507a2012-07-02 19:48:45 +0000327 /// Add a pass to the PassManager if that pass is supposed to be run, as
Benjamin Kramerf8e16c62013-08-05 11:11:11 +0000328 /// determined by the StartAfter and StopAfter options. Takes ownership of the
329 /// pass.
Bob Wilson564fbf62012-07-02 19:48:31 +0000330 void addPass(Pass *P);
331
Andrew Trick8dd26252012-02-10 04:10:36 +0000332 /// addMachinePasses helper to create the target-selected or overriden
333 /// regalloc pass.
334 FunctionPass *createRegAllocPass(bool Optimized);
335
Andrew Trick843ee2e2012-02-03 05:12:41 +0000336 /// printAndVerify - Add a pass to dump then verify the machine function, if
337 /// those steps are enabled.
338 ///
Bob Wilson564fbf62012-07-02 19:48:31 +0000339 void printAndVerify(const char *Banner);
Andrew Trick843ee2e2012-02-03 05:12:41 +0000340};
341} // namespace llvm
342
343/// List of target independent CodeGen pass IDs.
344namespace llvm {
Chandler Carruthaeef83c2013-01-07 01:37:14 +0000345 /// \brief Create a basic TargetTransformInfo analysis pass.
346 ///
347 /// This pass implements the target transform info analysis using the target
348 /// independent information available to the LLVM code generator.
Benjamin Kramer69e42db2013-01-11 20:05:37 +0000349 ImmutablePass *
Bill Wendlingf9fd58a2013-06-19 21:07:11 +0000350 createBasicTargetTransformInfoPass(const TargetMachine *TM);
Chandler Carruthaeef83c2013-01-07 01:37:14 +0000351
Chris Lattner8b708e42004-07-02 05:44:13 +0000352 /// createUnreachableBlockEliminationPass - The LLVM code generator does not
353 /// work well with unreachable basic blocks (what live ranges make sense for a
354 /// block that cannot be reached?). As such, a code generator should either
Jim Grosbachf6912292010-08-06 21:31:35 +0000355 /// not instruction select unreachable blocks, or run this pass as its
Chris Lattner8b708e42004-07-02 05:44:13 +0000356 /// last LLVM modifying pass to clean up blocks that are not reachable from
357 /// the entry block.
358 FunctionPass *createUnreachableBlockEliminationPass();
Misha Brukmanea61c352005-04-21 20:39:54 +0000359
Chris Lattner3e200e62003-12-20 10:18:58 +0000360 /// MachineFunctionPrinter pass - This pass prints out the machine function to
Jim Grosbachf6912292010-08-06 21:31:35 +0000361 /// the given stream as a debugging tool.
David Greene5c8aa952010-04-02 23:17:14 +0000362 MachineFunctionPass *
363 createMachineFunctionPrinterPass(raw_ostream &OS,
364 const std::string &Banner ="");
Brian Gaeke09caa372004-01-30 21:53:46 +0000365
Andrew Trick1dd8c852012-02-08 21:23:13 +0000366 /// MachineLoopInfo - This pass is a loop analysis pass.
Owen Anderson90c579d2010-08-06 18:33:48 +0000367 extern char &MachineLoopInfoID;
Bill Wendling67d65bb2008-01-04 20:54:55 +0000368
Andrew Trick1dd8c852012-02-08 21:23:13 +0000369 /// MachineDominators - This pass is a machine dominators analysis pass.
Owen Anderson90c579d2010-08-06 18:33:48 +0000370 extern char &MachineDominatorsID;
Bill Wendling67d65bb2008-01-04 20:54:55 +0000371
Jakob Stoklund Olesen8dd070e2011-01-04 21:10:05 +0000372 /// EdgeBundles analysis - Bundle machine CFG edges.
Jakob Stoklund Olesen8dd070e2011-01-04 21:10:05 +0000373 extern char &EdgeBundlesID;
374
Andrew Trick8dd26252012-02-10 04:10:36 +0000375 /// LiveVariables pass - This pass computes the set of blocks in which each
376 /// variable is life and sets machine operand kill flags.
377 extern char &LiveVariablesID;
378
Andrew Trick1dd8c852012-02-08 21:23:13 +0000379 /// PHIElimination - This pass eliminates machine instruction PHI nodes
Chris Lattner3e200e62003-12-20 10:18:58 +0000380 /// by inserting copy instructions. This destroys SSA information, but is the
381 /// desired input for some register allocators. This pass is "required" by
382 /// these register allocator like this: AU.addRequiredID(PHIEliminationID);
Owen Anderson90c579d2010-08-06 18:33:48 +0000383 extern char &PHIEliminationID;
Jim Grosbachf6912292010-08-06 21:31:35 +0000384
Jakob Stoklund Olesendcc44362012-08-03 22:12:54 +0000385 /// LiveIntervals - This analysis keeps track of the live ranges of virtual
386 /// and physical registers.
387 extern char &LiveIntervalsID;
388
Jakob Stoklund Olesen2d172932010-10-26 00:11:33 +0000389 /// LiveStacks pass. An analysis keeping track of the liveness of stack slots.
390 extern char &LiveStacksID;
391
Andrew Trick1dd8c852012-02-08 21:23:13 +0000392 /// TwoAddressInstruction - This pass reduces two-address instructions to
Chris Lattner3e200e62003-12-20 10:18:58 +0000393 /// use two operands. This destroys SSA information but it is desired by
394 /// register allocators.
Owen Anderson90c579d2010-08-06 18:33:48 +0000395 extern char &TwoAddressInstructionPassID;
Chris Lattnerdb000652003-01-13 01:01:31 +0000396
Andrew Trick8dd26252012-02-10 04:10:36 +0000397 /// ProcessImpicitDefs pass - This pass removes IMPLICIT_DEFs.
398 extern char &ProcessImplicitDefsID;
399
400 /// RegisterCoalescer - This pass merges live ranges to eliminate copies.
401 extern char &RegisterCoalescerID;
Jakob Stoklund Olesen27215672011-08-09 00:29:53 +0000402
Andrew Trick1dd8c852012-02-08 21:23:13 +0000403 /// MachineScheduler - This pass schedules machine instructions.
Andrew Trick42b7a712012-01-17 06:55:03 +0000404 extern char &MachineSchedulerID;
Andrew Trick96f678f2012-01-13 06:30:30 +0000405
Jakob Stoklund Olesen8bfe5082011-01-06 01:21:53 +0000406 /// SpillPlacement analysis. Suggest optimal placement of spill code between
407 /// basic blocks.
Jakob Stoklund Olesen8bfe5082011-01-06 01:21:53 +0000408 extern char &SpillPlacementID;
409
Jakob Stoklund Olesen05ec7122012-06-08 23:44:45 +0000410 /// VirtRegRewriter pass. Rewrite virtual registers to physical registers as
411 /// assigned in VirtRegMap.
412 extern char &VirtRegRewriterID;
413
Andrew Trick1dd8c852012-02-08 21:23:13 +0000414 /// UnreachableMachineBlockElimination - This pass removes unreachable
Owen Andersonbd3ba462008-08-04 23:54:43 +0000415 /// machine basic blocks.
Owen Anderson90c579d2010-08-06 18:33:48 +0000416 extern char &UnreachableMachineBlockElimID;
Owen Andersonbd3ba462008-08-04 23:54:43 +0000417
Andrew Trick1dd8c852012-02-08 21:23:13 +0000418 /// DeadMachineInstructionElim - This pass removes dead machine instructions.
419 extern char &DeadMachineInstructionElimID;
Dan Gohmand3ead432008-09-17 00:43:24 +0000420
Jakob Stoklund Olesen00207232010-04-21 18:02:42 +0000421 /// FastRegisterAllocation Pass - This pass register allocates as fast as
422 /// possible. It is best suited for debug code where live ranges are short.
423 ///
424 FunctionPass *createFastRegisterAllocator();
425
Andrew Trick14e8d712010-10-22 23:09:15 +0000426 /// BasicRegisterAllocation Pass - This pass implements a degenerate global
427 /// register allocator using the basic regalloc framework.
428 ///
429 FunctionPass *createBasicRegisterAllocator();
430
Jakob Stoklund Olesencba2e062010-12-08 03:26:16 +0000431 /// Greedy register allocation pass - This pass implements a global register
432 /// allocator for optimized builds.
433 ///
434 FunctionPass *createGreedyRegisterAllocator();
435
Evan Chengb1290a62008-10-02 18:29:27 +0000436 /// PBQPRegisterAllocation Pass - This pass implements the Partitioned Boolean
437 /// Quadratic Prograaming (PBQP) based register allocator.
438 ///
Lang Hamesf70e7cc2010-09-23 04:28:54 +0000439 FunctionPass *createDefaultPBQPRegisterAllocator();
Evan Chengb1290a62008-10-02 18:29:27 +0000440
Andrew Trick1dd8c852012-02-08 21:23:13 +0000441 /// PrologEpilogCodeInserter - This pass inserts prolog and epilog code,
Chris Lattner3e200e62003-12-20 10:18:58 +0000442 /// and eliminates abstract frame references.
Andrew Trick1dd8c852012-02-08 21:23:13 +0000443 extern char &PrologEpilogCodeInserterID;
Jim Grosbachf6912292010-08-06 21:31:35 +0000444
Andrew Trick1dd8c852012-02-08 21:23:13 +0000445 /// ExpandPostRAPseudos - This pass expands pseudo instructions after
Jakob Stoklund Olesen74e2d6e2011-09-25 16:46:08 +0000446 /// register allocation.
Andrew Trick1dd8c852012-02-08 21:23:13 +0000447 extern char &ExpandPostRAPseudosID;
Chris Lattnerdb000652003-01-13 01:01:31 +0000448
Evan Chengfa163542009-10-16 21:06:15 +0000449 /// createPostRAScheduler - This pass performs post register allocation
450 /// scheduling.
Andrew Trick1dd8c852012-02-08 21:23:13 +0000451 extern char &PostRASchedulerID;
Dale Johannesene7e7d0d2007-07-13 17:13:54 +0000452
Andrew Trick1dd8c852012-02-08 21:23:13 +0000453 /// BranchFolding - This pass performs machine code CFG based
Chris Lattner36c29db2004-07-31 09:59:14 +0000454 /// optimizations to delete branches to branches, eliminate branches to
455 /// successor blocks (creating fall throughs), and eliminating branches over
456 /// branches.
Andrew Trick61f1e3d2012-02-08 21:22:48 +0000457 extern char &BranchFolderPassID;
Chris Lattner36c29db2004-07-31 09:59:14 +0000458
Bob Wilson6e1b8122012-05-30 00:17:12 +0000459 /// MachineFunctionPrinterPass - This pass prints out MachineInstr's.
460 extern char &MachineFunctionPrinterPassID;
461
Andrew Trick1dd8c852012-02-08 21:23:13 +0000462 /// TailDuplicate - Duplicate blocks with unconditional branches
Bob Wilson15acadd2009-11-26 00:32:21 +0000463 /// into tails of their predecessors.
Andrew Trick1dd8c852012-02-08 21:23:13 +0000464 extern char &TailDuplicateID;
Bob Wilson15acadd2009-11-26 00:32:21 +0000465
Jakob Stoklund Olesen9f63e102012-07-26 18:38:11 +0000466 /// MachineTraceMetrics - This pass computes critical path and CPU resource
467 /// usage in an ensemble of traces.
468 extern char &MachineTraceMetricsID;
469
Jakob Stoklund Olesen33242fd2012-07-04 00:09:54 +0000470 /// EarlyIfConverter - This pass performs if-conversion on SSA form by
471 /// inserting cmov instructions.
472 extern char &EarlyIfConverterID;
473
Nadav Rotemc05d3062012-09-06 09:17:37 +0000474 /// StackSlotColoring - This pass performs stack coloring and merging.
475 /// It merges disjoint allocas to reduce the stack size.
476 extern char &StackColoringID;
477
Andrew Trick1dd8c852012-02-08 21:23:13 +0000478 /// IfConverter - This pass performs machine code if conversion.
479 extern char &IfConverterID;
Evan Cheng4e654852007-05-16 02:00:57 +0000480
Andrew Trick1dd8c852012-02-08 21:23:13 +0000481 /// MachineBlockPlacement - This pass places basic blocks based on branch
Chandler Carruthdb350872011-10-21 06:46:38 +0000482 /// probabilities.
Andrew Trick1dd8c852012-02-08 21:23:13 +0000483 extern char &MachineBlockPlacementID;
Chandler Carruthdb350872011-10-21 06:46:38 +0000484
Andrew Trick1dd8c852012-02-08 21:23:13 +0000485 /// MachineBlockPlacementStats - This pass collects statistics about the
Chandler Carruth37efc9f2011-11-02 07:17:12 +0000486 /// basic block placement using branch probabilities and block frequency
487 /// information.
Andrew Trick1dd8c852012-02-08 21:23:13 +0000488 extern char &MachineBlockPlacementStatsID;
Chandler Carruth37efc9f2011-11-02 07:17:12 +0000489
Andrew Trick1dd8c852012-02-08 21:23:13 +0000490 /// GCLowering Pass - Performs target-independent LLVM IR transformations for
491 /// highly portable strategies.
492 ///
Gordon Henriksenad93c4f2007-12-11 00:30:17 +0000493 FunctionPass *createGCLoweringPass();
Jim Grosbachf6912292010-08-06 21:31:35 +0000494
Andrew Trick1dd8c852012-02-08 21:23:13 +0000495 /// GCMachineCodeAnalysis - Target-independent pass to mark safe points
496 /// in machine code. Must be added very late during code generation, just
497 /// prior to output, and importantly after all CFG transformations (such as
498 /// branch folding).
499 extern char &GCMachineCodeAnalysisID;
Jim Grosbachf6912292010-08-06 21:31:35 +0000500
Gordon Henriksen5eca0752008-08-17 18:44:35 +0000501 /// Creates a pass to print GC metadata.
Jim Grosbachf6912292010-08-06 21:31:35 +0000502 ///
Chris Lattnercf143a42009-08-23 03:13:20 +0000503 FunctionPass *createGCInfoPrinter(raw_ostream &OS);
Jim Grosbachf6912292010-08-06 21:31:35 +0000504
Andrew Trick1dd8c852012-02-08 21:23:13 +0000505 /// MachineCSE - This pass performs global CSE on machine instructions.
506 extern char &MachineCSEID;
Evan Chengc6fe3332010-03-02 02:38:24 +0000507
Andrew Trick1dd8c852012-02-08 21:23:13 +0000508 /// MachineLICM - This pass performs LICM on machine instructions.
509 extern char &MachineLICMID;
Bill Wendling0f940c92007-12-07 21:42:31 +0000510
Andrew Trick1dd8c852012-02-08 21:23:13 +0000511 /// MachineSinking - This pass performs sinking on machine instructions.
512 extern char &MachineSinkingID;
Evan Cheng3f32d652008-06-04 09:18:41 +0000513
Andrew Trick1dd8c852012-02-08 21:23:13 +0000514 /// MachineCopyPropagation - This pass performs copy propagation on
Evan Cheng977679d2012-01-07 03:02:36 +0000515 /// machine instructions.
Andrew Trick1dd8c852012-02-08 21:23:13 +0000516 extern char &MachineCopyPropagationID;
Evan Cheng977679d2012-01-07 03:02:36 +0000517
Andrew Trick1dd8c852012-02-08 21:23:13 +0000518 /// PeepholeOptimizer - This pass performs peephole optimizations -
Bill Wendling6cdb1ab2010-08-09 23:59:04 +0000519 /// like extension and comparison eliminations.
Andrew Trick1dd8c852012-02-08 21:23:13 +0000520 extern char &PeepholeOptimizerID;
Evan Cheng7da9ecf2010-01-13 00:30:23 +0000521
Andrew Trick1dd8c852012-02-08 21:23:13 +0000522 /// OptimizePHIs - This pass optimizes machine instruction PHIs
Bob Wilsonfe61fb12010-02-12 01:30:21 +0000523 /// to take advantage of opportunities created during DAG legalization.
Andrew Trick1dd8c852012-02-08 21:23:13 +0000524 extern char &OptimizePHIsID;
Bob Wilsonfe61fb12010-02-12 01:30:21 +0000525
Andrew Trick1dd8c852012-02-08 21:23:13 +0000526 /// StackSlotColoring - This pass performs stack slot coloring.
527 extern char &StackSlotColoringID;
Bill Wendling2b58ce52008-11-04 02:10:20 +0000528
529 /// createStackProtectorPass - This pass adds stack protectors to functions.
Andrew Trick1dd8c852012-02-08 21:23:13 +0000530 ///
Bill Wendlingea442812013-06-19 20:51:24 +0000531 FunctionPass *createStackProtectorPass(const TargetMachine *TM);
Bill Wendling2b58ce52008-11-04 02:10:20 +0000532
Jakob Stoklund Olesen48872e02009-05-16 00:33:53 +0000533 /// createMachineVerifierPass - This pass verifies cenerated machine code
534 /// instructions for correctness.
Andrew Trick1dd8c852012-02-08 21:23:13 +0000535 ///
Jakob Stoklund Olesen89cab932010-12-18 00:06:56 +0000536 FunctionPass *createMachineVerifierPass(const char *Banner = 0);
Jakob Stoklund Olesen48872e02009-05-16 00:33:53 +0000537
Duncan Sandsb0f1e172009-05-22 20:36:31 +0000538 /// createDwarfEHPass - This pass mulches exception handling code into a form
539 /// adapted to code generation. Required if using dwarf exception handling.
Bill Wendlingea442812013-06-19 20:51:24 +0000540 FunctionPass *createDwarfEHPass(const TargetMachine *TM);
Duncan Sandsb0f1e172009-05-22 20:36:31 +0000541
Bill Wendlingeabae1d2012-03-13 20:04:21 +0000542 /// createSjLjEHPreparePass - This pass adapts exception handling code to use
Jim Grosbach8b818d72009-08-17 16:41:22 +0000543 /// the GCC-style builtin setjmp/longjmp (sjlj) to handling EH control flow.
Andrew Trick1dd8c852012-02-08 21:23:13 +0000544 ///
Bill Wendlingea442812013-06-19 20:51:24 +0000545 FunctionPass *createSjLjEHPreparePass(const TargetMachine *TM);
Jim Grosbach8b818d72009-08-17 16:41:22 +0000546
Andrew Trick1dd8c852012-02-08 21:23:13 +0000547 /// LocalStackSlotAllocation - This pass assigns local frame indices to stack
548 /// slots relative to one another and allocates base registers to access them
549 /// when it is estimated by the target to be out of range of normal frame
550 /// pointer or stack pointer index addressing.
551 extern char &LocalStackSlotAllocationID;
Jim Grosbach3d723672010-08-14 00:15:52 +0000552
Andrew Trick1dd8c852012-02-08 21:23:13 +0000553 /// ExpandISelPseudos - This pass expands pseudo-instructions.
554 extern char &ExpandISelPseudosID;
Dan Gohman668ac2f2010-11-16 21:02:37 +0000555
Jakob Stoklund Olesendf4b35e2011-09-27 23:50:46 +0000556 /// createExecutionDependencyFixPass - This pass fixes execution time
557 /// problems with dependent instructions, such as switching execution
558 /// domains to match.
559 ///
560 /// The pass will examine instructions using and defining registers in RC.
561 ///
562 FunctionPass *createExecutionDependencyFixPass(const TargetRegisterClass *RC);
563
Andrew Trick1dd8c852012-02-08 21:23:13 +0000564 /// UnpackMachineBundles - This pass unpack machine instruction bundles.
565 extern char &UnpackMachineBundlesID;
Evan Chengddfd1372011-12-14 02:11:42 +0000566
Andrew Trick1dd8c852012-02-08 21:23:13 +0000567 /// FinalizeMachineBundles - This pass finalize machine instruction
Evan Chengef2887d2012-01-19 07:47:03 +0000568 /// bundles (created earlier, e.g. during pre-RA scheduling).
Andrew Trick1dd8c852012-02-08 21:23:13 +0000569 extern char &FinalizeMachineBundlesID;
Evan Chengef2887d2012-01-19 07:47:03 +0000570
Brian Gaeked0fde302003-11-11 22:41:34 +0000571} // End llvm namespace
572
Chris Lattnerdb000652003-01-13 01:01:31 +0000573#endif