Changeset View
Changeset View
Standalone View
Standalone View
llvm/trunk/lib/Target/AMDGPU/SIFormMemoryClauses.cpp
Show First 20 Lines • Show All 313 Lines • ▼ Show 20 Lines | bool SIFormMemoryClauses::runOnMachineFunction(MachineFunction &MF) { | ||||
MRI = &MF.getRegInfo(); | MRI = &MF.getRegInfo(); | ||||
MFI = MF.getInfo<SIMachineFunctionInfo>(); | MFI = MF.getInfo<SIMachineFunctionInfo>(); | ||||
LiveIntervals *LIS = &getAnalysis<LiveIntervals>(); | LiveIntervals *LIS = &getAnalysis<LiveIntervals>(); | ||||
SlotIndexes *Ind = LIS->getSlotIndexes(); | SlotIndexes *Ind = LIS->getSlotIndexes(); | ||||
bool Changed = false; | bool Changed = false; | ||||
MaxVGPRs = TRI->getAllocatableSet(MF, &AMDGPU::VGPR_32RegClass).count(); | MaxVGPRs = TRI->getAllocatableSet(MF, &AMDGPU::VGPR_32RegClass).count(); | ||||
MaxSGPRs = TRI->getAllocatableSet(MF, &AMDGPU::SGPR_32RegClass).count(); | MaxSGPRs = TRI->getAllocatableSet(MF, &AMDGPU::SGPR_32RegClass).count(); | ||||
unsigned FuncMaxClause = AMDGPU::getIntegerAttribute( | |||||
MF.getFunction(), "amdgpu-max-memory-clause", MaxClause); | |||||
for (MachineBasicBlock &MBB : MF) { | for (MachineBasicBlock &MBB : MF) { | ||||
MachineBasicBlock::instr_iterator Next; | MachineBasicBlock::instr_iterator Next; | ||||
for (auto I = MBB.instr_begin(), E = MBB.instr_end(); I != E; I = Next) { | for (auto I = MBB.instr_begin(), E = MBB.instr_end(); I != E; I = Next) { | ||||
MachineInstr &MI = *I; | MachineInstr &MI = *I; | ||||
Next = std::next(I); | Next = std::next(I); | ||||
bool IsVMEM = isVMEMClauseInst(MI); | bool IsVMEM = isVMEMClauseInst(MI); | ||||
if (!isValidClauseInst(MI, IsVMEM)) | if (!isValidClauseInst(MI, IsVMEM)) | ||||
continue; | continue; | ||||
RegUse Defs, Uses; | RegUse Defs, Uses; | ||||
GCNDownwardRPTracker RPT(*LIS); | GCNDownwardRPTracker RPT(*LIS); | ||||
RPT.reset(MI); | RPT.reset(MI); | ||||
if (!processRegUses(MI, Defs, Uses, RPT)) | if (!processRegUses(MI, Defs, Uses, RPT)) | ||||
continue; | continue; | ||||
unsigned Length = 1; | unsigned Length = 1; | ||||
for ( ; Next != E && Length < MaxClause; ++Next) { | for ( ; Next != E && Length < FuncMaxClause; ++Next) { | ||||
if (!isValidClauseInst(*Next, IsVMEM)) | if (!isValidClauseInst(*Next, IsVMEM)) | ||||
break; | break; | ||||
// A load from pointer which was loaded inside the same bundle is an | // A load from pointer which was loaded inside the same bundle is an | ||||
// impossible clause because we will need to write and read the same | // impossible clause because we will need to write and read the same | ||||
// register inside. In this case processRegUses will return false. | // register inside. In this case processRegUses will return false. | ||||
if (!processRegUses(*Next, Defs, Uses, RPT)) | if (!processRegUses(*Next, Defs, Uses, RPT)) | ||||
break; | break; | ||||
▲ Show 20 Lines • Show All 57 Lines • Show Last 20 Lines |