aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/TwoAddressInstructionPass.cpp
diff options
context:
space:
mode:
authorJay Foad <jay.foad@amd.com>2023-02-03 09:42:25 +0000
committerJay Foad <jay.foad@amd.com>2023-02-07 11:50:57 +0000
commitd170a254a53bce54596ed0f94aa86ffa3eede42b (patch)
treea910e6d7c653f66b9435f0a28d58115de4e4a472 /llvm/lib/CodeGen/TwoAddressInstructionPass.cpp
parent3d6b108a87cc017faf27824b82b90d9aaea707ca (diff)
downloadllvm-d170a254a53bce54596ed0f94aa86ffa3eede42b.zip
llvm-d170a254a53bce54596ed0f94aa86ffa3eede42b.tar.gz
llvm-d170a254a53bce54596ed0f94aa86ffa3eede42b.tar.bz2
[CodeGen] Define and use MachineOperand::getOperandNo
This is a helper function to very slightly simplify many calls to MachineInstruction::getOperandNo. Differential Revision: https://reviews.llvm.org/D143250
Diffstat (limited to 'llvm/lib/CodeGen/TwoAddressInstructionPass.cpp')
-rw-r--r--llvm/lib/CodeGen/TwoAddressInstructionPass.cpp8
1 files changed, 3 insertions, 5 deletions
diff --git a/llvm/lib/CodeGen/TwoAddressInstructionPass.cpp b/llvm/lib/CodeGen/TwoAddressInstructionPass.cpp
index 8cb3667a..8b0751f 100644
--- a/llvm/lib/CodeGen/TwoAddressInstructionPass.cpp
+++ b/llvm/lib/CodeGen/TwoAddressInstructionPass.cpp
@@ -404,7 +404,7 @@ findOnlyInterestingUse(Register Reg, MachineBasicBlock *MBB,
}
if (UseMI.isCommutable()) {
unsigned Src1 = TargetInstrInfo::CommuteAnyOperandIndex;
- unsigned Src2 = UseMI.getOperandNo(UseOp);
+ unsigned Src2 = UseOp->getOperandNo();
if (TII->findCommutedOpIndices(UseMI, Src1, Src2)) {
MachineOperand &MO = UseMI.getOperand(Src1);
if (MO.isReg() && MO.isUse() &&
@@ -693,10 +693,8 @@ bool TwoAddressInstructionPass::convertInstTo3Addr(
assert(NewMI->getNumExplicitDefs() == 1);
// Find the old and new def location.
- auto OldIt = mi->defs().begin();
- auto NewIt = NewMI->defs().begin();
- unsigned OldIdx = mi->getOperandNo(OldIt);
- unsigned NewIdx = NewMI->getOperandNo(NewIt);
+ unsigned OldIdx = mi->defs().begin()->getOperandNo();
+ unsigned NewIdx = NewMI->defs().begin()->getOperandNo();
// Record that one def has been replaced by the other.
unsigned NewInstrNum = NewMI->getDebugInstrNum();