|
LLVM 22.0.0git
|
This class provides access to building LLVM's passes. More...
#include "llvm/Passes/CodeGenPassBuilder.h"
Public Member Functions | |
| CodeGenPassBuilder (TargetMachineT &TM, const CGPassBuilderOption &Opts, PassInstrumentationCallbacks *PIC) | |
| Error | buildPipeline (ModulePassManager &MPM, raw_pwrite_stream &Out, raw_pwrite_stream *DwoOut, CodeGenFileType FileType) const |
| PassInstrumentationCallbacks * | getPassInstrumentationCallbacks () const |
Protected Types | |
| template<typename PassT> | |
| using | is_module_pass_t |
| template<typename PassT> | |
| using | is_function_pass_t |
| template<typename PassT> | |
| using | is_machine_function_pass_t |
| using | CreateMCStreamer |
Protected Member Functions | |
| template<typename PassT> | |
| void | addFunctionPass (PassT &&Pass, PassManagerWrapper &PMW, bool Force=false, StringRef Name=PassT::name()) const |
| template<typename PassT> | |
| void | addModulePass (PassT &&Pass, PassManagerWrapper &PMW, bool Force=false, StringRef Name=PassT::name()) const |
| template<typename PassT> | |
| void | addMachineFunctionPass (PassT &&Pass, PassManagerWrapper &PMW, bool Force=false, StringRef Name=PassT::name()) const |
| void | flushFPMsToMPM (PassManagerWrapper &PMW, bool FreeMachineFunctions=false) const |
| void | requireCGSCCOrder (PassManagerWrapper &PMW) const |
| void | stopAddingInCGSCCOrder (PassManagerWrapper &PMW) const |
| template<typename TMC> | |
| TMC & | getTM () const |
| CodeGenOptLevel | getOptLevel () const |
| bool | isGlobalISelAbortEnabled () const |
| Check whether or not GlobalISel should abort on error. | |
| bool | reportDiagnosticWhenGlobalISelFallback () const |
| Check whether or not a diagnostic should be emitted when GlobalISel uses the fallback path. | |
| Error | addInstSelector (PassManagerWrapper &PMW) const |
| addInstSelector - This method should install an instruction selector pass, which converts from LLVM code to machine instructions. | |
| void | addGlobalMergePass (PassManagerWrapper &PMW) const |
| Target can override this to add GlobalMergePass before all IR passes. | |
| void | addILPOpts (PassManagerWrapper &PMW) const |
| Add passes that optimize instruction level parallelism for out-of-order targets. | |
| void | addPreRegAlloc (PassManagerWrapper &PMW) const |
| This method may be implemented by targets that want to run passes immediately before register allocation. | |
| void | addPreRewrite (PassManagerWrapper &PMW) const |
| addPreRewrite - Add passes to the optimized register allocation pipeline after register allocation is complete, but before virtual registers are rewritten to physical registers. | |
| void | addPostRewrite (PassManagerWrapper &PMW) const |
| Add passes to be run immediately after virtual registers are rewritten to physical registers. | |
| void | addPostRegAlloc (PassManagerWrapper &PMW) const |
| This method may be implemented by targets that want to run passes after register allocation pass pipeline but before prolog-epilog insertion. | |
| void | addPreSched2 (PassManagerWrapper &PMW) const |
| This method may be implemented by targets that want to run passes after prolog-epilog insertion and before the second instruction scheduling pass. | |
| void | addPreEmitPass (PassManagerWrapper &PMW) const |
| This pass may be implemented by targets that want to run passes immediately before machine code is emitted. | |
| void | addPreEmitPass2 (PassManagerWrapper &PMW) const |
| Targets may add passes immediately before machine code is emitted in this callback. | |
| void | addPreISel (PassManagerWrapper &PMW) const |
| {{@ For GlobalISel | |
| Error | addIRTranslator (PassManagerWrapper &PMW) const |
| This method should install an IR translator pass, which converts from LLVM code to machine instructions with possibly generic opcodes. | |
| void | addPreLegalizeMachineIR (PassManagerWrapper &PMW) const |
| This method may be implemented by targets that want to run passes immediately before legalization. | |
| Error | addLegalizeMachineIR (PassManagerWrapper &PMW) const |
| This method should install a legalize pass, which converts the instruction sequence into one that can be selected by the target. | |
| void | addPreRegBankSelect (PassManagerWrapper &PMW) const |
| This method may be implemented by targets that want to run passes immediately before the register bank selection. | |
| Error | addRegBankSelect (PassManagerWrapper &PMW) const |
| This method should install a register bank selector pass, which assigns register banks to virtual registers without a register class or register banks. | |
| void | addPreGlobalInstructionSelect (PassManagerWrapper &PMW) const |
| This method may be implemented by targets that want to run passes immediately before the (global) instruction selection. | |
| Error | addGlobalInstructionSelect (PassManagerWrapper &PMWM) const |
| This method should install a (global) instruction selector pass, which converts possibly generic instructions to fully target-specific instructions, thereby constraining all generic virtual registers to register classes. | |
| void | addISelPasses (PassManagerWrapper &PMW) const |
| High level function that adds all passes necessary to go from llvm IR representation to the MI representation. | |
| Error | addCoreISelPasses (PassManagerWrapper &PMW) const |
| Add the actual instruction selection passes. | |
| Error | addMachinePasses (PassManagerWrapper &PMW) const |
| Add the complete, standard set of LLVM CodeGen passes. | |
| void | addPassesToHandleExceptions (PassManagerWrapper &PMW) const |
| Add passes to lower exception handling for the code generator. | |
| void | addIRPasses (PassManagerWrapper &PMW) const |
| Add common target configurable passes that perform LLVM IR to IR transforms following machine independent optimization. | |
| void | addCodeGenPrepare (PassManagerWrapper &PMW) const |
| Add pass to prepare the LLVM IR for code generation. | |
| void | addISelPrepare (PassManagerWrapper &PMW) const |
| Add common passes that perform LLVM IR to IR transforms in preparation for instruction selection. | |
| void | addMachineSSAOptimization (PassManagerWrapper &PMW) const |
| Methods with trivial inline returns are convenient points in the common codegen pass pipeline where targets may insert passes. | |
| Error | addFastRegAlloc (PassManagerWrapper &PMW) const |
| addFastRegAlloc - Add the minimum set of target-independent passes that are required for fast register allocation. | |
| void | addOptimizedRegAlloc (PassManagerWrapper &PMW) const |
| addOptimizedRegAlloc - Add passes related to register allocation. | |
| void | addMachineLateOptimization (PassManagerWrapper &PMW) const |
| Add passes that optimize machine instructions after register allocation. | |
| void | addGCPasses (PassManagerWrapper &PMW) const |
| addGCPasses - Add late codegen passes that analyze code for garbage collection. | |
| void | addBlockPlacement (PassManagerWrapper &PMW) const |
| Add standard basic block placement passes. | |
| void | addAsmPrinter (PassManagerWrapper &PMW, CreateMCStreamer) const |
| void | addTargetRegisterAllocator (PassManagerWrapper &PMW, bool Optimized) const |
| Utilities for targets to add passes to the pass manager. | |
| void | addRegAllocPass (PassManagerWrapper &PMW, bool Optimized) const |
| addMachinePasses helper to create the target-selected or overriden regalloc pass. | |
| Error | addRegAssignmentFast (PassManagerWrapper &PMW) const |
| Add core register alloator passes which do the actual register assignment and rewriting. | |
| Error | addRegAssignmentOptimized (PassManagerWrapper &PMWM) const |
| template<typename... PassTs> | |
| void | disablePass () |
| Allow the target to disable a specific pass by default. | |
| template<typename TargetPassT, typename InsertedPassT> | |
| void | insertPass (InsertedPassT &&Pass) const |
| Insert InsertedPass pass after TargetPass pass. | |
Protected Attributes | |
| TargetMachineT & | TM |
| CGPassBuilderOption | Opt |
| PassInstrumentationCallbacks * | PIC |
This class provides access to building LLVM's passes.
Its members provide the baseline state available to passes during their construction. The MachinePassRegistry.def file specifies how to construct all of the built-in passes, and those may reference these members during construction.
Definition at line 179 of file CodeGenPassBuilder.h.
|
protected |
Definition at line 489 of file CodeGenPassBuilder.h.
|
protected |
Definition at line 218 of file CodeGenPassBuilder.h.
|
protected |
Definition at line 222 of file CodeGenPassBuilder.h.
|
protected |
Definition at line 214 of file CodeGenPassBuilder.h.
|
inlineexplicit |
Definition at line 181 of file CodeGenPassBuilder.h.
|
inlineprotected |
Definition at line 491 of file CodeGenPassBuilder.h.
|
protected |
Add standard basic block placement passes.
Definition at line 1296 of file CodeGenPassBuilder.h.
References addMachineFunctionPass(), and Opt.
|
protected |
Add pass to prepare the LLVM IR for code generation.
This should be done before exception handling preparation passes.
Definition at line 821 of file CodeGenPassBuilder.h.
References addFunctionPass(), getOptLevel(), llvm::None, Opt, and TM.
|
protected |
Add the actual instruction selection passes.
This does not include preparation passes on IR.
Definition at line 860 of file CodeGenPassBuilder.h.
References addGlobalInstructionSelect(), addInstSelector(), addIRTranslator(), addLegalizeMachineIR(), addMachineFunctionPass(), addRegBankSelect(), isGlobalISelAbortEnabled(), llvm::None, Opt, reportDiagnosticWhenGlobalISelFallback(), llvm::Error::success(), and TM.
Referenced by buildPipeline().
|
protected |
addFastRegAlloc - Add the minimum set of target-independent passes that are required for fast register allocation.
Add the minimum set of target-independent passes that are required for register allocation.
No coalescing or scheduling.
Definition at line 1197 of file CodeGenPassBuilder.h.
References addMachineFunctionPass().
Referenced by addMachinePasses().
|
inlineprotected |
Definition at line 227 of file CodeGenPassBuilder.h.
Referenced by addCodeGenPrepare(), addIRPasses(), addISelPasses(), addISelPrepare(), and addPassesToHandleExceptions().
|
inlineprotected |
addGCPasses - Add late codegen passes that analyze code for garbage collection.
This should return true if GC info should be printed after these passes.
Definition at line 484 of file CodeGenPassBuilder.h.
|
inlineprotected |
This method should install a (global) instruction selector pass, which converts possibly generic instructions to fully target-specific instructions, thereby constraining all generic virtual registers to register classes.
Definition at line 422 of file CodeGenPassBuilder.h.
Referenced by addCoreISelPasses().
|
inlineprotected |
Target can override this to add GlobalMergePass before all IR passes.
Definition at line 324 of file CodeGenPassBuilder.h.
|
inlineprotected |
Add passes that optimize instruction level parallelism for out-of-order targets.
These passes are run while the machine code is still in SSA form, so they can use MachineTraceMetrics to control their heuristics.
All passes added here should preserve the MachineDominatorTree, MachineLoopInfo, and MachineTraceMetrics analyses.
Definition at line 332 of file CodeGenPassBuilder.h.
|
inlineprotected |
addInstSelector - This method should install an instruction selector pass, which converts from LLVM code to machine instructions.
Definition at line 318 of file CodeGenPassBuilder.h.
Referenced by addCoreISelPasses().
|
protected |
Add common target configurable passes that perform LLVM IR to IR transforms following machine independent optimization.
Definition at line 693 of file CodeGenPassBuilder.h.
References addFunctionPass(), addModulePass(), llvm::createFunctionToLoopPassAdaptor(), flushFPMsToMPM(), getOptLevel(), llvm::PassInfoMixin< ShadowStackGCLoweringPass >::name(), llvm::None, Opt, and TM.
|
inlineprotected |
This method should install an IR translator pass, which converts from LLVM code to machine instructions with possibly generic opcodes.
Definition at line 386 of file CodeGenPassBuilder.h.
Referenced by addCoreISelPasses().
|
protected |
High level function that adds all passes necessary to go from llvm IR representation to the MI representation.
Adds IR based lowering and target specific optimization passes and finally the core instruction selection passes.
Definition at line 674 of file CodeGenPassBuilder.h.
References addFunctionPass(), addModulePass(), addPassesToHandleExceptions(), getOptLevel(), and TM.
Referenced by buildPipeline().
|
protected |
Add common passes that perform LLVM IR to IR transforms in preparation for instruction selection.
Definition at line 832 of file CodeGenPassBuilder.h.
References addFunctionPass(), llvm::dbgs(), getOptLevel(), llvm::None, Opt, requireCGSCCOrder(), and TM.
|
inlineprotected |
This method should install a legalize pass, which converts the instruction sequence into one that can be selected by the target.
Definition at line 397 of file CodeGenPassBuilder.h.
Referenced by addCoreISelPasses().
|
inlineprotected |
Definition at line 251 of file CodeGenPassBuilder.h.
Referenced by addBlockPlacement(), addCoreISelPasses(), addFastRegAlloc(), addMachineLateOptimization(), addMachinePasses(), addMachineSSAOptimization(), addOptimizedRegAlloc(), addRegAllocPass(), addRegAssignmentOptimized(), addTargetRegisterAllocator(), and buildPipeline().
|
protected |
Add passes that optimize machine instructions after register allocation.
Post RegAlloc Pass Configuration.
Add passes that optimize machine instructions after register allocation.
Definition at line 1275 of file CodeGenPassBuilder.h.
References addMachineFunctionPass(), Opt, and TM.
|
protected |
Add the complete, standard set of LLVM CodeGen passes.
Add the complete set of target-independent postISel code generator passes.
Fully developed targets will not generally override this.
This can be read as the standard order of major LLVM CodeGen stages. Stages with nontrivial configuration or multiple passes are broken out below in addStage routines.
Any CodeGenPassBuilder<Derived, TargetMachine>::addXX routine may be overriden by the Target. The addPre/Post methods with empty header implementations allow injecting target-specific fixups just before or after major stages. Additionally, targets have the flexibility to change pass order within a stage by overriding default implementation of addStage routines below. Each technique has maintainability tradeoffs because alternate pass orders are not well supported. addPre/Post works better if the target pass is easily tied to a common pass. But if it has subtle dependencies on multiple passes, the target should override the stage instead.
Add passes that optimize machine instructions after register allocation.
Definition at line 955 of file CodeGenPassBuilder.h.
References addFastRegAlloc(), addMachineFunctionPass(), addModulePass(), flushFPMsToMPM(), getOptLevel(), getTM(), llvm::NeverOutline, llvm::None, Opt, Options, llvm::Error::success(), llvm::TargetDefault, and TM.
Referenced by buildPipeline().
|
protected |
Methods with trivial inline returns are convenient points in the common codegen pass pipeline where targets may insert passes.
Add passes that optimize machine instructions in SSA form.
Methods with out-of-line standard implementations are major CodeGen stages called by addMachinePasses. Some targets may override major stages when inserting passes is insufficient, but maintaining overriden stages is more work. addMachineSSAOptimization - Add standard passes that optimize machine instructions in SSA form.
Definition at line 1076 of file CodeGenPassBuilder.h.
References addMachineFunctionPass(), and Opt.
|
inlineprotected |
Definition at line 238 of file CodeGenPassBuilder.h.
Referenced by addIRPasses(), addISelPasses(), addMachinePasses(), and buildPipeline().
|
protected |
addOptimizedRegAlloc - Add passes related to register allocation.
Add standard target-independent passes that are tightly coupled with optimized register allocation, including coalescing, machine instruction scheduling, and register allocation itself.
CodeGenTargetMachineImpl provides standard regalloc passes for most targets.
Definition at line 1208 of file CodeGenPassBuilder.h.
References addMachineFunctionPass(), addRegAssignmentOptimized(), Opt, and TM.
|
protected |
Add passes to lower exception handling for the code generator.
Turn exception handling constructs into something the code generators can handle.
Definition at line 774 of file CodeGenPassBuilder.h.
References addFunctionPass(), llvm::AIX, llvm::ARM, assert(), llvm::DwarfCFI, llvm::MCAsmInfo::getExceptionHandlingType(), llvm::None, llvm::SjLj, TM, llvm::Wasm, llvm::WinEH, and llvm::ZOS.
Referenced by addISelPasses().
|
inlineprotected |
This method may be implemented by targets that want to run passes after register allocation pass pipeline but before prolog-epilog insertion.
Definition at line 358 of file CodeGenPassBuilder.h.
|
inlineprotected |
Add passes to be run immediately after virtual registers are rewritten to physical registers.
Definition at line 354 of file CodeGenPassBuilder.h.
|
inlineprotected |
This pass may be implemented by targets that want to run passes immediately before machine code is emitted.
Definition at line 366 of file CodeGenPassBuilder.h.
|
inlineprotected |
Targets may add passes immediately before machine code is emitted in this callback.
This is called even later than addPreEmitPass.
Definition at line 373 of file CodeGenPassBuilder.h.
|
inlineprotected |
This method may be implemented by targets that want to run passes immediately before the (global) instruction selection.
Definition at line 416 of file CodeGenPassBuilder.h.
|
inlineprotected |
{{@ For GlobalISel
addPreISel - This method should add any "last minute" LLVM->LLVM passes (which are run just before instruction selector).
Definition at line 380 of file CodeGenPassBuilder.h.
|
inlineprotected |
This method may be implemented by targets that want to run passes immediately before legalization.
Definition at line 393 of file CodeGenPassBuilder.h.
|
inlineprotected |
This method may be implemented by targets that want to run passes immediately before register allocation.
Definition at line 336 of file CodeGenPassBuilder.h.
|
inlineprotected |
This method may be implemented by targets that want to run passes immediately before the register bank selection.
Definition at line 404 of file CodeGenPassBuilder.h.
|
inlineprotected |
addPreRewrite - Add passes to the optimized register allocation pipeline after register allocation is complete, but before virtual registers are rewritten to physical registers.
These passes must preserve VirtRegMap and LiveIntervals, and when running after RABasic or RAGreedy, they should take advantage of LiveRegMatrix. When these passes run, VirtRegMap contains legal physreg assignments for all virtual registers.
Note if the target overloads addRegAssignAndRewriteOptimized, this may not be honored. This is also not generally used for the fast variant, where the allocation and rewriting are done in one pass.
Definition at line 350 of file CodeGenPassBuilder.h.
|
inlineprotected |
This method may be implemented by targets that want to run passes after prolog-epilog insertion and before the second instruction scheduling pass.
Definition at line 362 of file CodeGenPassBuilder.h.
|
protected |
addMachinePasses helper to create the target-selected or overriden regalloc pass.
Find and instantiate the register allocation pass requested by this target at the current optimization level.
Different register allocators are defined as separate passes because they may require different analysis.
This helper ensures that the -regalloc-npm= option is always available, even for targets that override the default allocator.
Definition at line 1145 of file CodeGenPassBuilder.h.
References addMachineFunctionPass(), llvm::Default, llvm::Fast, llvm::Greedy, Opt, and llvm::reportFatalUsageError().
Referenced by addRegAssignmentFast(), and addRegAssignmentOptimized().
|
protected |
Add core register alloator passes which do the actual register assignment and rewriting.
Definition at line 1167 of file CodeGenPassBuilder.h.
References addRegAllocPass(), and llvm::Error::success().
|
protected |
Definition at line 1175 of file CodeGenPassBuilder.h.
References addMachineFunctionPass(), addRegAllocPass(), and llvm::Error::success().
Referenced by addOptimizedRegAlloc().
|
inlineprotected |
This method should install a register bank selector pass, which assigns register banks to virtual registers without a register class or register banks.
Definition at line 409 of file CodeGenPassBuilder.h.
Referenced by addCoreISelPasses().
|
protected |
Utilities for targets to add passes to the pass manager.
Register Allocation Pass Configuration.
createTargetRegisterAllocator - Create the register allocator pass for this target at the current optimization level.
Instantiate the default register allocator pass for this target for either the optimized or unoptimized allocation path. This will be added to the pass manager by addFastRegAlloc in the unoptimized case or addOptimizedRegAlloc in the optimized case.
A target that uses the standard regalloc pass order for fast or optimized allocation may still override this for per-target regalloc selection. But -regalloc-npm=... always takes precedence. If a target does not want to allow users to set -regalloc-npm=... at all, check if Opt.RegAlloc == RegAllocType::Unset.
Definition at line 1130 of file CodeGenPassBuilder.h.
References addMachineFunctionPass().
| Error llvm::CodeGenPassBuilder< Derived, TargetMachineT >::buildPipeline | ( | ModulePassManager & | MPM, |
| raw_pwrite_stream & | Out, | ||
| raw_pwrite_stream * | DwoOut, | ||
| CodeGenFileType | FileType ) const |
Definition at line 562 of file CodeGenPassBuilder.h.
References addCoreISelPasses(), addISelPasses(), addMachineFunctionPass(), addMachinePasses(), addModulePass(), flushFPMsToMPM(), llvm::TargetPassConfig::getStartStopInfo(), llvm::Null, Opt, PIC, and llvm::TargetPassConfig::willCompleteCodeGenPipeline().
Referenced by llvm::R600TargetMachine::buildCodeGenPipeline().
|
inlineprotected |
Allow the target to disable a specific pass by default.
Backend can declare unwanted passes in constructor.
Definition at line 514 of file CodeGenPassBuilder.h.
|
inlineprotected |
Definition at line 264 of file CodeGenPassBuilder.h.
Referenced by addIRPasses(), addMachinePasses(), buildPipeline(), llvm::CodeGenPassBuilder< AMDGPUCodeGenPassBuilder, GCNTargetMachine >::requireCGSCCOrder(), and llvm::CodeGenPassBuilder< AMDGPUCodeGenPassBuilder, GCNTargetMachine >::stopAddingInCGSCCOrder().
|
inlineprotected |
Definition at line 300 of file CodeGenPassBuilder.h.
Referenced by addCodeGenPrepare(), addIRPasses(), addISelPasses(), addISelPrepare(), and addMachinePasses().
|
inline |
Definition at line 208 of file CodeGenPassBuilder.h.
|
inlineprotected |
Definition at line 299 of file CodeGenPassBuilder.h.
Referenced by addMachinePasses().
|
inlineprotected |
Insert InsertedPass pass after TargetPass pass.
Only machine function passes are supported.
Definition at line 522 of file CodeGenPassBuilder.h.
|
inlineprotected |
Check whether or not GlobalISel should abort on error.
When this is disabled, GlobalISel will fall back on SDISel instead of erroring out.
Definition at line 305 of file CodeGenPassBuilder.h.
Referenced by addCoreISelPasses().
|
inlineprotected |
Check whether or not a diagnostic should be emitted when GlobalISel uses the fallback path.
In other words, it will emit a diagnostic when GlobalISel failed and isGlobalISelAbortEnabled is false.
Definition at line 312 of file CodeGenPassBuilder.h.
Referenced by addCoreISelPasses().
|
inlineprotected |
Definition at line 284 of file CodeGenPassBuilder.h.
Referenced by addISelPrepare().
|
inlineprotected |
Definition at line 289 of file CodeGenPassBuilder.h.
|
protected |
Definition at line 296 of file CodeGenPassBuilder.h.
Referenced by addBlockPlacement(), addCodeGenPrepare(), addCoreISelPasses(), addIRPasses(), addISelPrepare(), addMachineLateOptimization(), addMachinePasses(), addMachineSSAOptimization(), addOptimizedRegAlloc(), addRegAllocPass(), and buildPipeline().
|
protected |
Definition at line 297 of file CodeGenPassBuilder.h.
Referenced by buildPipeline().
|
protected |
Definition at line 295 of file CodeGenPassBuilder.h.
Referenced by addCodeGenPrepare(), addCoreISelPasses(), addIRPasses(), addISelPasses(), addISelPrepare(), addMachineLateOptimization(), addMachinePasses(), addOptimizedRegAlloc(), and addPassesToHandleExceptions().