30#define DEBUG_TYPE "si-lower-wwm-copies"
34class SILowerWWMCopies {
37 : LIS(LIS), Indexes(SI), VRM(VRM) {}
82char SILowerWWMCopiesLegacy::
ID = 0;
101 if (Reg.isPhysical())
106 assert(PhysReg &&
"should have allocated a physical register");
108 MFI->allocateWWMSpill(MF, PhysReg);
111bool SILowerWWMCopiesLegacy::runOnMachineFunction(
MachineFunction &MF) {
112 auto *LISWrapper = getAnalysisIfAvailable<LiveIntervalsWrapperPass>();
113 auto *LIS = LISWrapper ? &LISWrapper->getLIS() :
nullptr;
115 auto *SIWrapper = getAnalysisIfAvailable<SlotIndexesWrapperPass>();
116 auto *Indexes = SIWrapper ? &SIWrapper->getSI() :
nullptr;
118 auto *VRMWrapper = getAnalysisIfAvailable<VirtRegMapWrapperLegacy>();
119 auto *VRM = VRMWrapper ? &VRMWrapper->getVRM() :
nullptr;
121 SILowerWWMCopies Impl(LIS, Indexes, VRM);
132 SILowerWWMCopies Impl(LIS, Indexes, VRM);
142 TRI = ST.getRegisterInfo();
145 if (!MFI->hasVRegFlags())
148 bool Changed =
false;
151 if (
MI.getOpcode() != AMDGPU::WWM_COPY)
161 Register RegForExecCopy = MFI->getSGPRForEXECCopy();
162 TII->insertScratchExecCopy(MF,
MBB, InsertPt,
DL, RegForExecCopy,
163 isSCCLiveAtMI(
MI), Indexes);
164 TII->restoreExec(MF,
MBB, ++InsertPt,
DL, RegForExecCopy, Indexes);
165 addToWWMSpills(MF,
MI.getOperand(0).getReg());
169 MI.setDesc(
TII->get(AMDGPU::COPY));
unsigned const MachineRegisterInfo * MRI
Provides AMDGPU specific target descriptions.
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
Returns the sub type a function will return at a given Idx Should correspond to the result type of an ExtractValue instruction executed with just that one unsigned Idx
AMD GCN specific subclass of TargetSubtarget.
const HexagonInstrInfo * TII
unsigned const TargetRegisterInfo * TRI
#define INITIALIZE_PASS_DEPENDENCY(depName)
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
#define INITIALIZE_PASS_BEGIN(passName, arg, name, cfg, analysis)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
A container for analyses that lazily runs them and caches their results.
PassT::Result * getCachedResult(IRUnitT &IR) const
Get the cached result of an analysis pass for a given IR unit.
Represent the analysis usage information of a pass.
AnalysisUsage & addUsedIfAvailable()
Add the specified Pass class to the set of analyses used by this pass.
void setPreservesAll()
Set by analyses that do not transform their input at all.
This class represents the liveness of a register, stack slot, etc.
bool liveAt(SlotIndex index) const
Wrapper class representing physical registers. Should be passed by value.
static MCRegister from(unsigned Val)
Check the provided unsigned value is a valid MCRegister.
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
virtual bool runOnMachineFunction(MachineFunction &MF)=0
runOnMachineFunction - This method must be overloaded to perform the desired machine code transformat...
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
Ty * getInfo()
getInfo - Keep track of various per-function pieces of information for backends that would like to do...
Representation of each machine instruction.
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
virtual StringRef getPassName() const
getPassName - Return a nice clean name for a pass.
A set of analyses that are preserved following a run of a transformation pass.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
Wrapper class representing virtual and physical registers.
PreservedAnalyses run(MachineFunction &MF, MachineFunctionAnalysisManager &MFAM)
This class keeps track of the SPI_SP_INPUT_ADDR config register, which tells the hardware which inter...
SlotIndex - An opaque wrapper around machine indexes.
StringRef - Represent a constant reference to a string, i.e.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
This is an optimization pass for GlobalISel generic memory operations.
void initializeSILowerWWMCopiesLegacyPass(PassRegistry &)
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
char & SILowerWWMCopiesLegacyID