48e1f210404cd957dac15448086f6ffeb23001eb
[oota-llvm.git] / include / llvm / CodeGen / Passes.h
1 //===-- Passes.h - Target independent code generation passes ----*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file defines interfaces to access the target independent code generation
11 // passes provided by the LLVM backend.
12 //
13 //===----------------------------------------------------------------------===//
14
15 #ifndef LLVM_CODEGEN_PASSES_H
16 #define LLVM_CODEGEN_PASSES_H
17
18 #include "llvm/Pass.h"
19 #include "llvm/Target/TargetMachine.h"
20 #include <string>
21
22 namespace llvm {
23
24 class FunctionPass;
25 class MachineFunctionPass;
26 class PassConfigImpl;
27 class PassInfo;
28 class ScheduleDAGInstrs;
29 class TargetLowering;
30 class TargetLoweringBase;
31 class TargetRegisterClass;
32 class raw_ostream;
33 struct MachineSchedContext;
34
35 // The old pass manager infrastructure is hidden in a legacy namespace now.
36 namespace legacy {
37 class PassManagerBase;
38 }
39 using legacy::PassManagerBase;
40
41 /// 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.
55 class IdentifyingPassPtr {
56   union {
57     AnalysisID ID;
58     Pass *P;
59   };
60   bool IsInstance;
61 public:
62   IdentifyingPassPtr() : P(nullptr), IsInstance(false) {}
63   IdentifyingPassPtr(AnalysisID IDPtr) : ID(IDPtr), IsInstance(false) {}
64   IdentifyingPassPtr(Pass *InstancePtr) : P(InstancePtr), IsInstance(true) {}
65
66   bool isValid() const { return P; }
67   bool isInstance() const { return IsInstance; }
68
69   AnalysisID getID() const {
70     assert(!IsInstance && "Not a Pass ID");
71     return ID;
72   }
73   Pass *getInstance() const {
74     assert(IsInstance && "Not a Pass Instance");
75     return P;
76   }
77 };
78
79 template <> struct isPodLike<IdentifyingPassPtr> {
80   static const bool value = true;
81 };
82
83 /// Target-Independent Code Generator Pass Configuration Options.
84 ///
85 /// This is an ImmutablePass solely for the purpose of exposing CodeGen options
86 /// to the internals of other CodeGen passes.
87 class TargetPassConfig : public ImmutablePass {
88 public:
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
102 private:
103   PassManagerBase *PM;
104   AnalysisID StartAfter;
105   AnalysisID StopAfter;
106   bool Started;
107   bool Stopped;
108   bool AddingMachinePasses;
109
110 protected:
111   TargetMachine *TM;
112   PassConfigImpl *Impl; // Internal data structures
113   bool Initialized;     // Flagged after all passes are configured.
114
115   // Target Pass Options
116   // Targets provide a default setting, user flags override.
117   //
118   bool DisableVerify;
119
120   /// Default setting for -enable-tail-merge on this target.
121   bool EnableTailMerge;
122
123 public:
124   TargetPassConfig(TargetMachine *tm, PassManagerBase &pm);
125   // Dummy constructor.
126   TargetPassConfig();
127
128   virtual ~TargetPassConfig();
129
130   static char ID;
131
132   /// Get the right type of TargetMachine for this target.
133   template<typename TMC> TMC &getTM() const {
134     return *static_cast<TMC*>(TM);
135   }
136
137   //
138   void setInitialized() { Initialized = true; }
139
140   CodeGenOpt::Level getOptLevel() const { return TM->getOptLevel(); }
141
142   /// setStartStopPasses - Set the StartAfter and StopAfter passes to allow
143   /// running only a portion of the normal code-gen pass sequence.  If the
144   /// Start pass ID is zero, then compilation will begin at the normal point;
145   /// otherwise, clear the Started flag to indicate that passes should not be
146   /// added until the starting pass is seen.  If the Stop pass ID is zero,
147   /// then compilation will continue to the end.
148   void setStartStopPasses(AnalysisID Start, AnalysisID Stop) {
149     StartAfter = Start;
150     StopAfter = Stop;
151     Started = (StartAfter == nullptr);
152   }
153
154   void setDisableVerify(bool Disable) { setOpt(DisableVerify, Disable); }
155
156   bool getEnableTailMerge() const { return EnableTailMerge; }
157   void setEnableTailMerge(bool Enable) { setOpt(EnableTailMerge, Enable); }
158
159   /// Allow the target to override a specific pass without overriding the pass
160   /// pipeline. When passes are added to the standard pipeline at the
161   /// point where StandardID is expected, add TargetID in its place.
162   void substitutePass(AnalysisID StandardID, IdentifyingPassPtr TargetID);
163
164   /// Insert InsertedPassID pass after TargetPassID pass.
165   void insertPass(AnalysisID TargetPassID, IdentifyingPassPtr InsertedPassID);
166
167   /// Allow the target to enable a specific standard pass by default.
168   void enablePass(AnalysisID PassID) { substitutePass(PassID, PassID); }
169
170   /// Allow the target to disable a specific standard pass by default.
171   void disablePass(AnalysisID PassID) {
172     substitutePass(PassID, IdentifyingPassPtr());
173   }
174
175   /// Return the pass substituted for StandardID by the target.
176   /// If no substitution exists, return StandardID.
177   IdentifyingPassPtr getPassSubstitution(AnalysisID StandardID) const;
178
179   /// Return true if the optimized regalloc pipeline is enabled.
180   bool getOptimizeRegAlloc() const;
181
182   /// Return true if the default global register allocator is in use and
183   /// has not be overriden on the command line with '-regalloc=...'
184   bool usingDefaultRegAlloc() const;
185
186   /// Add common target configurable passes that perform LLVM IR to IR
187   /// transforms following machine independent optimization.
188   virtual void addIRPasses();
189
190   /// Add passes to lower exception handling for the code generator.
191   void addPassesToHandleExceptions();
192
193   /// Add pass to prepare the LLVM IR for code generation. This should be done
194   /// before exception handling preparation passes.
195   virtual void addCodeGenPrepare();
196
197   /// Add common passes that perform LLVM IR to IR transforms in preparation for
198   /// instruction selection.
199   virtual void addISelPrepare();
200
201   /// addInstSelector - This method should install an instruction selector pass,
202   /// which converts from LLVM code to machine instructions.
203   virtual bool addInstSelector() {
204     return true;
205   }
206
207   /// Add the complete, standard set of LLVM CodeGen passes.
208   /// Fully developed targets will not generally override this.
209   virtual void addMachinePasses();
210
211   /// Create an instance of ScheduleDAGInstrs to be run within the standard
212   /// MachineScheduler pass for this function and target at the current
213   /// optimization level.
214   ///
215   /// This can also be used to plug a new MachineSchedStrategy into an instance
216   /// of the standard ScheduleDAGMI:
217   ///   return new ScheduleDAGMI(C, make_unique<MyStrategy>(C), /* IsPostRA= */false)
218   ///
219   /// Return NULL to select the default (generic) machine scheduler.
220   virtual ScheduleDAGInstrs *
221   createMachineScheduler(MachineSchedContext *C) const {
222     return nullptr;
223   }
224
225   /// Similar to createMachineScheduler but used when postRA machine scheduling
226   /// is enabled.
227   virtual ScheduleDAGInstrs *
228   createPostMachineScheduler(MachineSchedContext *C) const {
229     return nullptr;
230   }
231
232 protected:
233   // Helper to verify the analysis is really immutable.
234   void setOpt(bool &Opt, bool Val);
235
236   /// Methods with trivial inline returns are convenient points in the common
237   /// codegen pass pipeline where targets may insert passes. Methods with
238   /// out-of-line standard implementations are major CodeGen stages called by
239   /// addMachinePasses. Some targets may override major stages when inserting
240   /// passes is insufficient, but maintaining overriden stages is more work.
241   ///
242
243   /// addPreISelPasses - This method should add any "last minute" LLVM->LLVM
244   /// passes (which are run just before instruction selector).
245   virtual bool addPreISel() {
246     return true;
247   }
248
249   /// addMachineSSAOptimization - Add standard passes that optimize machine
250   /// instructions in SSA form.
251   virtual void addMachineSSAOptimization();
252
253   /// Add passes that optimize instruction level parallelism for out-of-order
254   /// targets. These passes are run while the machine code is still in SSA
255   /// form, so they can use MachineTraceMetrics to control their heuristics.
256   ///
257   /// All passes added here should preserve the MachineDominatorTree,
258   /// MachineLoopInfo, and MachineTraceMetrics analyses.
259   virtual bool addILPOpts() {
260     return false;
261   }
262
263   /// This method may be implemented by targets that want to run passes
264   /// immediately before register allocation.
265   virtual void addPreRegAlloc() { }
266
267   /// createTargetRegisterAllocator - Create the register allocator pass for
268   /// this target at the current optimization level.
269   virtual FunctionPass *createTargetRegisterAllocator(bool Optimized);
270
271   /// addFastRegAlloc - Add the minimum set of target-independent passes that
272   /// are required for fast register allocation.
273   virtual void addFastRegAlloc(FunctionPass *RegAllocPass);
274
275   /// addOptimizedRegAlloc - Add passes related to register allocation.
276   /// LLVMTargetMachine provides standard regalloc passes for most targets.
277   virtual void addOptimizedRegAlloc(FunctionPass *RegAllocPass);
278
279   /// addPreRewrite - Add passes to the optimized register allocation pipeline
280   /// after register allocation is complete, but before virtual registers are
281   /// rewritten to physical registers.
282   ///
283   /// These passes must preserve VirtRegMap and LiveIntervals, and when running
284   /// after RABasic or RAGreedy, they should take advantage of LiveRegMatrix.
285   /// When these passes run, VirtRegMap contains legal physreg assignments for
286   /// all virtual registers.
287   virtual bool addPreRewrite() {
288     return false;
289   }
290
291   /// This method may be implemented by targets that want to run passes after
292   /// register allocation pass pipeline but before prolog-epilog insertion.
293   virtual void addPostRegAlloc() { }
294
295   /// Add passes that optimize machine instructions after register allocation.
296   virtual void addMachineLateOptimization();
297
298   /// This method may be implemented by targets that want to run passes after
299   /// prolog-epilog insertion and before the second instruction scheduling pass.
300   virtual void addPreSched2() { }
301
302   /// addGCPasses - Add late codegen passes that analyze code for garbage
303   /// collection. This should return true if GC info should be printed after
304   /// these passes.
305   virtual bool addGCPasses();
306
307   /// Add standard basic block placement passes.
308   virtual void addBlockPlacement();
309
310   /// This pass may be implemented by targets that want to run passes
311   /// immediately before machine code is emitted.
312   virtual void addPreEmitPass() { }
313
314   /// Utilities for targets to add passes to the pass manager.
315   ///
316
317   /// Add a CodeGen pass at this point in the pipeline after checking overrides.
318   /// Return the pass that was added, or zero if no pass was added.
319   /// @p printAfter    if true and adding a machine function pass add an extra
320   ///                  machine printer pass afterwards
321   /// @p verifyAfter   if true and adding a machine function pass add an extra
322   ///                  machine verification pass afterwards.
323   AnalysisID addPass(AnalysisID PassID, bool verifyAfter = true,
324                      bool printAfter = true);
325
326   /// Add a pass to the PassManager if that pass is supposed to be run, as
327   /// determined by the StartAfter and StopAfter options. Takes ownership of the
328   /// pass.
329   /// @p printAfter    if true and adding a machine function pass add an extra
330   ///                  machine printer pass afterwards
331   /// @p verifyAfter   if true and adding a machine function pass add an extra
332   ///                  machine verification pass afterwards.
333   void addPass(Pass *P, bool verifyAfter = true, bool printAfter = true);
334
335   /// addMachinePasses helper to create the target-selected or overriden
336   /// regalloc pass.
337   FunctionPass *createRegAllocPass(bool Optimized);
338
339   /// printAndVerify - Add a pass to dump then verify the machine function, if
340   /// those steps are enabled.
341   ///
342   void printAndVerify(const std::string &Banner);
343
344   /// Add a pass to print the machine function if printing is enabled.
345   void addPrintPass(const std::string &Banner);
346
347   /// Add a pass to perform basic verification of the machine function if
348   /// verification is enabled.
349   void addVerifyPass(const std::string &Banner);
350 };
351 } // namespace llvm
352
353 /// List of target independent CodeGen pass IDs.
354 namespace llvm {
355   FunctionPass *createAtomicExpandPass(const TargetMachine *TM);
356
357   /// createUnreachableBlockEliminationPass - The LLVM code generator does not
358   /// work well with unreachable basic blocks (what live ranges make sense for a
359   /// block that cannot be reached?).  As such, a code generator should either
360   /// not instruction select unreachable blocks, or run this pass as its
361   /// last LLVM modifying pass to clean up blocks that are not reachable from
362   /// the entry block.
363   FunctionPass *createUnreachableBlockEliminationPass();
364
365   /// MachineFunctionPrinter pass - This pass prints out the machine function to
366   /// the given stream as a debugging tool.
367   MachineFunctionPass *
368   createMachineFunctionPrinterPass(raw_ostream &OS,
369                                    const std::string &Banner ="");
370
371   /// createCodeGenPreparePass - Transform the code to expose more pattern
372   /// matching during instruction selection.
373   FunctionPass *createCodeGenPreparePass(const TargetMachine *TM = nullptr);
374
375   /// AtomicExpandID -- Lowers atomic operations in terms of either cmpxchg
376   /// load-linked/store-conditional loops.
377   extern char &AtomicExpandID;
378
379   /// MachineLoopInfo - This pass is a loop analysis pass.
380   extern char &MachineLoopInfoID;
381
382   /// MachineDominators - This pass is a machine dominators analysis pass.
383   extern char &MachineDominatorsID;
384
385 /// MachineDominanaceFrontier - This pass is a machine dominators analysis pass.
386   extern char &MachineDominanceFrontierID;
387
388   /// EdgeBundles analysis - Bundle machine CFG edges.
389   extern char &EdgeBundlesID;
390
391   /// LiveVariables pass - This pass computes the set of blocks in which each
392   /// variable is life and sets machine operand kill flags.
393   extern char &LiveVariablesID;
394
395   /// PHIElimination - This pass eliminates machine instruction PHI nodes
396   /// by inserting copy instructions.  This destroys SSA information, but is the
397   /// desired input for some register allocators.  This pass is "required" by
398   /// these register allocator like this: AU.addRequiredID(PHIEliminationID);
399   extern char &PHIEliminationID;
400
401   /// LiveIntervals - This analysis keeps track of the live ranges of virtual
402   /// and physical registers.
403   extern char &LiveIntervalsID;
404
405   /// LiveStacks pass. An analysis keeping track of the liveness of stack slots.
406   extern char &LiveStacksID;
407
408   /// TwoAddressInstruction - This pass reduces two-address instructions to
409   /// use two operands. This destroys SSA information but it is desired by
410   /// register allocators.
411   extern char &TwoAddressInstructionPassID;
412
413   /// ProcessImpicitDefs pass - This pass removes IMPLICIT_DEFs.
414   extern char &ProcessImplicitDefsID;
415
416   /// RegisterCoalescer - This pass merges live ranges to eliminate copies.
417   extern char &RegisterCoalescerID;
418
419   /// MachineScheduler - This pass schedules machine instructions.
420   extern char &MachineSchedulerID;
421
422   /// PostMachineScheduler - This pass schedules machine instructions postRA.
423   extern char &PostMachineSchedulerID;
424
425   /// SpillPlacement analysis. Suggest optimal placement of spill code between
426   /// basic blocks.
427   extern char &SpillPlacementID;
428
429   /// VirtRegRewriter pass. Rewrite virtual registers to physical registers as
430   /// assigned in VirtRegMap.
431   extern char &VirtRegRewriterID;
432
433   /// UnreachableMachineBlockElimination - This pass removes unreachable
434   /// machine basic blocks.
435   extern char &UnreachableMachineBlockElimID;
436
437   /// DeadMachineInstructionElim - This pass removes dead machine instructions.
438   extern char &DeadMachineInstructionElimID;
439
440   /// FastRegisterAllocation Pass - This pass register allocates as fast as
441   /// possible. It is best suited for debug code where live ranges are short.
442   ///
443   FunctionPass *createFastRegisterAllocator();
444
445   /// BasicRegisterAllocation Pass - This pass implements a degenerate global
446   /// register allocator using the basic regalloc framework.
447   ///
448   FunctionPass *createBasicRegisterAllocator();
449
450   /// Greedy register allocation pass - This pass implements a global register
451   /// allocator for optimized builds.
452   ///
453   FunctionPass *createGreedyRegisterAllocator();
454
455   /// PBQPRegisterAllocation Pass - This pass implements the Partitioned Boolean
456   /// Quadratic Prograaming (PBQP) based register allocator.
457   ///
458   FunctionPass *createDefaultPBQPRegisterAllocator();
459
460   /// PrologEpilogCodeInserter - This pass inserts prolog and epilog code,
461   /// and eliminates abstract frame references.
462   extern char &PrologEpilogCodeInserterID;
463
464   /// ExpandPostRAPseudos - This pass expands pseudo instructions after
465   /// register allocation.
466   extern char &ExpandPostRAPseudosID;
467
468   /// createPostRAScheduler - This pass performs post register allocation
469   /// scheduling.
470   extern char &PostRASchedulerID;
471
472   /// BranchFolding - This pass performs machine code CFG based
473   /// optimizations to delete branches to branches, eliminate branches to
474   /// successor blocks (creating fall throughs), and eliminating branches over
475   /// branches.
476   extern char &BranchFolderPassID;
477
478   /// MachineFunctionPrinterPass - This pass prints out MachineInstr's.
479   extern char &MachineFunctionPrinterPassID;
480
481   /// TailDuplicate - Duplicate blocks with unconditional branches
482   /// into tails of their predecessors.
483   extern char &TailDuplicateID;
484
485   /// MachineTraceMetrics - This pass computes critical path and CPU resource
486   /// usage in an ensemble of traces.
487   extern char &MachineTraceMetricsID;
488
489   /// EarlyIfConverter - This pass performs if-conversion on SSA form by
490   /// inserting cmov instructions.
491   extern char &EarlyIfConverterID;
492
493   /// This pass performs instruction combining using trace metrics to estimate
494   /// critical-path and resource depth.
495   extern char &MachineCombinerID;
496
497   /// StackSlotColoring - This pass performs stack coloring and merging.
498   /// It merges disjoint allocas to reduce the stack size.
499   extern char &StackColoringID;
500
501   /// IfConverter - This pass performs machine code if conversion.
502   extern char &IfConverterID;
503
504   /// MachineBlockPlacement - This pass places basic blocks based on branch
505   /// probabilities.
506   extern char &MachineBlockPlacementID;
507
508   /// MachineBlockPlacementStats - This pass collects statistics about the
509   /// basic block placement using branch probabilities and block frequency
510   /// information.
511   extern char &MachineBlockPlacementStatsID;
512
513   /// GCLowering Pass - Used by gc.root to perform its default lowering
514   /// operations.
515   FunctionPass *createGCLoweringPass();
516
517   /// ShadowStackGCLowering - Implements the custom lowering mechanism
518   /// used by the shadow stack GC.  Only runs on functions which opt in to
519   /// the shadow stack collector.
520   FunctionPass *createShadowStackGCLoweringPass();
521
522   /// GCMachineCodeAnalysis - Target-independent pass to mark safe points
523   /// in machine code. Must be added very late during code generation, just
524   /// prior to output, and importantly after all CFG transformations (such as
525   /// branch folding).
526   extern char &GCMachineCodeAnalysisID;
527
528   /// Creates a pass to print GC metadata.
529   ///
530   FunctionPass *createGCInfoPrinter(raw_ostream &OS);
531
532   /// MachineCSE - This pass performs global CSE on machine instructions.
533   extern char &MachineCSEID;
534
535   /// MachineLICM - This pass performs LICM on machine instructions.
536   extern char &MachineLICMID;
537
538   /// MachineSinking - This pass performs sinking on machine instructions.
539   extern char &MachineSinkingID;
540
541   /// MachineCopyPropagation - This pass performs copy propagation on
542   /// machine instructions.
543   extern char &MachineCopyPropagationID;
544
545   /// PeepholeOptimizer - This pass performs peephole optimizations -
546   /// like extension and comparison eliminations.
547   extern char &PeepholeOptimizerID;
548
549   /// OptimizePHIs - This pass optimizes machine instruction PHIs
550   /// to take advantage of opportunities created during DAG legalization.
551   extern char &OptimizePHIsID;
552
553   /// StackSlotColoring - This pass performs stack slot coloring.
554   extern char &StackSlotColoringID;
555
556   /// createStackProtectorPass - This pass adds stack protectors to functions.
557   ///
558   FunctionPass *createStackProtectorPass(const TargetMachine *TM);
559
560   /// createMachineVerifierPass - This pass verifies cenerated machine code
561   /// instructions for correctness.
562   ///
563   FunctionPass *createMachineVerifierPass(const std::string& Banner);
564
565   /// createDwarfEHPass - This pass mulches exception handling code into a form
566   /// adapted to code generation.  Required if using dwarf exception handling.
567   FunctionPass *createDwarfEHPass(const TargetMachine *TM);
568
569   /// createWinEHPass - Prepares personality functions used by MSVC on Windows,
570   /// in addition to the Itanium LSDA based personalities.
571   FunctionPass *createWinEHPass(const TargetMachine *TM);
572
573   /// createSjLjEHPreparePass - This pass adapts exception handling code to use
574   /// the GCC-style builtin setjmp/longjmp (sjlj) to handling EH control flow.
575   ///
576   FunctionPass *createSjLjEHPreparePass(const TargetMachine *TM);
577
578   /// LocalStackSlotAllocation - This pass assigns local frame indices to stack
579   /// slots relative to one another and allocates base registers to access them
580   /// when it is estimated by the target to be out of range of normal frame
581   /// pointer or stack pointer index addressing.
582   extern char &LocalStackSlotAllocationID;
583
584   /// ExpandISelPseudos - This pass expands pseudo-instructions.
585   extern char &ExpandISelPseudosID;
586
587   /// createExecutionDependencyFixPass - This pass fixes execution time
588   /// problems with dependent instructions, such as switching execution
589   /// domains to match.
590   ///
591   /// The pass will examine instructions using and defining registers in RC.
592   ///
593   FunctionPass *createExecutionDependencyFixPass(const TargetRegisterClass *RC);
594
595   /// UnpackMachineBundles - This pass unpack machine instruction bundles.
596   extern char &UnpackMachineBundlesID;
597
598   /// FinalizeMachineBundles - This pass finalize machine instruction
599   /// bundles (created earlier, e.g. during pre-RA scheduling).
600   extern char &FinalizeMachineBundlesID;
601
602   /// StackMapLiveness - This pass analyses the register live-out set of
603   /// stackmap/patchpoint intrinsics and attaches the calculated information to
604   /// the intrinsic for later emission to the StackMap.
605   extern char &StackMapLivenessID;
606
607   /// createJumpInstrTables - This pass creates jump-instruction tables.
608   ModulePass *createJumpInstrTablesPass();
609
610   /// createForwardControlFlowIntegrityPass - This pass adds control-flow
611   /// integrity.
612   ModulePass *createForwardControlFlowIntegrityPass();
613 } // End llvm namespace
614
615 /// Target machine pass initializer for passes with dependencies. Use with
616 /// INITIALIZE_TM_PASS_END.
617 #define INITIALIZE_TM_PASS_BEGIN INITIALIZE_PASS_BEGIN
618
619 /// Target machine pass initializer for passes with dependencies. Use with
620 /// INITIALIZE_TM_PASS_BEGIN.
621 #define INITIALIZE_TM_PASS_END(passName, arg, name, cfg, analysis) \
622     PassInfo *PI = new PassInfo(name, arg, & passName ::ID, \
623       PassInfo::NormalCtor_t(callDefaultCtor< passName >), cfg, analysis, \
624       PassInfo::TargetMachineCtor_t(callTargetMachineCtor< passName >)); \
625     Registry.registerPass(*PI, true); \
626     return PI; \
627   } \
628   void llvm::initialize##passName##Pass(PassRegistry &Registry) { \
629     CALL_ONCE_INITIALIZATION(initialize##passName##PassOnce) \
630   }
631
632 /// This initializer registers TargetMachine constructor, so the pass being
633 /// initialized can use target dependent interfaces. Please do not move this
634 /// macro to be together with INITIALIZE_PASS, which is a complete target
635 /// independent initializer, and we don't want to make libScalarOpts depend
636 /// on libCodeGen.
637 #define INITIALIZE_TM_PASS(passName, arg, name, cfg, analysis) \
638     INITIALIZE_TM_PASS_BEGIN(passName, arg, name, cfg, analysis) \
639     INITIALIZE_TM_PASS_END(passName, arg, name, cfg, analysis)
640
641 #endif