Skip to content

Commit a07584d

Browse files
committed
[CodeGen] Make more use of MachineOperand::getOperandNo. NFC.
Differential Revision: https://reviews.llvm.org/D143252
1 parent d170a25 commit a07584d

13 files changed

+20
-24
lines changed

llvm/lib/Target/AArch64/AArch64CollectLOH.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ static bool isCandidateStore(const MachineInstr &MI, const MachineOperand &MO) {
212212
// In case we have str xA, [xA, #imm], this is two different uses
213213
// of xA and we cannot fold, otherwise the xA stored may be wrong,
214214
// even if #imm == 0.
215-
return MI.getOperandNo(&MO) == 1 &&
215+
return MO.getOperandNo() == 1 &&
216216
MI.getOperand(0).getReg() != MI.getOperand(1).getReg();
217217
}
218218
}

llvm/lib/Target/AMDGPU/AMDGPUInsertDelayAlu.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ class AMDGPUInsertDelayAlu : public MachineFunctionPass {
380380
// TODO: Scan implicit defs too?
381381
for (const auto &Op : MI.defs()) {
382382
unsigned Latency = SchedModel.computeOperandLatency(
383-
&MI, MI.getOperandNo(&Op), nullptr, 0);
383+
&MI, Op.getOperandNo(), nullptr, 0);
384384
for (MCRegUnitIterator UI(Op.getReg(), TRI); UI.isValid(); ++UI)
385385
State[*UI] = DelayInfo(Type, Latency);
386386
}

