54 "r600-ir-structurize",
55 cl::desc(
"Use StructurizeCFG IR pass"),
60 cl::desc(
"Run SROA after promote alloca pass"),
77 "amdgpu-load-store-vectorizer",
78 cl::desc(
"Enable load store vectorizer"),
84 "amdgpu-scalarize-global-loads",
85 cl::desc(
"Enable global load scalarization"),
91 "amdgpu-internalize-symbols",
92 cl::desc(
"Enable elimination of non-kernel functions and unused globals"),
98 "amdgpu-early-inline-all",
99 cl::desc(
"Inline all functions early"),
104 "amdgpu-sdwa-peephole",
110 cl::desc(
"Enable AMDGPU Alias Analysis"),
115 "enable-si-insert-waitcnts",
116 cl::desc(
"Use new waitcnt insertion pass"),
121 "amdgpu-late-structurize",
122 cl::desc(
"Enable late CFG structurization"),
160 return llvm::make_unique<AMDGPUTargetObjectFile>();
205 "Run GCN scheduler to maximize occupancy",
210 "Run GCN scheduler to maximize occupancy (experimental)",
215 "Run GCN iterative scheduler for minimal register usage (experimental)",
221 return "e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128"
222 "-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64";
229 return "e-p:64:64-p1:64:64-p2:64:64-p3:32:32-p4:32:32-p5:32:32"
230 "-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128"
231 "-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-A5";
232 return "e-p:32:32-p1:64:64-p2:64:64-p3:32:32-p4:64:64-p5:32:32"
233 "-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128"
234 "-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64";
312 if (
const Function *
F = dyn_cast<Function>(&GV)) {
313 if (
F->isDeclaration())
315 switch (
F->getCallingConv()) {
375 auto &
I = SubtargetMap[SubtargetKey];
381 I = llvm::make_unique<R600Subtarget>(
TargetTriple, GPU, FS, *
this);
405 auto &
I = SubtargetMap[SubtargetKey];
411 I = llvm::make_unique<SISubtarget>(
TargetTriple, GPU, FS, *
this);
436 return getTM<AMDGPUTargetMachine>();
447 void addEarlyCSEOrGVNPass();
448 void addStraightLineScalarOptimizationPasses();
449 void addIRPasses()
override;
450 void addCodeGenPrepare()
override;
451 bool addPreISel()
override;
452 bool addInstSelector()
override;
453 bool addGCPasses()
override;
456 class R600PassConfig final :
public AMDGPUPassConfig {
459 : AMDGPUPassConfig(TM, PM) {}
466 bool addPreISel()
override;
467 void addPreRegAlloc()
override;
468 void addPreSched2()
override;
469 void addPreEmitPass()
override;
472 class GCNPassConfig final :
public AMDGPUPassConfig {
475 : AMDGPUPassConfig(TM, PM) {}
478 return getTM<GCNTargetMachine>();
484 bool addPreISel()
override;
485 void addMachineSSAOptimization()
override;
486 bool addILPOpts()
override;
487 bool addInstSelector()
override;
488 #ifdef LLVM_BUILD_GLOBAL_ISEL
489 bool addIRTranslator()
override;
490 bool addLegalizeMachineIR()
override;
491 bool addRegBankSelect()
override;
492 bool addGlobalInstructionSelect()
override;
494 void addFastRegAlloc(
FunctionPass *RegAllocPass)
override;
495 void addOptimizedRegAlloc(
FunctionPass *RegAllocPass)
override;
496 void addPreRegAlloc()
override;
497 void addPostRegAlloc()
override;
498 void addPreSched2()
override;
499 void addPreEmitPass()
override;
510 void AMDGPUPassConfig::addEarlyCSEOrGVNPass() {
517 void AMDGPUPassConfig::addStraightLineScalarOptimizationPasses() {
525 addEarlyCSEOrGVNPass();
533 void AMDGPUPassConfig::addIRPasses() {
569 addStraightLineScalarOptimizationPasses();
596 addEarlyCSEOrGVNPass();
599 void AMDGPUPassConfig::addCodeGenPrepare() {
606 bool AMDGPUPassConfig::addPreISel() {
611 bool AMDGPUPassConfig::addInstSelector() {
616 bool AMDGPUPassConfig::addGCPasses() {
625 bool R600PassConfig::addPreISel() {
626 AMDGPUPassConfig::addPreISel();
633 void R600PassConfig::addPreRegAlloc() {
637 void R600PassConfig::addPreSched2() {
644 void R600PassConfig::addPreEmitPass() {
653 return new R600PassConfig(*
this, PM);
668 bool GCNPassConfig::addPreISel() {
669 AMDGPUPassConfig::addPreISel();
690 void GCNPassConfig::addMachineSSAOptimization() {
713 bool GCNPassConfig::addILPOpts() {
721 bool GCNPassConfig::addInstSelector() {
722 AMDGPUPassConfig::addInstSelector();
728 #ifdef LLVM_BUILD_GLOBAL_ISEL
729 bool GCNPassConfig::addIRTranslator() {
734 bool GCNPassConfig::addLegalizeMachineIR() {
739 bool GCNPassConfig::addRegBankSelect() {
744 bool GCNPassConfig::addGlobalInstructionSelect() {
751 void GCNPassConfig::addPreRegAlloc() {
758 void GCNPassConfig::addFastRegAlloc(
FunctionPass *RegAllocPass) {
770 void GCNPassConfig::addOptimizedRegAlloc(
FunctionPass *RegAllocPass) {
783 void GCNPassConfig::addPostRegAlloc() {
789 void GCNPassConfig::addPreSched2() {
792 void GCNPassConfig::addPreEmitPass() {
814 return new GCNPassConfig(*
this, PM);
FunctionPass * createSpeculativeExecutionPass()
Pass interface - Implemented by all 'passes'.
Calling convention used for Mesa compute shaders.
OSType getOS() const
getOS - Get the parsed operating system type of this triple.
FunctionPass * createStraightLineStrengthReducePass()
FunctionPass * createGVNPass(bool NoLoads=false)
Create a legacy GVN pass.
StringRef getTargetCPU() const
Target & getTheGCNTarget()
The target for GCN GPUs.
char & AMDGPUUnifyDivergentExitNodesID
void addAAResult(AAResultT &AAResult)
Register a specific AA result.
FunctionPass * createSIAnnotateControlFlowPass()
Create the annotation pass.
ModulePass * createAMDGPUAlwaysInlinePass(bool GlobalOpt=true)
static LLVM_READNONE StringRef getGPUOrDefault(const Triple &TT, StringRef GPU)
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
PassManagerBuilder - This class is used to set up a standard optimization sequence for languages like...
const AMDGPUSubtarget * getSubtargetImpl() const
void initializeSIFixVGPRCopiesPass(PassRegistry &)
virtual void addIRPasses()
Add common target configurable passes that perform LLVM IR to IR transforms following machine indepen...
static cl::opt< bool > EnableLoadStoreVectorizer("amdgpu-load-store-vectorizer", cl::desc("Enable load store vectorizer"), cl::init(true), cl::Hidden)
void initializeSIInsertWaitcntsPass(PassRegistry &)
void initializeAMDGPUAnnotateKernelFeaturesPass(PassRegistry &)
Triple TargetTriple
Triple string, CPU name, and target feature strings the TargetMachine instance is created with...
char & SILoadStoreOptimizerID
Target & getTheAMDGPUTarget()
The target which supports all AMD GPUs.
char & MachineLICMID
MachineLICM - This pass performs LICM on machine instructions.
This file describes how to lower LLVM calls to machine code calls.
char & FuncletLayoutID
This pass lays out funclets contiguously.
AMDGPUAS getAMDGPUAS(const Module &M)
char & EarlyIfConverterID
EarlyIfConverter - This pass performs if-conversion on SSA form by inserting cmov instructions...
Analysis pass providing the TargetTransformInfo.
void initializeAMDGPUAnnotateUniformValuesPass(PassRegistry &)
FunctionPass * createAMDGPUPromoteAlloca()
virtual void add(Pass *P)=0
Add a pass to the queue of passes to run.
char & BranchRelaxationPassID
BranchRelaxation - This pass replaces branches that need to jump further than is supported by a branc...
FunctionPass * createAMDGPUCodeGenPreparePass()
Calling convention used for Mesa geometry shaders.
Attribute getFnAttribute(Attribute::AttrKind Kind) const
Return the attribute for the given attribute kind.
R600 Machine Scheduler interface.
char & MachineSchedulerID
MachineScheduler - This pass schedules machine instructions.
FunctionPass * createAMDGPUCFGStructurizerPass()
MachineSchedRegistry provides a selection of available machine instruction schedulers.
virtual void addMachineSSAOptimization()
addMachineSSAOptimization - Add standard passes that optimize machine instructions in SSA form...
void initializeAMDGPUAAWrapperPassPass(PassRegistry &)
FunctionPass * createAMDGPUISelDag(TargetMachine &TM, CodeGenOpt::Level OptLevel)
This pass converts a legalized DAG into a AMDGPU-specific.
static std::unique_ptr< TargetLoweringObjectFile > createTLOF(const Triple &TT)
void initializeAMDGPUPromoteAllocaPass(PassRegistry &)
bool hasAttribute(AttrKind Val) const
Return true if the attribute is present.
FunctionPass * createSIInsertWaitcntsPass()
ScheduleDAGMILive is an implementation of ScheduleDAGInstrs that schedules machine instructions while...
const Triple & getTargetTriple() const
bool enableSIScheduler() const
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
This file declares the targeting of the InstructionSelector class for AMDGPU.
AnalysisType * getAnalysisIfAvailable() const
getAnalysisIfAvailable<AnalysisType>() - Subclasses use this function to get analysis information tha...
static cl::opt< bool > EnableSDWAPeephole("amdgpu-sdwa-peephole", cl::desc("Enable SDWA peepholer"), cl::init(true))
Pass * createLoadStoreVectorizerPass()
This file declares the AMDGPU-specific subclass of TargetLoweringObjectFile.
GCNTargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, TargetOptions Options, Optional< Reloc::Model > RM, CodeModel::Model CM, CodeGenOpt::Level OL)
Pass * createAMDGPUAnnotateKernelFeaturesPass()
void initializeAMDGPUCodeGenPreparePass(PassRegistry &)
This file contains the simple types necessary to represent the attributes associated with functions a...
No attributes have been set.
FunctionPass * createSinkingPass()
R600TargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, TargetOptions Options, Optional< Reloc::Model > RM, CodeModel::Model CM, CodeGenOpt::Level OL)
char & SIFixControlFlowLiveIntervalsID
EP_ModuleOptimizerEarly - This extension point allows adding passes just before the main module-level...
char & FinalizeMachineBundlesID
FinalizeMachineBundles - This pass finalize machine instruction bundles (created earlier, e.g.
static MachineSchedRegistry R600SchedRegistry("r600","Run R600's custom scheduler", createR600MachineScheduler)
Target-Independent Code Generator Pass Configuration Options.
Calling convention used for Mesa hull shaders.
static StringRef computeDataLayout(const Triple &TT)
static cl::opt< bool > ScalarizeGlobal("amdgpu-scalarize-global-loads", cl::desc("Enable global load scalarization"), cl::init(true), cl::Hidden)
FunctionPass * createR600ExpandSpecialInstrsPass()
char & MachineCSEID
MachineCSE - This pass performs global CSE on machine instructions.
FunctionPass * createAMDGPUMachineCFGStructurizerPass()
FunctionPass * createSILowerI1CopiesPass()
void initializeSIOptimizeExecMaskingPass(PassRegistry &)
char & DeadMachineInstructionElimID
DeadMachineInstructionElim - This pass removes dead machine instructions.
ArchType getArch() const
getArch - Get the parsed architecture type of this triple.
ScheduleDAGMILive * createGenericSchedLive(MachineSchedContext *C)
Create the standard converging machine scheduler.
CodeGenOpt::Level getOptLevel() const
Returns the optimization level: None, Less, Default, or Aggressive.
virtual bool addILPOpts()
Add passes that optimize instruction level parallelism for out-of-order targets.
void initializeSIFixSGPRCopiesPass(PassRegistry &)
void initializeAMDGPULowerIntrinsicsPass(PassRegistry &)
ModulePass * createGlobalDCEPass()
createGlobalDCEPass - This transform is designed to eliminate unreachable internal globals (functions...
FunctionPass * createR600VectorRegMerger()
static MachineSchedRegistry GCNMinRegSchedRegistry("gcn-minreg","Run GCN iterative scheduler for minimal register usage (experimental)", createMinRegScheduler)
static ScheduleDAGInstrs * createIterativeGCNMaxOccupancyMachineScheduler(MachineSchedContext *C)
static cl::opt< bool > InternalizeSymbols("amdgpu-internalize-symbols", cl::desc("Enable elimination of non-kernel functions and unused globals"), cl::init(false), cl::Hidden)
SI Machine Scheduler interface.
void append(in_iter S, in_iter E)
Append from an iterator pair.
SPIR_KERNEL - Calling convention for SPIR kernel functions.
char & PHIEliminationID
PHIElimination - This pass eliminates machine instruction PHI nodes by inserting copy instructions...
ImmutablePass * createExternalAAWrapperPass(std::function< void(Pass &, Function &, AAResults &)> Callback)
A wrapper pass around a callback which can be used to populate the AAResults in the AAResultsWrapperP...
StringRef getEnvironmentName() const
getEnvironmentName - Get the optional environment (fourth) component of the triple, or "" if empty.
initializer< Ty > init(const Ty &Val)
FunctionPass * createSeparateConstOffsetFromGEPPass(const TargetMachine *TM=nullptr, bool LowerGEP=false)
FunctionPass * createSIDebuggerInsertNopsPass()
static Reloc::Model getEffectiveRelocModel(Optional< Reloc::Model > RM)
This pass implements the reg bank selector pass used in the GlobalISel pipeline.
FunctionPass * createFlattenCFGPass()
FunctionPass * createSIWholeQuadModePass()
This file provides the interface for LLVM's Global Value Numbering pass which eliminates fully redund...
static cl::opt< bool > EarlyInlineAll("amdgpu-early-inline-all", cl::desc("Inline all functions early"), cl::init(false), cl::Hidden)
char & SIInsertSkipsPassID
virtual void addOptimizedRegAlloc(FunctionPass *RegAllocPass)
addOptimizedRegAlloc - Add passes related to register allocation.
void adjustPassManager(PassManagerBuilder &) override
Allow the target to modify the pass manager, e.g.
void LLVMInitializeAMDGPUTarget()
void initializeSIPeepholeSDWAPass(PassRegistry &)
static MachineSchedRegistry GCNMaxOccupancySchedRegistry("gcn-max-occupancy","Run GCN scheduler to maximize occupancy", createGCNMaxOccupancyMachineScheduler)
static cl::opt< bool > EnableSROA("amdgpu-sroa", cl::desc("Run SROA after promote alloca pass"), cl::ReallyHidden, cl::init(true))
TargetPassConfig * createPassConfig(PassManagerBase &PM) override
Create a pass configuration object to be used by addPassToEmitX methods for generating a pipeline of ...
FunctionPass * createR600ControlFlowFinalizer()
Legacy wrapper pass to provide the AMDGPUAAResult object.
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang","erlang-compatible garbage collector")
static MachineSchedRegistry SISchedRegistry("si","Run SI's custom scheduler", createSIMachineScheduler)
This class describes a target machine that is implemented with the LLVM target-independent code gener...
ModulePass * createBarrierNoopPass()
createBarrierNoopPass - This pass is purely a module pass barrier in a pass manager.
FunctionPass class - This class is used to implement most global optimizations.
Pass * createAlwaysInlinerLegacyPass(bool InsertLifetime=true)
Create a legacy pass manager instance of a pass to inline and remove functions marked as "always_inli...
AMDGPUTargetMachine(const Target &T, const Triple &TT, StringRef CPU, StringRef FS, TargetOptions Options, Optional< Reloc::Model > RM, CodeModel::Model CM, CodeGenOpt::Level OL)
void initializeSILowerControlFlowPass(PassRegistry &)
static ScheduleDAGInstrs * createMinRegScheduler(MachineSchedContext *C)
ModulePass * createAMDGPULowerIntrinsicsPass()
virtual void addCodeGenPrepare()
Add pass to prepare the LLVM IR for code generation.
FunctionPass * createR600ClauseMergePass()
The AMDGPU TargetMachine interface definition for hw codgen targets.
static cl::opt< bool > EnableR600IfConvert("r600-if-convert", cl::desc("Use if conversion pass"), cl::ReallyHidden, cl::init(true))
std::unique_ptr< ScheduleDAGMutation > createStoreClusterDAGMutation(const TargetInstrInfo *TII, const TargetRegisterInfo *TRI)
static ScheduleDAGInstrs * createR600MachineScheduler(MachineSchedContext *C)
std::unique_ptr< ScheduleDAGMutation > createAMDGPUMacroFusionDAGMutation()
Note that you have to add: DAG.addMutation(createAMDGPUMacroFusionDAGMutation()); to AMDGPUPassConfig...
void initializeSIShrinkInstructionsPass(PassRegistry &)
Calling convention used for Mesa vertex shaders.
Analysis pass providing a never-invalidated alias analysis result.
EP_EarlyAsPossible - This extension point allows adding passes before any other transformations, allowing them to see the code as it is coming out of the frontend.
void initializeSIInsertSkipsPass(PassRegistry &)
Triple - Helper class for working with autoconf configuration names.
FunctionPass * createAMDGPUAnnotateUniformValues()
This is the AMGPU address space based alias analysis pass.
Provides passes to inlining "always_inline" functions.
char & SIOptimizeExecMaskingID
EP_CGSCCOptimizerLate - This extension point allows adding CallGraphSCC passes at the end of the main...
StringRef getFeatureString(const Function &F) const
std::unique_ptr< ScheduleDAGMutation > createLoadClusterDAGMutation(const TargetInstrInfo *TII, const TargetRegisterInfo *TRI)
ImmutablePass class - This class is used to provide information that does not need to be run...
StringRef getTargetFeatureString() const
PassManagerBase - An abstract interface to allow code to add passes to a pass manager without having ...
char & StackMapLivenessID
StackMapLiveness - This pass analyses the register live-out set of stackmap/patchpoint intrinsics and...
ModulePass * createInternalizePass(std::function< bool(const GlobalValue &)> MustPreserveGV)
createInternalizePass - This pass loops over all of the functions in the input module, internalizing all globals (functions and variables) it can.
Calling convention used for Mesa pixel shaders.
void initializeSIWholeQuadModePass(PassRegistry &)
void setRequiresStructuredCFG(bool Value)
ImmutablePass * createAMDGPUAAWrapperPass()
static cl::opt< bool > EnableSIInsertWaitcntsPass("enable-si-insert-waitcnts", cl::desc("Use new waitcnt insertion pass"), cl::init(true))
FunctionPass * createR600EmitClauseMarkers()
This pass is responsible for selecting generic machine instructions to target-specific instructions...
void initializeAMDGPUUnifyMetadataPass(PassRegistry &)
Target - Wrapper for Target specific information.
virtual void addPostRegAlloc()
This method may be implemented by targets that want to run passes after register allocation pass pipe...
This file declares the targeting of the Machinelegalizer class for AMDGPU.
LLVM_NODISCARD LLVM_ATTRIBUTE_ALWAYS_INLINE bool empty() const
empty - Check if the string is empty.
virtual void addFastRegAlloc(FunctionPass *RegAllocPass)
addFastRegAlloc - Add the minimum set of target-independent passes that are required for fast registe...
FunctionPass * createR600Packetizer()
void initializeSILoadStoreOptimizerPass(PassRegistry &)
char & SILowerControlFlowID
ModulePass * createAMDGPUUnifyMetadataPass()
void initializeSIAnnotateControlFlowPass(PassRegistry &)
A ScheduleDAG for scheduling lists of MachineInstr.
char & PatchableFunctionID
This pass implements the "patchable-function" attribute.
FunctionPass * createInferAddressSpacesPass()
void initializeSIFoldOperandsPass(PassRegistry &)
const TargetRegisterInfo * TRI
Target processor register info.
FunctionPass * createSIShrinkInstructionsPass()
static cl::opt< bool > EnableAMDGPUAliasAnalysis("enable-amdgpu-aa", cl::Hidden, cl::desc("Enable AMDGPU Alias Analysis"), cl::init(true))
static cl::opt< bool > LateCFGStructurize("amdgpu-late-structurize", cl::desc("Enable late CFG structurization"), cl::init(false), cl::Hidden)
void initializeSIDebuggerInsertNopsPass(PassRegistry &)
char & IfConverterID
IfConverter - This pass performs machine code if conversion.
MachineSchedContext provides enough context from the MachineScheduler pass for the target to instanti...
void initializeSIInsertWaitsPass(PassRegistry &)
void resetTargetOptions(const Function &F) const
Reset the target options based on the function's attributes.
FunctionPass * createSROAPass()
StringRef getGPUName(const Function &F) const
const TargetInstrInfo * TII
Target instruction information.
TargetIRAnalysis getTargetIRAnalysis() override
Get a TargetIRAnalysis implementation for the target.
FunctionPass * createSIInsertWaitsPass()
StringRef getValueAsString() const
Return the attribute's value as a string.
This file declares the IRTranslator pass.
RegisterTargetMachine - Helper template for registering a target machine implementation, for use in the target machine initialization function.
static MachineSchedRegistry IterativeGCNMaxOccupancySchedRegistry("gcn-max-occupancy-experimental","Run GCN scheduler to maximize occupancy (experimental)", createIterativeGCNMaxOccupancyMachineScheduler)
void initializeSIFixControlFlowLiveIntervalsPass(PassRegistry &)
char & PostRAHazardRecognizerID
createPostRAHazardRecognizer - This pass runs the post-ra hazard recognizer.
FunctionPass * createEarlyCSEPass(bool UseMemorySSA=false)
~AMDGPUTargetMachine() override
StringRef - Represent a constant reference to a string, i.e.
PassRegistry - This class manages the registration and intitialization of the pass subsystem as appli...
void initializeSILowerI1CopiesPass(PassRegistry &)
static GCMetadataPrinterRegistry::Add< OcamlGCMetadataPrinter > Y("ocaml","ocaml 3.10-compatible collector")
void addExtension(ExtensionPointTy Ty, ExtensionFn Fn)
void initializeAMDGPUUnifyDivergentExitNodesPass(PassRegistry &)
ModulePass * createAMDGPUOpenCLImageTypeLoweringPass()
static cl::opt< bool > EnableR600StructurizeCFG("r600-ir-structurize", cl::desc("Use StructurizeCFG IR pass"), cl::init(true))
Pass * createStructurizeCFGPass(bool SkipUniformRegions=false)
When SkipUniformRegions is true the structizer will not structurize regions that only contain uniform...
void initializeAMDGPUAlwaysInlinePass(PassRegistry &)
TargetPassConfig * createPassConfig(PassManagerBase &PM) override
Create a pass configuration object to be used by addPassToEmitX methods for generating a pipeline of ...
Calling convention for AMDGPU code object kernels.
static ImmutablePass * createAMDGPUExternalAAWrapperPass()
static ScheduleDAGInstrs * createSIMachineScheduler(MachineSchedContext *C)
static ScheduleDAGInstrs * createGCNMaxOccupancyMachineScheduler(MachineSchedContext *C)
static cl::opt< bool > EnableEarlyIfConversion("amdgpu-early-ifcvt", cl::Hidden, cl::desc("Run early if-conversion"), cl::init(false))
void addMutation(std::unique_ptr< ScheduleDAGMutation > Mutation)
Add a postprocessing step to the DAG builder.
FunctionPass * createNaryReassociatePass()