Skip to content

Commit 7e5019e

Browse files
authored
[AMDGPU] Simplify WaitcntBrackets::getRegInterval with getPhysRegBaseClass (#74087)
This means that getRegInterval no longer depends on the MCInstrDesc, so it could be simplified further to take just a MachineOperand or just a physical register. NFCI.
1 parent fda3a13 commit 7e5019e

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ class WaitcntBrackets {
238238

239239
bool merge(const WaitcntBrackets &Other);
240240

241-
RegInterval getRegInterval(const MachineInstr *MI, const SIInstrInfo *TII,
241+
RegInterval getRegInterval(const MachineInstr *MI,
242242
const MachineRegisterInfo *MRI,
243243
const SIRegisterInfo *TRI, unsigned OpNo) const;
244244

@@ -500,7 +500,6 @@ class SIInsertWaitcnts : public MachineFunctionPass {
500500
} // end anonymous namespace
501501

502502
RegInterval WaitcntBrackets::getRegInterval(const MachineInstr *MI,
503-
const SIInstrInfo *TII,
504503
const MachineRegisterInfo *MRI,
505504
const SIRegisterInfo *TRI,
506505
unsigned OpNo) const {
@@ -534,7 +533,7 @@ RegInterval WaitcntBrackets::getRegInterval(const MachineInstr *MI,
534533
else
535534
return {-1, -1};
536535

537-
const TargetRegisterClass *RC = TII->getOpRegClass(*MI, OpNo);
536+
const TargetRegisterClass *RC = TRI->getPhysRegBaseClass(Op.getReg());
538537
unsigned Size = TRI->getRegSizeInBits(*RC);
539538
Result.second = Result.first + ((Size + 16) / 32);
540539

@@ -546,7 +545,7 @@ void WaitcntBrackets::setExpScore(const MachineInstr *MI,
546545
const SIRegisterInfo *TRI,
547546
const MachineRegisterInfo *MRI, unsigned OpNo,
548547
unsigned Val) {
549-
RegInterval Interval = getRegInterval(MI, TII, MRI, TRI, OpNo);
548+
RegInterval Interval = getRegInterval(MI, MRI, TRI, OpNo);
550549
assert(TRI->isVectorRegister(*MRI, MI->getOperand(OpNo).getReg()));
551550
for (int RegNo = Interval.first; RegNo < Interval.second; ++RegNo) {
552551
setRegScore(RegNo, EXP_CNT, Val);
@@ -674,7 +673,7 @@ void WaitcntBrackets::updateByEvent(const SIInstrInfo *TII,
674673
Inst.getOpcode() == AMDGPU::BUFFER_STORE_DWORDX4) {
675674
MachineOperand *MO = TII->getNamedOperand(Inst, AMDGPU::OpName::data);
676675
unsigned OpNo;//TODO: find the OpNo for this operand;
677-
RegInterval Interval = getRegInterval(&Inst, TII, MRI, TRI, OpNo);
676+
RegInterval Interval = getRegInterval(&Inst, MRI, TRI, OpNo);
678677
for (int RegNo = Interval.first; RegNo < Interval.second;
679678
++RegNo) {
680679
setRegScore(RegNo + NUM_ALL_VGPRS, t, CurrScore);
@@ -686,7 +685,7 @@ void WaitcntBrackets::updateByEvent(const SIInstrInfo *TII,
686685
auto &Op = Inst.getOperand(I);
687686
if (!Op.isReg() || !Op.isDef())
688687
continue;
689-
RegInterval Interval = getRegInterval(&Inst, TII, MRI, TRI, I);
688+
RegInterval Interval = getRegInterval(&Inst, MRI, TRI, I);
690689
if (T == VM_CNT) {
691690
if (Interval.first >= NUM_ALL_VGPRS)
692691
continue;
@@ -1140,7 +1139,7 @@ bool SIInsertWaitcnts::generateWaitcntInstBefore(MachineInstr &MI,
11401139

11411140
if (MI.getOperand(CallAddrOpIdx).isReg()) {
11421141
RegInterval CallAddrOpInterval =
1143-
ScoreBrackets.getRegInterval(&MI, TII, MRI, TRI, CallAddrOpIdx);
1142+
ScoreBrackets.getRegInterval(&MI, MRI, TRI, CallAddrOpIdx);
11441143

11451144
for (int RegNo = CallAddrOpInterval.first;
11461145
RegNo < CallAddrOpInterval.second; ++RegNo)
@@ -1150,7 +1149,7 @@ bool SIInsertWaitcnts::generateWaitcntInstBefore(MachineInstr &MI,
11501149
AMDGPU::getNamedOperandIdx(MI.getOpcode(), AMDGPU::OpName::dst);
11511150
if (RtnAddrOpIdx != -1) {
11521151
RegInterval RtnAddrOpInterval =
1153-
ScoreBrackets.getRegInterval(&MI, TII, MRI, TRI, RtnAddrOpIdx);
1152+
ScoreBrackets.getRegInterval(&MI, MRI, TRI, RtnAddrOpIdx);
11541153

11551154
for (int RegNo = RtnAddrOpInterval.first;
11561155
RegNo < RtnAddrOpInterval.second; ++RegNo)
@@ -1202,8 +1201,7 @@ bool SIInsertWaitcnts::generateWaitcntInstBefore(MachineInstr &MI,
12021201
if (Op.isTied() && Op.isUse() && TII->doesNotReadTiedSource(MI))
12031202
continue;
12041203

1205-
RegInterval Interval =
1206-
ScoreBrackets.getRegInterval(&MI, TII, MRI, TRI, I);
1204+
RegInterval Interval = ScoreBrackets.getRegInterval(&MI, MRI, TRI, I);
12071205

12081206
const bool IsVGPR = TRI->isVectorRegister(*MRI, Op.getReg());
12091207
for (int RegNo = Interval.first; RegNo < Interval.second; ++RegNo) {
@@ -1782,7 +1780,7 @@ bool SIInsertWaitcnts::shouldFlushVmCnt(MachineLoop *ML,
17821780
MachineOperand &Op = MI.getOperand(I);
17831781
if (!Op.isReg() || !TRI->isVectorRegister(*MRI, Op.getReg()))
17841782
continue;
1785-
RegInterval Interval = Brackets.getRegInterval(&MI, TII, MRI, TRI, I);
1783+
RegInterval Interval = Brackets.getRegInterval(&MI, MRI, TRI, I);
17861784
// Vgpr use
17871785
if (Op.isUse()) {
17881786
for (int RegNo = Interval.first; RegNo < Interval.second; ++RegNo) {

0 commit comments

Comments
 (0)