]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/include/llvm/CodeGen/Passes.h
Merge llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp
[FreeBSD/FreeBSD.git] / contrib / llvm / 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 <functional>
19 #include <string>
20
21 namespace llvm {
22
23 class FunctionPass;
24 class MachineFunction;
25 class MachineFunctionPass;
26 class ModulePass;
27 class Pass;
28 class TargetMachine;
29 class TargetRegisterClass;
30 class raw_ostream;
31
32 } // End llvm namespace
33
34 /// List of target independent CodeGen pass IDs.
35 namespace llvm {
36   FunctionPass *createAtomicExpandPass();
37
38   /// createUnreachableBlockEliminationPass - The LLVM code generator does not
39   /// work well with unreachable basic blocks (what live ranges make sense for a
40   /// block that cannot be reached?).  As such, a code generator should either
41   /// not instruction select unreachable blocks, or run this pass as its
42   /// last LLVM modifying pass to clean up blocks that are not reachable from
43   /// the entry block.
44   FunctionPass *createUnreachableBlockEliminationPass();
45
46   /// MachineFunctionPrinter pass - This pass prints out the machine function to
47   /// the given stream as a debugging tool.
48   MachineFunctionPass *
49   createMachineFunctionPrinterPass(raw_ostream &OS,
50                                    const std::string &Banner ="");
51
52   /// MIRPrinting pass - this pass prints out the LLVM IR into the given stream
53   /// using the MIR serialization format.
54   MachineFunctionPass *createPrintMIRPass(raw_ostream &OS);
55
56   /// This pass resets a MachineFunction when it has the FailedISel property
57   /// as if it was just created.
58   /// If EmitFallbackDiag is true, the pass will emit a
59   /// DiagnosticInfoISelFallback for every MachineFunction it resets.
60   /// If AbortOnFailedISel is true, abort compilation instead of resetting.
61   MachineFunctionPass *createResetMachineFunctionPass(bool EmitFallbackDiag,
62                                                       bool AbortOnFailedISel);
63
64   /// createCodeGenPreparePass - Transform the code to expose more pattern
65   /// matching during instruction selection.
66   FunctionPass *createCodeGenPreparePass();
67
68   /// createScalarizeMaskedMemIntrinPass - Replace masked load, store, gather
69   /// and scatter intrinsics with scalar code when target doesn't support them.
70   FunctionPass *createScalarizeMaskedMemIntrinPass();
71
72   /// AtomicExpandID -- Lowers atomic operations in terms of either cmpxchg
73   /// load-linked/store-conditional loops.
74   extern char &AtomicExpandID;
75
76   /// MachineLoopInfo - This pass is a loop analysis pass.
77   extern char &MachineLoopInfoID;
78
79   /// MachineDominators - This pass is a machine dominators analysis pass.
80   extern char &MachineDominatorsID;
81
82 /// MachineDominanaceFrontier - This pass is a machine dominators analysis pass.
83   extern char &MachineDominanceFrontierID;
84
85   /// MachineRegionInfo - This pass computes SESE regions for machine functions.
86   extern char &MachineRegionInfoPassID;
87
88   /// EdgeBundles analysis - Bundle machine CFG edges.
89   extern char &EdgeBundlesID;
90
91   /// LiveVariables pass - This pass computes the set of blocks in which each
92   /// variable is life and sets machine operand kill flags.
93   extern char &LiveVariablesID;
94
95   /// PHIElimination - This pass eliminates machine instruction PHI nodes
96   /// by inserting copy instructions.  This destroys SSA information, but is the
97   /// desired input for some register allocators.  This pass is "required" by
98   /// these register allocator like this: AU.addRequiredID(PHIEliminationID);
99   extern char &PHIEliminationID;
100
101   /// LiveIntervals - This analysis keeps track of the live ranges of virtual
102   /// and physical registers.
103   extern char &LiveIntervalsID;
104
105   /// LiveStacks pass. An analysis keeping track of the liveness of stack slots.
106   extern char &LiveStacksID;
107
108   /// TwoAddressInstruction - This pass reduces two-address instructions to
109   /// use two operands. This destroys SSA information but it is desired by
110   /// register allocators.
111   extern char &TwoAddressInstructionPassID;
112
113   /// ProcessImpicitDefs pass - This pass removes IMPLICIT_DEFs.
114   extern char &ProcessImplicitDefsID;
115
116   /// RegisterCoalescer - This pass merges live ranges to eliminate copies.
117   extern char &RegisterCoalescerID;
118
119   /// MachineScheduler - This pass schedules machine instructions.
120   extern char &MachineSchedulerID;
121
122   /// PostMachineScheduler - This pass schedules machine instructions postRA.
123   extern char &PostMachineSchedulerID;
124
125   /// SpillPlacement analysis. Suggest optimal placement of spill code between
126   /// basic blocks.
127   extern char &SpillPlacementID;
128
129   /// ShrinkWrap pass. Look for the best place to insert save and restore
130   // instruction and update the MachineFunctionInfo with that information.
131   extern char &ShrinkWrapID;
132
133   /// LiveRangeShrink pass. Move instruction close to its definition to shrink
134   /// the definition's live range.
135   extern char &LiveRangeShrinkID;
136
137   /// Greedy register allocator.
138   extern char &RAGreedyID;
139
140   /// Basic register allocator.
141   extern char &RABasicID;
142
143   /// VirtRegRewriter pass. Rewrite virtual registers to physical registers as
144   /// assigned in VirtRegMap.
145   extern char &VirtRegRewriterID;
146
147   /// UnreachableMachineBlockElimination - This pass removes unreachable
148   /// machine basic blocks.
149   extern char &UnreachableMachineBlockElimID;
150
151   /// DeadMachineInstructionElim - This pass removes dead machine instructions.
152   extern char &DeadMachineInstructionElimID;
153
154   /// This pass adds dead/undef flags after analyzing subregister lanes.
155   extern char &DetectDeadLanesID;
156
157   /// This pass perform post-ra machine sink for COPY instructions.
158   extern char &PostRAMachineSinkingID;
159
160   /// FastRegisterAllocation Pass - This pass register allocates as fast as
161   /// possible. It is best suited for debug code where live ranges are short.
162   ///
163   FunctionPass *createFastRegisterAllocator();
164
165   /// BasicRegisterAllocation Pass - This pass implements a degenerate global
166   /// register allocator using the basic regalloc framework.
167   ///
168   FunctionPass *createBasicRegisterAllocator();
169
170   /// Greedy register allocation pass - This pass implements a global register
171   /// allocator for optimized builds.
172   ///
173   FunctionPass *createGreedyRegisterAllocator();
174
175   /// PBQPRegisterAllocation Pass - This pass implements the Partitioned Boolean
176   /// Quadratic Prograaming (PBQP) based register allocator.
177   ///
178   FunctionPass *createDefaultPBQPRegisterAllocator();
179
180   /// PrologEpilogCodeInserter - This pass inserts prolog and epilog code,
181   /// and eliminates abstract frame references.
182   extern char &PrologEpilogCodeInserterID;
183   MachineFunctionPass *createPrologEpilogInserterPass();
184
185   /// ExpandPostRAPseudos - This pass expands pseudo instructions after
186   /// register allocation.
187   extern char &ExpandPostRAPseudosID;
188
189   /// createPostRAHazardRecognizer - This pass runs the post-ra hazard
190   /// recognizer.
191   extern char &PostRAHazardRecognizerID;
192
193   /// createPostRAScheduler - This pass performs post register allocation
194   /// scheduling.
195   extern char &PostRASchedulerID;
196
197   /// BranchFolding - This pass performs machine code CFG based
198   /// optimizations to delete branches to branches, eliminate branches to
199   /// successor blocks (creating fall throughs), and eliminating branches over
200   /// branches.
201   extern char &BranchFolderPassID;
202
203   /// BranchRelaxation - This pass replaces branches that need to jump further
204   /// than is supported by a branch instruction.
205   extern char &BranchRelaxationPassID;
206
207   /// MachineFunctionPrinterPass - This pass prints out MachineInstr's.
208   extern char &MachineFunctionPrinterPassID;
209
210   /// MIRPrintingPass - this pass prints out the LLVM IR using the MIR
211   /// serialization format.
212   extern char &MIRPrintingPassID;
213
214   /// TailDuplicate - Duplicate blocks with unconditional branches
215   /// into tails of their predecessors.
216   extern char &TailDuplicateID;
217
218   /// Duplicate blocks with unconditional branches into tails of their
219   /// predecessors. Variant that works before register allocation.
220   extern char &EarlyTailDuplicateID;
221
222   /// MachineTraceMetrics - This pass computes critical path and CPU resource
223   /// usage in an ensemble of traces.
224   extern char &MachineTraceMetricsID;
225
226   /// EarlyIfConverter - This pass performs if-conversion on SSA form by
227   /// inserting cmov instructions.
228   extern char &EarlyIfConverterID;
229
230   /// This pass performs instruction combining using trace metrics to estimate
231   /// critical-path and resource depth.
232   extern char &MachineCombinerID;
233
234   /// StackSlotColoring - This pass performs stack coloring and merging.
235   /// It merges disjoint allocas to reduce the stack size.
236   extern char &StackColoringID;
237
238   /// IfConverter - This pass performs machine code if conversion.
239   extern char &IfConverterID;
240
241   FunctionPass *createIfConverter(
242       std::function<bool(const MachineFunction &)> Ftor);
243
244   /// MachineBlockPlacement - This pass places basic blocks based on branch
245   /// probabilities.
246   extern char &MachineBlockPlacementID;
247
248   /// MachineBlockPlacementStats - This pass collects statistics about the
249   /// basic block placement using branch probabilities and block frequency
250   /// information.
251   extern char &MachineBlockPlacementStatsID;
252
253   /// GCLowering Pass - Used by gc.root to perform its default lowering
254   /// operations.
255   FunctionPass *createGCLoweringPass();
256
257   /// ShadowStackGCLowering - Implements the custom lowering mechanism
258   /// used by the shadow stack GC.  Only runs on functions which opt in to
259   /// the shadow stack collector.
260   FunctionPass *createShadowStackGCLoweringPass();
261
262   /// GCMachineCodeAnalysis - Target-independent pass to mark safe points
263   /// in machine code. Must be added very late during code generation, just
264   /// prior to output, and importantly after all CFG transformations (such as
265   /// branch folding).
266   extern char &GCMachineCodeAnalysisID;
267
268   /// Creates a pass to print GC metadata.
269   ///
270   FunctionPass *createGCInfoPrinter(raw_ostream &OS);
271
272   /// MachineCSE - This pass performs global CSE on machine instructions.
273   extern char &MachineCSEID;
274
275   /// ImplicitNullChecks - This pass folds null pointer checks into nearby
276   /// memory operations.
277   extern char &ImplicitNullChecksID;
278
279   /// This pass performs loop invariant code motion on machine instructions.
280   extern char &MachineLICMID;
281
282   /// This pass performs loop invariant code motion on machine instructions.
283   /// This variant works before register allocation. \see MachineLICMID.
284   extern char &EarlyMachineLICMID;
285
286   /// MachineSinking - This pass performs sinking on machine instructions.
287   extern char &MachineSinkingID;
288
289   /// MachineCopyPropagation - This pass performs copy propagation on
290   /// machine instructions.
291   extern char &MachineCopyPropagationID;
292
293   /// PeepholeOptimizer - This pass performs peephole optimizations -
294   /// like extension and comparison eliminations.
295   extern char &PeepholeOptimizerID;
296
297   /// OptimizePHIs - This pass optimizes machine instruction PHIs
298   /// to take advantage of opportunities created during DAG legalization.
299   extern char &OptimizePHIsID;
300
301   /// StackSlotColoring - This pass performs stack slot coloring.
302   extern char &StackSlotColoringID;
303
304   /// This pass lays out funclets contiguously.
305   extern char &FuncletLayoutID;
306
307   /// This pass inserts the XRay instrumentation sleds if they are supported by
308   /// the target platform.
309   extern char &XRayInstrumentationID;
310
311   /// This pass inserts FEntry calls
312   extern char &FEntryInserterID;
313
314   /// This pass implements the "patchable-function" attribute.
315   extern char &PatchableFunctionID;
316
317   /// createStackProtectorPass - This pass adds stack protectors to functions.
318   ///
319   FunctionPass *createStackProtectorPass();
320
321   /// createMachineVerifierPass - This pass verifies cenerated machine code
322   /// instructions for correctness.
323   ///
324   FunctionPass *createMachineVerifierPass(const std::string& Banner);
325
326   /// createDwarfEHPass - This pass mulches exception handling code into a form
327   /// adapted to code generation.  Required if using dwarf exception handling.
328   FunctionPass *createDwarfEHPass();
329
330   /// createWinEHPass - Prepares personality functions used by MSVC on Windows,
331   /// in addition to the Itanium LSDA based personalities.
332   FunctionPass *createWinEHPass(bool DemoteCatchSwitchPHIOnly = false);
333
334   /// createSjLjEHPreparePass - This pass adapts exception handling code to use
335   /// the GCC-style builtin setjmp/longjmp (sjlj) to handling EH control flow.
336   ///
337   FunctionPass *createSjLjEHPreparePass();
338
339   /// createWasmEHPass - This pass adapts exception handling code to use
340   /// WebAssembly's exception handling scheme.
341   FunctionPass *createWasmEHPass();
342
343   /// LocalStackSlotAllocation - This pass assigns local frame indices to stack
344   /// slots relative to one another and allocates base registers to access them
345   /// when it is estimated by the target to be out of range of normal frame
346   /// pointer or stack pointer index addressing.
347   extern char &LocalStackSlotAllocationID;
348
349   /// ExpandISelPseudos - This pass expands pseudo-instructions.
350   extern char &ExpandISelPseudosID;
351
352   /// UnpackMachineBundles - This pass unpack machine instruction bundles.
353   extern char &UnpackMachineBundlesID;
354
355   FunctionPass *
356   createUnpackMachineBundles(std::function<bool(const MachineFunction &)> Ftor);
357
358   /// FinalizeMachineBundles - This pass finalize machine instruction
359   /// bundles (created earlier, e.g. during pre-RA scheduling).
360   extern char &FinalizeMachineBundlesID;
361
362   /// StackMapLiveness - This pass analyses the register live-out set of
363   /// stackmap/patchpoint intrinsics and attaches the calculated information to
364   /// the intrinsic for later emission to the StackMap.
365   extern char &StackMapLivenessID;
366
367   /// LiveDebugValues pass
368   extern char &LiveDebugValuesID;
369
370   /// createJumpInstrTables - This pass creates jump-instruction tables.
371   ModulePass *createJumpInstrTablesPass();
372
373   /// createForwardControlFlowIntegrityPass - This pass adds control-flow
374   /// integrity.
375   ModulePass *createForwardControlFlowIntegrityPass();
376
377   /// InterleavedAccess Pass - This pass identifies and matches interleaved
378   /// memory accesses to target specific intrinsics.
379   ///
380   FunctionPass *createInterleavedAccessPass();
381
382   /// InterleavedLoadCombines Pass - This pass identifies interleaved loads and
383   /// combines them into wide loads detectable by InterleavedAccessPass
384   ///
385   FunctionPass *createInterleavedLoadCombinePass();
386
387   /// LowerEmuTLS - This pass generates __emutls_[vt].xyz variables for all
388   /// TLS variables for the emulated TLS model.
389   ///
390   ModulePass *createLowerEmuTLSPass();
391
392   /// This pass lowers the \@llvm.load.relative and \@llvm.objc.* intrinsics to
393   /// instructions.  This is unsafe to do earlier because a pass may combine the
394   /// constant initializer into the load, which may result in an overflowing
395   /// evaluation.
396   ModulePass *createPreISelIntrinsicLoweringPass();
397
398   /// GlobalMerge - This pass merges internal (by default) globals into structs
399   /// to enable reuse of a base pointer by indexed addressing modes.
400   /// It can also be configured to focus on size optimizations only.
401   ///
402   Pass *createGlobalMergePass(const TargetMachine *TM, unsigned MaximalOffset,
403                               bool OnlyOptimizeForSize = false,
404                               bool MergeExternalByDefault = false);
405
406   /// This pass splits the stack into a safe stack and an unsafe stack to
407   /// protect against stack-based overflow vulnerabilities.
408   FunctionPass *createSafeStackPass();
409
410   /// This pass detects subregister lanes in a virtual register that are used
411   /// independently of other lanes and splits them into separate virtual
412   /// registers.
413   extern char &RenameIndependentSubregsID;
414
415   /// This pass is executed POST-RA to collect which physical registers are
416   /// preserved by given machine function.
417   FunctionPass *createRegUsageInfoCollector();
418
419   /// Return a MachineFunction pass that identifies call sites
420   /// and propagates register usage information of callee to caller
421   /// if available with PysicalRegisterUsageInfo pass.
422   FunctionPass *createRegUsageInfoPropPass();
423
424   /// This pass performs software pipelining on machine instructions.
425   extern char &MachinePipelinerID;
426
427   /// This pass frees the memory occupied by the MachineFunction.
428   FunctionPass *createFreeMachineFunctionPass();
429
430   /// This pass performs outlining on machine instructions directly before
431   /// printing assembly.
432   ModulePass *createMachineOutlinerPass(bool RunOnAllFunctions = true);
433
434   /// This pass expands the experimental reduction intrinsics into sequences of
435   /// shuffles.
436   FunctionPass *createExpandReductionsPass();
437
438   // This pass expands memcmp() to load/stores.
439   FunctionPass *createExpandMemCmpPass();
440
441   /// Creates Break False Dependencies pass. \see BreakFalseDeps.cpp
442   FunctionPass *createBreakFalseDeps();
443
444   // This pass expands indirectbr instructions.
445   FunctionPass *createIndirectBrExpandPass();
446
447   /// Creates CFI Instruction Inserter pass. \see CFIInstrInserter.cpp
448   FunctionPass *createCFIInstrInserter();
449
450 } // End llvm namespace
451
452 #endif