llvm/lib/Target/AMDGPU/GCNHazardRecognizer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2026,7 +2026,7 @@ int GCNHazardRecognizer::checkMAIHazards908(MachineInstr *MI) {
20262026
MaxWaitStates);
20272027
int NeedWaitStates = MFMAWritesAGPROverlappedSrcABWaitStates;
20282028
int SrcCIdx = AMDGPU::getNamedOperandIdx(Opc, AMDGPU::OpName::src2);
2029-
int OpNo = MI->getOperandNo(&Op);
2029+
int OpNo = Op.getOperandNo();
20302030
if (OpNo == SrcCIdx) {
20312031
NeedWaitStates = MFMAWritesAGPROverlappedSrcCWaitStates;
20322032
} else if (Opc == AMDGPU::V_ACCVGPR_READ_B32_e64) {
@@ -2205,7 +2205,7 @@ int GCNHazardRecognizer::checkMAIHazards90A(MachineInstr *MI) {
22052205
if (NumWaitStates == std::numeric_limits<int>::max())
22062206
continue;
22072207

2208-
int OpNo = MI->getOperandNo(&Use);
2208+
int OpNo = Use.getOperandNo();
22092209
unsigned Opc1 = MI1->getOpcode();
22102210
int NeedWaitStates = 0;
22112211
if (OpNo == SrcCIdx) {

llvm/lib/Target/AMDGPU/SIFixSGPRCopies.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ static bool tryChangeVGPRtoSGPRinCopy(MachineInstr &MI,
231231
UseMI->getOpcode() <= TargetOpcode::GENERIC_OP_END)
232232
return false;
233233

234-
unsigned OpIdx = UseMI->getOperandNo(&MO);
234+
unsigned OpIdx = MO.getOperandNo();
235235
if (OpIdx >= UseMI->getDesc().getNumOperands() ||
236236
!TII->isOperandLegal(*UseMI, OpIdx, &Src))
237237
return false;
@@ -658,7 +658,7 @@ bool SIFixSGPRCopies::runOnMachineFunction(MachineFunction &MF) {
658658
TRI->getEquivalentSGPRClass(SrcRC);
659659
Register NewDst = MRI->createVirtualRegister(DestRC);
660660
MachineBasicBlock *BlockToInsertCopy =
661-
MI.isPHI() ? MI.getOperand(MI.getOperandNo(&MO) + 1).getMBB()
661+
MI.isPHI() ? MI.getOperand(MO.getOperandNo() + 1).getMBB()
662662
: MBB;
663663
MachineBasicBlock::iterator PointToInsertCopy =
664664
MI.isPHI() ? BlockToInsertCopy->getFirstInstrTerminator() : I;

llvm/lib/Target/AMDGPU/SIInstrInfo.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -841,7 +841,7 @@ class SIInstrInfo final : public AMDGPUGenInstrInfo {
841841
const MachineOperand &UseMO,
842842
const MachineOperand &DefMO) const {
843843
assert(UseMO.getParent() == &MI);
844-
int OpIdx = MI.getOperandNo(&UseMO);
844+
int OpIdx = UseMO.getOperandNo();
845845
if (OpIdx >= MI.getDesc().NumOperands)
846846
return false;
847847

@@ -873,8 +873,7 @@ class SIInstrInfo final : public AMDGPUGenInstrInfo {
873873
}
874874

875875
bool isInlineConstant(const MachineOperand &MO) const {
876-
const MachineInstr *Parent = MO.getParent();
877-
return isInlineConstant(*Parent, Parent->getOperandNo(&MO));
876+
return isInlineConstant(*MO.getParent(), MO.getOperandNo());
878877
}
879878

880879
bool isImmOperandLegal(const MachineInstr &MI, unsigned OpNo,

llvm/lib/Target/AMDGPU/SIPeepholeSDWA.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1158,7 +1158,7 @@ void SIPeepholeSDWA::legalizeScalarOperands(MachineInstr &MI,
11581158
if (!Op.isImm() && !(Op.isReg() && !TRI->isVGPR(*MRI, Op.getReg())))
11591159
continue;
11601160

1161-
unsigned I = MI.getOperandNo(&Op);
1161+
unsigned I = Op.getOperandNo();
11621162
if (Desc.operands()[I].RegClass == -1 ||
11631163
!TRI->isVSSuperClass(TRI->getRegClass(Desc.operands()[I].RegClass)))
11641164
continue;

llvm/lib/Target/AMDGPU/SIShrinkInstructions.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,14 +161,12 @@ bool SIShrinkInstructions::shouldShrinkTrue16(MachineInstr &MI) const {
161161

162162
bool SIShrinkInstructions::isKImmOperand(const MachineOperand &Src) const {
163163
return isInt<16>(Src.getImm()) &&
164-
!TII->isInlineConstant(*Src.getParent(),
165-
Src.getParent()->getOperandNo(&Src));
164+
!TII->isInlineConstant(*Src.getParent(), Src.getOperandNo());
166165
}
167166

168167
bool SIShrinkInstructions::isKUImmOperand(const MachineOperand &Src) const {
169168
return isUInt<16>(Src.getImm()) &&
170-
!TII->isInlineConstant(*Src.getParent(),
171-
Src.getParent()->getOperandNo(&Src));
169+
!TII->isInlineConstant(*Src.getParent(), Src.getOperandNo());
172170
}
173171

174172
bool SIShrinkInstructions::isKImmOrKUImmOperand(const MachineOperand &Src,

llvm/lib/Target/ARC/ARCOptAddrMode.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,11 +153,10 @@ static bool dominatesAllUsesOf(const MachineInstr *MI, unsigned VReg,
153153

154154
assert(Register::isVirtualRegister(VReg) && "Expected virtual register!");
155155

156-
for (auto it = MRI->use_nodbg_begin(VReg), end = MRI->use_nodbg_end();
157-
it != end; ++it) {
158-
MachineInstr *User = it->getParent();
156+
for (const MachineOperand &Use : MRI->use_nodbg_operands(VReg)) {
157+
const MachineInstr *User = Use.getParent();
159158
if (User->isPHI()) {
160-
unsigned BBOperandIdx = User->getOperandNo(&*it) + 1;
159+
unsigned BBOperandIdx = Use.getOperandNo() + 1;
161160
MachineBasicBlock *MBB = User->getOperand(BBOperandIdx).getMBB();
162161
if (MBB->empty()) {
163162
const MachineBasicBlock *InstBB = MI->getParent();

llvm/lib/Target/ARM/ARMLowOverheadLoops.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -907,7 +907,7 @@ static bool producesFalseLanesZero(MachineInstr &MI,
907907
continue;
908908
// Skip the lr predicate reg
909909
int PIdx = llvm::findFirstVPTPredOperandIdx(MI);
910-
if (PIdx != -1 && (int)MI.getOperandNo(&MO) == PIdx + 2)
910+
if (PIdx != -1 && (int)MO.getOperandNo() == PIdx + 2)
911911
continue;
912912

913913
// Check that this instruction will produce zeros in its false lanes:

llvm/lib/Target/M68k/M68kInstrInfo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -609,7 +609,7 @@ bool M68kInstrInfo::isPCRelRegisterOperandLegal(
609609
const MachineInstr *MI = MO.getParent();
610610
const unsigned NameIndices = M68kInstrNameIndices[MI->getOpcode()];
611611
StringRef InstrName(&M68kInstrNameData[NameIndices]);
612-
const unsigned OperandNo = MI->getOperandNo(&MO);
612+
const unsigned OperandNo = MO.getOperandNo();
613613

614614
// If this machine operand is the 2nd operand, then check
615615
// whether the instruction has destination addressing mode 'k'.

llvm/lib/Target/RISCV/RISCVInstrInfo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2563,7 +2563,7 @@ bool RISCVInstrInfo::hasAllNBitUsers(const MachineInstr &OrigMI,
25632563

25642564
for (auto &UserOp : MRI.use_operands(MI->getOperand(0).getReg())) {
25652565
const MachineInstr *UserMI = UserOp.getParent();
2566-
unsigned OpIdx = UserMI->getOperandNo(&UserOp);
2566+
unsigned OpIdx = UserOp.getOperandNo();
25672567

25682568
switch (UserMI->getOpcode()) {
25692569
default:

llvm/lib/Target/RISCV/RISCVRegisterInfo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -759,7 +759,7 @@ bool RISCVRegisterInfo::getRegAllocationHints(
759759

760760
for (auto &MO : MRI->reg_nodbg_operands(VirtReg)) {
761761
const MachineInstr &MI = *MO.getParent();
762-
unsigned OpIdx = MI.getOperandNo(&MO);
762+
unsigned OpIdx = MO.getOperandNo();
763763
bool NeedGPRC;
764764
if (isCompressible(MI, NeedGPRC)) {
765765
if (OpIdx == 0 && MI.getOperand(1).isReg()) {

llvm/lib/Target/WebAssembly/WebAssemblyExplicitLocals.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ bool WebAssemblyExplicitLocals::runOnMachineFunction(MachineFunction &MF) {
352352
unsigned LocalId = getLocalId(Reg2Local, MFI, CurLocal, OldReg);
353353
// If this register operand is tied to another operand, we can't
354354
// change it to an immediate. Untie it first.
355-
MI.untieRegOperand(MI.getOperandNo(&MO));
355+
MI.untieRegOperand(MO.getOperandNo());
356356
MO.ChangeToImmediate(LocalId);
357357
continue;
358358
}
@@ -369,7 +369,7 @@ bool WebAssemblyExplicitLocals::runOnMachineFunction(MachineFunction &MF) {
369369
if (MI.isInlineAsm()) {
370370
unsigned LocalId = getLocalId(Reg2Local, MFI, CurLocal, OldReg);
371371
// Untie it first if this reg operand is tied to another operand.
372-
MI.untieRegOperand(MI.getOperandNo(&MO));
372+
MI.untieRegOperand(MO.getOperandNo());
373373
MO.ChangeToImmediate(LocalId);
374374
continue;
375375
}

0 commit comments

Comments
 (0)