LLVM 20.0.0git
AMDGPUCodeGenPassBuilder.cpp
Go to the documentation of this file.
1//===- lib/Target/AMDGPU/AMDGPUCodeGenPassBuilder.cpp ---------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
10#include "AMDGPU.h"
11#include "AMDGPUISelDAGToDAG.h"
13#include "AMDGPUTargetMachine.h"
15#include "SIFixSGPRCopies.h"
23
24using namespace llvm;
25
29 : CodeGenPassBuilder(TM, Opts, PIC) {
31 // Exceptions and StackMaps are not supported, so these passes will never do
32 // anything.
33 // Garbage collection is not supported.
34 disablePass<StackMapLivenessPass, FuncletLayoutPass,
36}
37
38void AMDGPUCodeGenPassBuilder::addPreISel(AddIRPass &addPass) const {
43
45 addPass(FlattenCFGPass());
46
48 addPass(SinkingPass());
49
51
52 // Merge divergent exit nodes. StructurizeCFG won't recognize the multi-exit
53 // regions formed by them.
54
56
59 addPass(FixIrreduciblePass());
60 addPass(UnifyLoopExitsPass());
61 }
62
63 addPass(StructurizeCFGPass(/*SkipUniformRegions=*/false));
64 }
65
67
70
71 // TODO: Move this right after structurizeCFG to avoid extra divergence
72 // analysis. This depends on stopping SIAnnotateControlFlow from making
73 // control flow modifications.
75 }
76
77 addPass(LCSSAPass());
78
81
82 // FIXME: Why isn't this queried as required from AMDGPUISelDAGToDAG, and why
83 // isn't this in addInstSelector?
85}
86
87void AMDGPUCodeGenPassBuilder::addAsmPrinter(AddMachinePass &addPass,
88 CreateMCStreamer) const {
89 // TODO: Add AsmPrinter.
90}
91
92Error AMDGPUCodeGenPassBuilder::addInstSelector(AddMachinePass &addPass) const {
93 addPass(AMDGPUISelDAGToDAGPass(TM));
94 addPass(SIFixSGPRCopiesPass());
95 addPass(SILowerI1CopiesPass());
96 return Error::success();
97}
Defines an instruction selector for the AMDGPU target.
Analyzes if a function potentially memory bound and if a kernel kernel may benefit from limiting numb...
static cl::opt< bool, true > EnableStructurizerWorkarounds("amdgpu-enable-structurizer-workarounds", cl::desc("Enable workarounds for the StructurizeCFG pass"), cl::location(AMDGPUTargetMachine::EnableStructurizerWorkarounds), cl::init(true), cl::Hidden)
static cl::opt< bool, true > DisableStructurizer("amdgpu-disable-structurizer", cl::desc("Disable structurizer for experiments; produces unusable code"), cl::location(AMDGPUTargetMachine::DisableStructurizer), cl::ReallyHidden)
static cl::opt< bool, true > LateCFGStructurize("amdgpu-late-structurize", cl::desc("Enable late CFG structurization"), cl::location(AMDGPUTargetMachine::EnableLateStructurizeCFG), cl::Hidden)
The AMDGPU TargetMachine interface definition for hw codegen targets.
const char LLVMTargetMachineRef TM
PassInstrumentationCallbacks PIC
LLVM IR instance of the generic uniformity analysis.
Error addInstSelector(AddMachinePass &) const
AMDGPUCodeGenPassBuilder(GCNTargetMachine &TM, const CGPassBuilderOption &Opts, PassInstrumentationCallbacks *PIC)
void addPreISel(AddIRPass &addPass) const
void addAsmPrinter(AddMachinePass &, CreateMCStreamer) const
This class provides access to building LLVM's passes.
void disablePass()
Allow the target to disable a specific pass by default.
Lightweight error class with error context and mandatory checking.
Definition: Error.h:160
static ErrorSuccess success()
Create a success value.
Definition: Error.h:337
Converts loops into loop-closed SSA form.
Definition: LCSSA.h:37
This class manages callbacks registration, as well as provides a way for PassInstrumentation to pass ...
Move instructions into successor blocks when possible.
Definition: Sink.h:24
CodeGenOptLevel getOptLevel() const
Returns the optimization level: None, Less, Default, or Aggressive.
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
A utility pass template to force an analysis result to be available.
Definition: PassManager.h:874